diff --git a/OAT.xml b/OAT.xml index f37f841f0df2a01463f888ee46233c957a6e17e5..234818b5e794b2f81266f3312d667a17423483f3 100644 --- a/OAT.xml +++ b/OAT.xml @@ -149,7 +149,8 @@ Note:If the text contains special characters, please escape them according to th - + + diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/build-common/package.json b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/build-common/package.json new file mode 100644 index 0000000000000000000000000000000000000000..57be05a8481f28f2efb6e3fad8b5acf58452d4e1 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/build-common/package.json @@ -0,0 +1,11 @@ +{ + "name": "@koalaui/build-common", + "version": "1.5.15+devel", + "description": "", + "files": [ + "tsconfig.json" + ], + "scripts": { + "compile": "" + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/build-common/tsconfig.json b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/build-common/tsconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..02ca836732ea922edcb061e64008364e67b8f1e9 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/build-common/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "target": "es2017", + "module": "ESNext", + "lib": ["ESNext", "ESNext.WeakRef"], + "moduleResolution": "node", + "composite": true, + "incremental": true, + "declarationMap": true, + "sourceMap": true, + "declaration": true, + "noEmitOnError": true, + "strict": true, + "skipLibCheck": true, + "removeComments": false + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/arktsconfig.json b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/arktsconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..dcacec76b99a9d7f60c6f2f3a3b18c1a87480bea --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/arktsconfig.json @@ -0,0 +1,14 @@ +{ + "compilerOptions": { + "package": "@koalaui/common", + "outDir": "build/abc", + "baseUrl": "./src", + "paths": { + "@koalaui/compat": ["../../compat/src/arkts"] + } + }, + "include": ["src/**/*.ts"], + "references": [ + { "path": "../compat" } + ] +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/bridges/ohos/src/chai/index.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/bridges/ohos/src/chai/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..b1df5415054f3aac1d78201b87a41395a8d3ba03 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/bridges/ohos/src/chai/index.ts @@ -0,0 +1,213 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { expect } from "@ohos/hypium" + +export interface Assert { + (expression: any, message?: string): asserts expression + + /** + * Asserts non-strict equality (==) of actual and expected. + */ + equal(actual: T, expected: T, message?: string): void + + /** + * Asserts non-strict inequality (!=) of actual and expected. + */ + notEqual(actual: T, expected: T, message?: string): void + + /** + * Asserts strict equality (===) of actual and expected. + */ + strictEqual(actual: T, expected: T, message?: string): void + + /** + * Asserts strict inequality (!==) of actual and expected. + */ + notStrictEqual(actual: T, expected: T, message?: string): void + + deepEqual(actual: any, expected: any, message?: string): void + + notDeepEqual(actual: any, expected: any, message?: string): void + + isTrue(value: any, message?: string): void + + isFalse(value: any, message?: string): void + + closeTo(actual: number, expected: number, delta: number, message?: string): void + + fail(message?: string): void + + isNull(value: any, message?: string): void + + isNotNull(value: any, message?: string): void + + instanceOf(value: any, constructor: Function, message?: string): void + + isAtLeast(valueToCheck: number, valueToBeAtLeast: number, message?: string): void + + exists(value: any, message?: string): void + + throw(fn: () => void, message?: string): void + + throws(fn: () => void, message?: string): void + + isAbove(valueToCheck: number, valueToBeAbove: number, message?: string): void + + isBelow(valueToCheck: number, valueToBeBelow: number, message?: string): void + + match(value: string, regexp: RegExp, message?: string): void + + isDefined(value: any, message?: string): void + + isUndefined(value: any, message?: string): void + + isEmpty(object: any, message?: string): void + + isNotEmpty(object: any, message?: string): void +} + +// todo: the 'message' arg is ignored + +export var assert: Assert = ((expression: any, message?: string): void => { + expect(Boolean(expression)).assertTrue() +}) as Assert + +assert.equal = (actual: T, expected: T, message?: string): void => { + expect(actual).assertEqual(expected) +} + +assert.notEqual = (actual: T, expected: T, message?: string): void => { + // todo: not accurate impl, because compared values are not printed + expect(actual != expected).assertTrue() +} + +assert.strictEqual = (actual: T, expected: T, message?: string): void => { + // todo: not accurate impl, because compared values are not printed + expect(actual === expected).assertTrue() +} + +assert.notStrictEqual = (actual: T, expected: T, message?: string): void => { + // todo: not accurate impl, because compared values are not printed + expect(actual !== expected).assertTrue() +} + +assert.deepEqual = (actual: any, expected: any, message?: string): void => { + // todo: implement + expect(actual).assertEqual(actual/*expected*/) +} + +assert.notDeepEqual = (actual: any, expected: any, message?: string): void => { + // todo: implement + expect(actual).assertEqual(actual/*expected*/) +} + +assert.isTrue = (value: any, message?: string): void => { + expect(value).assertTrue() +} + +assert.isFalse = (value: any, message?: string): void => { + expect(value).assertFalse() +} + +assert.closeTo = (actual: number, expected: number, delta: number, message?: string): void => { + // implementation of 'assertClose' does not fit: + // expect(actual).assertClose(expected, delta) + + const diff = Math.abs(actual - expected) + if (diff == delta) + expect(diff).assertEqual(delta) + else + expect(diff).assertLess(delta) +} + +assert.fail = (message?: string): void => { + expect().assertFail() +} + +assert.isNull = (value: any, message?: string): void => { + expect(value).assertNull() +} + +assert.isNotNull = (value: any, message?: string): void => { + expect(value ? null : value).assertNull() +} + +assert.instanceOf = (value: any, constructor: Function, message?: string): void => { + // todo: not accurate impl + // expect(value).assertInstanceOf(constructor.name) + expect(value instanceof constructor).assertTrue() +} + +assert.isAtLeast = (valueToCheck: number, valueToBeAtLeast: number, message?: string): void => { + if (valueToCheck == valueToBeAtLeast) + expect(valueToCheck).assertEqual(valueToBeAtLeast) + else + expect(valueToCheck).assertLarger(valueToBeAtLeast) +} + +assert.exists = (value: any, message?: string): void => { + // todo: not accurate impl + expect(value == null).assertFalse() +} + +assert.throw = (fn: () => void, message?: string): void => { + let fnWrapper = () => { + try { + fn() + } catch (e) { + throw new Error("fn thrown exception") + } + } + expect(fnWrapper).assertThrowError("fn thrown exception") +} + +assert.throws = (fn: () => void, message?: string): void => { + assert.throw(fn, message) +} + +assert.isAbove = (valueToCheck: number, valueToBeAbove: number, message?: string): void => { + expect(valueToCheck).assertLarger(valueToBeAbove) +} + +assert.isBelow = (valueToCheck: number, valueToBeBelow: number, message?: string): void => { + expect(valueToCheck).assertLess(valueToBeBelow) +} + +assert.match = (value: string, regexp: RegExp, message?: string): void => { + // todo: not accurate impl + expect(regexp.test(value)).assertTrue() +} + +assert.isDefined = (value: any, message?: string): void => { + // todo: not accurate impl + expect(value === undefined).assertFalse() +} + +assert.isUndefined = (value: any, message?: string): void => { + expect(value).assertUndefined() +} + +assert.isEmpty = (object: any, message?: string): void => { + // todo: implement + expect(object !== undefined).assertTrue() +} + +assert.isNotEmpty = (object: any, message?: string): void => { + // todo: implement + expect(object !== undefined).assertTrue() +} + + diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/bridges/ohos/src/index.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/bridges/ohos/src/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..17641d36d4c622f8472d8c4431350788e9f29991 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/bridges/ohos/src/index.ts @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export {startTests} from "./mocha" +export * from "./chai" + +import "./mocha" // globals diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/bridges/ohos/src/mocha/index.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/bridges/ohos/src/mocha/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..2d2cf81c5272957e24c2d2e8edab5aad6882385d --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/bridges/ohos/src/mocha/index.ts @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import {describe, beforeEach, it, Size} from "@ohos/hypium" + +declare namespace globalThis { + let __OpenHarmony: boolean + let __generateGolden: boolean +} + +globalThis.__OpenHarmony = true + +const suiteMap = new Map() + +suite = (title: string, fn: Fn): void => { + suiteMap.set(title, fn) +} + +suiteSetup = (title: string, fn: Fn): void => { + beforeEach(fn) +} + +test = ((title: string, fn?: Fn): void => { + it(fn ? title : `[SKIP] ${title}`, Size.MEDIUMTEST, fn ? fn : () => {}) +}) as TestFn + +test.skip = (title: string, fn?: Fn): void => { + it(`[SKIP] ${title}`, Size.MEDIUMTEST, () => {}) +} + +(performance as TimeFn) = { + now: (): number => { + return Date.now() + } +} + +export function startTests(generateGolden: boolean = false) { + globalThis.__generateGolden = generateGolden + suiteMap.forEach((fn: Fn, title: string) => { + describe(title, function () { + fn() + }) + }) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/bridges/ohos/src/mocha/types/index.d.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/bridges/ohos/src/mocha/types/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..61d2fc500934061be3d7fb4a8d395ef1d9170fd1 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/bridges/ohos/src/mocha/types/index.d.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +declare global { + type Fn = () => void + + type SuiteFn = (title: string, fn: Fn) => void + + interface TestFn { + (title: string, fn?: Fn): void + skip(title: string, fn?: Fn): void + } + + let suite: SuiteFn + let suiteSetup: SuiteFn + let test: TestFn + + interface TimeFn { + now: () => number + } + + let performance: TimeFn +} + +export {} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/bridges/ohos/tsconfig.json b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/bridges/ohos/tsconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..632f9f62e6c54a7433103a6f6734c921bd9155b5 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/bridges/ohos/tsconfig.json @@ -0,0 +1,13 @@ +{ + "extends": "@koalaui/build-common/tsconfig.json", + "compilerOptions": { + "outDir": "../../build/bridges/ohos", + "rootDir": "src", + "baseUrl": ".", + "module": "CommonJS", + "paths": { + "chai": ["./src/chai"] + }, + "typeRoots": ["./src/mocha/types"] + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/empty.js b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/empty.js new file mode 100644 index 0000000000000000000000000000000000000000..ac57d1240ec618f291f4624f135240eb8c6bde18 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/empty.js @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/package.json b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/package.json new file mode 100644 index 0000000000000000000000000000000000000000..556786e78ae2350a680735b08f5e12d268781add --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/package.json @@ -0,0 +1,60 @@ +{ + "name": "@koalaui/common", + "version": "1.5.15+devel", + "description": "", + "main": "build/lib/src/index.js", + "types": "./index.d.ts", + "files": [ + "build/lib/**/*.js", + "build/lib/**/*.d.ts", + "build/bridges/ohos/**/*.js", + "build/bridges/ohos/**/*.d.ts", + "src/**/*", + "oh-package.json5" + ], + "exports": { + ".": "./build/lib/src/index.js", + "./golden": "./test/golden.js", + "./bridges": { + "ark": "./build/bridges/ohos/index.js", + "default": null + } + }, + "typesVersions": { + "*": { + "bridges": [ + "build/bridges/ohos/index.d.ts" + ], + "*": [ + "build/lib/src/*", + "build/lib/typescript/*" + ] + } + }, + "scripts": { + "compile": "ets-tsc -b .", + "clean": "rimraf build", + "test": "mocha", + "test:coverage": "nyc mocha", + "clean:common": "npm run clean", + "build:common": "npm run build:common:inc", + "build:common:inc": "fast-arktsc --config ./arktsconfig.json --compiler ../tools/panda/arkts/arktsc --link-name ./build/common.abc && ninja ${NINJA_OPTIONS} -f build/abc/build.ninja", + "build:common:inc:ui2abc": "fast-arktsc --config ./arktsconfig.json --compiler ../tools/panda/arkts/ui2abc --file-option --link-name ./build/common.abc && PANDA_SDK_PATH=../tools/panda/node_modules/@panda/sdk ninja ${NINJA_OPTIONS} -f build/abc/build.ninja" + }, + "keywords": [], + "dependencies": { + "@koalaui/compat": "1.5.15+devel" + }, + "devDependencies": { + "@ohos/hypium": "1.0.6", + "@types/chai": "^4.3.1", + "@types/mocha": "^9.1.0", + "@typescript-eslint/eslint-plugin": "^5.20.0", + "@typescript-eslint/parser": "^5.20.0", + "chai": "^4.3.6", + "eslint": "^8.13.0", + "eslint-plugin-unused-imports": "^2.0.0", + "mocha": "^9.2.2", + "source-map-support": "^0.5.21" + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/Errors.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/Errors.ts new file mode 100644 index 0000000000000000000000000000000000000000..41db13a180b0e962d231e60ebb3997476c83a9bb --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/Errors.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +// "assert" is a reserved keyword in ArkTS :-( +export function assertion(condition: boolean, message: string) { + if (!condition) throw new Error(message) +} + +// The unknonwn type support in ArkTS compiler is not ready yet. +// When it is ready move from +// ensure(value, message) +// to +// value ?? error(message) +// which is much more readable +export function ensure(value: T|undefined, message: string): T { + if (value == undefined) throw new Error(message) + return value as T +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/Finalization.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/Finalization.ts new file mode 100644 index 0000000000000000000000000000000000000000..2ba480ca2d549e5299bb8d71454f9c7b0294c57f --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/Finalization.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { finalizerRegister as finalizerRegisterCompat, finalizerUnregister as finalizerUnregisterCompat, Thunk } from "@koalaui/compat" + +export { Thunk } from "@koalaui/compat" + +export function finalizerRegister(target: object, thunk: Thunk) { + finalizerRegisterCompat(target, thunk) +} + +export function finalizerRegisterWithCleaner(target: object, cleaner: () => void) { + finalizerRegisterCompat(target, new CleanerThunk(cleaner)) +} + +export function finalizerUnregister(target: object) { + finalizerUnregisterCompat(target) +} + +class CleanerThunk implements Thunk { + private cleaner: () => void + constructor(cleaner: () => void) { + this.cleaner = cleaner + } + clean() { + this.cleaner() + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/KoalaProfiler.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/KoalaProfiler.ts new file mode 100644 index 0000000000000000000000000000000000000000..639b5d82b5ee4a30bada9869e40f464bf3901a49 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/KoalaProfiler.ts @@ -0,0 +1,190 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { int32 } from "@koalaui/compat" + +/** + * Adds statistics for constructing/disposing of the TreeNode instances. + * It is disabled by default because collecting such data affects performance. + */ +const DEBUG_WITH_NODE_STATS = false + +export class KoalaProfiler { + private static readonly map = DEBUG_WITH_NODE_STATS + ? new Map>() + : undefined + + static nodeCreated(nodeType: int32, node: Object) { + if (KoalaProfiler.map === undefined) return + let set = KoalaProfiler.map!.get(nodeType) + if (set === undefined) { + set = new Set() + KoalaProfiler.map!.set(nodeType, set) + } + set.add(node) + } + + static nodeDisposed(nodeType: int32, node: Object) { + if (KoalaProfiler.map === undefined) return + let set = KoalaProfiler.map!.get(nodeType) + if (set === undefined) throw new Error("node never existed") + if (!set.delete(node)) console.log("node is already disposed") + } + + public static counters: KoalaProfiler | undefined = undefined + + private invalidations = 0 + private computes = 0 + private builds = 0 + private nodes = 0 + private realDraws = 0 + private cachedDraws = 0 + private measures = 0 + private layouts = 0 + private frames = 0 + private lastTime = 0.0 + private lastFPS = 0 + private updateEnterTime = 0.0 + private updateExitTime = 0.0 + private updateTime = 0.0 + private buildEnterTime = 0.0 + private buildExitTime = 0.0 + private buildTime = 0.0 + private layoutEnterTime = 0.0 + private layoutExitTime = 0.0 + private layoutTime = 0.0 + private drawEnterTime = 0.0 + private drawExitTime = 0.0 + private drawTime = 0.0 + private updatableStates = 0 + private mutableStates = 0 + private computableValues = 0 + + static enable() { + KoalaProfiler.counters = new KoalaProfiler() + } + + static disable() { + KoalaProfiler.counters = undefined + } + + static enabled(): boolean { + return KoalaProfiler.counters != undefined + } + + reset() { + this.invalidations = 0 + this.computes = 0 + this.builds = 0 + this.nodes = 0 + this.realDraws = 0 + this.cachedDraws = 0 + this.layouts = 0 + this.measures = 0 + this.updateEnterTime = 0 + this.updateExitTime = 0 + this.updatableStates = 0 + this.mutableStates = 0 + this.computableValues = 0 + } + + report() { + console.log(this.getReport()) + } + + getReport(): string { + const updateTime = Math.round(1000 * (this.updateExitTime - this.updateEnterTime)) + const buildTime = Math.round(1000 * (this.buildExitTime - this.buildEnterTime)) + const layoutTime = Math.round(1000 * (this.layoutExitTime - this.layoutEnterTime)) + const drawTime = Math.round(1000 * (this.drawExitTime - this.drawEnterTime)) + if (this.updateTime < updateTime) this.updateTime = updateTime + if (this.buildTime < buildTime) this.buildTime = buildTime + if (this.layoutTime < layoutTime) this.layoutTime = layoutTime + if (this.drawTime < drawTime) this.drawTime = drawTime + + // TODO: OHOS does not properly handle \n in template literals + const array = Array.of( + `invalidations: ${this.invalidations}`, + `modified states: ${this.mutableStates}/${this.updatableStates} + ${this.computableValues}`, + `update states (mks): ${this.updateTime} / ${updateTime}`, + `build root node (mks): ${this.buildTime} / ${buildTime}`, + `layout view (mks): ${this.layoutTime} / ${layoutTime}`, + `draw view (mks): ${this.drawTime} / ${drawTime}`, + `computes: ${this.computes}`, + `builds: ${this.builds}`, + `nodes: ${this.nodes}`, + `realDraws: ${this.realDraws}`, + `cachedDraws: ${this.cachedDraws}`, + `measures: ${this.measures}`, + `layouts: ${this.layouts}`, + `FPS: ${this.lastFPS}`, + ) + KoalaProfiler.map?.forEach((set:Set, kind:int32) => { + if (set.size > 0) array.push(kind + ":" + set.size) + }) + return array.join("\n") + } + + invalidation() { this.invalidations++ } + compute() { this.computes++ } + build() { this.builds++ } + node() { this.nodes++ } + realDraw() { this.realDraws++ } + cachedDraw() { this.cachedDraws++ } + layout() { this.layouts++ } + measure() { this.measures++ } + frame(ms: number) { + if (ms - this.lastTime <= 1000) { + this.frames++ + } else { + this.lastFPS = Math.round(this.frames * 1000 / (ms - this.lastTime)) as int32 + this.frames = 1 + this.lastTime = ms + } + } + buildRootEnter() { + this.buildEnterTime = Date.now() + } + buildRootExit() { + this.buildExitTime = Date.now() + } + layoutEnter() { + this.layoutEnterTime = Date.now() + } + layoutExit() { + this.layoutExitTime = Date.now() + } + drawEnter() { + this.drawEnterTime = Date.now() + } + drawExit() { + this.drawExitTime = Date.now() + } + updateSnapshotEnter() { + this.updateEnterTime = Date.now() + } + updateSnapshotExit() { + this.updateExitTime = Date.now() + } + updateSnapshot(modified: int32, all?: int32) { + if (all === undefined) { + this.computableValues = modified - this.mutableStates + + } else { + this.mutableStates = modified + this.updatableStates = all + } + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/LifecycleEvent.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/LifecycleEvent.ts new file mode 100644 index 0000000000000000000000000000000000000000..577d161d41b686b0146bebf0773f22596f4d9643 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/LifecycleEvent.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export enum LifecycleEventKind { + SHOW_FRAME, + HIDE_FRAME, + CLOSE_FRAME, + ON_APPEAR, + ON_DISAPPEAR, + SHOW_COMPONENT, + HIDE_COMPONENT, + BACK, + FOCUS_FRAME, + UNFOCUS_FRAME +} + +export class LifecycleEvent { + kind: LifecycleEventKind + constructor(kind: LifecycleEventKind) { + this.kind = kind + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/MarkableQueue.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/MarkableQueue.ts new file mode 100644 index 0000000000000000000000000000000000000000..99adf2fbd4a5540335fc21d4de58185d1d7bff5b --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/MarkableQueue.ts @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AtomicRef } from "@koalaui/compat" + +/** + * A markable queue that allows to accumulate callbacks and to call them to the latest set marker. + */ +export interface MarkableQueue { + /** Sets the new marker to the queue. */ + setMarker(): void + /** Adds the given callback to the queue. */ + addCallback(callback: () => void): void + /** Calls all accumulated callbacks to the latest set marker. */ + callCallbacks(): void + /** Clears the queue. */ + clear(): void +} + +/** + * Creates a new markable queue to safely process callbacks across several threads or tasks. + * @param reversed - `true` changes the order of calling callbacks + */ +export function markableQueue(reversed: boolean = false): MarkableQueue { + return reversed ? new ReversedQueue() : new DefaultQueue() +} + +class DefaultQueue implements MarkableQueue { + private readonly last = new AtomicRef(new Block()) + private readonly first = new AtomicRef(this.last.value) + private readonly marker = new AtomicRef(undefined) + + setMarker(): void { + const marker = new Block() + this.last.getAndSet(marker).next.value = marker + this.marker.value = marker + } + + addCallback(callback: () => void): void { + const block = new Block(callback) + this.last.getAndSet(block).next.value = block + } + + callCallbacks(): void { + const marker = this.marker.getAndSet(undefined) + if (marker) { + let block = this.first.getAndSet(marker) + while (block !== marker) { + block.callback?.() + block = block.next.value! + } + } + } + + clear(): void { + this.last.value = this.first.value + this.marker.value = undefined + } +} + +class ReversedQueue implements MarkableQueue { + private readonly last = new AtomicRef(undefined) + private readonly marker = new AtomicRef(undefined) + + setMarker(): void { + const marker = new Block() + marker.next.value = this.last.getAndSet(marker) + this.marker.value = marker + } + + addCallback(callback: () => void): void { + const block = new Block(callback) + block.next.value = this.last.getAndSet(block) + } + + callCallbacks(): void { + const marker = this.marker.getAndSet(undefined) + if (marker) { + let block = marker.next.getAndSet(undefined) + while (block) { + block!.callback?.() + block = block!.next.value + } + } + } + + clear(): void { + this.last.value = undefined + this.marker.value = undefined + } +} + +class Block { + readonly next = new AtomicRef(undefined) + readonly callback: (() => void) | undefined + + constructor(callback?: () => void) { + this.callback = callback + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/Matrix33.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/Matrix33.ts new file mode 100644 index 0000000000000000000000000000000000000000..9ff2feb33895acfd48b904e54e2d98c708139a89 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/Matrix33.ts @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Array_from_number, float32, float64 } from "@koalaui/compat" + +export function mat33(array?: Float32Array): Matrix33 { + return (array == undefined) ? new Matrix33 () : new Matrix33(array) +} + +const tolerance: float32 = (1.0 / (1 << 12)) + +export class Matrix33 { + public readonly array: Float32Array + constructor (array: Float32Array = new Float32Array(Array_from_number([ + 1.0, 0.0, 0.0, + 0.0, 1.0, 0.0, + 0.0, 0.0, 1.0 + ]))) { + this.array = array.slice() + } + + static zero(): Matrix33 { + return new Matrix33(new Float32Array(Array_from_number([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]))) + } + + static makeTranslate(dx: float32, dy: float32): Matrix33 { + return new Matrix33(new Float32Array(Array_from_number([1.0, 0.0, dx as float64, 0.0, 1.0, dy as float64, 0.0, 0.0, 1.0]))) + } + + static makeScale(dx: float32, dy: float32 = dx): Matrix33 { + return new Matrix33(new Float32Array(Array_from_number([dx as float64, 0.0, 0.0, 0.0, dy as float64, 0.0, 0.0, 0.0, 1.0]))) + } + + static makeRotate(degrees: float32, pivotX?: float32, pivotY?: float32): Matrix33 { + let rads = degrees * Math.PI / 180 + let cos = Math.cos(rads) + let sin = Math.sin(rads) + if (Math.abs(sin) <= tolerance) sin = 0.0 + if (Math.abs(cos) <= tolerance) cos = 0.0 + if (pivotX !== undefined && pivotY != undefined) { + let dx = pivotX - pivotX * cos + pivotY * sin + let dy = pivotY - pivotY * cos - pivotX * sin + return new Matrix33(new Float32Array(Array_from_number([cos, -sin, dx, sin, cos, dy, 0.0, 0.0, 1.0]))) + } else { + return new Matrix33(new Float32Array(Array_from_number([cos, -sin, 0.0, sin, cos, 0.0, 0.0, 0.0, 1.0]))) + } + } + + static makeSkew(sx: float32, sy: float32): Matrix33 { + return new Matrix33(new Float32Array(Array_from_number([1.0, sx, 0.0, sy, 1.0, 0.0, 0.0, 0.0, 1.0]))) + } + + makeConcat(rhs: Matrix33): Matrix33 { + return new Matrix33(new Float32Array(Array_from_number([ + this.array[0] * rhs.array[0] + this.array[1] * rhs.array[3] + this.array[2] * rhs.array[6], + this.array[0] * rhs.array[1] + this.array[1] * rhs.array[4] + this.array[2] * rhs.array[7], + this.array[0] * rhs.array[2] + this.array[1] * rhs.array[5] + this.array[2] * rhs.array[8], + this.array[3] * rhs.array[0] + this.array[4] * rhs.array[3] + this.array[5] * rhs.array[6], + this.array[3] * rhs.array[1] + this.array[4] * rhs.array[4] + this.array[5] * rhs.array[7], + this.array[3] * rhs.array[2] + this.array[4] * rhs.array[5] + this.array[5] * rhs.array[8], + this.array[6] * rhs.array[0] + this.array[7] * rhs.array[3] + this.array[8] * rhs.array[6], + this.array[6] * rhs.array[1] + this.array[7] * rhs.array[4] + this.array[8] * rhs.array[7], + this.array[6] * rhs.array[2] + this.array[7] * rhs.array[5] + this.array[8] * rhs.array[8], + ]))) + } + + makeTranspose(): Matrix33{ + return new Matrix33(new Float32Array(Array_from_number([ + this.array[0], this.array[3], this.array[6], + this.array[1], this.array[4], this.array[7], + this.array[2], this.array[5], this.array[8] + ]))) + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/Matrix44.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/Matrix44.ts new file mode 100644 index 0000000000000000000000000000000000000000..07e7e68bff203a5801591da1ee059a55ecc0b6b2 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/Matrix44.ts @@ -0,0 +1,381 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Array_from_number, float32 } from "@koalaui/compat" +import { Matrix33 } from "./Matrix33" +import { Point3 } from "./Point3" + + +export interface RotateOptions { + angle?: float32 + x?: float32 + y?: float32 + z?: float32 + pivotX?: float32 + pivotY?: float32 + pivotZ?: float32 +} + +export interface ScaleOptions { + x?: float32 + y?: float32 + z?: float32 + pivotX?: float32 + pivotY?: float32 + pivotZ?: float32 +} + +export interface TranslateOptions { + x?: float32 + y?: float32 + z?: float32 +} + +// TODO: this is because ArkTS doesn allow interface literal instances. +class TranslateOptionsImpl implements TranslateOptions { + _x: float32 | undefined + _y: float32 | undefined + _z: float32 | undefined + + get x(): float32 | undefined { return this._x } + get y(): float32 | undefined { return this._y } + get z(): float32 | undefined { return this._z } + + set x(x: float32 | undefined) { this._x = x } + set y(y: float32 | undefined) { this._y = y } + set z(z: float32 | undefined) { this._z = z } + + constructor( + x: float32 | undefined, + y: float32 | undefined, + z: float32 | undefined + ) { + this._x = x + this._y = y + this._z = z + } +} + +export function mat44(array?: Float32Array): Matrix44 { + return (array == undefined)? new Matrix44() : new Matrix44(array) +} +/** + * 4x4 matrix with right-handed coordinate system: + * +x goes to the right + * +y goes down + * +z goes into the screen (away from the viewer) + */ +export class Matrix44 { + public readonly array: Float32Array + constructor (array: Float32Array = new Float32Array(Array_from_number([ + 1.0, 0.0, 0.0, 0.0, + 0.0, 1.0, 0.0, 0.0, + 0.0, 0.0, 1.0, 0.0, + 0.0, 0.0, 0.0, 1.0 + ]))) { + this.array = array.slice() + } + + public static identity(): Matrix44 { + return mat44() + } + + static zero(): Matrix44 { + return mat44(new Float32Array(Array_from_number([ + 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, + ]))) + } + + public static lookAt(eye: Point3, center: Point3, up: Point3): Matrix44 { + const f = center.subtract(eye).normalize() + const u = up.normalize() + const s = f.cross(u).normalize() + const sf = s.cross(f) + return new Matrix44(new Float32Array(Array_from_number([ + s.x, sf.x, -f.x, eye.x, + s.y, sf.y, -f.y, eye.y, + s.z, sf.z, -f.z, eye.z, + 0, 0, 0, 1, + ]))).invert() + } + + public static perspective(depth: float32): Matrix44 { + return new Matrix44(new Float32Array(Array_from_number([ + 1.0, 0.0, 0.0, 0.0, + 0.0, 1.0, 0.0, 0.0, + 0.0, 0.0, 1.0, 0.0, + 0.0, 0.0, -1.0 / depth, 1.0, + ]))) + } + + public static perspectiveFov(fov: float32, near: float32, far: float32): Matrix44 { + const denomInv = (far - near) + const halfAngle = fov * 0.5; + const cot = Math.cos(halfAngle) / Math.sin(halfAngle) + return new Matrix44(new Float32Array(Array_from_number([ + cot, 0.0, 0.0, 0.0, + 0.0, cot, 0.0, 0.0, + 0.0, 0.0, (far + near) * denomInv, 2 * far * near * denomInv, + 0.0, 0.0, -1.0, 0.0, + ]))) + } + + /** + * Returns new matrix, made from Matrix33. + * + * @param matrix - 3x3 matrix + * @returns the new instance of Matrix44 + * + */ + public static makeFromMatrix33(matrix: Matrix33): Matrix44{ + return new Matrix44(new Float32Array(Array_from_number([ + matrix.array[0], matrix.array[1], 0.0, matrix.array[2], + matrix.array[3], matrix.array[4], 0.0, matrix.array[5], + 0.0, 0.0, 1.0, 0.0, + matrix.array[6], matrix.array[7], 0.0, matrix.array[8] + ]))) + } + + /** + * Returns new 3x3 matrix, made from this matrix by dropping the third row and the third column. + * + * @returns the new instance of Matrix33 + * + */ + public asMatrix33(): Matrix33{ + return new Matrix33(new Float32Array(Array_from_number([ + this.array[0], this.array[1], this.array[3], + this.array[4], this.array[5], this.array[7], + this.array[12], this.array[13], this.array[15] + ]))) + } + + public copy(): Matrix44 { + return new Matrix44(new Float32Array(Array_from_number([ + this.array[0], this.array[1], this.array[2], this.array[3], + this.array[4], this.array[5], this.array[6], this.array[7], + this.array[8], this.array[9], this.array[10], this.array[11], + this.array[12], this.array[13], this.array[14], this.array[15] + ]))) + } + + concat(matrix: Matrix44): Matrix44 { + const result: Float32Array = new Float32Array(Array_from_number([ + 1.0, 0.0, 0.0, 0.0, + 0.0, 1.0, 0.0, 0.0, + 0.0, 0.0, 1.0, 0.0, + 0.0, 0.0, 0.0, 1.0, + ])) + for (let row = 0; row < 4; row++) { + for (let col = 0; col < 4; col++) { + let num: float32 = 0 + for (let k = 0; k < 4; k++) { + num += this.array[row * 4 + k] * matrix.array[col + 4 * k] + } + result[row * 4 + col] = num + } + } + for (let i = 0; i < this.array.length; i++) { + this.array[i] = result[i] + } + return this + } + + public scale(options: ScaleOptions): Matrix44 { + const scaled = new Matrix44() + scaled.array[0] = options.x ?? 1.0 as float32 + scaled.array[5] = options.y ?? 1.0 as float32 + scaled.array[10] = options.z ?? 1.0 as float32 + + this.translate(new TranslateOptionsImpl( + -(options.pivotX ?? 0.0 as float32) * (options.x ?? 1.0 as float32) + (options.pivotX ?? 0.0 as float32), + -(options.pivotY ?? 0.0 as float32) * (options.y ?? 1.0 as float32) + (options.pivotY ?? 0.0 as float32), + undefined + )).concat(scaled) + + return this + } + + public rotate(options: RotateOptions): Matrix44 { + const translationToPivot = mat44().translate(new TranslateOptionsImpl( + (options.pivotX ?? 0.0 as float32), + (options.pivotY ?? 0.0 as float32), + (options.pivotZ ?? 0.0 as float32), + )) + const translationToBack = mat44().translate(new TranslateOptionsImpl( + -(options.pivotX ?? 0.0 as float32), + -(options.pivotY ?? 0.0 as float32), + -(options.pivotZ ?? 0.0 as float32), + )) + + const vec = new Point3(options.x ?? 0.0 as float32, options.y ?? 0.0 as float32, options.z ?? 0.0 as float32).normalize() + const rads = (options.angle ?? 0.0 as float32) * Math.PI / 180 + let c = Math.cos(rads) + let s = Math.sin(rads) + const tolerance = (1.0 / (1 << 12)) + if (Math.abs(s) <= tolerance) s = 0.0 + if (Math.abs(c) <= tolerance) c = 0.0 + let t = 1 - c + const x = vec.x + const y = vec.y + const z = vec.z + + const rotation = mat44() + rotation.array[0] = t * x * x + c + rotation.array[1] = t * x * y - s * z + rotation.array[2] = t * x * z + s * y + rotation.array[3] = 0 + rotation.array[4] = t * x * y + s * z + rotation.array[5] = t * y * y + c + rotation.array[6] = t * y * z - s * x + rotation.array[7] = 0 + rotation.array[8] = t * x * z - s * y + rotation.array[9] = t * y * z + s * x + rotation.array[10] = t * z * z + c + rotation.array[11] = 0 + rotation.array[12] = 0 + rotation.array[13] = 0 + rotation.array[14] = 0 + rotation.array[15] = 1 + + this.concat(translationToPivot).concat(rotation).concat(translationToBack) + + return this + } + + public translate(options: TranslateOptions): Matrix44 { + this.array[3] = options.x ?? 0.0 as float32 + this.array[7] = options.y ?? 0.0 as float32 + this.array[11] = options.z ?? 0.0 as float32 + return this + } + + public invert(): Matrix44 { + const result: Float32Array = new Float32Array(16) + + let a00 = this.array[0] + let a01 = this.array[1] + let a02 = this.array[2] + let a03 = this.array[3] + let a10 = this.array[4] + let a11 = this.array[5] + let a12 = this.array[6] + let a13 = this.array[7] + let a20 = this.array[8] + let a21 = this.array[9] + let a22 = this.array[10] + let a23 = this.array[11] + let a30 = this.array[12] + let a31 = this.array[13] + let a32 = this.array[14] + let a33 = this.array[15] + + let b00 = a00 * a11 - a01 * a10 + let b01 = a00 * a12 - a02 * a10 + let b02 = a00 * a13 - a03 * a10 + let b03 = a01 * a12 - a02 * a11 + let b04 = a01 * a13 - a03 * a11 + let b05 = a02 * a13 - a03 * a12 + let b06 = a20 * a31 - a21 * a30 + let b07 = a20 * a32 - a22 * a30 + let b08 = a20 * a33 - a23 * a30 + let b09 = a21 * a32 - a22 * a31 + let b10 = a21 * a33 - a23 * a31 + let b11 = a22 * a33 - a23 * a32 + + let determinant = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06 + let invdet = 1.0 / determinant + b00 *= invdet + b01 *= invdet + b02 *= invdet + b03 *= invdet + b04 *= invdet + b05 *= invdet + b06 *= invdet + b07 *= invdet + b08 *= invdet + b09 *= invdet + b10 *= invdet + b11 *= invdet + + result[0] = a11 * b11 - a12 * b10 + a13 * b09 + result[1] = a02 * b10 - a01 * b11 - a03 * b09 + result[2] = a31 * b05 - a32 * b04 + a33 * b03 + result[3] = a22 * b04 - a21 * b05 - a23 * b03 + result[4] = a12 * b08 - a10 * b11 - a13 * b07 + result[5] = a00 * b11 - a02 * b08 + a03 * b07 + result[6] = a32 * b02 - a30 * b05 - a33 * b01 + result[7] = a20 * b05 - a22 * b02 + a23 * b01 + result[8] = a10 * b10 - a11 * b08 + a13 * b06 + result[9] = a01 * b08 - a00 * b10 - a03 * b06 + result[10] = a30 * b04 - a31 * b02 + a33 * b00 + result[11] = a21 * b02 - a20 * b04 - a23 * b00 + result[12] = a11 * b07 - a10 * b09 - a12 * b06 + result[13] = a00 * b09 - a01 * b07 + a02 * b06 + result[14] = a31 * b01 - a30 * b03 - a32 * b00 + result[15] = a20 * b03 - a21 * b01 + a22 * b00 + + // If 1/det overflows to infinity (i.e. det is denormalized) or any of the inverted matrix + // values is non-finite, return zero to indicate a non-invertible matrix. + let prod = 0 + for (let i = 0; i < result.length; ++i) { + prod *= result[i] + } + // At this point, prod will either be NaN or 0 + // if prod is NaN, this check will return false + if (prod == 0) { + for (let i = 0; i < this.array.length; i++) { + this.array[i] = result[i] + } + } + return this + } + + public transpose(): Matrix44 { + const result: Float32Array = new Float32Array(16) + + result[0] = this.array[0] + result[1] = this.array[4] + result[2] = this.array[8] + result[3] = this.array[12] + result[4] = this.array[1] + result[5] = this.array[5] + result[6] = this.array[9] + result[7] = this.array[13] + result[8] = this.array[2] + result[9] = this.array[6] + result[10] = this.array[10] + result[11] = this.array[14] + result[12] = this.array[3] + result[13] = this.array[7] + result[14] = this.array[11] + result[15] = this.array[15] + + for (let i = 0; i < this.array.length; i++) { + this.array[i] = result[i] + } + + return this + } + + public skew(x?: float32, y?: float32): Matrix44 { + this.array[1] += x ?? 0.0 as float32 + this.array[4] += y ?? 0.0 as float32 + return this + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/PerfProbe.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/PerfProbe.ts new file mode 100644 index 0000000000000000000000000000000000000000..61db32f6711c99d473ca8791c13d497d280fdf6f --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/PerfProbe.ts @@ -0,0 +1,435 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { float64, int32, timeNow, numberToFixed } from "@koalaui/compat" + +/** + * A probe to measure performance. + * + * A probe can measure performance of any activity which has an entry and an exit points. + * Such activity can be a method call, or a sequence of actions, possibly asynchronous. + * + * A probe which has been entered and exited is considered a performed probe (see {@link MainPerfProbe.probePerformed}). + * A probe can be entered recursively. When all the recursive calls exits the probe becomes a performed probe. + * + * All performing probes form a hierarchy which is rooted at the main probe (see {@link enterMainPerfProbe}). + * A last started probe (see {@link MainPerfProbe.enterProbe}) which has not yet performed becomes a parent + * for the next started probe. It's the responsibility of the API caller to keep this parent-child relationship valid, + * that is: a child probe should exit before its parent probe exits. + * + * Statistics gathered by a probe: + * - call count + * - recursive call count + * - total time and percentage relative to the main (root) probe + */ +export interface PerfProbe { + /** + * The name of the probe. + */ + readonly name: string + + /** + * Whether this is a dummy probe which does not measure (a noop). + * + * @see MainPerfProbe.getProbe + */ + readonly dummy: boolean + + /** + * Exists the probe. + * + * @param log log the gathered statistics. + * @see MainPerfProbe.enterProbe + */ + exit(log: boolean|undefined): void + + /** + * Cancels measuring the probe and its children probes. + */ + cancel(b?: Boolean): void + + /** + * User-defined data associated with the probe. + */ + userData: string | undefined + + /** + * Whether the probe was canceled. + */ + readonly canceled: boolean +} + +/** + * The main (root) {@link PerfProbe}. + * + * This probe is used to enter the main activity. + * + * Calling {@link PerfProbe.cancel} removes the main probe and disposes all its resources. + * + * Calling {@link PerfProbe.exit} exits the main probe, cancels it and when the log option is provided + * logs the gathered statistics. + * + * @see enterMainPerfProbe + * @see getMainPerfProbe + */ +export interface MainPerfProbe extends PerfProbe { + /** + * Enters a child probe referenced by the {@link name} and measures it. + * If the probe does not exist, returns a dummy instance. + * + * If the probe already performs a recursive call is counted. + * + * @see PerfProbe.exit + * @see exitProbe + */ + enterProbe(name: string): PerfProbe + + /** + * Exits a child probe referenced by the {@link name}. + * If the probe does not exist, returns a dummy instance. + * + * This is an equivalent of calling {@link getProbe} and then {@link PerfProbe.exit}. + */ + exitProbe(name: string): PerfProbe + + /** + * Returns the child probe referenced by the {@link name} if it exists, + * otherwise a dummy instance. + * + * @see PerfProbe.dummy + */ + getProbe(name: string): PerfProbe + + /** + * Performs the {@link func} of a child probe referenced by the {@link name} and measures it. + * + * This is an equivalent of calling {@link enterProbe} and then {@link exitProbe}. + * + * If the probe already performs a recursive call is counted. + */ + performProbe(name: string, func: () => T): T + + /** + * Returns true if the probe referenced by the {@link name} has been performed + * (entered and exited all the recursive calls). + */ + probePerformed(name: string): boolean +} + +/** + * Creates a {@link MainPerfProbe} instance with the {@link name} and enters its main probe. + * + * If a {@link MainPerfProbe} with this {@link name} already exists then it is canceled and the new one is created. + * + * Exit it with {@link MainPerfProbe.exit}. + */ +export function enterMainPerfProbe(name: string): MainPerfProbe { + return new MainPerfProbeImpl(name) +} + +/** + * Returns {@link MainPerfProbe} instance with the {@link name} if it exists, + * otherwise a dummy instance. + * + * @see MainPerfProbe.dummy + */ +export function getMainPerfProbe(name: string): MainPerfProbe { + const instance = MainPerfProbeImpl.mainProbes.get(name) + return instance ? instance : MainPerfProbeImpl.DUMMY +} + +class DummyPerfProbe implements MainPerfProbe { + get name(): string { return "dummy" } + get dummy(): boolean { return true } + exit(log: boolean|undefined): void {} + cancel(b?: Boolean) {} + get canceled(): boolean { return false } + enterProbe(name: string): PerfProbe { return PerfProbeImpl.DUMMY } + exitProbe (name: string): PerfProbe { return PerfProbeImpl.DUMMY } + getProbe(name: string): PerfProbe { return PerfProbeImpl.DUMMY } + //performProbe: (_: string, func: () => T) => func(), + performProbe(name: string, func: () => T): T { return func() } + probePerformed(_: string): boolean { return false } + + get userData(): string | undefined { + return undefined + } + set userData(_: string | undefined) {} +} + +class PerfProbeImpl implements PerfProbe { + constructor( + name: string, + main?: MainPerfProbeImpl, + parent?: PerfProbeImpl, + remainder: boolean = false + ) { + this._name = name + this._main = main + this.parent = parent + this.remainder = remainder + } + + private readonly _name: string + private readonly _main: MainPerfProbeImpl|undefined + public parent: PerfProbeImpl|undefined + public readonly remainder: boolean + + children: Array = new Array() + childrenSorted: boolean = false + index: int32 = 0 + startTime: float64 = 0.0 + totalTime: float64 = 0.0 + callCount: int32 = 0 + currentRecursionDepth: int32 = 0 + recursiveCallCount: int32 = 0 + _canceled: boolean = false + private _userData?: string + + get name(): string { + return this._name + } + + get dummy(): boolean { + return false + } + + get main(): MainPerfProbeImpl { + return this._main! + } + + get performing(): boolean { + return this.startTime > 0 + } + + get userData(): string | undefined { + return this._userData + } + + set userData(value: string | undefined) { + this._userData = value + } + + exit(log?: boolean): void { + if (this.canceled) return + + if (this.currentRecursionDepth == 0) { + this.totalTime += timeNow() - this.startTime + this.startTime = 0 + } else { + this.currentRecursionDepth-- + } + if (!this.performing) { + this.main.pop(this) + } + if (log) this.log() + } + + cancelWithChildren() { + this.cancel() + this.maybeCancelChildren() + } + + cancel(b?: Boolean) { + this._canceled = true + } + + private maybeCancelChildren() { + MainPerfProbeImpl.visit(this, false, (probe: PerfProbeImpl, depth: int32) => { + if (probe.performing) probe.cancel() + }) + } + + get canceled(): boolean { + return this._canceled + } + + toString(): string { + if (this.canceled) { + return `[${this.name}] canceled` + } + if (this.performing) { + return `[${this.name}] still performing...` + } + const mainProbe = this.main.probes.get(this.main.name)! + const percentage = mainProbe.totalTime > 0 ? Math.round((100 / mainProbe.totalTime) * this.totalTime) : 0 + + let result = `[${this.name}] call count: ${this.callCount}` + + ` | recursive call count: ${this.recursiveCallCount}` + + ` | time: ${this.totalTime}ms ${percentage}%` + + if (this.userData) { + result += ` | user data: ${this.userData}` + } + + return result + } + + protected log(prefix?: string) { + console.log(prefix ? `${prefix}${this.toString()}` : this.toString()) + } + + static readonly DUMMY: PerfProbe = new DummyPerfProbe() +} + +class MainPerfProbeImpl extends PerfProbeImpl implements MainPerfProbe { + constructor( + name: string + ) { + super(name) + const prev = MainPerfProbeImpl.mainProbes.get(name) + if (prev) prev.cancel() + MainPerfProbeImpl.mainProbes.set(name, this) + this.currentProbe = this.enterProbe(name) + } + + static readonly mainProbes: Map = new Map() + + currentProbe: PerfProbeImpl + probes: Map = new Map() + + private createProbe(name: string): PerfProbeImpl { + const probes = name == this.name ? this : new PerfProbeImpl(name, this) + this.push(probes) + return probes + } + + get main(): MainPerfProbeImpl { + return this + } + + push(probe: PerfProbeImpl) { + probe.parent = this.currentProbe + probe.index = probe.parent ? probe.parent!.children.length as int32 : 0 + if (probe.parent) probe.parent!.children.push(probe) + this.currentProbe = probe + } + + pop(probe: PerfProbeImpl) { + if (probe.parent) { + this.currentProbe = probe.parent! + } + } + + performProbe(name: string, func: () => T): T { + const probe = this.enterProbe(name) + try { + return func() + } finally { + probe.exit() + } + } + + enterProbe(name: string): PerfProbeImpl { + let probe = this.probes.get(name) + if (!probe) { + probe = this.createProbe(name) + this.probes.set(name, probe) + } + probe._canceled = false + + if (probe.performing) { + probe.recursiveCallCount++ + probe.currentRecursionDepth++ + } else { + probe.startTime = timeNow() + probe.callCount++ + } + return probe + } + + exitProbe(name: string): PerfProbe { + const probe = this.getProbe(name) + probe.exit(undefined) + return probe + } + + getProbe(name: string): PerfProbe { + const probe = this.probes.get(name) + return probe !== undefined ? probe : PerfProbeImpl.DUMMY + } + + probePerformed(name: string): boolean { + const probe = this.probes.get(name) + return probe != undefined && !probe!.performing && !probe!.canceled + } + + exit(log?: boolean) { + super.exit() + if (log) this.log() + this.cancel() + } + + cancel(b?: Boolean) { + MainPerfProbeImpl.mainProbes.delete(this.name) + } + + static visit(root: PerfProbeImpl, logging: boolean, apply: (probe: PerfProbeImpl, depth: int32) => void) { + let current: PerfProbeImpl = root + let index = 0 + let depth = 0 + let visiting = true + while (true) { + if (visiting) { + current.index = 0 + apply(current, depth) + } + if (index >= current.children.length) { + if (!current.parent) { + break + } + current = current.parent! + index = ++current.index + depth-- + visiting = false + continue + } + visiting = true + if (logging && !current.childrenSorted) { + current.childrenSorted = true + current.children = current.children.sort((p1: PerfProbeImpl, p2: PerfProbeImpl):number => p2.totalTime - p1.totalTime) + if (depth == 0) { + // a special probe to log the time remained + current.children.push(new PerfProbeImpl("", root.main, current, true)) + } + } + current = current.children[index] + index = 0 + depth++ + } + } + + protected log(prefix?: string) { + prefix = prefix !== undefined ? `${prefix}: ` : "" + console.log(`${prefix}perf probes:`) + + MainPerfProbeImpl.visit(this.main, true, (probe, depth):void => { + let indent = "\t" + for (let i = 0; i < depth; i++) indent += "\t" + if (probe.remainder) { + const parentTime = probe.parent!.totalTime + let childrenTime = 0 + probe.parent!.children.forEach((a: PerfProbeImpl):void => { childrenTime += a.totalTime }) + probe.totalTime = Math.max(0, parentTime - childrenTime) as int32 + const percentage = parentTime > 0 ? Math.round((100 / parentTime) * probe.totalTime) : 0 + console.log(`${prefix}${indent}[${probe.name}] time: ${numberToFixed(probe.totalTime, 2)}ms ${percentage}%`) + } else { + console.log(`${prefix}${indent}${probe.toString()}`) + } + }) + } + + static readonly DUMMY: MainPerfProbe = new DummyPerfProbe() +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/Point.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/Point.ts new file mode 100644 index 0000000000000000000000000000000000000000..f8f260dc0a642aad89f14aeb250d990076dc0ff4 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/Point.ts @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { float32 } from "@koalaui/compat" + +export class Point { + coordinates: Float32Array + + constructor (x: float32, y: float32) { + this.coordinates = new Float32Array(2) + this.coordinates[0] = x + this.coordinates[1] = y + } + + get x(): float32 { + return this.coordinates[0] as float32 + } + + get y(): float32 { + return this.coordinates[1] as float32 + } + + offsetXY(dx: float32, dy: float32): Point { + return new Point(this.x + dx, this.y + dy) + } + + offset(vec: Point): Point { + return this.offsetXY(vec.x, vec.y) + } + + scale(scale: float32): Point { + return this.scaleXY(scale, scale) + } + + scaleXY(sx: float32, sy: float32): Point { + return new Point(this.x * sx, this.y * sy) + } + + static ZERO = new Point(0.0 as float32, 0.0 as float32) + + toArray(): Float32Array { + return this.coordinates + } + + static flattenArray(points: Array): Float32Array { + let array = new Float32Array(points.length * 2) + for (let i = 0; i < points.length; i++) { + array[i * 2] = points[i].x + array[i * 2 + 1] = points[i].y + } + return array + } + + static fromArray(points: Float32Array): Array { + if (points.length % 2 != 0) + throw new Error("Expected " + points.length + " % 2 == 0") + + let array = new Array(points.length / 2) + for (let i = 0; i < points.length / 2; i++) { + array[i] = new Point(points[i * 2] as float32, points[i * 2 + 1] as float32) + } + return array + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/Point3.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/Point3.ts new file mode 100644 index 0000000000000000000000000000000000000000..0ea70e185e788a921ee9d49d5255220249820e33 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/Point3.ts @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { float32 } from "@koalaui/compat" + +export class Point3 { + x: float32 + y: float32 + z: float32 + constructor(x: float32, y: float32, z: float32) { + this.x = x + this.y = y + this.z = z + } + + subtract(value: Point3): Point3 { + return new Point3( + this.x - value.x, + this.y - value.y, + this.z - value.z + ) + } + + cross(value: Point3): Point3 { + return new Point3( + this.y * value.z - this.z * value.y, + this.z * value.x - this.x * value.z, + this.x * value.y - this.y * value.x + ) + } + + normalize(): Point3 { + const mag = Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z) as float32 + const tolerance = (1.0 / (1 << 12)) + if (mag < tolerance) { + // This semicolon after return this is a workaround for ArkTS bug + return this; + } + return new Point3(this.x / mag, this.y / mag, this.z / mag) + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/index.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..8ecbb2c9ab689964d652307eb21cebcd8a4a9827 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/index.ts @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export { + int8, uint8, + int32, uint32, + int64, uint64, + float32, float64, + asArray, + asFloat64, + float32FromBits, + int32BitsFromFloat, + Array_from_set, + AtomicRef, + CustomTextDecoder, + CustomTextEncoder, + className, lcClassName, + functionOverValue, + Observed, + Observable, + ObservableHandler, + observableProxy, + observableProxyArray, + isFunction, + propDeepCopy, + refEqual, + int8Array, + unsafeCast, + scheduleCoroutine, + memoryStats, + launchJob +} from "@koalaui/compat" +export { clamp, lerp, modulo, parseNumber, isFiniteNumber, getDistancePx } from "./math" +export { hashCodeFromString } from "./stringUtils" +export { KoalaProfiler } from "./KoalaProfiler" +export * from "./PerfProbe" +export * from "./Errors" +export * from "./LifecycleEvent" +export * from "./Finalization" +export * from "./MarkableQueue" +export * from "./Matrix33" +export * from "./Matrix44" +export * from "./Point3" +export * from "./Point" +export { SHA1Hash, createSha1 } from "./sha1" +export { UniqueId } from "./uniqueId" +export * from "./koalaKey" diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/koalaKey.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/koalaKey.ts new file mode 100644 index 0000000000000000000000000000000000000000..c78ff5eb8d17155a7f0d0fb3b234f13e797a1655 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/koalaKey.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { int32 } from "@koalaui/compat" + +export type KoalaCallsiteKey = int32 + +export class KoalaCallsiteKeys { + static readonly empty: KoalaCallsiteKey = 0 as int32 + + static combine (key1: KoalaCallsiteKey, key2: KoalaCallsiteKey): KoalaCallsiteKey { + return key1 + key2 + } + + static asString(key: KoalaCallsiteKey): string { + return new Number(key).toString(16) + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/math.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/math.ts new file mode 100644 index 0000000000000000000000000000000000000000..8827d8d7b5e5b5268775bc36c557eb384f6db8f1 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/math.ts @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { asFloat64, asString, float64 } from "@koalaui/compat" + +/** + * Computes the linear interpolation between `source` and `target` based on `weight`. + * + * @param weight - interpolation factor in the range [0..1] + * @param source - a value corresponding to weight 0 + * @param target - a value corresponding to weight 1 + * @returns interpolated value + */ +export function lerp(weight: float64, source: float64, target: float64): float64 { + return source * (1.0 - weight) + target * weight +} + +/** + * Clamps a {@link value} within the specified range. + * + * @param value - a value to clamp + * @param min - the lower boundary of the range + * @param max - the upper boundary of the range + * @returns `min` if `value` is less than `min`, + * `max` if `value` is greater than `max`, + * `value` otherwise + */ +export function clamp(value: float64, min: float64, max: float64): float64 { + return value <= min ? min : value >= max ? max : value +} + +/** + * Calculates the difference between the argument and + * the largest (closest to positive infinity) integer value + * that is less than or equal to the argument. + * + * @param value a floating-point value to process + * @returns a floor modulus of the given value in the range [0..1) + */ +export function modulo(value: float64): float64 { + // The casts below are needed since floor returns double in ArkTS + const modulo: float64 = value - Math.floor(value) + return (modulo < 1.0) ? modulo : 0.0 +} + +/** + * @param str a string to parse + * @param name a name for error message + * @param verify whether to verify parsing validity + * @returns a floating-point number + * @throws Error if `str` cannot be parsed + */ +export function parseNumber(str: string, name: string = "number", verify: boolean = false): float64 { + if (str != "") { // do not parse empty string to 0 + // ArkTS does not support NaN, isNaN, parseFloat + const value = asFloat64(str) + if (verify) { + const reverseStr = asString(value) + if (reverseStr !== undefined && reverseStr?.length == str.length && reverseStr == str) { + return value + } + } + else { + return value + } + } + throw new Error(`cannot parse ${name}: "${str}"`) +} + +/** + * An ArkTS-compliant replacement for {@link isFinite}. + */ +export function isFiniteNumber(number: float64): boolean { + // With Node.js: + // isFiniteNumber(Number.NEGATIVE_INFINITY) == false + // isFiniteNumber(Number.POSITIVE_INFINITY) == false + // isFiniteNumber(NaN) == false + return number >= Number.MIN_SAFE_INTEGER && number <= Number.MAX_SAFE_INTEGER +} + +export function getDistancePx(startX: float64, startY: float64, endX: float64, endY: float64): float64 { + const cathetA = Math.abs(endX - startX) + const cathetB = Math.abs(endY - startY) + return Math.sqrt(cathetA * cathetA + cathetB * cathetB) as float64 +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/sha1.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/sha1.ts new file mode 100644 index 0000000000000000000000000000000000000000..6f75fe0f18d2fecb97d3894c804a082a194660d0 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/sha1.ts @@ -0,0 +1,354 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { CustomTextDecoder } from "@koalaui/compat" +import { int32 } from "@koalaui/compat" + +const K = [ + (0x5a827999 | 0) as int32, + (0x6ed9eba1 | 0) as int32, + (0x8f1bbcdc | 0) as int32, + (0xca62c1d6 | 0) as int32, +] + +const inputBytes = 64 +const inputWords = inputBytes / 4 +const highIndex = inputWords - 2 +const lowIndex = inputWords - 1 +const workWords = 80 +const allocBytes = 80 +const allocWords = allocBytes / 4 +const allocTotal = allocBytes * 100 + +export function createSha1(): SHA1Hash { + return new SHA1Hash() +} + +export class SHA1Hash { + private A = (0x67452301 | 0) as int32 + private B = (0xefcdab89 | 0) as int32 + private C = (0x98badcfe | 0) as int32 + private D = (0x10325476 | 0) as int32 + private E = (0xc3d2e1f0 | 0) as int32 + private readonly _byte: Uint8Array + private readonly _word: Int32Array + private _size = 0 + private _sp = 0 // surrogate pair + + constructor() { + if (!sharedBuffer || sharedOffset >= allocTotal) { + sharedBuffer = new ArrayBuffer(allocTotal) + sharedOffset = 0 + } + + this._byte = new Uint8Array(sharedBuffer, sharedOffset, allocBytes) + this._word = new Int32Array(sharedBuffer, sharedOffset, allocWords) + sharedOffset += allocBytes + } + + updateString(data: string, encoding?: string): SHA1Hash { + return this._utf8(data) + } + updateInt32(data: int32): SHA1Hash { + const buffer = new Int32Array(1) + buffer[0] = data + return this.update(buffer) + } + + update(data: Int32Array | Float32Array | Uint32Array | Uint8Array): SHA1Hash { + if (data == null) { + throw new TypeError("SHA1Hash expected non-null data: ") + } + + let byteOffset: int32 = 0 + let length: int32 = 0 + let buffer: ArrayBufferLike | undefined = undefined + + // TODO: an attempt to wrie this in a generic form causes + // es2panda to segfault. + let BYTES_PER_ELEMENT = 4 + if (data instanceof Int32Array) { + byteOffset = data.byteOffset as int32 + length = data.byteLength as int32 + buffer = data.buffer + } else if (data instanceof Uint32Array) { + byteOffset = data.byteOffset as int32 + length = data.byteLength as int32 + buffer = data.buffer + } else if (data instanceof Float32Array) { + byteOffset = data.byteOffset as int32 + length = data.byteLength as int32 + buffer = data.buffer + } else if (data instanceof Uint8Array) { + byteOffset = data.byteOffset as int32 + length = data.byteLength as int32 + buffer = data.buffer + BYTES_PER_ELEMENT = 1 + } + + let blocks: int32 = ((length / inputBytes) | 0) as int32 + let offset: int32 = 0 + + // longer than 1 block + if ((blocks != 0) && !(byteOffset & 3) && !(this._size % inputBytes)) { + const block = new Int32Array(buffer!, byteOffset, blocks * inputWords) + while (blocks--) { + this._int32(block, offset >> 2) + offset += inputBytes + } + this._size += offset + } + + // data: TypedArray | DataView + if ((BYTES_PER_ELEMENT != 1) && buffer != undefined) { + const rest = new Uint8Array(buffer, byteOffset + offset, length - offset) + return this._uint8(rest) + } + + // no more bytes + if (offset == length) return this + + return this._uint8(new Uint8Array(buffer!), offset) + } + + private _uint8(data: Uint8Array, offset?: int32): SHA1Hash { + const _byte = this._byte + const _word = this._word + const length = data.length + offset = ((offset ?? 0) | 0) as int32 + + while (offset < length) { + const start = this._size % inputBytes + let index = start + + while (offset < length && index < inputBytes) { + _byte[index++] = data[offset++] + } + + if (index >= inputBytes) { + this._int32(_word) + } + + this._size += index - start + } + + return this + } + + private _utf8(text: string): SHA1Hash { + const _byte = this._byte + const _word = this._word + const length = text.length + let surrogate = this._sp + + for (let offset = 0; offset < length; ) { + const start = this._size % inputBytes + let index = start + + while (offset < length && index < inputBytes) { + let code = text.charCodeAt(offset++) | 0 + if (code < 0x80) { + // ASCII characters + _byte[index++] = code + } else if (code < 0x800) { + // 2 bytes + _byte[index++] = 0xC0 | (code >>> 6) + _byte[index++] = 0x80 | (code & 0x3F) + } else if (code < 0xD800 || code > 0xDFFF) { + // 3 bytes + _byte[index++] = 0xE0 | (code >>> 12) + _byte[index++] = 0x80 | ((code >>> 6) & 0x3F) + _byte[index++] = 0x80 | (code & 0x3F) + } else if (surrogate) { + // 4 bytes - surrogate pair + code = ((surrogate & 0x3FF) << 10) + (code & 0x3FF) + 0x10000 + _byte[index++] = 0xF0 | (code >>> 18) + _byte[index++] = 0x80 | ((code >>> 12) & 0x3F) + _byte[index++] = 0x80 | ((code >>> 6) & 0x3F) + _byte[index++] = 0x80 | (code & 0x3F) + surrogate = 0 + } else { + surrogate = code + } + } + + if (index >= inputBytes) { + this._int32(_word) + _word[0] = _word[inputWords] + } + + this._size += index - start + } + + this._sp = surrogate + return this + } + + private _int32(data: Int32Array, offset?: int32): void { + let A = this.A + let B = this.B + let C = this.C + let D = this.D + let E = this.E + let i = 0 + offset = ((offset ?? 0) | 0) as int32 + + while (i < inputWords) { + W[i++] = swap32(data[offset++] as int32) + } + + for (i = inputWords; i < workWords; i++) { + W[i] = rotate1((W[i - 3] as int32) ^ (W[i - 8] as int32) ^ (W[i - 14] as int32) ^ (W[i - 16] as int32)) + } + + for (i = 0; i < workWords; i++) { + const S = (i / 20) | 0 + const T = ((rotate5(A) + ft(S, B, C, D) + E + W[i] + K[S]) as int32) | 0 + E = D + D = C + C = rotate30(B) + B = A + A = T + } + + this.A = (A + this.A) | 0 + this.B = (B + this.B) | 0 + this.C = (C + this.C) | 0 + this.D = (D + this.D) | 0 + this.E = (E + this.E) | 0 + } + + // digest(): Uint8Array + // digest(encoding: string): string + digest(encoding?: string): Uint8Array | string { + const _byte = this._byte + const _word = this._word + let i = (this._size % inputBytes) | 0 + _byte[i++] = 0x80 + + // pad 0 for current word + while (i & 3) { + _byte[i++] = 0 + } + i >>= 2 + + if (i > highIndex) { + while (i < inputWords) { + _word[i++] = 0 + } + i = 0 + this._int32(_word) + } + + // pad 0 for rest words + while (i < inputWords) { + _word[i++] = 0 + } + + // input size + const bits64: int32 = this._size * 8 + const low32: int32 = ((bits64 & 0xffffffff) as int32 >>> 0) as int32 + const high32: int32 = ((bits64 - low32) as int32 / 0x100000000) as int32 + if (high32) _word[highIndex] = swap32(high32) as int32 + if (low32) _word[lowIndex] = swap32(low32) as int32 + + this._int32(_word) + + return (encoding === "hex") ? this._hex() : this._bin() + } + + private _hex(): string { + let A = this.A + let B = this.B + let C = this.C + let D = this.D + let E = this.E + + return hex32Str(A, B, C, D, E) + } + + private _bin(): Uint8Array { + let A = this.A + let B = this.B + let C = this.C + let D = this.D + let E = this.E + const _byte = this._byte + const _word = this._word + + _word[0] = swap32(A) + _word[1] = swap32(B) + _word[2] = swap32(C) + _word[3] = swap32(D) + _word[4] = swap32(E) + + return _byte.slice(0, 20) + } +} + +type NS = (num: int32) => string +type NN = (num: int32) => int32 + +const W = new Int32Array(workWords) + +let sharedBuffer: ArrayBuffer +let sharedOffset: int32 = 0 + +const swapLE: NN = ((c:int32):int32 => (((c << 24) & 0xff000000) | ((c << 8) & 0xff0000) | ((c >> 8) & 0xff00) | ((c >> 24) & 0xff))) +const swapBE: NN = ((c:int32):int32 => c) +const swap32: NN = isBE() ? swapBE : swapLE +const rotate1: NN = (num: int32): int32 => (num << 1) | (num >>> 31) +const rotate5: NN = (num: int32): int32 => (num << 5) | (num >>> 27) +const rotate30: NN = (num: int32): int32 => (num << 30) | (num >>> 2) + +function isBE(): boolean { + let a16 = new Uint16Array(1) + a16[0] = 0xFEFF + let a8 = new Uint8Array(a16.buffer) + return a8[0] == 0xFE // BOM +} + + +function ft(s: int32, b: int32, c: int32, d: int32) { + if (s == 0) return (b & c) | ((~b) & d) + if (s == 2) return (b & c) | (b & d) | (c & d) + return b ^ c ^ d +} + +const hex32Decoder = new CustomTextDecoder() +const hex32DecodeBuffer = new Uint8Array(40) +function hex32Str(A: int32, B: int32, C: int32, D: int32, E: int32): string { + writeIntAsHexUTF8(A, hex32DecodeBuffer, 0) + writeIntAsHexUTF8(B, hex32DecodeBuffer, 8) + writeIntAsHexUTF8(C, hex32DecodeBuffer, 16) + writeIntAsHexUTF8(D, hex32DecodeBuffer, 24) + writeIntAsHexUTF8(E, hex32DecodeBuffer, 32) + return hex32Decoder.decode(hex32DecodeBuffer) +} + +function writeIntAsHexUTF8(value: int32, buffer: Uint8Array, byteOffset: int32) { + buffer[byteOffset++] = nibbleToHexCode((value >> 28) & 0xF) + buffer[byteOffset++] = nibbleToHexCode((value >> 24) & 0xF) + buffer[byteOffset++] = nibbleToHexCode((value >> 20) & 0xF) + buffer[byteOffset++] = nibbleToHexCode((value >> 16) & 0xF) + buffer[byteOffset++] = nibbleToHexCode((value >> 12) & 0xF) + buffer[byteOffset++] = nibbleToHexCode((value >> 8 ) & 0xF) + buffer[byteOffset++] = nibbleToHexCode((value >> 4 ) & 0xF) + buffer[byteOffset++] = nibbleToHexCode((value >> 0 ) & 0xF) +} + +function nibbleToHexCode(nibble: int32) { + return nibble > 9 ? nibble + 87 : nibble + 48 +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/stringUtils.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/stringUtils.ts new file mode 100644 index 0000000000000000000000000000000000000000..ce01753ae35a55952e5f5526a7654942d8f75367 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/stringUtils.ts @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { int32 } from "@koalaui/compat" + + +/** + * Computes a hash code from the string {@link value}. + */ +export function hashCodeFromString(value: string): int32 { + let hash = 5381 + for(let i = 0; i < value.length; i++) { + hash = (hash * 33) ^ value.charCodeAt(i) + hash |= 0 + } + return hash +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/uniqueId.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/uniqueId.ts new file mode 100644 index 0000000000000000000000000000000000000000..a0e324dbe3d423ee77bc1b00cdcb4e25e00bc84c --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/src/uniqueId.ts @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { int32 } from "@koalaui/compat" +import { createSha1 } from "./sha1"; + +export class UniqueId { + private sha = createSha1() + + public addString(data: string): UniqueId { + this.sha.updateString(data) + return this + } + + public addI32(data: int32): UniqueId { + this.sha.updateInt32(data) + return this + } + + public addF32Array(data: Float32Array): UniqueId { + this.sha.update(data) + return this + } + + public addI32Array(data: Int32Array): UniqueId { + this.sha.update(data) + return this + } + + public addU32Array(data: Uint32Array): UniqueId { + this.sha.update(data) + return this + } + + public addU8Array(data: Uint8Array): UniqueId { + this.sha.update(data) + return this + } + + public addPtr(data: Uint32Array | number): UniqueId { + if (data instanceof Uint32Array) { + return this.addU32Array(data) + } + return this.addI32(data as int32) + } + + public compute(): string { + return this.sha.digest("hex") as string + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/test/golden.js b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/test/golden.js new file mode 100644 index 0000000000000000000000000000000000000000..42298bd342e3cd908fa9f1f0494b6afddac7c572 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/test/golden.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const path = require("path") +const process = require("process") + +function goldenSetup(resDir, testDir) { + const root = path.resolve(".", resDir) + const testRoot = path.resolve(testDir) + if (root != testRoot) { + process.env.KOALAUI_RESOURCE_ROOT = root + } + process.env.KOALAUI_TEST_ROOT = path.relative(root, testRoot) + const argGenGolden = "--gen-golden" + for (let str of process.argv) { + if (str.startsWith(argGenGolden)) { + process.env.KOALAUI_TEST_GOLDEN_GEN_DIR = path.relative(root, path.resolve(testRoot, "test", "resources", "golden")) + if (str.length > argGenGolden.length + 1) { + const gdir = str.substring(argGenGolden.length + 1); + if (gdir.length > 0 && gdir != "true") { + process.env.KOALAUI_TEST_GOLDEN_GEN_DIR = path.relative(root, path.resolve(gdir)) + } + } + break + } + } +} + +exports.goldenSetup = goldenSetup diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/tsconfig.json b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/tsconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..0e6d985ed7ad92ea6019d71386ad681cdf8297ab --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/common/tsconfig.json @@ -0,0 +1,17 @@ +{ + "extends": "@koalaui/build-common/tsconfig.json", + "compilerOptions": { + "baseUrl": ".", + "outDir": "build/lib", + "module": "CommonJS", + "paths": { + "@koalaui/compat": ["../compat/typescript"] + } + }, + "include": ["./src/**/*"], + "exclude": ["./src/ohos"], + "references": [ + {"path": "../compat"}, + {"path": "./bridges/ohos"} + ] +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/README.md b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/README.md new file mode 100644 index 0000000000000000000000000000000000000000..5bd0a19519508172171ec07655e7f2813e35fde6 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/README.md @@ -0,0 +1,4 @@ +This is a typescript and ArkTS compatibility library. + +It abstracts out such things as reflection which are quite different in typescript and ArkTS. + diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/arktsconfig.json b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/arktsconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..6b515b376363ad6fa66a8d74cde7c9c3987dd1e4 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/arktsconfig.json @@ -0,0 +1,14 @@ +{ + "compilerOptions": { + "package": "@koalaui/compat", + "outDir": "build/abc", + "rootDir": "./src/arkts", + "baseUrl": "./src/arkts", + "paths": { + "#platform": ["./"], + "@koalaui/compat": ["../"] + } + }, + "include": ["src/index.ts", "src/arkts/**/*.ts"], + "exclude": ["./src/arkts/index.ts"] +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/package.json b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/package.json new file mode 100644 index 0000000000000000000000000000000000000000..2a43e0eedcde594e1ad66b779a7fc5735b40c227 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/package.json @@ -0,0 +1,42 @@ +{ + "name": "@koalaui/compat", + "version": "1.5.15+devel", + "description": "", + "main": "build/src/index.js", + "types": "build/src/index.d.ts", + "files": [ + "build/src/**/*.js", + "build/src/**/*.d.ts", + "src/**/*" + ], + "imports": { + "#platform": { + "ark": "./build/src/ohos/index.js", + "ios": "./build/src/typescript/index.js", + "browser": "./build/src/typescript/index.js", + "node": "./build/src/typescript/index.js", + "default": "./build/src/typescript/index.js" + } + }, + "exports": { + ".": "./build/src/index.js" + }, + "scripts": { + "clean": "rimraf build dist", + "compile": "ets-tsc -b .", + "compile:ohos": "ets-tsc -b ./tsconfig-ohos.json", + "compile:all": "npm run compile && npm run compile:ohos", + "build:compat": "npm run build:compat:inc", + "build:compat:inc": "fast-arktsc --config ./arktsconfig.json --compiler ../tools/panda/arkts/arktsc --link-name ./build/compat.abc && ninja ${NINJA_OPTIONS} -f build/abc/build.ninja", + "build:compat:inc:ui2abc": "fast-arktsc --config ./arktsconfig.json --compiler ../tools/panda/arkts/ui2abc --file-option --link-name ./build/compat.abc && PANDA_SDK_PATH=../tools/panda/node_modules/@panda/sdk ninja ${NINJA_OPTIONS} -f build/abc/build.ninja" + }, + "keywords": [], + "dependencies": {}, + "devDependencies": { + "@typescript-eslint/eslint-plugin": "^5.20.0", + "@typescript-eslint/parser": "^5.20.0", + "eslint": "^8.13.0", + "eslint-plugin-unused-imports": "^2.0.0", + "source-map-support": "^0.5.21" + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/arkts/array.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/arkts/array.ts new file mode 100644 index 0000000000000000000000000000000000000000..83e3b1dcea5cb56fa4749ea0ac2597910aa466a0 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/arkts/array.ts @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { float64, int32, int8 } from "./types" + +// TODO: this can be a performance disaster +// just wait for the library to provide the proper functionality. +export function asArray(value: T[]): Array { + return Array.of(...value) +} + +// TODO: this can be a performance disaster +// just wait for the library to provide the proper functionality. +export function Array_from_set(set: Set): Array { + const array = new Array() // to avoid creation of undefined content + const values = set.values() + for (let it = values.next(); it.done != true; it = values.next()) { + array.push(it.value as T) + } + return array +} + +// TODO: this can be a performance disaster +// just wait for the library to provide the proper functionality. +export function Array_from_int32(data: Int32Array): number[] { + const result: number[] = [] + for (let i: int32 = 0; i < data.length; i++) { + result[i] = data.at(i) as number + } + return result +} + +// TODO: this can be a performance disaster +// just wait for the library to provide the proper functionality. +export function Array_from_number(data: float64[]): Array { + const result = new Array(data.length) + for (let i: int32 = 0; i < data.length; i++) { + result[i] = data[i] + } + return result +} + +export function int8Array(size: int32): FixedArray { + const array: FixedArray = new int8[size] + return array +} + diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/arkts/atomic.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/arkts/atomic.ts new file mode 100644 index 0000000000000000000000000000000000000000..d8efb0840a8da89dc0832afd1af67d493a17f416 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/arkts/atomic.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * A reference that may be updated atomically. + */ +export class AtomicRef { + value: Value + + /** + * Creates a new reference object with the given initial value. + * @param value - the new value + */ + constructor(value: Value) { + this.value = value + } + + /** + * Atomically sets the reference value to the given value and returns the previous one. + * @param value - the new value + * @returns the previous value + */ + getAndSet(value: Value): Value { + // TODO: replace with the implementation from ArkTS language when it is ready + const result = this.value + this.value = value + return result + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/arkts/double.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/arkts/double.ts new file mode 100644 index 0000000000000000000000000000000000000000..ed3fb70a5e246c47827b5744cab19d74d3464eb5 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/arkts/double.ts @@ -0,0 +1,33 @@ + +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { float64, int32, float32 } from "./types" + +export function asFloat64(value: string): float64 { + return (new Number(value)).valueOf() +} + +export function asString(value: float64 | undefined): string | undefined { + if (value === undefined) return undefined + return (new Number(value)).toString() +} + +export function float32FromBits(value: int32): float32 { + return Float.bitCastFromInt(value) +} + +export function int32BitsFromFloat(value: float32): int32 { + return Float.bitCastToInt(value) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/arkts/finalization.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/arkts/finalization.ts new file mode 100644 index 0000000000000000000000000000000000000000..021bc1d43f17c58b07110041d506202183097f1f --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/arkts/finalization.ts @@ -0,0 +1,31 @@ + +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export interface Thunk { + clean(): void +} + +const registry = new FinalizationRegistry((thunk: Thunk) => { + thunk.clean() +}) + +export function finalizerRegister(target: Object, thunk: Object) { + registry.register(target, thunk as Thunk) +} + +export function finalizerUnregister(target: Object) { + registry.unregister(target) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/arkts/index.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/arkts/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..95ec1799f3ee2e82960a2bc4c7e1a6ac41ebf1c7 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/arkts/index.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export * from "./array" +export * from "./atomic" +export * from "./double" +export * from "./finalization" +export * from "./performance" +export * from "./prop-deep-copy" +export * from "./observable" +export * from "./reflection" +export * from "./strings" +export * from "./ts-reflection" +export * from "./types" +export * from "./utils" diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/arkts/observable.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/arkts/observable.ts new file mode 100644 index 0000000000000000000000000000000000000000..ff5810c17415aa8cfda39eada49872202ac8c251 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/arkts/observable.ts @@ -0,0 +1,1035 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export function getObservableTarget(proxy: Object): Object { + if (PROXY_DISABLED) return proxy + try { + return Proxy.tryGetTarget(proxy) ?? proxy + } catch (error) { + return proxy + } +} + +/** + * Data class decorator that makes all child fields trackable. + */ +export function Observed() { + throw new Error("TypeScript class decorators are not supported yet") +} + +/** @internal */ +export interface Observable { + /** It is called when the observable value is accessed. */ + onAccess(): void + /** It is called when the observable value is modified. */ + onModify(): void +} + +/** @internal */ +export class ObservableHandler implements Observable { + private static handlers: WeakMap | undefined = undefined + + private parents = new Set() + private children = new Map() + + private readonly observables = new Set() + private _modified = false + + readonly observed: boolean + constructor(parent?: ObservableHandler, observed: boolean = false) { + this.observed = observed + if (parent) this.addParent(parent) + } + + onAccess(): void { + if (this.observables.size > 0) { + const it = this.observables.keys() + while (true) { + const result = it.next() + if (result.done) break + result.value?.onAccess() + } + } + } + + onModify(): void { + const set = new Set() + this.collect(true, set) + set.forEach((handler: ObservableHandler) => { + handler._modified = true + if (handler.observables.size > 0) { + const it = handler.observables.keys() + while (true) { + const result = it.next() + if (result.done) break + result.value?.onModify() + } + } + }) + } + + static dropModified(value: Value): boolean { + const handler = ObservableHandler.findIfObject(value) + if (handler === undefined) return false + const result = handler._modified + handler._modified = false + return result + } + + /** Adds the specified `observable` to the handler corresponding to the given `value`. */ + static attach(value: Value, observable: Observable): void { + const handler = ObservableHandler.findIfObject(value) + if (handler) handler.observables.add(observable) + } + + /** Deletes the specified `observable` from the handler corresponding to the given `value`. */ + static detach(value: Value, observable: Observable): void { + const handler = ObservableHandler.findIfObject(value) + if (handler) handler.observables.delete(observable) + } + + /** @returns the handler corresponding to the given `value` if it was installed */ + private static findIfObject(value: Value): ObservableHandler | undefined { + const handlers = ObservableHandler.handlers + return handlers !== undefined && value instanceof Object ? handlers.get(getObservableTarget(value as Object)) : undefined + } + + /** + * @param value - any non-null object including arrays + * @returns an observable handler or `undefined` if it is not installed + */ + static find(value: Object): ObservableHandler | undefined { + const handlers = ObservableHandler.handlers + return handlers ? handlers.get(getObservableTarget(value)) : undefined + } + + /** + * @param value - any non-null object including arrays + * @param observable - a handler to install on this object + * @throws an error if observable handler cannot be installed + */ + static installOn(value: Object, observable?: ObservableHandler): void { + let handlers = ObservableHandler.handlers + if (handlers === undefined) { + handlers = new WeakMap() + ObservableHandler.handlers = handlers + } + observable + ? handlers.set(getObservableTarget(value), observable) + : handlers.delete(getObservableTarget(value)) + } + + addParent(parent: ObservableHandler) { + const count = parent.children.get(this) ?? 0 + parent.children.set(this, count + 1) + this.parents.add(parent) + } + + removeParent(parent: ObservableHandler) { + const count = parent.children.get(this) ?? 0 + if (count > 1) { + parent.children.set(this, count - 1) + } + else if (count == 1) { + parent.children.delete(this) + this.parents.delete(parent) + } + } + + removeChild(value: Value) { + const child = ObservableHandler.findIfObject(value) + if (child) child.removeParent(this) + } + + private collect(all: boolean, guards: Set) { + if (guards.has(this)) return guards // already collected + guards.add(this) // handler is already guarded + this.parents.forEach((handler: ObservableHandler) => { handler.collect(all, guards) }) + if (all) this.children.forEach((_count: number, handler: ObservableHandler) => { handler.collect(all, guards) }) + return guards + } + + static contains(observable: ObservableHandler, guards?: Set) { + if (observable.observed) return true + if (guards === undefined) guards = new Set() // create if needed + else if (guards!.has(observable)) return false // already checked + guards.add(observable) // handler is already guarded + for (const it of observable.parents.keys()) { + if (ObservableHandler.contains(it, guards)) return true + } + return false + } +} + +/** @internal */ +export function observableProxyArray(...value: Value[]): Array { + return observableProxy(Array.of(...value)) +} + +const PROXY_DISABLED = true // because of ArkTS Reflection performance + +/** @internal */ +export function observableProxy(value: Value, parent?: ObservableHandler, observed?: boolean, strict: boolean = true): Value { + if (value instanceof ObservableHandler) return value as Value // do not proxy a marker itself + if (value == null || !(value instanceof Object)) return value as Value // only non-null object can be observable + const observable = ObservableHandler.find(value as Object) + if (observable) { + if (parent) { + if (strict) observable.addParent(parent) + if (observed === undefined) observed = ObservableHandler.contains(parent) + } + if (observed) { + if (value instanceof Array) { + for (let index = 0; index < value.length; index++) { + value[index] = observableProxy(value[index], observable, observed, false) + } + } else { + // TODO: proxy fields of the given object + } + } + return value as Value + } + if (value instanceof Array) { + return ObservableArray(value, parent, observed) as Value + } else if (value instanceof Map) { + return ObservableMap(value, parent, observed) as Value + // TODO: relates to https://gitee.com/rri_opensource/koala_projects/issues/IC14KY + // } else if (value instanceof Set) { + // return ObservableSet(value, parent, observed) as Value + } else if (value instanceof Date) { + return ObservableDate(value, parent, observed) as Value + } + if (PROXY_DISABLED) return value as Value + // TODO: proxy the given object + return Proxy.create(value as Object, new CustomProxyHandler()) as Value +} + +class CustomProxyHandler extends DefaultProxyHandler { + override get(target: T, name: string): NullishType { + const observable = ObservableHandler.find(target) + if (observable) observable.onAccess() + return super.get(target, name) + } + + override set(target: T, name: string, value: NullishType): boolean { + const observable = ObservableHandler.find(target) + if (observable) { + observable.onModify() + observable.removeChild(super.get(target, name)) + value = observableProxy(value, observable, ObservableHandler.contains(observable)) + } + return super.set(target, name, value) + } +} + +function proxyChildrenOnly(array: T[], parent: ObservableHandler, observed?: boolean) { + for (let i = 0; i < array.length; i++) { + if (observed === undefined) observed = ObservableHandler.contains(parent) + array[i] = observableProxy(array[i], parent, observed) + } +} + +class ObservableArray extends Array { + static $_invoke(array: Array, parent?: ObservableHandler, observed?: boolean): Array { + return new ObservableArray(array, parent, observed); + } + + constructor(array: Array, parent?: ObservableHandler, observed?: boolean) { + super(array.length) + const handler = new ObservableHandler(parent) + for (let i = 0; i < array.length; i++) { + if (observed === undefined) observed = ObservableHandler.contains(handler) + super.$_set(i, observableProxy(array[i], handler, observed)) + } + ObservableHandler.installOn(this, handler) + } + + private get handler(): ObservableHandler | undefined { + return ObservableHandler.find(this) + } + + override get length(): number { + this.handler?.onAccess() + return super.length + } + + override set length(length: number) { + this.handler?.onModify() + super.length = length + } + + override at(index: int): T | undefined { + this.handler?.onAccess() + return super.at(index) + } + + override $_get(index: int): T { + this.handler?.onAccess() + return super.$_get(index) + } + + override $_set(index: int, value: T): void { + const handler = this.handler + if (handler) { + handler.onModify() + handler.removeChild(super.$_get(index)) + value = observableProxy(value, handler) + } + super.$_set(index, value) + } + + override copyWithin(target: int, start: int, end: int): this { + this.handler?.onModify() + super.copyWithin(target, start, end) + return this + } + + override fill(value: T, start: int, end: int): this { + const handler = this.handler + if (handler) { + handler.onModify() + value = observableProxy(value, handler) + } + super.fill(value, start, end) + return this + } + + override pop(): T | undefined { + const handler = this.handler + handler?.onModify() + const result = super.pop() + if (result) handler?.removeChild(result) + return result + } + + override push(...items: T[]): number { + const handler = this.handler + if (handler) { + handler.onModify() + proxyChildrenOnly(items, handler) + } + return super.push(...items) + } + + override pushECMA(...items: T[]): number { + const handler = this.handler + if (handler) { + handler.onModify() + proxyChildrenOnly(items, handler) + } + return super.pushECMA(...items) + } + + override reverse(): this { + this.handler?.onModify() + super.reverse() + return this + } + + override shift(): T | undefined { + const handler = this.handler + handler?.onModify() + const result = super.shift() + if (result) handler?.removeChild(result) + return result + } + + override sort(comparator?: (a: T, b: T) => number): this { + this.handler?.onModify() + super.sort(comparator) + return this + } + + override splice(index: int, count: int, ...items: T[]): Array { + const handler = this.handler + if (handler) { + handler.onModify() + proxyChildrenOnly(items, handler) + const result = super.splice(index, count, ...items) + for (let i = 0; i < result.length; i++) { + handler.removeChild(result[i]) + } + return result + } + return super.splice(index, count, ...items) + } + + override unshift(...items: T[]): number { + const handler = this.handler + if (handler) { + handler.onModify() + proxyChildrenOnly(items, handler) + } + return super.unshift(...items) + } + + override keys(): IterableIterator { + this.handler?.onAccess() + return super.keys() + } + + // === methods with uncompatible implementation === + + override filter(predicate: (value: T, index: number, array: Array) => boolean): Array { + this.handler?.onAccess() + return super.filter(predicate) + } + + override flat(depth: int): Array { + this.handler?.onAccess() + return super.flat(depth) + } + + override flatMap(fn: (v: T, k: number, arr: Array) => U): Array { + this.handler?.onAccess() + return super.flatMap(fn) + } + + // === methods common among all arrays === + + override concat(...items: FixedArray>): Array { + this.handler?.onAccess() + return super.concat(...items) + } + + override find(predicate: (value: T, index: number, array: Array) => boolean): T | undefined { + this.handler?.onAccess() + return super.find(predicate) + } + + override findIndex(predicate: (value: T, index: number, array: Array) => boolean): number { + this.handler?.onAccess() + return super.findIndex(predicate) + } + + override findLast(predicate: (elem: T, index: number, array: Array) => boolean): T | undefined { + this.handler?.onAccess() + return super.findLast(predicate) + } + + override every(predicate: (value: T, index: number, array: Array) => boolean): boolean { + this.handler?.onAccess() + return super.every(predicate) + } + + override some(predicate: (value: T, index: number, array: Array) => boolean): boolean { + this.handler?.onAccess() + return super.some(predicate) + } + + override findLastIndex(predicate: (element: T, index: number, array: Array) => boolean): number { + this.handler?.onAccess() + return super.findLastIndex(predicate) + } + + override reduce(callbackfn: (previousValue: T, currentValue: T, index: number, array: Array) => T): T { + this.handler?.onAccess() + return super.reduce(callbackfn) + } + + override reduce(callbackfn: (previousValue: U, currentValue: T, index: number, array: Array) => U, initialValue: U): U { + this.handler?.onAccess() + return super.reduce(callbackfn, initialValue) + } + + override reduceRight(callbackfn: (previousValue: T, currentValue: T, index: number, array: Array) => T): T { + this.handler?.onAccess() + return super.reduceRight(callbackfn) + } + + override reduceRight(callbackfn: (previousValue: U, currentValue: T, index: number, array: Array) => U, initialValue: U): U { + this.handler?.onAccess() + return super.reduceRight(callbackfn, initialValue) + } + + override forEach(callbackfn: (value: T, index: number, array: Array) => void): void { + this.handler?.onAccess() + super.forEach(callbackfn) + } + + override slice(start: int, end: int): Array { + this.handler?.onAccess() + return super.slice(start, end) + } + + override lastIndexOf(searchElement: T, fromIndex: int): int { + this.handler?.onAccess() + return super.lastIndexOf(searchElement, fromIndex) + } + + override join(sep?: String): string { + this.handler?.onAccess() + return super.join(sep) + } + + override toLocaleString(): string { + this.handler?.onAccess() + return super.toLocaleString() + } + + override toSpliced(start: int, delete: int, ...items: FixedArray): Array { + this.handler?.onAccess() + return super.toSpliced(start, delete, ...items) + } + + override includes(val: T, fromIndex?: Number): boolean { + this.handler?.onAccess() + return super.includes(val, fromIndex) + } + + override indexOf(val: T, fromIndex: int): int { + this.handler?.onAccess() + return super.indexOf(val, fromIndex) + } + + override toSorted(): Array { + this.handler?.onAccess() + return super.toSorted() + } + + override toSorted(comparator: (a: T, b: T) => number): Array { + this.handler?.onAccess() + return super.toSorted(comparator) + } + + override toReversed(): Array { + this.handler?.onAccess() + return super.toReversed() + } + + override with(index: int, value: T): Array { + this.handler?.onAccess() + return super.with(index, value) + } + + override values(): IterableIterator { + this.handler?.onAccess() + return super.values() + } + + override entries(): IterableIterator<[number, T]> { + this.handler?.onAccess() + return super.entries() + } + + override map(callbackfn: (value: T, index: number, array: Array) => U): Array { + this.handler?.onAccess() + return super.map(callbackfn) + } +} + +class ObservableMap extends Map { + static $_invoke(data: Map, parent?: ObservableHandler, observed?: boolean): Map { + return new ObservableMap(data, parent, observed); + } + + constructor(data: Map, parent?: ObservableHandler, observed?: boolean) { + super() + const handler = new ObservableHandler(parent) + for (let item: [T, V] of data.entries()) { + if (observed === undefined) observed = ObservableHandler.contains(handler) + super.set(item[0], observableProxy(item[1], handler, observed)) + } + ObservableHandler.installOn(this, handler) + } + + private get handler(): ObservableHandler | undefined { + return ObservableHandler.find(this) + } + + override get size(): number { + this.handler?.onAccess() + return super.size + } + + override has(key: T): boolean { + this.handler?.onAccess() + return super.has(key) + } + + override get(key: T): V | undefined { + this.handler?.onAccess() + return super.get(key) + } + + override set(key: T, value: V): this { + const handler = this.handler + if (handler) { + handler.onModify() + const prev = super.get(key) + if (prev) handler.removeChild(prev) + value = observableProxy(value, handler) + } + super.set(key, value) + return this + } + + override delete(key: T): boolean { + const handler = this.handler + if (handler) { + handler.onModify() + const value = super.get(key) + if (value) handler.removeChild(value) + } + return super.delete(key) + } + + override clear() { + const handler = this.handler + if (handler) { + handler.onModify() + for (let value of super.values()) { + handler!.removeChild(value) + } + } + super.clear() + } + + override keys(): IterableIterator { + this.handler?.onAccess() + return super.keys() + } + + override values(): IterableIterator { + this.handler?.onAccess() + return super.values() + } + + override $_iterator(): IterableIterator<[T, V]> { + this.handler?.onAccess() + return super.$_iterator() + } + + override entries(): IterableIterator<[T, V]> { + this.handler?.onAccess() + return super.entries() + } + + override forEach(callbackfn: (value: V, key: T, map: Map) => void) { + this.handler?.onAccess() + super.forEach(callbackfn) + } + + override toString(): string { + this.handler?.onAccess() + return super.toString() + } +} + +/* + * TODO: relates to https://gitee.com/rri_opensource/koala_projects/issues/IC14KY + * +class ObservableSet extends Set { + static $_invoke(data: Map, parent?: ObservableHandler, observed?: boolean): Map { + return new ObservableSet(data, parent, observed); + } + + constructor(data: Set, parent?: ObservableHandler, observed?: boolean) { + super(data) + const handler = new ObservableHandler(parent) + // for (let item of data.values()) { + // if (observed === undefined) observed = ObservableHandler.contains(handler) + // super.add(observableProxy(item, handler, observed)) + // } + ObservableHandler.installOn(this, handler) + } + + private get handler(): ObservableHandler | undefined { + return ObservableHandler.find(this) + } + + override get size(): number { + this.handler?.onAccess() + return super.size + } + + override has(value: T): boolean { + this.handler?.onAccess() + return super.has(key) + } + + override add(value: T): this { + this.handler?.onModify() + super.add(value) + return this + } + + override delete(value: T): boolean { + this.handler?.onModify() + return super.delete(key) + } + + override clear() { + this.handler?.onModify() + super.clear() + } + + override keys(): IterableIterator { + this.handler?.onAccess() + return super.keys() + } + + override values(): IterableIterator { + this.handler?.onAccess() + return super.values() + } + + override $_iterator(): IterableIterator { + this.handler?.onAccess() + return super.$_iterator() + } + + override entries(): IterableIterator<[T, T]> { + this.handler?.onAccess() + return super.entries() + } + + override forEach(callbackfn: (value: T, key: T, set: Set) => void) { + this.handler?.onAccess() + super.forEach(callbackfn) + } +} +*/ + +class ObservableDate extends Date { + static $_invoke(value: Date, parent?: ObservableHandler, observed?: boolean): Date { + return new ObservableDate(value, parent, observed); + } + + constructor(value: Date, parent?: ObservableHandler, observed?: boolean) { + super(value) + const handler = new ObservableHandler(parent) + ObservableHandler.installOn(this, handler) + } + + private get handler(): ObservableHandler | undefined { + return ObservableHandler.find(this) + } + + override isDateValid(): boolean { + this.handler?.onAccess() + return super.isDateValid() + } + + override valueOf(): number { + this.handler?.onAccess() + return super.valueOf() + } + + override toLocaleTimeString(): string { + this.handler?.onAccess() + return super.toLocaleTimeString() + } + + override toLocaleString(): string { + this.handler?.onAccess() + return super.toLocaleString() + } + + override toLocaleDateString(): string { + this.handler?.onAccess() + return super.toLocaleDateString() + } + + override toISOString(): string { + this.handler?.onAccess() + return super.toISOString() + } + + override toTimeString(): string { + this.handler?.onAccess() + return super.toTimeString() + } + + override toDateString(): string { + this.handler?.onAccess() + return super.toDateString() + } + + override toString(): string { + this.handler?.onAccess() + return super.toString() + } + + override toUTCString(): string { + this.handler?.onAccess() + return super.toUTCString() + } + + override getDate(): number { + this.handler?.onAccess() + return super.getDate() + } + + override setDate(value: byte) { + this.handler?.onModify() + super.setDate(value) + } + + override setDate(value: number): number { + this.handler?.onModify() + return super.setDate(value) + } + + override getUTCDate(): number { + this.handler?.onAccess() + return super.getUTCDate() + } + + override setUTCDate(value: byte) { + this.handler?.onModify() + super.setUTCDate(value) + } + + override setUTCDate(value: number): number { + this.handler?.onModify() + return super.setUTCDate(value) + } + + override getDay(): number { + this.handler?.onAccess() + return super.getDay() + } + + override setDay(value: byte) { + this.handler?.onModify() + super.setDay(value) + } + + override getUTCDay(): number { + this.handler?.onAccess() + return super.getUTCDay() + } + + override setUTCDay(value: byte) { + this.handler?.onModify() + super.setUTCDay(value) + } + + override setUTCDay(value: number): number { + this.handler?.onModify() + return super.setUTCDay(value) + } + + override getMonth(): number { + this.handler?.onAccess() + return super.getMonth() + } + + override setMonth(value: int) { + this.handler?.onModify() + super.setMonth(value) + } + + override setMonth(value: number, date?: number): number { + this.handler?.onModify() + return super.setMonth(value, date) + } + + override getUTCMonth(): number { + this.handler?.onAccess() + return super.getUTCMonth() + } + + override setUTCMonth(value: int) { + this.handler?.onModify() + super.setUTCMonth(value) + } + + override setUTCMonth(value: number, date?: number): number { + this.handler?.onModify() + return super.setUTCMonth(value, date) + } + + override getYear(): int { + this.handler?.onAccess() + return super.getYear() + } + + override setYear(value: int) { + this.handler?.onModify() + super.setYear(value) + } + + override setYear(value: number) { + this.handler?.onModify() + super.setYear(value) + } + + override getFullYear(): number { + this.handler?.onAccess() + return super.getFullYear() + } + + override setFullYear(value: number, month?: number, date?: number): number { + this.handler?.onModify() + return super.setFullYear(value, month, date) + } + + override setFullYear(value: int) { + this.handler?.onModify() + super.setFullYear(value) + } + + override getUTCFullYear(): number { + this.handler?.onAccess() + return super.getUTCFullYear() + } + + override setUTCFullYear(value: number, month?: number, date?: number): number { + this.handler?.onModify() + return super.setUTCFullYear(value, month, date) + } + + override setUTCFullYear(value: int) { + this.handler?.onModify() + super.setUTCFullYear(value) + } + + override getTime(): number { + this.handler?.onAccess() + return super.getTime() + } + + override setTime(value: long) { + this.handler?.onModify() + super.setTime(value) + } + + override setTime(value: number): number { + this.handler?.onModify() + return super.setTime(value) + } + + override getHours(): number { + this.handler?.onAccess() + return super.getHours() + } + + override setHours(value: number, min?: number, sec?: number, ms?: number): number { + this.handler?.onModify() + return super.setHours(value, min, sec, ms) + } + + override setHours(value: byte) { + this.handler?.onModify() + super.setHours(value) + } + + override getUTCHours(): number { + this.handler?.onAccess() + return super.getUTCHours() + } + + override setUTCHours(value: number, min?: number, sec?: number, ms?: number): number { + this.handler?.onModify() + return super.setUTCHours(value, min, sec, ms) + } + + override setUTCHours(value: byte) { + this.handler?.onModify() + super.setUTCHours(value) + } + + override getMilliseconds(): number { + this.handler?.onAccess() + return super.getMilliseconds() + } + + override setMilliseconds(value: short) { + this.handler?.onModify() + super.setMilliseconds(value) + } + + override setMilliseconds(value: number): number { + this.handler?.onModify() + return super.setMilliseconds(value) + } + + override getUTCMilliseconds(): number { + this.handler?.onAccess() + return super.getUTCMilliseconds() + } + + override setUTCMilliseconds(value: short) { + this.handler?.onModify() + super.setUTCMilliseconds(value) + } + + override setUTCMilliseconds(value: number): number { + this.handler?.onModify() + return super.setUTCMilliseconds(value) + } + + override getSeconds(): number { + this.handler?.onAccess() + return super.getSeconds() + } + + override setSeconds(value: byte) { + this.handler?.onModify() + super.setSeconds(value) + } + + override setSeconds(value: number, ms?: number): number { + this.handler?.onModify() + return super.setSeconds(value, ms) + } + + override getUTCSeconds(): number { + this.handler?.onAccess() + return super.getUTCSeconds() + } + + override setUTCSeconds(value: byte) { + this.handler?.onModify() + super.setUTCSeconds(value) + } + + override setUTCSeconds(value: number, ms?: number): number { + this.handler?.onModify() + return super.setUTCSeconds(value, ms) + } + + override getMinutes(): number { + this.handler?.onAccess() + return super.getMinutes() + } + + override setMinutes(value: byte) { + this.handler?.onModify() + super.setMinutes(value) + } + + override setMinutes(value: number, sec?: Number, ms?: number): number { + this.handler?.onModify() + return super.setMinutes(value, sec, ms) + } + + override getUTCMinutes(): number { + this.handler?.onAccess() + return super.getUTCMinutes() + } + + override setUTCMinutes(value: byte) { + this.handler?.onModify() + super.setUTCMinutes(value) + } + + override setUTCMinutes(value: number, sec?: Number, ms?: number): number { + this.handler?.onModify() + return super.setUTCMinutes(value, sec, ms) + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/arkts/performance.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/arkts/performance.ts new file mode 100644 index 0000000000000000000000000000000000000000..8926ff8519d1a22bb9a26c81d4d0bae7476ddd9b --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/arkts/performance.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @returns the number of milliseconds elapsed since midnight, + * January 1, 1970 Universal Coordinated Time (UTC). + */ +export function timeNow(): number { + return Date.now() +} + +/** + * @param fractionDigits - number of digits after the decimal point [0 - 20] + * @returns a string representing a number in fixed-point notation + */ +export function numberToFixed(value: number, fractionDigits: number): string { + return new Number(value).toFixed(fractionDigits) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/arkts/prop-deep-copy.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/arkts/prop-deep-copy.ts new file mode 100644 index 0000000000000000000000000000000000000000..1e13dfc129de3c5f4d10ccc64cfd6b2fcad4ac43 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/arkts/prop-deep-copy.ts @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + When decorating variables of complex types, + @Prop makes a deep copy, during which all types, + except primitive types, Map, Set, Date, and Array, will be lost. + */ + +export function propDeepCopy(sourceObject: T): T { + return deepcopy(sourceObject) as T +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/arkts/reflection.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/arkts/reflection.ts new file mode 100644 index 0000000000000000000000000000000000000000..7961ab53e335fea16eec61cd8444bc890e318790 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/arkts/reflection.ts @@ -0,0 +1,20 @@ + +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { className } from "./ts-reflection" + +export function lcClassName(object: Object) { + return className(object).toLowerCase() +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/arkts/strings.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/arkts/strings.ts new file mode 100644 index 0000000000000000000000000000000000000000..852320fd77ed1c6d8f12bbb2ab2a58b0f2b7c9b1 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/arkts/strings.ts @@ -0,0 +1,214 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { int32, uint8 } from "./types" +import { Array_from_int32 } from "./array" + + +interface SystemTextEncoder { + encode(input?: string): Uint8Array; + encodeInto(src: string, dest: Uint8Array): void; +} + +interface WithStreamOption { + stream: Boolean | undefined; +} + +interface SystemTextDecoder { + decode( + input: ArrayBuffer | null | undefined | Uint8Array, + options: WithStreamOption | undefined + ): string; +} + +export class CustomTextEncoder { + static readonly HeaderLen: int32 = Int32Array.BYTES_PER_ELEMENT + + constructor(encoder:SystemTextEncoder|undefined = undefined) { + this.encoder = encoder + } + + private readonly encoder: SystemTextEncoder|undefined + + public static stringLength(input: string): int32 { + let length = 0 + for (let i = 0; i < input.length; i++) { + length++ + let cp = input.codePointAt(i)! + if (cp >= 0x10000) { + i++ + } + } + return length + } + + encodedLength(input: string): int32 { + let length = 0 + for (let i = 0; i < input.length; i++) { + let cp = input.codePointAt(i)! + if (cp < 0x80) { + length += 1 + } else if (cp < 0x800) { + length += 2 + } else if (cp < 0x10000) { + length += 3 + } else { + length += 4 + i++ + } + } + return length + } + + private addLength(array: Uint8Array, offset: int32, length: int32 | number): void { + const len = length as int32 + array.set(offset, len & 0xff) + array.set(offset + 1, (len >> 8) & 0xff) + array.set(offset + 2, (len >> 16) & 0xff) + array.set(offset + 3, (len >> 24) & 0xff) + } + + static getHeaderLength(array: Uint8Array, offset: int32 = 0): int32 { + return ( + (array.at(offset) as int32) | + (array.at(((offset + 1) << 8)) as int32) | + (array.at((offset + 2) << 16) as int32) | + (array.at((offset + 3) << 24)) as int32) + } + + // Produces array of bytes with encoded string headed by 4 bytes (little endian) size information: + // [s0][s1][s2][s3] [c_0] ... [c_size-1] + encode(input: string | undefined, addLength: boolean = true): Uint8Array { + let headerLen = addLength ? CustomTextEncoder.HeaderLen : 0 + let result: Uint8Array + if (!input) { + result = new Uint8Array(headerLen) + } else if (this.encoder !== undefined) { + result = this.encoder!.encode('s'.repeat(headerLen) + input) + } else { + let length = this.encodedLength(input) + result = new Uint8Array(length + headerLen) + this.encodeInto(input, result, headerLen) + } + if (addLength) { + this.addLength(result, 0, (result.length - headerLen) as int32) + } + return result + } + + // Produces encoded array of strings with size information. + encodeArray(strings: Array): Uint8Array { + let totalBytes = CustomTextEncoder.HeaderLen + let lengths = new Int32Array(strings.length) + for (let i = 0; i < lengths.length; i++) { + let len = this.encodedLength(strings[i]) + lengths[i] = len + totalBytes += len + CustomTextEncoder.HeaderLen + } + let array = new Uint8Array(totalBytes) + let position = 0 + this.addLength(array, position, lengths.length as int32) + position += CustomTextEncoder.HeaderLen + for (let i = 0; i < lengths.length; i++) { + this.addLength(array, position, lengths[i] as int32) + position += CustomTextEncoder.HeaderLen + this.encodeInto(strings[i], array, position) + position += lengths[i] + } + return array + } + + encodeInto(input: string, result: Uint8Array, position: int32): Uint8Array { + if (this.encoder !== undefined) { + this.encoder!.encodeInto(input, result.subarray(position, result.length)) + return result + } + let index = position + for (let stringPosition = 0; stringPosition < input.length; stringPosition++) { + let cp = input.codePointAt(stringPosition)! + if (cp < 0x80) { + result[index++] = (cp | 0) + } else if (cp < 0x800) { + result[index++] = ((cp >> 6) | 0xc0) + result[index++] = ((cp & 0x3f) | 0x80) + } else if (cp < 0x10000) { + result[index++] = ((cp >> 12) | 0xe0) + result[index++] = (((cp >> 6) & 0x3f) | 0x80) + result[index++] = ((cp & 0x3f) | 0x80) + } else { + result[index++] = ((cp >> 18) | 0xf0) + result[index++] = (((cp >> 12) & 0x3f) | 0x80) + result[index++] = (((cp >> 6) & 0x3f) | 0x80) + result[index++] = ((cp & 0x3f) | 0x80) + stringPosition++ + } + } + result[index] = 0 + return result + } +} + +export class CustomTextDecoder { + static cpArrayMaxSize = 128 + constructor(decoder: SystemTextDecoder|undefined = undefined) { + this.decoder = decoder + } + + private readonly decoder: SystemTextDecoder|undefined + + decode(input: Uint8Array): string { + if (this.decoder !== undefined) { + return this.decoder!.decode(input, undefined) + } + + const cpSize = Math.min(CustomTextDecoder.cpArrayMaxSize, input.length) + let codePoints = new Int32Array(cpSize) + let cpIndex = 0; + let index = 0 + let result = "" + while (index < input.length) { + let elem = input[index] as uint8 + let lead = elem & 0xff + let count = 0 + let value = 0 + if (lead < 0x80) { + count = 1 + value = elem + } else if ((lead >> 5) == 0x6) { + value = (((elem << 6) & 0x7ff) + (input[index + 1] & 0x3f)) as int32 + count = 2 + } else if ((lead >> 4) == 0xe) { + value = (((elem << 12) & 0xffff) + ((input[index + 1] << 6) & 0xfff) + + (input[index + 2] & 0x3f)) as int32 + count = 3 + } else if ((lead >> 3) == 0x1e) { + value = (((elem << 18) & 0x1fffff) + ((input[index + 1] << 12) & 0x3ffff) + + ((input[index + 2] << 6) & 0xfff) + (input[index + 3] & 0x3f)) as int32 + count = 4 + } + codePoints[cpIndex++] = value + if (cpIndex == cpSize) { + cpIndex = 0 + //result += String.fromCodePoint(...codePoints) + result += String.fromCodePoint(...Array_from_int32(codePoints)) + } + index += count + } + if (cpIndex > 0) { + result += String.fromCodePoint(...Array_from_int32(codePoints.slice(0, cpIndex))) + } + return result + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/arkts/ts-reflection.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/arkts/ts-reflection.ts new file mode 100644 index 0000000000000000000000000000000000000000..65325206ed7b90989b48ce27c457c956b3f156b3 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/arkts/ts-reflection.ts @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export function className(object?: Object): string { + return object ? (Type.of(object) as ClassType).getName() : "null" +} + +export function isFunction(object?: Object): boolean { + return Type.of(object) instanceof FunctionType +} + +// TODO: This is an very ad hoc function, +// but I could not find in ArkTS stdlib enough functionality +// for a more generic way. +export function functionOverValue(value: Value|(()=>Value)): boolean { + return Type.of(value) instanceof FunctionType +} + +// Somehow es2panda only allows === on reference types. +export function refEqual(a: Value, b: Value): boolean { + return a == b +} + +export function isNotPrimitive(value: Object): boolean { + return !Type.of(value).isPrimitive() +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/arkts/types.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/arkts/types.ts new file mode 100644 index 0000000000000000000000000000000000000000..b0edbd27a4e7da12223d11fdf834cd34739ac413 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/arkts/types.ts @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export type uint8 = byte +export type int8 = byte +export type unt16 = short +export type int16 = short +export type int32 = int +export type uint32 = int +export type int64 = long +export type uint64 = long +export type float32 = float +export type float64 = double \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/arkts/utils.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/arkts/utils.ts new file mode 100644 index 0000000000000000000000000000000000000000..c49c8e7113a07302bbd8e56d6de0e88f88c7acfd --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/arkts/utils.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export function unsafeCast(value: Object): T { + return value as T +} + +export function scheduleCoroutine(): void { + Coroutine.Schedule() +} + +export function memoryStats(): string { + return `used ${GC.getUsedHeapSize()} free ${GC.getFreeHeapSize()}` +} + +export function launchJob(job: () => void): Promise { + throw new Error("unsupported yet: return launch job()") +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/index.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..ca2f90f6a53edd7c720689e47127ec1862937fce --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/index.ts @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export { + asArray, + Array_from_set, + Array_from_int32, + Array_from_number, + AtomicRef, + asFloat64, + asString, + float32FromBits, + int32BitsFromFloat, + Thunk, + finalizerRegister, + finalizerUnregister, + timeNow, + numberToFixed, + Observed, + Observable, + ObservableHandler, + observableProxy, + observableProxyArray, + propDeepCopy, + lcClassName, + CustomTextEncoder, + CustomTextDecoder, + className, + isFunction, + functionOverValue, + refEqual, + isNotPrimitive, + uint8, + int8, + int16, + int32, + uint32, + int64, + uint64, + float32, + float64, + int8Array, + unsafeCast, + scheduleCoroutine, + memoryStats, + launchJob +} from "#platform" diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/ohos/index.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/ohos/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..efa5fb787e1c0f898f02c544690f9c9162a480d7 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/ohos/index.ts @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export { + asArray, + Array_from_set, + Array_from_int32, + Array_from_number, + AtomicRef, + asFloat64, + asString, + float32FromBits, + int32BitsFromFloat, + Thunk, + finalizerRegister, + finalizerUnregister, + Observed, + Observable, + ObservableHandler, + observableProxy, + observableProxyArray, + propDeepCopy, + lcClassName, + CustomTextEncoder, + CustomTextDecoder, + className, + isFunction, + functionOverValue, + refEqual, + isNotPrimitive, + uint8, + int8, + int16, + int32, + uint32, + int64, + uint64, + float32, + float64, + int8Array, + unsafeCast, + scheduleCoroutine, + memoryStats, + launchJob +} from "../typescript" + +export { + timeNow, + numberToFixed, +} from "./performance" diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/ohos/performance.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/ohos/performance.ts new file mode 100644 index 0000000000000000000000000000000000000000..8926ff8519d1a22bb9a26c81d4d0bae7476ddd9b --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/ohos/performance.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @returns the number of milliseconds elapsed since midnight, + * January 1, 1970 Universal Coordinated Time (UTC). + */ +export function timeNow(): number { + return Date.now() +} + +/** + * @param fractionDigits - number of digits after the decimal point [0 - 20] + * @returns a string representing a number in fixed-point notation + */ +export function numberToFixed(value: number, fractionDigits: number): string { + return new Number(value).toFixed(fractionDigits) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/typescript/Types.d.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/typescript/Types.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4d42fbbf5de01bc8cb67946a38e9d8c42b70bc9a --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/typescript/Types.d.ts @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +type int = number +type long = number +type float = number +type double = number diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/typescript/array.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/typescript/array.ts new file mode 100644 index 0000000000000000000000000000000000000000..156ea36f2e31b66ebb1fdfa8aaa564dfd32c29ef --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/typescript/array.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { float64, int32, int8 } from "./types" + +export function asArray(value: T[]): Array { + return value +} + +export function Array_from_set(set: Set): Array { + return Array.from(set) +} + +export function Array_from_int32(data: Int32Array): int32[] { + return Array.from(data) +} + +export function Array_from_number(data: float64[]): Array { + return data +} + +export function int8Array(size: int32): int8[] { + return [] +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/typescript/atomic.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/typescript/atomic.ts new file mode 100644 index 0000000000000000000000000000000000000000..b3b12b85fa0b57555b12e219c515c26ca97ebb15 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/typescript/atomic.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * A reference that may be updated atomically. + */ +export class AtomicRef { + value: Value + + /** + * Creates a new reference object with the given initial value. + * @param value - the new value + */ + constructor(value: Value) { + this.value = value + } + + /** + * Atomically sets the reference value to the given value and returns the previous one. + * @param value - the new value + * @returns the previous value + */ + getAndSet(value: Value): Value { + const result = this.value + this.value = value + return result + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/typescript/double.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/typescript/double.ts new file mode 100644 index 0000000000000000000000000000000000000000..a8289f87c79c573d5b81b1647caada7128c0ea6b --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/typescript/double.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { float64, int32, float32 } from "./types" + +export function asFloat64(value: string): float64 { + return Number(value) +} + +export function asString(value: float64 | undefined): string | undefined { + return value?.toString() +} + +export function float32FromBits(value: int32): float32 { + return value +} + +export function int32BitsFromFloat(value: float32): int32 { + return value +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/typescript/finalization.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/typescript/finalization.ts new file mode 100644 index 0000000000000000000000000000000000000000..ad5d977f86e4f81994efa5c9728db4dc366dcad9 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/typescript/finalization.ts @@ -0,0 +1,43 @@ + +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export interface Thunk { + clean(): void +} + +interface FinalizationRegistry { + register(target: object, value: any, token?: object): void; + unregister(token: object): void; +} + +interface FinalizationRegistryConstructor { + readonly prototype: FinalizationRegistry; + new(callback: (value: any) => void): FinalizationRegistry; +} + +declare const FinalizationRegistry: FinalizationRegistryConstructor + +const registry = new FinalizationRegistry((thunk: Thunk) => { + thunk.clean() +}) + +export function finalizerRegister(target: object, thunk: object) { + registry.register(target, thunk) +} + +export function finalizerUnregister(target: object) { + registry.unregister(target) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/typescript/index.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/typescript/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..03bb4fbddd19dc1b318e50ee6c3a5eac5f4cc9d9 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/typescript/index.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export * from "./array" +export * from "./atomic" +export * from "./double" +export * from "./finalization" +export * from "./observable" +export * from "./performance" +export * from "./prop-deep-copy" +export * from "./reflection" +export * from "./strings" +export * from "./ts-reflection" +export * from "./types" +export * from "./utils" diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/typescript/observable.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/typescript/observable.ts new file mode 100644 index 0000000000000000000000000000000000000000..24709748a69923cbb93428a2f8aca2f1321083e2 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/typescript/observable.ts @@ -0,0 +1,404 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const OBSERVABLE_TARGET = "__proxy_observable_target__" + +export function getObservableTarget(proxy: Object): Object { + return getPropertyValue(OBSERVABLE_TARGET, proxy) ?? proxy +} + +function getPropertyValue(name: string, object: any): any { + return object[name] +} + +/** + * Data class decorator that makes all child fields trackable. + */ +export function Observed(constructorFunction: Function) { + constructorFunction.prototype[OBSERVED] = true +} + +const OBSERVED = "__ObservedByArkUI__" +function isObserved(value: any): boolean { + return value[OBSERVED] === true +} + +/** @internal */ +export interface Observable { + /** It is called when the observable value is accessed. */ + onAccess(): void + /** It is called when the observable value is modified. */ + onModify(): void +} + +/** @internal */ +export class ObservableHandler implements Observable { + private static handlers: WeakMap | undefined = undefined + + private parents = new Set() + private children = new Map() + + private readonly observables = new Set() + private _modified = false + + readonly observed: boolean + constructor(parent?: ObservableHandler, observed: boolean = false) { + this.observed = observed + if (parent) this.addParent(parent) + } + + onAccess(): void { + if (this.observables.size > 0) { + const it = this.observables.keys() + while (true) { + const result = it.next() + if (result.done) break + result.value?.onAccess() + } + } + } + + onModify(): void { + const set = new Set() + this.collect(true, set) + set.forEach((handler: ObservableHandler) => { + handler._modified = true + if (handler.observables.size > 0) { + const it = handler.observables.keys() + while (true) { + const result = it.next() + if (result.done) break + result.value?.onModify() + } + } + }) + } + + static dropModified(value: Value): boolean { + const handler = ObservableHandler.findIfObject(value) + if (handler === undefined) return false + const result = handler._modified + handler._modified = false + return result + } + + /** Adds the specified `observable` to the handler corresponding to the given `value`. */ + static attach(value: Value, observable: Observable): void { + const handler = ObservableHandler.findIfObject(value) + if (handler) handler.observables.add(observable) + } + + /** Deletes the specified `observable` from the handler corresponding to the given `value`. */ + static detach(value: Value, observable: Observable): void { + const handler = ObservableHandler.findIfObject(value) + if (handler) handler.observables.delete(observable) + } + + /** @returns the handler corresponding to the given `value` if it was installed */ + private static findIfObject(value: Value): ObservableHandler | undefined { + const handlers = ObservableHandler.handlers + return handlers !== undefined && value instanceof Object ? handlers.get(getObservableTarget(value as Object)) : undefined + } + + /** + * @param value - any non-null object including arrays + * @returns an observable handler or `undefined` if it is not installed + */ + static find(value: Object): ObservableHandler | undefined { + const handlers = ObservableHandler.handlers + return handlers ? handlers.get(getObservableTarget(value)) : undefined + } + + /** + * @param value - any non-null object including arrays + * @param observable - a handler to install on this object + * @throws an error if observable handler cannot be installed + */ + static installOn(value: Object, observable?: ObservableHandler): void { + let handlers = ObservableHandler.handlers + if (handlers === undefined) { + handlers = new WeakMap() + ObservableHandler.handlers = handlers + } + observable + ? handlers.set(getObservableTarget(value), observable) + : handlers.delete(getObservableTarget(value)) + } + + addParent(parent: ObservableHandler) { + const count = parent.children.get(this) ?? 0 + parent.children.set(this, count + 1) + this.parents.add(parent) + } + + removeParent(parent: ObservableHandler) { + const count = parent.children.get(this) ?? 0 + if (count > 1) { + parent.children.set(this, count - 1) + } + else if (count == 1) { + parent.children.delete(this) + this.parents.delete(parent) + } + } + + removeChild(value: Value) { + const child = ObservableHandler.findIfObject(value) + if (child) child.removeParent(this) + } + + private collect(all: boolean, guards = new Set()) { + if (guards.has(this)) return guards // already collected + guards.add(this) // handler is already guarded + this.parents.forEach(handler => handler.collect(all, guards)) + if (all) this.children.forEach((_count, handler) => handler.collect(all, guards)) + return guards + } + + static contains(observable: ObservableHandler, guards?: Set) { + if (observable.observed) return true + if (guards === undefined) guards = new Set() // create if needed + else if (guards.has(observable)) return false // already checked + guards.add(observable) // handler is already guarded + for (const it of observable.parents.keys()) { + if (ObservableHandler.contains(it, guards)) return true + } + return false + } +} + +/** @internal */ +export function observableProxyArray(...value: Value[]): Array { + return observableProxy(value) +} + +/** @internal */ +export function observableProxy(value: Value, parent?: ObservableHandler, observed?: boolean, strict = true): Value { + if (value instanceof ObservableHandler) return value // do not proxy a marker itself + if (value === null || !(value instanceof Object)) return value // only non-null object can be observable + const observable = ObservableHandler.find(value) + if (observable) { + if (parent) { + if (strict) observable.addParent(parent) + if (observed === undefined) observed = ObservableHandler.contains(parent) + } + if (observed) { + if (Array.isArray(value)) { + for (let index = 0; index < value.length; index++) { + value[index] = observableProxy(value[index], observable, observed, false) + } + } else { + proxyFields(value, false, observable) + } + } + return value + } + if (Array.isArray(value)) { + const handler = new ObservableHandler(parent) + const array = proxyChildrenOnly(value, handler, observed) + copyWithinObservable(array) + fillObservable(array) + popObservable(array) + pushObservable(array) + reverseObservable(array) + shiftObservable(array) + sortObservable(array) + spliceObservable(array) + unshiftObservable(array) + return proxyObject(array, handler) + } + if (value instanceof Date) { + const valueAsAny = (value as any) + const handler = new ObservableHandler(parent) + const setMethods = new Set([ + "setFullYear", "setMonth", "setDate", "setHours", "setMinutes", "setSeconds", + "setMilliseconds", "setTime", "setUTCFullYear", "setUTCMonth", "setUTCDate", + "setUTCHours", "setUTCMinutes", "setUTCSeconds", "setUTCMilliseconds" + ]) + setMethods.forEach((method: string) => { + const originalMethod = method + 'Original' + if (valueAsAny[originalMethod] !== undefined) { + return + } + valueAsAny[originalMethod] = valueAsAny[method] + valueAsAny[method] = function (...args: any[]) { + ObservableHandler.find(this)?.onModify() + return this[originalMethod](...args) + } + }) + return proxyObject(value, handler) + } + // TODO: support set/map + const handler = new ObservableHandler(parent, isObserved(value)) + if (handler.observed || observed) proxyFields(value, true, handler) + return proxyObject(value, handler) +} + +function proxyObject(value: any, observable: ObservableHandler) { + ObservableHandler.installOn(value, observable) + return new Proxy(value, { + get(target, property, receiver) { + if (property == OBSERVABLE_TARGET) return target + const value: any = Reflect.get(target, property, receiver) + ObservableHandler.find(target)?.onAccess() + return typeof value == "function" + ? value.bind(target) + : value + }, + set(target, property, value, receiver) { + const old = Reflect.get(target, property, receiver) + if (value === old) return true + const observable = ObservableHandler.find(target) + if (observable) { + observable.onModify() + observable.removeChild(old) + const observed = ObservableHandler.contains(observable) + if (observed || Array.isArray(target)) { + value = observableProxy(value, observable, observed) + } + } + return Reflect.set(target, property, value, receiver) + }, + deleteProperty(target, property) { + ObservableHandler.find(target)?.onModify() + delete target[property] + return true + }, + }) +} + +function proxyFields(value: any, strict: boolean, parent?: ObservableHandler) { + for (const name of Object.getOwnPropertyNames(value)) { + const descriptor = Object.getOwnPropertyDescriptor(value, name) + if (descriptor?.writable) value[name] = observableProxy(value[name], parent, true, strict) + } +} + +function proxyChildrenOnly(array: any[], parent: ObservableHandler, observed?: boolean): any[] { + if (observed === undefined) observed = ObservableHandler.contains(parent) + return array.map(it => observableProxy(it, parent, observed)) +} + +function copyWithinObservable(array: any) { + if (array.copyWithinOriginal === undefined) { + array.copyWithinOriginal = array.copyWithin + array.copyWithin = function (this, target: number, start: number, end?: number) { + const observable = ObservableHandler.find(this) + observable?.onModify() + return this.copyWithinOriginal(target, start, end) + } + } +} + +function fillObservable(array: any) { + if (array.fillOriginal === undefined) { + array.fillOriginal = array.fill + array.fill = function (this, value: any, start?: number, end?: number) { + const observable = ObservableHandler.find(this) + observable?.onModify() + if (observable) value = observableProxy(value, observable) + return this.fillOriginal(value, start, end) + } + } +} + +function popObservable(array: any) { + if (array.popOriginal === undefined) { + array.popOriginal = array.pop + array.pop = function (...args: any[]) { + const observable = ObservableHandler.find(this) + observable?.onModify() + const result = this.popOriginal(...args) + if (observable) observable.removeChild(result) + return result + } + } +} + +function pushObservable(array: any) { + if (array.pushOriginal === undefined) { + array.pushOriginal = array.push + array.push = function (this, ...args: any[]) { + const observable = ObservableHandler.find(this) + observable?.onModify() + if (observable) args = proxyChildrenOnly(args, observable) + return this.pushOriginal(...args) + } + } +} + +function reverseObservable(array: any) { + if (array.reverseOriginal === undefined) { + array.reverseOriginal = array.reverse + array.reverse = function (this) { + const observable = ObservableHandler.find(this) + observable?.onModify() + return this.reverseOriginal() + } + } +} + +function shiftObservable(array: any) { + if (array.shiftOriginal === undefined) { + array.shiftOriginal = array.shift + array.shift = function (this, ...args: any[]) { + const observable = ObservableHandler.find(this) + observable?.onModify() + const result = this.shiftOriginal(...args) + if (observable) observable.removeChild(result) + return result + } + } +} + +function sortObservable(array: any) { + if (array.sortOriginal === undefined) { + array.sortOriginal = array.sort + array.sort = function (this, compareFn?: (a: any, b: any) => number) { + const observable = ObservableHandler.find(this) + observable?.onModify() + return this.sortOriginal(compareFn) + } + } +} + +function spliceObservable(array: any) { + if (array.spliceOriginal === undefined) { + array.spliceOriginal = array.splice + array.splice = function (this, start: number, deleteCount: number, ...items: any[]) { + const observable = ObservableHandler.find(this) + observable?.onModify() + if (observable) items = proxyChildrenOnly(items, observable) + if (deleteCount === undefined) deleteCount = array.length + const result = this.spliceOriginal(start, deleteCount, ...items) + if (observable && Array.isArray(result)) { + result.forEach(it => observable.removeChild(it)) + } + return result + } + } +} + +function unshiftObservable(array: any) { + if (array.unshiftOriginal === undefined) { + array.unshiftOriginal = array.unshift + array.unshift = function (this, ...items: any[]) { + const observable = ObservableHandler.find(this) + observable?.onModify() + if (observable) items = proxyChildrenOnly(items, observable) + return this.unshiftOriginal(...items) + } + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/typescript/performance.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/typescript/performance.ts new file mode 100644 index 0000000000000000000000000000000000000000..9451185bcdcd9caa514e08d22f7c54d1d315eca9 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/typescript/performance.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @returns the number of milliseconds elapsed since midnight, + * January 1, 1970 Universal Coordinated Time (UTC). + */ +export function timeNow(): number { + return performance.now() +} + +/** + * @param fractionDigits - number of digits after the decimal point [0 - 20] + * @returns a string representing a number in fixed-point notation + */ +export function numberToFixed(value: number, fractionDigits: number): string { + return value.toFixed(fractionDigits) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/typescript/prop-deep-copy.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/typescript/prop-deep-copy.ts new file mode 100644 index 0000000000000000000000000000000000000000..3dd13819df356a5701b8e7bbb9d8f9769cd1e33e --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/typescript/prop-deep-copy.ts @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { getObservableTarget } from "./observable" + +/* + When decorating variables of complex types, + @Prop makes a deep copy, during which all types, + except primitive types, Map, Set, Date, and Array, will be lost. + */ + +export function propDeepCopy(sourceObject: T): T { + if (!sourceObject || typeof sourceObject !== 'object') { + return sourceObject + } + + const copiedObjects = new Map() + return recursiveDeepCopy(sourceObject) as T + + function recursiveDeepCopy(sourceObject: Object): Object { + if (!sourceObject || typeof sourceObject !== 'object') { + return sourceObject + } + + const storedObject = copiedObjects.get(sourceObject) + if (storedObject !== undefined) { + return storedObject + } + + const copy: any = copyDeepTrackable(sourceObject) + + const objectToCopyFrom = getObservableTarget(sourceObject) + Object.keys(objectToCopyFrom) + .forEach((key) => { + const property = objectToCopyFrom[key as keyof Object] + + if (typeof property === "function") { + Reflect.set(copy, key, property) + copy[key] = copy[key].bind(copy) + return + } + Reflect.set(copy, key, recursiveDeepCopy(property)); + }) + + return copy + } + + function copyDeepTrackable(sourceObject: T): T { + if (sourceObject instanceof Set) { + const copy = new Set() + Object.setPrototypeOf(copy, Object.getPrototypeOf(sourceObject)) + copiedObjects.set(sourceObject, copy) + for (const setKey of sourceObject.keys()) { + copy.add(recursiveDeepCopy(setKey)) + } + return copy as T + } + if (sourceObject instanceof Map) { + const copy = new Map() + Object.setPrototypeOf(copy, Object.getPrototypeOf(sourceObject)) + copiedObjects.set(sourceObject, copy) + for (const mapKey of sourceObject.keys()) { + copy.set(mapKey, recursiveDeepCopy(sourceObject.get(mapKey))) + } + return copy as T + } + if (sourceObject instanceof Date) { + const copy = new Date() + copy.setTime(sourceObject.getTime()) + Object.setPrototypeOf(copy, Object.getPrototypeOf(sourceObject)) + copiedObjects.set(sourceObject, copy) + return copy as T + } + if (sourceObject instanceof Object) { + const copy = Array.isArray(sourceObject) ? [] : {} + Object.setPrototypeOf(copy, Object.getPrototypeOf(sourceObject)) + copiedObjects.set(sourceObject, copy) + return copy as T + } + + return sourceObject + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/typescript/reflection.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/typescript/reflection.ts new file mode 100644 index 0000000000000000000000000000000000000000..7961ab53e335fea16eec61cd8444bc890e318790 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/typescript/reflection.ts @@ -0,0 +1,20 @@ + +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { className } from "./ts-reflection" + +export function lcClassName(object: Object) { + return className(object).toLowerCase() +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/typescript/strings.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/typescript/strings.ts new file mode 100644 index 0000000000000000000000000000000000000000..3fd4a2a78db63831b19f9c026a1911e3e62a0196 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/typescript/strings.ts @@ -0,0 +1,205 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { int32 } from "./types" + +interface SystemTextEncoder { + encode(input?: string): Uint8Array; + encodeInto(src: string, dest: Uint8Array): void; +} + +interface WithStreamOption { + stream?: boolean | undefined; +} + +interface SystemTextDecoder { + decode( + input?: ArrayBuffer | null, + options?: WithStreamOption + ): string; +} + +export class CustomTextEncoder { + static readonly HeaderLen: int32 = Int32Array.BYTES_PER_ELEMENT + + constructor(encoder: SystemTextEncoder|undefined = ((typeof TextEncoder != "undefined") ? new TextEncoder() : undefined)) { + this.encoder = encoder + } + + private readonly encoder: SystemTextEncoder|undefined + + public static stringLength(input: string): int32 { + let length = 0 + for (let i = 0; i < input.length; i++) { + length++ + let cp = input.codePointAt(i)! + if (cp >= 0x10000) { + i++ + } + } + return length + } + + encodedLength(input: string): int32 { + let length = 0 + for (let i = 0; i < input.length; i++) { + let cp = input.codePointAt(i)! + if (cp < 0x80) { + length += 1 + } else if (cp < 0x800) { + length += 2 + } else if (cp < 0x10000) { + length += 3 + } else { + length += 4 + i++ + } + } + return length + } + + private addLength(array: Uint8Array, offset: int32, len: int32): void { + array[offset] = (len & 0xff) + array[offset + 1] = ((len >> 8) & 0xff) + array[offset + 2] = ((len >> 16) & 0xff) + array[offset + 3] = ((len >> 24) & 0xff) + } + + static getHeaderLength(array: Uint8Array, offset: int32 = 0): int32 { + return (array[offset] | (array[offset + 1] << 8) | (array[offset + 2] << 16) | (array[offset + 3] << 24)) + } + + // Produces array of bytes with encoded string headed by 4 bytes (little endian) size information: + // [s0][s1][s2][s3] [c_0] ... [c_size-1] + encode(input: string | undefined, addLength: boolean = true): Uint8Array { + let headerLen = addLength ? CustomTextEncoder.HeaderLen : 0 + let result: Uint8Array + if (!input) { + result = new Uint8Array(headerLen) + } else if (this.encoder !== undefined) { + result = this.encoder!.encode('s'.repeat(headerLen) + input) + } else { + let length = this.encodedLength(input) + result = new Uint8Array(length + headerLen) + this.encodeInto(input, result, headerLen) + } + if (addLength) { + this.addLength(result, 0, result.length - headerLen) + } + return result + } + + // Produces encoded array of strings with size information. + encodeArray(strings: Array): Uint8Array { + let totalBytes = CustomTextEncoder.HeaderLen + let lengths = new Int32Array(strings.length) + for (let i = 0; i < lengths.length; i++) { + let len = this.encodedLength(strings[i]) + lengths[i] = len + totalBytes += len + CustomTextEncoder.HeaderLen + } + let array = new Uint8Array(totalBytes) + let position = 0 + this.addLength(array, position, lengths.length) + position += CustomTextEncoder.HeaderLen + for (let i = 0; i < lengths.length; i++) { + this.addLength(array, position, lengths[i]) + position += CustomTextEncoder.HeaderLen + this.encodeInto(strings[i], array, position) + position += lengths[i] + } + return array + } + + encodeInto(input: string, result: Uint8Array, position: int32): Uint8Array { + if (this.encoder !== undefined) { + this.encoder!.encodeInto(input, result.subarray(position, result.length)) + return result + } + let index = position + for (let stringPosition = 0; stringPosition < input.length; stringPosition++) { + let cp = input.codePointAt(stringPosition)! + if (cp < 0x80) { + result[index++] = (cp | 0) + } else if (cp < 0x800) { + result[index++] = ((cp >> 6) | 0xc0) + result[index++] = ((cp & 0x3f) | 0x80) + } else if (cp < 0x10000) { + result[index++] = ((cp >> 12) | 0xe0) + result[index++] = (((cp >> 6) & 0x3f) | 0x80) + result[index++] = ((cp & 0x3f) | 0x80) + } else { + result[index++] = ((cp >> 18) | 0xf0) + result[index++] = (((cp >> 12) & 0x3f) | 0x80) + result[index++] = (((cp >> 6) & 0x3f) | 0x80) + result[index++] = ((cp & 0x3f) | 0x80) + stringPosition++ + } + } + result[index] = 0 + return result + } +} + +export class CustomTextDecoder { + static cpArrayMaxSize = 128 + constructor(decoder: SystemTextDecoder|undefined = ((typeof TextDecoder != "undefined") ? new TextDecoder() : undefined)) { + this.decoder = decoder + } + + private readonly decoder: SystemTextDecoder|undefined + + decode(input: Uint8Array): string { + if (this.decoder !== undefined) { + return this.decoder!.decode(input) + } + const cpSize = Math.min(CustomTextDecoder.cpArrayMaxSize, input.length) + let codePoints = new Int32Array(cpSize) + let cpIndex = 0; + let index = 0 + let result = "" + while (index < input.length) { + let elem = input[index] + let lead = elem & 0xff + let count = 0 + let value = 0 + if (lead < 0x80) { + count = 1 + value = elem + } else if ((lead >> 5) == 0x6) { + value = ((elem << 6) & 0x7ff) + (input[index + 1] & 0x3f) + count = 2 + } else if ((lead >> 4) == 0xe) { + value = ((elem << 12) & 0xffff) + ((input[index + 1] << 6) & 0xfff) + + (input[index + 2] & 0x3f) + count = 3 + } else if ((lead >> 3) == 0x1e) { + value = ((elem << 18) & 0x1fffff) + ((input[index + 1] << 12) & 0x3ffff) + + ((input[index + 2] << 6) & 0xfff) + (input[index + 3] & 0x3f) + count = 4 + } + codePoints[cpIndex++] = value + if (cpIndex == cpSize) { + cpIndex = 0 + result += String.fromCodePoint(...codePoints) + } + index += count + } + if (cpIndex > 0) { + result += String.fromCodePoint(...codePoints.slice(0, cpIndex)) + } + return result + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/typescript/ts-reflection.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/typescript/ts-reflection.ts new file mode 100644 index 0000000000000000000000000000000000000000..f99c90278bb8e8db172bcd0bf1657a0ddf673b7a --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/typescript/ts-reflection.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export function className(object?: Object): string { + return object?.constructor.name ?? "" +} + +export function isFunction(object?: Object): boolean { + return typeof object === 'function' +} + +// TODO: this is to match arkts counterpart +export function functionOverValue(value: Value|(()=>Value)): boolean { + return typeof value === 'function' +} + +export function refEqual(a: Value, b: Value): boolean { + return a === b +} + +export function isNotPrimitive(value: Object): boolean { + return true +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/typescript/types.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/typescript/types.ts new file mode 100644 index 0000000000000000000000000000000000000000..07796d8d41823a990f30f73a4a075c6b3a2b22d7 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/typescript/types.ts @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// +export type uint8 = int +export type int8 = int +export type int16 = int +export type int32 = int +export type uint32 = int +export type int64 = long +export type uint64 = long +export type float32 = float +export type float64 = double diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/typescript/utils.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/typescript/utils.ts new file mode 100644 index 0000000000000000000000000000000000000000..c3303e93fd4b6c5faa1f8d30e80f89b3a7f73a6c --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/src/typescript/utils.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export function unsafeCast(value: unknown): T { + return value as unknown as T +} + +export function scheduleCoroutine(): void {} + +export function memoryStats(): string { + return `none` +} + +export function launchJob(job: () => void): Promise { + return new Promise(resolve => setTimeout(() => { + resolve() + job() + }, 0) + ) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/tsconfig-ohos.json b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/tsconfig-ohos.json new file mode 100644 index 0000000000000000000000000000000000000000..76fd633d88903cb80a14b798e18a4b01df6a5f17 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/tsconfig-ohos.json @@ -0,0 +1,13 @@ +{ + "extends": "@koalaui/build-common/tsconfig.json", + "compilerOptions": { + "baseUrl": ".", + "rootDir": ".", + "outDir": "build/", + "module": "CommonJS", + "paths": { + "#platform": ["./src/ohos"] + } + }, + "include": ["./src/index.ts", "./src/typescript/**/*", "./src/ohos/**/*"] +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/tsconfig.json b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/tsconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..595bc28a0a80e17714720a214ec119cb15774206 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/compat/tsconfig.json @@ -0,0 +1,13 @@ +{ + "extends": "@koalaui/build-common/tsconfig.json", + "compilerOptions": { + "baseUrl": ".", + "rootDir": ".", + "outDir": "build/", + "module": "CommonJS", + "paths": { + "#platform": ["./src/typescript"] + } + }, + "include": ["./src/index.ts", "./src/typescript/**/*"] +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/package.json b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/package.json new file mode 100644 index 0000000000000000000000000000000000000000..5be3485965df3ad2240e108caa8bad470aa9e5f3 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/package.json @@ -0,0 +1,33 @@ +{ + "name": "incremental", + "private": true, + "workspaces": [ + "build-common", + "compat", + "common", + "runtime", + ], + "devDependencies": { + "ts-node": "^10.7.0", + "ts-patch": "^2.1.0", + "tslib": "^2.3.1", + "typescript": "4.9.5", + "rimraf": "^6.0.1" + }, + "scripts": { + "prepare": "cd node_modules/typescript && ts-patch install", + "all:clean": "npm run clean --ws --if-present -s", + "all:clean:unmemoized": "npm run clean:unmemoized --ws --if-present -s", + "compile": "npm run compile -w ./compat && npm run compile -w ./common && npm run compile -w ./runtime" + }, + "dependencies": { + "@koalaui/fast-arktsc": "1.5.15", + "@koalaui/ets-tsc": "4.9.5-r5", + "circular-dependency-plugin": "^5.2.2", + "copy-webpack-plugin": "^12.0.2", + "source-map-loader": "^5.0.0", + "ts-loader": "^9.5.1", + "webpack": "^5.93.0", + "webpack-cli": "^5.1.4" + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/.gitignore b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..0165b3adcc2415c3281cff840b3c2c744d71afa7 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/.gitignore @@ -0,0 +1,2 @@ +test/ohos-index.ts +ets \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/.mocharc.json b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/.mocharc.json new file mode 100644 index 0000000000000000000000000000000000000000..fba4c55b0e4952e1ef019b1f94cd0a854eac2599 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/.mocharc.json @@ -0,0 +1,7 @@ +{ + "ui": "tdd", + "spec": "./test/**/*.test.ts", + "exclude": "./test/browser/**/*", + "extension": ["ts"], + "require": ["../test-utils/scripts/register"] +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/.nycrc.json b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/.nycrc.json new file mode 100644 index 0000000000000000000000000000000000000000..b1bfe80ef6f55347ada470b73fe3d72d6d4d74ed --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/.nycrc.json @@ -0,0 +1,6 @@ +{ + "extends": "tsconfig-with-tests.json", + "reporter": ["html", "text-summary"], + "report-dir": "./build/coverage/report", + "temp-dir": "./build/coverage/temp" +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/.ohconf.test.json b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/.ohconf.test.json new file mode 100644 index 0000000000000000000000000000000000000000..ac752286683c12f11c6ccdc1f06c2b7cc18339ad --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/.ohconf.test.json @@ -0,0 +1,6 @@ +{ + "test_root": "test", + "build": [ + "npm run compile:test" + ] +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/annotations/index.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/annotations/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..7e51be7e2c8aa179fa907cb89633b29cde413eeb --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/annotations/index.ts @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Retention({policy: "SOURCE"}) +export @interface memo {} + +@Retention({policy: "SOURCE"}) +export @interface memo_intrinsic {} + +@Retention({policy: "SOURCE"}) +export @interface memo_entry {} + +@Retention({policy: "SOURCE"}) +export @interface memo_stable {} + +@Retention({policy: "SOURCE"}) +export @interface memo_skip {} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/arktsconfig-run-unmemoized.json b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/arktsconfig-run-unmemoized.json new file mode 100644 index 0000000000000000000000000000000000000000..b2d38a2786582539c24ffced380094cb833dbb4a --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/arktsconfig-run-unmemoized.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "package": "@koalaui/runtime", + "outDir": "build/unmemoized/abc", + "baseUrl": "./build/unmemoized/src", + "paths": { + "@koalaui/common": ["../../../../common/src"], + "@koalaui/compat": ["../../../../compat/src/arkts"] + } + }, + "include": ["build/unmemoized/src/**/*.ts", "build/unmemoized/src/*.ts"], + "references": [ + { "path": "../common" }, + { "path": "../compat" } + ] +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/arktsconfig-test-unmemoized.json b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/arktsconfig-test-unmemoized.json new file mode 100644 index 0000000000000000000000000000000000000000..231ac60b86853aa03c2694fd80a6bdf8fe7809d8 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/arktsconfig-test-unmemoized.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "package": "@koalaui/runtime-tests", + "outDir": "build/unmemoized/abc", + "baseUrl": "./build/unmemoized", + "paths": { + "@koalaui/compat": [ "../../../compat/src/arkts" ], + "@koalaui/common": [ "../../../common/src" ], + "@koalaui/harness": [ "../../../harness/src/arkts" ], + "@koalaui/runtime": [ "../../../runtime/build/unmemoized/src" ] + } + }, + "include": [ + "build/unmemoized/src/**/*.ts", + "build/unmemoized/src/*.ts", + "build/unmemoized/test-arkts/**/*.ts", + "build/unmemoized/test-arkts/*.ts" + ], + "exclude": [ + "build/unmemoized/test-arkts/states/state_basics.test.ts" + ] +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/arktsconfig.json b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/arktsconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..f2abbcdadb140d4f85f00992bfdabba147523d53 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/arktsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "package": "@koalaui/runtime", + "outDir": "build/abc", + "baseUrl": "./src", + "paths": { + "@koalaui/common": ["../../common/src"], + "@koalaui/compat": ["../../compat/src/arkts"] + } + }, + "include": ["./src/**/*.ts"], + "references": [ + { "path": "../common" }, + { "path": "../compat" } + ] + +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/docs/basic-concepts.md b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/docs/basic-concepts.md new file mode 100644 index 0000000000000000000000000000000000000000..a9fadf46c6bab392dfe2df328c9c40d9c8ab374c --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/docs/basic-concepts.md @@ -0,0 +1,193 @@ +# Basic concepts of the incremental UI building + +Incremental runtime is part of the declarative UI framework +designed to optimize calculations and rebuilding trees depending on states. +This document explains the basic concepts underlying the chosen approach. + +## 1. Positional memoization + +### Call graphs + +A call graph is a control-flow diagram, +which represents calling relationships between subroutines in a computer program. +Each node represents a function (or a method) +and each directional edge indicates that one function calls another one. + +![A call graph example](call.graph.drawio.svg) +> Figure 1. A call graph example + +### Idempotent functions + +Idempotence is the property of certain operations in mathematics and computer science +whereby they can be applied multiple times +without changing the result beyond the initial application. + +If all functions in some call graph are idempotent, then such graph is also idempotent. +Therefore, it's enough to call it only once and use the cached result later. + +### @memo functions + +The @memo function is a kind of idempotent function +that should recalculate the cached result when the used state has changed. +If none of the used states has changed, the @memo function is considered idempotent +and its cached result is used instead of recalculation. + +The @memo function can only be called within some @memo context, +i.e. from other @memo functions. +An attempt to call the @memo function without the @memo context +will cause a compiler error (in some cases a runtime error). + +```typescript +const state = mutableState("some text") + +/** @memo */ +function printAll() { + console.log("state: " + state.value) // recomposed on state change +} +``` + +Consider the example of a call graph shown in Figure 1. +Suppose that each of its functions is a @memo function. +Then the first time we evaluate `main entry`, +we need to call each used function in the specified order. +This initial calculation is called *composition*. + +Now assume that `create second paragraph` uses some state that has just changed. +This means that the cached result of this @memo function needs to be recalculated. +Also, `create body` must be recalculated too, because it uses `create second paragraph`. +Similarly, `main entry` must also be recalculated. +This partial recalculation of the call graph is called *recomposition*. +Thus, the recomposition of the considering example will look like this: +- compute the value of `main entry` + - use the cached value of `create prefix` + - compute the value of `create body` + - use the cached value of `create first paragraph` + - compute the value of `create second paragraph` + - use the cached value of `create third paragraph` + - use the cached value of `create postfix` + +### Parameters + +A @memo function can have parameters, +which (as well as states) affect its idempotence. +If some @memo function during recomposition computes a different argument, +the called @memo function will be recomputed even if its states are not changed. + +```typescript +const state = mutableState(10) + +/** @memo */ +function printAll() { + print(Math.floor(state.value / 10)) // recomposed on state change +} + +/** @memo */ +function print(value: number) { + console.log("parameter: " + value) // recomposed on parameter change +} +``` + +Consider the example above. +Both methods will be called during composition. +The argument for `print` will be `1`. +If the state value is changed, `printAll` will be recomposed +and the argument for `print` will be recalculated. + +Suppose the state value becomes `15`. +Then the argument will be `1`, and the recomposition of `print` will not occur. +But if the state value becomes `20`, the argument will be `2`. +Changing the parameter value will cause the recomposition of `print`, +and this value will be logged. + +### Positioning + +A @memo function can be called from another one several times. +Therefore, it is needed to distinguish between different calls. +For this purpose, *positional memoization* is used. +For each @memo function call, the compiler computes +the corresponding callsite key based on its position in the code. + +```typescript +const state1 = mutableState("some text") +const state2 = mutableState("separate text") + +/** @memo */ +function printAll() { + print("state1", state1.value) // recomposed on first state change + print("state2", state2.value) // recomposed on second state change +} + +/** @memo */ +function print(name: string, value: string) { + console.log(name + ": " + value) // recomposed on parameter change +} +``` + +In the example above, `print` is called twice during composition. +If a single state is changed, only the corresponding `print` is recomposed. +If both states are changed, `print` is recomposed twice, +even if the values of both states are equal. + +### Conditional constructs + +The @memo function can call other functions, both @memo and regular ones. +In addition, conditional statements can be used without any restrictions. + +```typescript +const state = mutableState(true) + +/** @memo */ +function print() { + const value = state.value ? random("ON") : random("OFF") + console.log("random value is " + value) +} + +/** @memo */ +function random(text: string): string { + return text + ": " + Math.random() +} +``` + +Consider the example above. +`print` has two different calls of `random`, +but only one of them is called during composition/recomposition +because of positional memoization. +When the state changes, +one call *leaves the composition* and another one *enters the composition*. +When a @memo function leaves the composition, all cached results are forgotten. + +Note that `random` is called with constant arguments and it does not use any states. +This means that this @memo function will be called only once during composition. +Therefore, the library `Math.random` will also be called only once, +and the calculated value will be cached for future use. + +### Loop constructs + +Positioning may be insufficient to distinguish +multiple calls at the same position in case of loops. +The current implementation allows to use loop statements +to iterate stable content only. +The example below contains ten `print` calls, +each of which is called with a constant argument. + +```typescript +/** @memo */ +function printAll() { + for (let i = 0; i < 10; i++) print(i) +} + +/** @memo */ +function print(index: number) { + console.log("index: " + index) +} +``` + +To resolve the positioning issue in loops, +the runtime provides additional @memo functions +to distinguish between calls on different iterations of the loop. +`RepeatWithKey`, `RepeatByArray`, and `RepeatRange` +allow to control the callsite key generation for each iteration. + +## 2. State management + +## 3. Build UI tree incrementally diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/docs/call.graph.drawio.svg b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/docs/call.graph.drawio.svg new file mode 100644 index 0000000000000000000000000000000000000000..6f03447646056099971fde33fe153459a01f5b42 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/docs/call.graph.drawio.svg @@ -0,0 +1,144 @@ + + + + + + + +
+
+
+ main entry +
+
+
+
+ + main entry + +
+
+ + + + +
+
+
+ create prefix +
+
+
+
+ + create prefix + +
+
+ + + + +
+
+
+ create body +
+
+
+
+ + create body + +
+
+ + + + +
+
+
+ create postfix +
+
+
+
+ + create postfix + +
+
+ + + + +
+
+
+ create first paragraph +
+
+
+
+ + create first paragraph + +
+
+ + + + +
+
+
+ create second paragraph +
+
+
+
+ + create second paragraph + +
+
+ + + + +
+
+
+ create third paragraph +
+
+
+
+ + create third paragraph + +
+
+ + + + + + + + + + + + +
+ + + + + Text is not SVG - cannot display + + + +
\ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/docs/explicit-state.md b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/docs/explicit-state.md new file mode 100644 index 0000000000000000000000000000000000000000..7e681e9ab4a9ea9519b4f6a5d868fcc771161806 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/docs/explicit-state.md @@ -0,0 +1,642 @@ +# Primitives for Explicit State Objects and Positional Memoization + +## Explicit State Interfaces + +The explicit state management interface allows to manipulate states as regular ArkTS objects. +This kind of primitive has proven to be useful in the industry and in our own experimental work. +It is a convenient implementation primitive. And it is a convenient user expression primitive. + +### The benefits + +#### Typing benefit + +The state objects explicitly differentiate the type of the value and the type of the state. + +#### Storage freedom + +The state objects can be stored global variables, local variables, class properties. They can be passed as function arguments. They can be placed in arrays and other standard data structures. + +#### Behaviour freedom + +The state interfaces are quite generic. But the implementation can be different. The state value updates can be done explicitly by user code (this is MutableState, see below), state values can be updated by implementation library, state value can change according some internal time based law allowing animated behavior. + +### The basic API structure + +The API consists of several areas: + + * State objects: several interfaces describing state abstraction + * Helper constructor functions that allow instantiate different kinds of states. + * "Construct and attach" helper functions. They instantiate a state of some kind and attach them to the tree. + +### The Interface + +#### State + +The most basic state interface is quite simple. + +``` +/** + * Individual state, wrapping a value of type `Value`. + */ +export interface State { + /** + * If state was modified since last UI computations. + */ + readonly modified: boolean + /** + * Current value of the state. + * State value doesn't change during memo code execution. + */ + readonly value: Value +} +``` +#### MutableState + +The most commonly used interface is + +``` +/** + * Individual mutable state, wrapping a value of type `Value`. + */ +export interface MutableState extends Disposable, State { + /** + * Current value of the state as a mutable value. + * You should not change state value from a memo code. + * State value doesn't change during memo code execution. + * In the event handlers and other non-memo code + * a changed value is immediately visible. + */ + value: Value +} +``` +#### ComputableState + +``` + +/** + * Individual computable state that provides recomputable value of type `Value`. + */ +export interface ComputableState extends Disposable, State { + /** + * If value will be recomputed on access. + */ + readonly recomputeNeeded: boolean +} + +``` + +### Constructor functions + +#### mutableState + +There is a constructor function to simplify instantiation of MutableState objects: + +``` +/** + * Creates new mutable state in the global state manager. + * This state is valid until it is manually detached from the manager. + * It will be detached automatically if it is in the {@link remember}. + * Note that thoughtless state disposing can lead to memory leaks. + * @param value - initial value to initialize the created state + * @param equivalent - optional value comparator for a state + * @param tracker - optional tracker of values assigned to a state + * @returns new mutable state trackable by memo-functions + */ +export function mutableState(value: T, equivalent?: Equivalent, tracker?: ValueTracker): MutableState +``` + +### Attachment Interfaces + +#### remember() + +The state objects can be cached in the UI tree. The basic attachment primitive is `remember` + +``` + +/** + * It calculates the value of the given lambda and caches its result. + * In contrast to the `memo` function, the given lambda is calculated only once + * even if it uses values of states (including parameters of @memo-functions). + * + * @param compute - a function to compute cacheable result + * @returns the last calculated value + * @see memo + */ +export function remember(compute: () => Value): Value + +``` + +#### memo() + +``` + +/** + * It calculates the value of the given lambda and caches its result. + * In contrast to the `remember` function, the given lambda can be recalculated + * if it uses values of states (including parameters of @memo-functions). + * If the given lambda does not use any state, it will be calculated only once. + * + * @param compute - a function to compute cacheable result + * @returns the last calculated value + * @see remember + * @experimental + */ +export function memo(compute: () => Value): Value +``` + +### Construct and remember helper functions + +#### rememberMutableState() + +This is the most regular instantiate+remember helper function. + +``` + +/** + * Creates remembered state which can be updated from anywhere, + * and if changed - all depending memo functions recache automatically. + * Note that you can specify the value directly for primitive values, + * which do not require computations or memory allocation. + * It is highly recommended to provide a lambda for all others values. + * + * @param initial - initial value supplier used on the state creation + * @returns a state remembered for the current code position + * @memo:intrinsic + */ +export function rememberMutableState(initial: (() => Value) | Value): MutableState +``` + +#### rememberMutableAsyncState() + +``` +/** + * Remember mutable state which is computed in async way and is undefined if promise + * is not fulfilled. + * + * @param compute function returning promise to compute the state + * @param initial value stored to the state + * @param onError callback called if promise was rejected + * @memo + */ +export function rememberMutableAsyncState(compute: () => Promise, initial?: Value, onError?: (error: Error) => void): MutableState +``` +#### rememberComputableState() + +``` +/** + * Remember mutable state which is + * re-computed in async way if key has changed + * and undefined while promise is not fulfilled. + * + * @param key a value to trigger state recomputation + * @param compute function returning promise to compute the state + * @param initial value stored to the state + * @param onError callback called if promise was rejected + * @memo + */ +export function rememberComputableState( + key: Key, + /** @skip:memo */ + compute: (key: Key) => Promise, + initial?: Value, + onError?: (error: Error) => void +): MutableState +``` + +#### rememberDisposableValue() + +``` + +/** + * It calculates the value of the given lambda, caches its result, + * and notifies, that this method is removed from the composition. + * + * @param compute - a function to compute cacheable result + * @param cleanup - a function to cleanup computed result on dispose + * @returns the last calculated value + * @see remember + * @memo:intrinsic + */ +export function rememberDisposable(compute: () => Value, cleanup: (value: Value | undefined) => void): Value + +``` + +#### rememberComputableValue() + +``` +/** + * Remember a value which is + * re-computed in async way if key has changed + * and undefined while promise is not fulfilled. + * + * @param key a value to trigger state recomputation + * @param compute function returning promise to compute the state + * @param initial value stored to the state + * @param onError callback called if promise was rejected + * @memo + */ +export function rememberComputableValue( + key: Key, + /** @skip:memo */ + compute: (key: Key) => Promise, + initial?: Value, + onError?: (e: Error) => void +): Value | undefined + +``` + +### Context local + +Context local state is a kind of state that allows named state scopes on the tree. + + +#### contextLocalScope() + +Creates a state, gives it a name and attaches it to the tree + +``` +/** + * Creates a named state with the specified value in the context scope. + * The specified value will be propagated immediately during recomposition. + * Note that the state name must not be dynamically changed. + * + * @param name - a name of a context state + * @param value - a value of a named state to share within the given content + * @param content - a scope content in which a named state is available + * @memo:intrinsic + */ +export function contextLocalScope( + name: string, + value: Value, + @memo + content: () => void +) +``` + +#### contextLocal() + +Finds the closest attached state with the given name up in the tree + +``` +/** + * @param name - a name of a context state + * @returns the named context state or `undefined` if it does not exist + * @memo:intrinsic + */ +export function contextLocal(name: string): State | undefined +``` + +#### contextLocalValue() + +Finds the closest attached state with the given name up in the tree and reurns its value + +``` +/** + * @param name - a name of a context state + * @returns a value of a context state + * @throws Error if a named context state does not exist + * @memo:intrinsic + */ +export function contextLocalValue(name: string): Value +``` + +### Positional memoization primitive functions + +#### Memo entry + +Memo entry is a family of functions to allow entering memoizing call chain. + +``` +/** + * This is where regular code can enter the memo realm. + * This function allows to run a memo function in a non-memo context. + * @internal + * @memo:entry + */ +export function memoEntry( + context: StateContext, + id: CallsiteKey, + @memo entry: () => R, +): R +``` + +``` +/** + * This is where regular code can enter the memo realm. + * This function allows to run a memo function in a non-memo context. + * @internal + * @memo:entry + */ +export function memoEntry1( + context: StateContext, + id: CallsiteKey, + @memo entry: (arg: T) => R, + arg: T, +): R +``` + +``` +/** + * This is where regular code can enter the memo realm. + * This function allows to run a memo function in a non-memo context. + * @internal + * @memo:entry + */ +export function memoEntry2( + memo_context: StateContext, + memo_id: CallsiteKey, + @memo entry: (arg1: T1, arg2: T2) => R, + arg1: T1, + arg2: T2, +): R +``` + +#### Memo bind + +These are functions transforming memo lambda arguments to memo lambda of lower arity by binding some arguments to given values. + +``` +export function memoBind( + @memo item: (arg: T) => void, + value: T +): @memo () => void + +``` + +``` +export function memoBind2( + @memo item: (arg1: T1, arg2: T2) => void, + value1: T1, + value2: T2 +): @memo () => void +``` + +## Positional Memoization + +### Semantics + +Functions marked with @memo provide "positional memoization semantics". +A function call, instead of evaluating the function again, returns the +same (memoized) value as the previous call at the same call site (position). +Unless any of two things happens: + 1. A value of any argument is changed + 2. Any state object the function is subscribed (see below) to is changed. + +### Subscription + +A memo function or a memo lambda subscribes to a state variable by the fact of reading its value. + +### Annotations + +There are several annotations used by the incremental runtime plugin + + * @memo + * @memo:entry + + +### Syntax + +The annotations are accepted at the following syntactic positions: + + +#### Function declaration + +``` +@memo +function foo() {} +``` + +#### Method declaration + +``` +class X { + @memo + foo() {} +} +``` + +#### Parameters of functional type + +``` +function foo( + @memo arg1: () => void +) +``` + +#### Lambda function literal +``` + @memo () => {...} +``` + + +#### Property declaration +``` +class X { + @memo public p +} +``` + +#### Function type declaration +``` +function foo(): + @memo () => void +``` + +### Memo code entry pointes @memo:entry +The places where regular code is allowed to enter memo realm are denoted @memo:entry. +The functions marked with @memo:entry are not memo themselves, +but they must provide enough implementation defined lexical context +for the memo call to succeed in their bodies. + +For example + +``` +/** @memo:entry */ +function entry( + context: Context, + id: MemoId, + @memo ui: () => void +) { + ui() +} +``` +### Inference and defaults + +For the first implementation we don't expect any type inference support. +There is the following simple inference allowing the user to omit memo markings. + +#### Call sites don't need special marks + +No special marking at the call site is needed. +Any call to an entity marked with @memo +(functions, methods, properties of functional types, variables of functional types, parameters of functional types etc) +including the entities declared in other modules +is automatically rewritten by the compiler. + +#### Lambda literal arguments + +Lambda literals passed as arguments to parameters marked as memo are treated by memo by default. For example: + +``` +function foo( + @memo content: () => void +) { + ... +} + + +foo(() => { // This lambda literal is assumed to be memo! + ... +}) +``` + +### Constraints + +#### memo code and state variables + +A memo function can only read state variable values. +A memo code can not write to a state variable. + +An attempt to assign a state variable will cause a compiler diagnostics or a runtime error. + +A memo function can create a non-memo lambda which contains an assignment to a state variable. +Such lambda can be called outside of memo context and is allowed to change the state variable value. + + +#### memo should only be called from memo code + +Any memo function should be called from another memo function. +An attempt to call a memo function in non-memo code will result in compiler diagnostics or a runtime error. + +See @memo:entry description for the details on how the implementation can initiate memo call sequence. + +Calling a non-memo code is allowed. +Although it is a good practice to call only pure functions without side effects. +As the memo function body is typically omitted because of positional memoisation. + + +### Implementation + +#### Annotations + +The annotations are to be implemented as compiler annotations. +For example: + +``` +@memo function foo() { + // ... +} +``` + + +## A vision for memo functions support in ArkTS + +We have three levels of desires of memo support in the static ArkTS language + +### Level 1 + +We'd like to have java-like code annotations (syntactically similar to TS decorators). +Like @Memo. +To be able to annotate callable declarations (functions; methods; lambdas; variables, parameters and properties of function types). +For example + +``` +@memo +function foo() { + // ... +} +``` + +We need the same set of annotations: @memo, @memo:intrinsic, @memo:entry and @skip:memo. +May be spelled differently (like @MemoIntrinsic). + +The implementation lowering should basically reproduce our current rewrite in the TS memo plugin. + +This lowering only needs to rewrite AST and read type information provided by the typechecker. +It needs to be able to read @Memo annotations from the other modules. + + +### Level 2 + +At the moment the typescript compiler doesn't help the user with type check and type inference of @memo functional types. +The only inference piece in the current TS compiler we have is the following + +``` +function foo( + /** @memo */ + content: () => void +) { + ... +} + + +foo(() => { // This lambda literal is assumed to be memo! + ... +}) +``` + +Just several examples of what would be nice: + +``` +let x = @memo n => { ... } // x is inferred to be of type @memo (int) => void + +function foo() { // foo return type is deduced as memo + return @memo (m, n) => {} +} + +// The right hand side is automatically promoted to @memo. +let y: @memo (String) => String = (s: String) => s + +let z: (String) => String = y // A type violation a memo assigned to non-memo. + +``` + + +The general rule seems to be: when there is an explicit type specified require exact memo/or non memo. When the type is induced propagate memo/non-memo information. + +After the inference is done we want the @Memo to stick to any functional type and only allow assigning memo types to memo types and non-memo to non-memo. + +That would also allow to drop the need to annotate variables, parameters and class properties as @Memo. Instead we can just annotate their types. +That would in general leave only two syntactic position for the @Memo annotation: on a function/method declaration and on a functional type. + + +In addition to the previous level, supporting this approach requires annotation stick to types. +And annotations need to participate in the inference and typecheking. +The plugin needs to interact with the type checker (may be provide the rules to handle the annotation). + + +### Level 3 + +memo function by themselves don't deal with anything UI specific. +This is just another semantics of function calls. + +It can be used whereever there is a need to incrementally update trees. +Like it can be used to implement a build system. + +If at some point we feel that it is a general useful mechanism and it is stable enough +we could promote @Memo annotation to a memo keyword. + +That would essentially turn the plugin supported AST transformation into regular lowerings. + +The compiler will have to enforce the typing and scoping rules +at the source as well as at the linker level. + +Also the compiler will need to answer the general questions such as for example, +how memo affects intermediate compiled artifacts, i.e. libraries. + +The question of stable ABI (for compatibility between releases and implementations) will need to be answered. +What is the stable runtime representation of memo functions? +What are the mechanism of compatibility under language and runtime evolution? + +### VM support and optimizations + +#### Optimizations + +The current implementation of memo semantics heavily relies on lambdas. +An efficient mechanisms of lambda instantiation and calls should benefit the performance. + +Aggressive inlining in the compiler or VM should also benefit the performance. + +#### Support + +The VM could provide intrinsics for efficient operations on positional id: compute, combine, compare diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/package.json b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/package.json new file mode 100644 index 0000000000000000000000000000000000000000..dca9a02fee556e095116700db8e3cedcc5010629 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/package.json @@ -0,0 +1,64 @@ +{ + "name": "@koalaui/runtime", + "version": "1.5.15+devel", + "description": "", + "main": "./build/lib/src/index.js", + "types": "./build/lib/src/index.d.ts", + "files": [ + "build/lib/**/*.js", + "build/lib/**/*.d.ts", + "src/**/*", + "oh-package.json5" + ], + "scripts": { + "compile": "npm run build:compiler-plugin && ets-tsc -p .", + "compile:test": "ets-tsc -b tsconfig-test.json", + "clean": "rimraf build ets", + "test": "mocha", + "test:coverage": "nyc mocha", + "panda:sdk:install": "cd ../tools/panda && npm run panda:sdk:install", + "arkts:test:run": "bash ../tools/panda/arkts/ark build/runtime-tests.abc --ark-boot-files ../compat/build/compat.abc:../common/build/common.abc:../harness/build/harness.abc --ark-entry-point @koalaui.runtime-tests.test-arkts.tests.ETSGLOBAL::main", + "arkts:test": "npm run panda:sdk:install && npm run build:compat && npm run build:common && npm run build:harness && npm run build:runtime:with:tests && npm run arkts:test:run", + "unmemoize": "mkdir -p build/unmemoized/abc && mkdir -p build/test/lib && ets-tsc -b tsconfig-unmemoize.json && mkdir -p build/test/lib", + "prepare:unmemoize:test": "mkdir -p ./test-arkts/exec/ && cp ../../ui2abc/memo-plugin/test/executable/*.ts ./test-arkts/exec/", + "unmemoize:with:tests": "npm run prepare:unmemoize:test && npm run compile:all --prefix ../harness && mkdir -p build/unmemoized/abc && mkdir -p build/test/lib && ets-tsc -b tsconfig-unmemoize-with-tests.json && mkdir -p build/test/lib", + "compile:arkts": "npm run unmemoize && ../tools/panda/arkts/arktsc --arktsconfig arktsconfig-run-unmemoized.json", + "build:compat": "npm run build:compat --prefix ../compat", + "build:compiler-plugin": "npm run compile --prefix ../compiler-plugin", + "build:compat:inc": "npm run build:compat:inc --prefix ../compat", + "build:compat:inc:ui2abc": "npm run build:compat:inc:ui2abc --prefix ../compat", + "build:common": "npm run build:common --prefix ../common", + "build:common:inc": "npm run build:common:inc --prefix ../common", + "build:common:inc:ui2abc": "npm run build:common:inc:ui2abc --prefix ../common", + "build:harness": "npm run build:harness --prefix ../harness", + "build:harness:inc": "npm run build:harness:inc --prefix ../harness", + "build:runtime": "npm run build:runtime:inc", + "build:runtime:inc": "npm run unmemoize && fast-arktsc --config ./arktsconfig-run-unmemoized.json --compiler ../tools/panda/arkts/arktsc --link-name ./build/runtime.abc && ninja ${NINJA_OPTIONS} -f build/unmemoized/abc/build.ninja", + "build:runtime:inc:ui2abc:restart": "npm run unmemoize && fast-arktsc --config ./ui2abcconfig-only-restart.json --compiler ../tools/panda/arkts/ui2abc --link-name ./build/runtime.abc --file-option --restart-stages && PANDA_SDK_PATH=../tools/panda/node_modules/@panda/sdk ninja ${NINJA_OPTIONS} -f build/build.ninja", + "annotate": "npm run compile --prefix ../../ui2abc/annotate && node ../../ui2abc/annotate", + "build:runtime:inc:ui2abc": "npm run annotate && fast-arktsc --config ./ui2abcconfig.json --compiler ../tools/panda/arkts/ui2abc --link-name ./build/runtime.abc --file-option --restart-stages && PANDA_SDK_PATH=../tools/panda/node_modules/@panda/sdk ninja ${NINJA_OPTIONS} -f build/build.ninja", + "build:runtime:with:tests": "npm run unmemoize:with:tests && fast-arktsc --config ./arktsconfig-test-unmemoized.json --compiler ../tools/panda/arkts/arktsc --link-name ./build/runtime-tests.abc && ninja ${NINJA_OPTIONS} -f build/unmemoized/abc/build.ninja", + "build:incremental:components": "npm run build:compat && npm run build:common && npm run build:runtime", + "build:incremental:components:inc": "npm run build:compat:inc && npm run build:common:inc && npm run build:runtime:inc", + "build:incremental:components:inc:ui2abc": "npm run build:compat:inc:ui2abc && npm run build:common:inc:ui2abc && npm run build:runtime:inc:ui2abc", + "link:incremental": "../tools/panda/arkts/arklink --output build/incremental.abc -- ../compat/build/compat.abc ../common/build/common.abc build/runtime.abc", + "build:incremental": "npm run build:incremental:components && npm run link:incremental", + "build:incremental:inc": "npm run build:incremental:components:inc && npm run link:incremental", + "build:incremental:inc:ui2abc": "npm run build:incremental:components:inc:ui2abc && npm run link:incremental", + "clean:incremental": "npm run clean && npm run clean -C ../compat && npm run clean -C ../common" + }, + "keywords": [], + "dependencies": { + "@koalaui/common": "1.5.15+devel", + "@koalaui/compat": "1.5.15+devel", + "@koalaui/harness": "1.5.15+devel" + }, + "devDependencies": { + "@typescript-eslint/eslint-plugin": "^5.20.0", + "@typescript-eslint/parser": "^5.20.0", + "eslint": "^8.13.0", + "eslint-plugin-unused-imports": "^2.0.0", + "mocha": "^9.2.2", + "source-map-support": "^0.5.21" + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/animation/AnimatedState.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/animation/AnimatedState.ts new file mode 100644 index 0000000000000000000000000000000000000000..ab50ecedb3db954e139a31c6c55d15f9f3d44ce9 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/animation/AnimatedState.ts @@ -0,0 +1,279 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { int64, refEqual } from "@koalaui/common" +import { getAnimationTimer } from "./GlobalTimer" +import { TimeAnimation, constAnimation } from "./TimeAnimation" +import { Disposable } from "../states/Disposable" +import { GlobalStateManager } from "../states/GlobalStateManager" +import { ComputableState, MutableState, State, StateContext } from "../states/State" + + +/** + * This interface represents a pauseable animated state, + * which value is changed according to the given animation. + */ +export interface AnimatedState extends State { + animation: TimeAnimation + readonly running: boolean + paused: boolean +} + +/** + * Creates animated state that could later be used as data source for animations. + * + * @param animation - animation definition + * @param startNow - if animation shall start immediately after creation + * @param timeProvider - custom time provider for testing purposes + * @returns animated state with the specified animation + */ +export function animatedState(animation: TimeAnimation, startNow: boolean = false, timeProvider?: () => int64): AnimatedState { + return new AnimatedStateImpl(animation, startNow, timeProvider) +} + + +/** + * This interface represents a mutable animated state, + * which value is changed according to the given animation. + * If its value is changed by user, a new animation is requested + * to change the current value to the target one. + */ +export interface MutableAnimatedState extends MutableState { + animation: TimeAnimation + readonly running: boolean +} + +/** + * Creates and remembers a mutable state that automatically animates the value as it changes. + * + * @param initial - initial value + * @param animationProvider - factory producing a new animation from the current value and the target one + * @returns a mutable state that automatically animates the value as it changes + */ +export function mutableAnimatedState(initial: Value, animationProvider: ImplicitAnimationProvider): MutableAnimatedState { + return new MutableAnimatedStateImpl(initial, animationProvider) +} + +/** + * A factory producing a new animation from the current value and the target one. + * @param from - start value for animation + * @param to - end value for animation + * @returns a new animation from the current value and the target one + */ +export type ImplicitAnimationProvider = (from: Value, to: Value) => TimeAnimation + + +/** + * This interface represents a value provider with ability to choose value animation by parameter. + */ +export interface StateAnimator { + parameter: Parameter + readonly value: Value + onValueChange(action: (newValue: Value) => void): void +} + +/** + * Creates state animator with controllable parameter. + * When parameter is changed, the animation is recreated. + * + * @param parameter - initial value for controlling parameter + * @param animationProvider - factory producing a new animation when parameter changed + * @returns state animator with the animation created for given parameter + */ +export function stateAnimator(parameter: P, animationProvider: ParametrizedAnimationProvider): StateAnimator { + return new StateAnimatorImpl(parameter, animationProvider) +} + +/** + * A factory producing a new animation when parameter changed. + * @param parameter - controlling parameter + * @param value - previous value of the animator if exists + * @returns a new animation when parameter changed + */ +export type ParametrizedAnimationProvider = (parameter: P, value: V | undefined) => TimeAnimation + + +// IMPLEMENTATION DETAILS: DO NOT USE IT DIRECTLY + + +class AnimatedStateImpl implements Disposable, AnimatedState { + private readonly timeProvider: () => int64 + private runningState: MutableState + private pausedState: MutableState + private valueState: ComputableState + private myAnimation: TimeAnimation + + dispose() { + this.runningState.dispose() + this.pausedState.dispose() + this.valueState.dispose() + } + + get disposed(): boolean { + return this.valueState.disposed + } + + get modified(): boolean { + return this.valueState.modified + } + + get value(): Value { + return this.valueState.value + } + + get running(): boolean { + return this.runningState.value + } + + get paused(): boolean { + return this.pausedState.value + } + + set paused(paused: boolean) { + this.pausedState.value = paused + } + + get animation(): TimeAnimation { + return this.myAnimation + } + + set animation(animation: TimeAnimation) { + if (this.myAnimation === animation) return // nothing to change + this.myAnimation = animation + if (!this.paused) animation.onStart(this.timeProvider()) + } + + constructor(myAnimation: TimeAnimation, startNow: boolean, timeProvider?: () => int64) { + const manager = GlobalStateManager.instance + if (timeProvider) { + this.timeProvider = timeProvider + } else { + this.timeProvider = (): int64 => { + const timer = getAnimationTimer(manager) + if (timer) return timer.value + console.log("global animation timer is not specified yet") + return 0 + } + } + this.myAnimation = myAnimation + this.runningState = manager.mutableState(startNow) + this.pausedState = manager.mutableState(!startNow) + this.valueState = manager.computableState((_context: StateContext): Value => { + try { + const time = this.timeProvider() + const paused = this.pausedState.value + if (this.pausedState.modified) { + if (paused) { + this.animation.onPause(time) + } else { + this.animation.onStart(time) + } + } + // compute value from the time provided + let newValue = this.animation.getValue(time) + this.action?.(newValue) + return newValue + } finally { + // update running state if needed + this.runningState.value = this.animation.running + } + }) + if (startNow) { + this.animation.onStart(this.timeProvider()) + } + } + + onValueChange(action: (newValue: Value) => void): void { + this.action = action + } + + action: ((newValue: Value) => void) | undefined = undefined +} + + +class MutableAnimatedStateImpl implements MutableAnimatedState { + private animatedState: AnimatedStateImpl + private readonly animationProvider: ImplicitAnimationProvider + + dispose(): void { + this.animatedState.dispose() + } + + constructor(initial: Value, animationProvider: ImplicitAnimationProvider) { + this.animatedState = new AnimatedStateImpl(constAnimation(initial), true) + this.animationProvider = animationProvider + } + + get disposed(): boolean { + return this.animatedState.disposed + } + + get modified(): boolean { + return this.animatedState.modified + } + + get value(): Value { + return this.animatedState.value + } + + set value(value: Value) { + this.animatedState.animation = this.animationProvider(this.value, value) + } + + get running(): boolean { + return this.animatedState.running + } + + get animation(): TimeAnimation { + return this.animatedState.animation + } + + set animation(animation: TimeAnimation) { + this.animatedState.animation = animation + } +} + + +class StateAnimatorImpl implements StateAnimator { + private parameterState: MutableState

+ private animatedState: AnimatedStateImpl + private readonly animationProvider: ParametrizedAnimationProvider + + constructor(parameter: P, animationProvider: ParametrizedAnimationProvider) { + this.parameterState = GlobalStateManager.instance.mutableState

(parameter) + this.animatedState = new AnimatedStateImpl(animationProvider(parameter, undefined), true) + this.animationProvider = animationProvider + } + + get parameter(): P { + return this.parameterState.value + } + + set parameter(parameter: P) { + if (refEqual(this.parameterState.value, parameter)) return // nothing to change + this.parameterState.value = parameter + this.animatedState.animation = this.animationProvider(parameter, this.animatedState.value) + } + + get value(): V { + return this.animatedState.value + } + + onValueChange(action: (newValue: V) => void): void { + // TODO: rethink how we'd better subscribe appropriate scope on value change. + this.value + this.animatedState.onValueChange(action) + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/animation/AnimationRange.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/animation/AnimationRange.ts new file mode 100644 index 0000000000000000000000000000000000000000..43d30486f008726230eee3001bac463a3dd08101 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/animation/AnimationRange.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { float64, isFiniteNumber, lerp } from "@koalaui/common" + +/** + * Declares a function that can convert a state to a value. + * Note that some easings may produce a state outside the `[0..1]` range. + */ +export type AnimationRange = (value: float64) => Value + +/** + * @param from - a first base array that corresponds to the `0` state + * @param to - a second base array that corresponds to the `1` state + * @returns a function to generate interpolated values + * @see ColorAnimationRange + * @see NumberAnimationRange + */ +export function ArrayAnimationRange(from: ReadonlyArray, to: ReadonlyArray, compute: (array: ReadonlyArray) => Value): AnimationRange { + const length = from.length + if (to.length != length) throw new Error("sizes of input arrays do not match") + const array = new Array(length) + return (weight: float64) => { + if (from.length != length) throw new Error("size of the first input array is changed unexpectedly") + if (to.length != length) throw new Error("size of the second input array is changed unexpectedly") + for (let index = 0; index < length; index++) { + array[index] = lerp(weight, from[index], to[index]) + } + return compute(array) + } +} + +/** + * @param from - a first base value that corresponds to the `0` state + * @param to - a second base value that corresponds to the `1` state + * @returns a function to generate interpolated numbers + */ +export function NumberAnimationRange(from: float64, to: float64): AnimationRange { + if (from == 0 && to == 1) return (state: float64) => state + if (!isFiniteNumber(from)) throw new Error("illegal start value: " + from) + if (!isFiniteNumber(to)) throw new Error("illegal end value: " + to) + return (weight: float64) => lerp(weight, from, to) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/animation/Easing.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/animation/Easing.ts new file mode 100644 index 0000000000000000000000000000000000000000..12cee45fc2f693686b27ee02fed209e99a6b7276 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/animation/Easing.ts @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { float64, uint32 } from "@koalaui/common" +import { EasingSupport } from "./EasingSupport" + +/** + * Easing functions specify the rate of change of a parameter over time. + * Our animations call them with input value in the ranging [0..1]. + * Usually easing functions return a value in the same range, + * but some of them may exceed that range. + */ +export type EasingCurve = (value: float64) => float64 + +/** + * This namespace provides predefined easing functions + * to use with {@link animation} and {@link transition}. + */ +export class Easing { + static readonly Linear: EasingCurve = (value: float64) => value + static readonly LinearReversed: EasingCurve = (value: float64) => 1 - value + static readonly EaseInSine: EasingCurve = (value: float64) => 1 - Math.cos(value * Math.PI / 2) + static readonly EaseOutSine: EasingCurve = (value: float64) => Math.sin(value * Math.PI / 2) + static readonly EaseInOutSine: EasingCurve = (value: float64) => (1 - Math.cos(value * Math.PI)) / 2 + static readonly Ease = Easing.cubicBezier(.25, .1, .25, 1) // https://cubic-bezier.com/#.25,.1,.25,1 + static readonly EaseIn = Easing.cubicBezier(.42, 0, 1, 1) // https://cubic-bezier.com/#.42,0,1,1 + static readonly EaseOut = Easing.cubicBezier(0, 0, .58, 1) // https://cubic-bezier.com/#0,0,.58,1 + static readonly EaseInOut = Easing.cubicBezier(.42, 0, .58, 1) // https://cubic-bezier.com/#.42,0,.58,1 + static readonly ViscousFluid = Easing.viscousFluid() + static readonly Bubble = Easing.cubicBezier(.32, 2.2, .72, 2.2) // https://cubic-bezier.com/#.32,2.2,.72,2.2 + + /** + * @param easing - an easing function to invert + * @returns easing function that reflects all points of the original shape + * through the central point (0.5;0.5) + */ + static inverted(easing: EasingCurve): EasingCurve { + return (value: float64) => 1 - easing(1 - value) + } + + /** + * @param easing - an easing function to reverse + * @returns easing function that reflects all points of the original shape + * through the central vertical axis (0.5) + */ + static reversed(easing: EasingCurve): EasingCurve { + return (value: float64) => easing(1 - value) + } + + /** + * @param easing - an easing function to modify + * @returns easing function that returns minimal value instead of maximal one + * @internal + */ + static restarted(easing: EasingCurve): EasingCurve { + return (value: float64) => easing(value < 1 ? value : 0) + } + + /** + * @param easing - an easing function to join + * @param count - an amount of iterations of the specified function + * @returns easing function that repeats the specified one several times + */ + static repeated(easing: EasingCurve, count: uint32): EasingCurve { + if (count == 1) return easing + if (!Number.isInteger(count) || (count < 1)) throw new Error("unexpected iteration count: " + count) + return (value: float64) => { + if (value <= 0) return easing(0) + if (value < 1) { + value *= count + const index = Math.floor(value) + if (index < count) return easing(value - index) + } + return easing(1) + } + } + + /** + * @param easing - easing functions to join + * @returns easing function that applies specified functions one by one + */ + static joined(...easing: EasingCurve[]): EasingCurve { + if (easing.length == 0) throw new Error("no easing functions to join") + if (easing.length == 1) return easing[0] + return (value: float64) => { + if (value <= 0) return easing[0](0) + if (value < 1) { + value *= easing.length + const index = Math.floor(value) + if (index < easing.length) return easing[index as uint32](value - index) + } + return easing[easing.length - 1](1) + } + } + + /** + * @param easing - an easing function to join + * @returns easing function that joins the specified function with its reversed variant + */ + static thereAndBackAgain(easing: EasingCurve): EasingCurve { + return (value: float64) => value < 0.5 ? easing(2 * value) : easing(2 - 2 * value) + } + + /** + * @param p1x the horizontal position of the first point + * @param p1y the vertical position of the first point + * @param p2x the horizontal position of the second point + * @param p2y the vertical position of the second point + * @returns easing function based on the cubic bezier curve + */ + static cubicBezier(p1x: float64, p1y: float64, p2x: float64, p2y: float64): EasingCurve { + const matrix = EasingSupport.newCubicBezier(p1x, p1y, p2x, p2y) + return (value: float64) => matrix.convert(value) + } + + /** + * @param stops - a number of frames with constant values + * @param jump - a preferred method to generate these values + * @returns easing function that displays an animation iteration along the specified stops, + * displaying each stop for equal lengths of time + * @see EasingStepJump + */ + static steps(stops: uint32, jump:EasingStepJump = EasingStepJump.None): EasingCurve { + if (stops == 1) { + switch (jump) { + case EasingStepJump.Start: return (value: float64) => 1.0 + case EasingStepJump.End: return (value: float64) => 0.0 + case EasingStepJump.Both: return (value: float64) => 0.5 + case EasingStepJump.None: throw new Error("easing with one stop must use jump other than EasingStepJump.None") + } + } + if (!Number.isInteger(stops) || stops <= 1) throw new Error("easing stops must be a positive integer, but is " + stops) + const delta = jump == EasingStepJump.None || jump == EasingStepJump.End ? 0 : 1 + const count: uint32 = jump == EasingStepJump.None ? stops - 1 : jump == EasingStepJump.Both ? stops + 1 : stops + return (value: float64) => (value > 0 ? Math.min(stops - 1, Math.floor(stops * value)) + delta : delta) / count + } + + static viscousFluid(v0: float64 = 1, f: float64 = 3): EasingCurve { + return (value: float64) => (v0 / (-4.2) * f) * (Math.exp((-4.2) * value * f) - 1) + } +} + +// https://developer.mozilla.org/en-US/docs/Web/CSS/animation-timing-function +export enum EasingStepJump { + /** Denotes a left-continuous function, so that the first jump happens when the animation begins. */ + Start, + /** Denotes a right-continuous function, so that the last jump happens when the animation ends. */ + End, + /** There is no jump on either end. Instead, holding at both the 0% mark and the 100% mark, each for 1/n of the duration. */ + None, + /** Includes pauses at both the 0% and 100% marks, effectively adding a step during the animation iteration. */ + Both, +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/animation/EasingSupport.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/animation/EasingSupport.ts new file mode 100644 index 0000000000000000000000000000000000000000..26921809755d41b6adaac10ec166dd83baaa6138 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/animation/EasingSupport.ts @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { float64, isFiniteNumber, uint32 } from "@koalaui/common" + +export class EasingSupport { + private x: Float64Array + private y: Float64Array + + private constructor(size: uint32, xSupplier: (value: float64) => float64, ySupplier: (value: float64) => float64) { + if (!Number.isInteger(size) || size <= 1) throw new Error("easing size must be integer value greater than 1, but is " + size) + this.x = new Float64Array(size) + this.y = new Float64Array(size) + this.x[0] = xSupplier(0) + this.y[0] = ySupplier(0) + const last = size - 1 + this.x[last] = xSupplier(1) + this.y[last] = ySupplier(1) + for (let i = 1; i < last; i++) { + const value = (i as float64) / last + this.x[i] = xSupplier(value) + this.y[i] = ySupplier(value) + } + } + + convert(value: float64): float64 { + let last = (this.x.length - 1) as uint32 + let left = 0 as uint32 + if (value < this.x[left]) return this.y[left] + let right = last + if (value > this.x[right]) return this.y[right] + while (left <= right) { + const center = ((left + right) >>> 1) as uint32 + if (value < this.x[center]) right = center - 1 + else if (value > this.x[center]) left = center + 1 + else return this.y[center] + } + return this.y[left > last ? last : left] + } + + static newCubicBezier(p1x: float64, p1y: float64, p2x: float64, p2y: float64, size: uint32 = 1024): EasingSupport { + if (!isFiniteNumber(p1x) || !isFiniteNumber(p1y) || p1x < 0 || 1 < p1x) throw new Error(`illegal point: (${p1x},${p1y}), where 0 <= x <= 1`) + if (!isFiniteNumber(p2x) || !isFiniteNumber(p2y) || p2x < 0 || 1 < p2x) throw new Error(`illegal point: (${p2x},${p2y}), where 0 <= x <= 1`) + return new EasingSupport(size, (value: float64) => cubicBezierValue(value, p1x, p2x), (value: float64) => cubicBezierValue(value, p1y, p2y)) + } +} + +function cubicBezierValue(left: float64, p1: float64, p2: float64): float64 { + const right = 1 - left + return left * (3 * right * (p1 * right + p2 * left) + left * left) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/animation/GlobalTimer.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/animation/GlobalTimer.ts new file mode 100644 index 0000000000000000000000000000000000000000..5a98d9327d9e05614ea34b5c417735b54bc47b4c --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/animation/GlobalTimer.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { int64 } from "@koalaui/common" +import { GlobalStateManager } from "../states/GlobalStateManager" +import { MutableState, StateContext } from "../states/State" + +const GLOBAL_ANIMATION_TIMER = "ohos.koala.runtime.global.animation.timer" + +/** + * @returns the state for the global animation timer, or `undefined` + * @internal + */ +export function getAnimationTimer(context: StateContext = GlobalStateManager.instance): MutableState | undefined { + return context.stateBy(GLOBAL_ANIMATION_TIMER, true) +} + +/** + * @param initial - initial timestamp for a timer + * @returns new state for the global animation timer + * @throws an error if it is already initialized + * @internal + */ +export function createAnimationTimer(context: StateContext, initial: int64 = 0): MutableState { + if (getAnimationTimer(context)) throw new Error("the global animation timer is already initialized") + return context.namedState(GLOBAL_ANIMATION_TIMER, () => initial, true) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/animation/TimeAnimation.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/animation/TimeAnimation.ts new file mode 100644 index 0000000000000000000000000000000000000000..d3843d4de02839a5cdc302094ca3fb8a222e89a5 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/animation/TimeAnimation.ts @@ -0,0 +1,558 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { float64, int32, int64, isFiniteNumber, uint32 } from "@koalaui/common" +import { AnimationRange, NumberAnimationRange } from "./AnimationRange" +import { Easing, EasingCurve } from "./Easing" +import { scheduleCallback } from "../states/GlobalStateManager" + +export const DEFAULT_ANIMATION_DURATION: uint32 = 300 + +/** + * This interface specifies animations in AnimatedState (or MutableAnimatedState). + * Its methods should not be used directly. + */ +export interface TimeAnimation { + readonly running: boolean + getValue(time: int64): Value + onStart(time: int64): void + onPause(time: int64): void +} + +/** + * This interface allows to control various settings of a duration-based animation. + */ +export interface AnimationSpec { + readonly duration: uint32 + readonly delay: uint32 + readonly easing: EasingCurve + readonly onEdge: OnEdge + readonly onPause: OnPause + readonly iterations: int32 | undefined // an amount of iterations of the specified function + readonly onStart: (() => void) | undefined // called when the animation has started + readonly onEnd: (() => void) | undefined // called when the animation has reached the target value + readonly onReset: (() => void) | undefined // called when the animation is reset to the initial value +} + +/** + * This enumeration specifies the animation behavior when duration is expired. + */ +export class OnEdge { + static Nothing = new OnEdge("Nothing") // the value stops changing + static Reverse = new OnEdge("Reverse") // the value starts changing to the initial state + static Restart = new OnEdge("Restart") // the value starts changing from the initial state again + private constructor(name: string) { + } +} + +/** + * This enumeration specifies the animation behavior on pause requested. + */ +export class OnPause { + static Nothing = new OnPause("Nothing") // the value stops changing immediately + static Reset = new OnPause("Reset") // the value resets to the initial state and stops changing + static Fade = new OnPause("Fade") // the value starts changing to the initial state and then stops changing + private constructor(name: string) { + } +} + + +/** + * @param value - value constantly returned by the animation + * @returns animation that always produces the same value + */ +export function constAnimation(value: Value): TimeAnimation { + return new ConstAnimationImpl(value) +} + +/** + * @param compute - value supplier to be computed for every frame + * @param initialTime - initial time value of the animation + * @returns simple time-based animation that starts with 0 + */ +export function timeAnimation(compute: (time: int64) => Value, initialTime: int64 = 0): TimeAnimation { + if (!isFiniteNumber(initialTime)) throw new Error("illegal initial time: " + initialTime) + return new TimeAnimationImpl(compute, initialTime) +} + +/** + * Computes smoothly changing values from `from` to `to` with given period in milliseconds. + * Current law of change is sinus. + * + * @param period during which value changes from `from` back to `from` + * @param from which value animation starts, default is 0.0 + * @param to which value animation reaches, default is 1.0 + * @returns animated value in 0.0 to 1.0 range + */ +export function smoothAnimation(period: uint32, from: float64 = 0.0, to: float64 = 1.0): TimeAnimation { + if (!isFiniteNumber(period) || (period < 1)) throw new Error("illegal period: " + period) + if (from >= to) throw new Error("`from` must be smaller than `to`") + return new TimeAnimationImpl((time: int64): float64 => (1 - Math.cos(time / period * Math.PI)) / 2 * (to - from) + from) +} + +/** + * @param period - number of milliseconds after which the animated state toggles boolean value + * @param initialValue - initial blinking state of the animation + * @returns animation of boolean value that is toggled periodically + */ +export function blinkAnimation(period: uint32, initialValue: boolean = false): TimeAnimation { + return periodicAnimation(period, (count: int64): boolean => (count % 2) != 0, initialValue ? 1 : 0) +} + +/** + * @param period - number of milliseconds after which the animated state increments number value + * @param initialCount - initial counter value of the animation + * @returns animation of integer value that is incremented periodically + */ +export function countAnimation(period: uint32, initialCount: int64 = 0): TimeAnimation { + return periodicAnimation(period, (count: int64): int64 => count, initialCount) +} + +/** + * @param period - number of milliseconds after which the animated state computes its value from period counter + * @param compute - value supplier to be computed every `period` milliseconds + * @param initialCount - initial counter value of the animation + * @returns animation of integer value that is computed periodically from counter + */ +export function periodicAnimation(period: uint32, compute: (count: int64) => Value, initialCount: int64 = 0): TimeAnimation { + if (!isFiniteNumber(period) || (period < 1)) throw new Error("illegal time period: " + period) + if (!isFiniteNumber(initialCount)) throw new Error("illegal initial count: " + initialCount) + return new PeriodicAnimationImpl(0, period, compute, initialCount) +} + +/** + * @param delay - number of milliseconds after which the animated state computes its first value + * @param period - number of milliseconds after which the animated state computes its value from period counter + * @param compute - value supplier to be computed every `period` milliseconds + * @param initialCount - initial counter value of the animation + * @returns animation of integer value that is computed periodically from counter + */ +export function periodicAnimationWithDelay(delay: uint32, period: uint32, compute: (count: int64) => Value, initialCount: int64 = 0): TimeAnimation { + if (!isFiniteNumber(period) || (period < 1)) throw new Error("illegal time period: " + period) + if (!isFiniteNumber(delay) || (delay < 1)) throw new Error("illegal time delay: " + delay) + if (!isFiniteNumber(initialCount)) throw new Error("illegal initial count: " + initialCount) + return new PeriodicAnimationImpl(delay - period, period, compute, initialCount) +} + + +/** + * @param frameTime - array of frame durations in milliseconds + * @param compute - value supplier to be computed when frame index is changed + * @returns frame-based animation + */ +export function frameAnimation(frameTime: ReadonlyArray, compute: (index: int64) => Value): TimeAnimation { + const count = frameTime.length + if (count == 1) return constAnimation(compute(0)) + if (count < 2) throw new Error("illegal frames count: " + count) + const time = new Array(count) + for (let index = 0; index < count; index++) { + const value = frameTime[index] + if (!isFiniteNumber(value) || (value < 1)) throw new Error("illegal time of frame " + index + ": " + value) + time[index] = index > 0 ? time[index - 1] + value : value + } + return new FrameAnimationImpl(time, compute) +} + + +/** + * @param spec - the animation specification + * @param from - a first base array that corresponds to the `0` state + * @param to - a second base array that corresponds to the `1` state + * @returns duration-based animation of number value + */ +export function numberAnimation(spec: Partial, to: float64 = 1.0, from: float64 = 0.0): TimeAnimation { + return animation(spec, NumberAnimationRange(from, to)) +} + +/** + * @param spec - the animation specification + * @param compute - value supplier to be computed when state animated from 0 to 1 + * @param initialState - initial inner state of the animation (-1..1] + * @returns duration-based animation + */ +export function animation(spec: Partial, compute: AnimationRange, initialState: float64 = 0): TimeAnimation { + if (!isFiniteNumber(initialState) || (initialState <= -1) || (initialState > 1)) throw new Error("illegal initial state: " + initialState) + let duration: uint32 = spec?.duration ?? DEFAULT_ANIMATION_DURATION + if (!isFiniteNumber(duration) || (duration < 0)) throw new Error("duration must not be negative, but is " + spec.duration) + let delay: uint32 = spec?.delay ?? 0 + if (!isFiniteNumber(delay) || (delay < 0)) throw new Error("delay must not be negative, but is " + spec.delay) + let easing = spec.easing ?? Easing.Linear + let onEdge: OnEdge = spec?.onEdge ?? OnEdge.Nothing + let iterations: int32 | undefined = spec?.iterations + if (iterations !== undefined) { + if (!Number.isInteger(iterations) || (iterations < 1)) throw new Error("iterations must be positive integer, but is " + spec.iterations) + if (onEdge == OnEdge.Reverse) { + easing = Easing.thereAndBackAgain(easing) + duration *= 2 + } + if (iterations > 1) { + easing = Easing.repeated(easing, iterations) + duration *= iterations + } + if (onEdge == OnEdge.Restart) { + easing = Easing.restarted(easing) + } + onEdge = OnEdge.Nothing + } + if (duration == 0 && onEdge != OnEdge.Nothing) { + throw new Error("cyclic animation must have a positive duration, but has " + spec.duration) + } + return new AnimationImpl( + duration, delay, easing, onEdge, spec?.onPause ?? OnPause.Nothing, + spec.onStart, spec.onEnd, spec.onReset, compute, initialState) +} + + +/** + * @param duration - duration of state transition from 0 to 1 + * @param easing - a way in which a motion tween proceeds + * @param compute - value supplier to be computed when state animated from 0 to 1 + * @param initialState - initial inner state of the animation (-1..1] + * @returns duration-based value transition + */ +export function transition(duration: uint32, easing: EasingCurve, compute: AnimationRange, initialState: int64 = 0): TimeAnimation { + if (!isFiniteNumber(initialState) || (initialState <= -1) || (initialState > 1)) throw new Error("illegal initial state: " + initialState) + if (!isFiniteNumber(duration) || (duration <= 0)) throw new Error("duration must be positive, but is " + duration) + return new AnimationImpl(duration, 0, easing, OnEdge.Nothing, OnPause.Fade, undefined, undefined, undefined, compute, initialState) +} + +/** + * @param duration - duration of state transition from 0 to 1 + * @param compute - value supplier to be computed when state animated from 0 to 1 + * @param initialState - initial inner state of the animation (-1..1] + * @returns duration-based value transition + */ +export function linearTransition(duration: uint32, compute: AnimationRange, initialState: int64 = 0): TimeAnimation { + return transition(duration, Easing.Linear, compute, initialState) +} + + +// IMPLEMENTATION DETAILS: DO NOT USE IT DIRECTLY + + +class TimeAnimationImpl implements TimeAnimation { + private startTime: int64 | undefined + private lastState: int64 + private lastValue: Value + private readonly compute: (time: int64) => Value + + running: boolean = false + + constructor(compute: (time: int64) => Value, initial: int64 = 0) { + this.lastState = initial + this.lastValue = compute(initial) + this.compute = compute + } + + get state(): int64 { + return this.lastState + } + + getState(startTime: int64, currentTime: int64): int64 { + this.startTime = currentTime + return this.lastState + (currentTime - startTime) + } + + getValue(time: int64): Value { + const startTime = this.startTime + if (startTime === undefined) return this.lastValue // paused + if (startTime >= time) return this.lastValue // delayed + const state = this.getState(startTime, time) + if (this.lastState == state) return this.lastValue // not changed + this.lastState = state + this.lastValue = this.compute(state) + return this.lastValue + } + + onStart(time: int64): void { + this.startTime = time + this.running = true + } + + onPause(time: int64): void { + this.startTime = undefined + this.running = false + } +} + + +class PeriodicAnimationImpl implements TimeAnimation { + private startTime: int64 | undefined + private lastState: int64 + private lastValue: Value + private readonly compute: (time: int64) => Value + private readonly period: uint32 + private readonly delay: int32 + + running: boolean = false + + constructor(delay: int32, period: uint32, compute: (count: int64) => Value, initial: int64 = 0) { + this.lastState = initial + this.lastValue = compute(initial) + this.compute = compute + this.period = period + this.delay = delay + } + + get state(): int64 { + return this.lastState + } + + getState(startTime: int64, currentTime: int64): int64 { + let result = this.state + let passedTime = currentTime - startTime + if (passedTime > this.period) { + result += Math.floor(passedTime / this.period) as int64 + passedTime = passedTime % this.period + // tune start time for long animations + this.startTime = currentTime - passedTime + this.running = true + } + return result + } + + getValue(time: int64): Value { + const startTime = this.startTime + if (startTime === undefined) return this.lastValue // paused + if (startTime >= time) return this.lastValue // delayed + const state = this.getState(startTime, time) + if (this.lastState == state) return this.lastValue // not changed + this.lastState = state + this.lastValue = this.compute(state) + return this.lastValue + } + + onStart(time: int64): void { + this.startTime = time + this.delay + this.running = true + } + + onPause(time: int64): void { + this.startTime = undefined + this.running = false + } +} + + +class ConstAnimationImpl implements TimeAnimation { + private lastValue: Value + + constructor(value: Value) { + this.lastValue = value + } + + running: boolean = false + + getValue(time: int64): Value { + return this.lastValue + } + + onStart(time: int64): void { + } + + onPause(time: int64): void { + } +} + + +class FrameAnimationImpl implements TimeAnimation { + private startTime: int64 | undefined + private lastState: int64 + private lastValue: Value + private readonly compute: (time: int64) => Value + private readonly time: ReadonlyArray + + running: boolean = false + + constructor(time: ReadonlyArray, compute: (time: int64) => Value) { + this.lastState = 0 + this.lastValue = compute(0) + this.compute = compute + this.time = time + } + + get state(): int64 { + return this.lastState + } + + getState(startTime: int64, currentTime: int64): int64 { + const cycleTime = this.time[this.time.length - 1] + + let passedTime = currentTime - startTime + if (passedTime > cycleTime) { + passedTime = passedTime % cycleTime + // tune start time for long animations + this.startTime = currentTime - passedTime + this.running = true + } + for (let index = 0; index < this.time.length; index++) { + if (passedTime < this.time[index]) return index + } + return 0 + } + + getValue(time: int64): Value { + const startTime = this.startTime + if (startTime === undefined) return this.lastValue // paused + if (startTime >= time) return this.lastValue // delayed + const state = this.getState(startTime, time) + if (this.lastState == state) return this.lastValue // not changed + this.lastState = state + this.lastValue = this.compute(state) + return this.lastValue + } + + onStart(time: int64): void { + this.startTime = time + this.running = true + } + + onPause(time: int64): void { + this.startTime = undefined + this.running = false + } +} + + +class AnimationImpl implements TimeAnimation { + private startTime: int64 | undefined + private lastState: float64 + private lastValue: Value + private readonly duration: uint32 + private readonly delay: uint32 + private readonly onEdgePolicy: OnEdge + private readonly onPausePolicy: OnPause + private readonly onStartCallback: (() => void) | undefined + private readonly onEndCallback: (() => void) | undefined + private readonly onResetCallback: (() => void) | undefined + private readonly compute: AnimationRange + private isPauseRequested = false + + running: boolean = false + + constructor( + duration: uint32, + delay: uint32, + easing: EasingCurve, + onEdge: OnEdge, + onPause: OnPause, + onStart: (() => void) | undefined, + onEnd: (() => void) | undefined, + onReset: (() => void) | undefined, + compute: AnimationRange, + initial: float64 = 0 + ) { + this.duration = duration + this.delay = delay + this.onEdgePolicy = onEdge + this.onPausePolicy = onPause + this.onStartCallback = onStart + this.onEndCallback = onEnd + this.onResetCallback = onReset + this.compute = (state: float64): Value => compute(easing(Math.abs(state))) + this.lastState = initial + this.lastValue = this.compute(initial) + } + + getState(startTime: int64, currentTime: int64): float64 { + const onPause = this.isPauseRequested ? this.onPausePolicy : OnPause.Nothing + if (onPause == OnPause.Reset) return this.onPauseReset() // pause + if (this.duration == 0) return this.onEdgeReached() // stop immediately + + const cycleTime: int64 = onPause == OnPause.Fade || this.onEdgePolicy == OnEdge.Reverse + ? this.duration * 2 + : this.duration + + let passedTime = currentTime - startTime + if (passedTime > cycleTime) { + if (onPause == OnPause.Fade) return this.onPauseReset() // fade stopped + if (this.onEdgePolicy == OnEdge.Nothing) return this.onEdgeReached() // stop on the edge + passedTime = passedTime % cycleTime + // tune start time for long animations + this.running = true + this.startTime = currentTime - passedTime + } + let state = passedTime / this.duration + return state > 1 ? state - 2 : state + } + + getValue(time: int64): Value { + const startTime = this.startTime + if (startTime === undefined) return this.lastValue // paused + if (startTime >= time) return this.lastValue // delayed + const state = this.getState(startTime, time) + if (this.lastState == state) return this.lastValue // not changed + this.lastState = state + this.lastValue = this.compute(state) + return this.lastValue + } + + onStart(time: int64): void { + scheduleCallback(this.onStartCallback) + if (this.isPauseRequested) { + this.isPauseRequested = false + if (this.lastState < 0) { + // tune start time on direction change + this.running = true + this.startTime = time + (this.lastState * this.duration) as int64 + } + } + else { + // set start time to continue animation from the current state + this.running = true + this.startTime = time - ( + this.lastState < 0 + ? (2 + this.lastState) * this.duration + : this.lastState > 0 + ? this.lastState * this.duration + : (0 - this.delay) // add delay for the state 0 only + ) as int64 + } + } + + onPause(time: int64): void { + if (this.lastState && this.onPausePolicy == OnPause.Reset) { + this.isPauseRequested = true + } + else if (this.lastState && this.onPausePolicy == OnPause.Fade) { + this.isPauseRequested = true + if (this.lastState > 0) { + // tune start time on direction change + this.running = true + this.startTime = time - (this.duration * (2 - this.lastState)) as int64 + } + } + else { + this.running = false + this.startTime = undefined + } + } + + private onPauseReset(): float64 { + this.running = false + this.startTime = undefined + this.isPauseRequested = false + scheduleCallback(this.onResetCallback) + return 0 + } + + private onEdgeReached(): float64 { + if (this.running) { + this.running = false + scheduleCallback(this.onEndCallback) + } + return 1 + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/animation/memo.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/animation/memo.ts new file mode 100644 index 0000000000000000000000000000000000000000..06792a01685eb260fc5d1671a6bc3197653cbb26 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/animation/memo.ts @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { float64, int64, uint32 } from "@koalaui/common" +import { RunEffect } from "../memo/changeListener" +import { remember } from "../memo/remember" +import { AnimatedState, ImplicitAnimationProvider, MutableAnimatedState, ParametrizedAnimationProvider, StateAnimator, animatedState, mutableAnimatedState, stateAnimator } from "./AnimatedState" +import { AnimationRange, NumberAnimationRange } from "./AnimationRange" +import { Easing, EasingCurve } from "./Easing" +import { AnimationSpec, TimeAnimation, animation, constAnimation, periodicAnimation, transition } from "./TimeAnimation" + +/** + * Function allowing to sample particular function with given rate. + * + * @param sampleRate number of milliseconds between samples + * @param generator dirty function that produces values we interested in + * + * @returns value of generator function taken once in sampleRate ms + */ +/** @memo */ +export function sampledValue(sampleRate: uint32, generator: (tick: int64) => V): V { + return rememberAnimatedState((): TimeAnimation => periodicAnimation(sampleRate, generator), true).value +} + + +/** + * Creates and remembers animated state that could later be used as data source for animations. + * + * @param animation - supplier of the animation definition + * @param startNow - if animation shall start immediately after creation + * @returns animated state with the specified animation + */ +/** @memo */ +export function rememberAnimatedState(animation: () => TimeAnimation, startNow: boolean = false): AnimatedState { + return remember(() => animatedState(animation(), startNow)) +} + +/** + * Creates and remembers number transition that could later be used as data source for animations. + * + * @param on - specifies the direction of the animation (false to 0, true to 1) + * @param duration - duration of state transition from 0 to 1 + * @param easing - a way in which a motion tween proceeds + * @param to - a target value that corresponds to the 1 state + * @param from - a initial value that corresponds to the 0 state + * @returns animated state with the specified transition + */ +/** @memo */ +export function rememberNumberTransition(on: boolean, duration: uint32, easing: EasingCurve = Easing.Linear, to: float64 = 1.0, from: float64 = 0.0): AnimatedState { + return rememberTransition(on, duration, easing, NumberAnimationRange(from, to)) +} + +/** + * Creates and remembers value transition that could later be used as data source for animations. + * If it is needed to start the transition on appearing, + * the `on` and `initial` parameters must have different values. + * + * @param on - specifies the direction of the animation (false to 0, true to 1) + * @param duration - duration of state transition from 0 to 1 + * @param easing - a way in which a motion tween proceeds + * @param compute - value supplier to be computed when state animated from 0 to 1 + * @param initial - initial state of the transition (false to 0, true to 1) + * @returns animated state with the specified transition + */ +/** @memo */ +export function rememberTransition(on: boolean, duration: uint32, easing: EasingCurve, compute: AnimationRange, initial: boolean = on): AnimatedState { + const state = rememberAnimatedState((): TimeAnimation => transition(duration, easing, compute, initial ? 1 : 0), on) + RunEffect(!on, (paused: boolean): void => { state.paused = paused }) + return state +} + + +/** + * Creates and remembers a mutable state that automatically animates the value as it changes. + * + * @param initial - initial value + * @param animationProvider - factory producing a new animation from the current value and the target one + * @returns a mutable state that automatically animates the value as it changes + */ +/** @memo */ +export function rememberMutableAnimatedState(initial: Value, animationProvider: ImplicitAnimationProvider): MutableAnimatedState { + return remember(() => mutableAnimatedState(initial, animationProvider)) +} + +/** + * Creates and remembers a mutable state that automatically animates the number value as it changes. + * + * @param initial - initial value + * @param animationSpec - the animation specification that does not depend on changed values + * @returns a mutable state that automatically animates the number value as it changes + * @see rememberMutableAnimatedState + */ +/** @memo */ +export function rememberMutableAnimatedStateNumber(initial: float64, animationSpec: Partial): MutableAnimatedState { + return remember(() => mutableAnimatedState(initial, (from: float64, to: float64) => from == to + ? constAnimation(to) + : animation(animationSpec, NumberAnimationRange(from, to)))) +} + + +/** + * Creates and remembers state animator with controllable parameter. + * When parameter is changed, the animation is recreated. + * + * @param parameter - initial value for controlling parameter + * @param animationProvider - factory producing a new animation when parameter changed + * @returns state animator with the animation created for given parameter + */ +/** @memo */ +export function rememberAnimator(parameter: P, animationProvider: ParametrizedAnimationProvider): StateAnimator { + return remember(() => stateAnimator(parameter, animationProvider)) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/index.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..bc630ffe8df252a44b15f197d8c05ce80620182e --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/index.ts @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export { + AnimatedState, + ImplicitAnimationProvider, + MutableAnimatedState, + ParametrizedAnimationProvider, + StateAnimator, + animatedState, + mutableAnimatedState, + stateAnimator, +} from "./animation/AnimatedState" +export { + AnimationRange, + ArrayAnimationRange, + NumberAnimationRange, +} from "./animation/AnimationRange" +export { + Easing, + EasingCurve, + EasingStepJump, +} from "./animation/Easing" +export { + createAnimationTimer, + getAnimationTimer, +} from "./animation/GlobalTimer" +export { + rememberAnimatedState, + rememberAnimator, + rememberMutableAnimatedState, + rememberMutableAnimatedStateNumber, + rememberNumberTransition, + rememberTransition, + sampledValue, +} from "./animation/memo" +export { + AnimationSpec, + OnEdge, + OnPause, + TimeAnimation, + animation, + blinkAnimation, + constAnimation, + countAnimation, + frameAnimation, + linearTransition, + numberAnimation, + periodicAnimation, + periodicAnimationWithDelay, + smoothAnimation, + timeAnimation, + transition, +} from "./animation/TimeAnimation" + +export { + memoBind, + memoBind2, + memoPartialBind2_1, + memoPartialBind3_2, + MemoCallbackContext, +} from "./memo/bind" +export { + OnChange, + RunEffect, +} from "./memo/changeListener" +export { + contextLocal, + contextLocalScope, + contextLocalValue, +} from "./memo/contextLocal" +export { + memoRoot, + memoEntry, + memoEntry1, + memoEntry2, +} from "./memo/entry" +export { + DataNode, + NodeAttach, + contextNode, +} from "./memo/node" +export { + memoize, + memoLifecycle, + once, + remember, + rememberArrayState, + rememberComputableState, + rememberComputableValue, + rememberControlledScope, + rememberDisposable, + rememberMutableAsyncState, + rememberMutableState, +} from "./memo/remember" +export { + Repeat, + RepeatByArray, + RepeatRange, + RepeatWithKey, +} from "./memo/repeat" +export { + TestNode, + ReusableTestNode, + testRoot, + testTick, + testUpdate, +} from "./memo/testing" + +export { + Disposable, + disposeContent, + disposeContentBackward, + disposeContentForward, +} from "./states/Disposable" +export { + GlobalStateManager, + arrayState, + callScheduledCallbacks, + mutableState, + scheduleCallback, + updateStateManager, +} from "./states/GlobalStateManager" +export { + ArrayState, + CONTEXT_ROOT_NODE, + CONTEXT_ROOT_SCOPE, + ComputableState, + ControlledScope, + createStateManager, + Equivalent, + MutableState, + State, + StateContext, + StateManager, + ValueTracker, +} from "./states/State" + +export { + __context, + __id, + __key, + __memo_context_type, + __memo_id_type, + __memo_transformed, + __memo_transformed_before, + __memo_transformed_after, +} from "./internals" + +export { IncrementalNode } from "./tree/IncrementalNode" +export { PrimeNumbers } from "./tree/PrimeNumbers" +export { ReadonlyTreeNode } from "./tree/ReadonlyTreeNode" +export { TreeNode } from "./tree/TreeNode" +export { TreePath } from "./tree/TreePath" + diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/internals.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/internals.ts new file mode 100644 index 0000000000000000000000000000000000000000..65939dfdefbad198e2f92c1b34bc48b1882944bd --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/internals.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { KoalaCallsiteKey } from "@koalaui/common" +import { StateContext } from "./states/State" + +// These are used for the hidden parameters inserted by the plugin. +// Must only be used by compiler rewrite, do not use directly. +export type __memo_context_type = StateContext +export type __memo_id_type = KoalaCallsiteKey +// References to this type will be changed to an incompatible type +// so that typing expression `x extends __memo_transformed ? A : B` +// can change its branch +export type __memo_transformed_before = string +export type __memo_transformed_after = number +export type __memo_transformed = __memo_transformed_before + +export function __context(): StateContext { + throw new Error("All __context() references should have been transformed by the compiler plugin. Either have 'context' argument or have '/** @memo */' marking and use intrinsic '__context()'.") +} + +export function __id(): KoalaCallsiteKey { + throw new Error("All __id() references should have been transformed by the compiler plugin. Either have 'id' argument or have '/** @memo */' marking and use intrinsic '__id()'.") +} + +export function __key(): KoalaCallsiteKey { + throw new Error("All __key() references should have been transformed by the compiler plugin.") +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/memo/bind.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/memo/bind.ts new file mode 100644 index 0000000000000000000000000000000000000000..e41c183a4aa604e59b05a03cd010bf3dd7ab0b1e --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/memo/bind.ts @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { KoalaCallsiteKey } from "@koalaui/common" +import { __context, __id } from "../internals" +import { StateContext } from "../states/State" +import { memoEntry1 } from "./entry" + +/** @internal */ +export class MemoCallbackContext { + private readonly context: StateContext + private readonly id: KoalaCallsiteKey + + private constructor(context: StateContext, id: KoalaCallsiteKey) { + this.context = context + this.id = id + } + + /** + * This method stores a memo context to call a memo-function later from non-memo-context. + * Do not use this dangerous API if you do not understand the incremental engine deeply. + * @see call + * @internal + */ + /** @memo */ + static Make(): MemoCallbackContext { + return new MemoCallbackContext(__context(), __id()) + } + + /** + * This method allows you to call a memo-function from non-memo-context. + * It can be used only if the state manager is not available, for example, from native code. + * Do not use this dangerous API if you do not understand the incremental engine deeply. + * @internal + */ + call( + /** @memo */ + callback: (args: Int32Array) => number, + args: Int32Array + ): number { + return memoEntry1(this.context, this.id, callback, args) + } +} + +/** @internal */ +export function memoBind( + /** @memo */ + item: (arg: T) => void, value: T +): + /** @memo */ + () => void +{ + return ( + /** @memo */ + () => { item(value) } + ) +} + +/** @internal */ +export function memoBind2( + /** @memo */ + item: (arg1: T1, arg2: T2) => void, value1: T1, value2: T2 +): + /** @memo */ + () => void +{ + return ( + /** @memo */ + () => { item(value1, value2) } + ) +} + +/** @internal */ +export function memoPartialBind2_1( + /** @memo */ + item: (arg1: T1, arg2: T2) => void, + value1: T1 +): + /** @memo */ + (arg2: T2) => void +{ + return ( + /** @memo */ + (arg2: T2) => { item(value1, arg2) } + ) +} + +/** @internal */ +export function memoPartialBind3_2( + /** @memo */ + item: (arg1: T1, arg2: T2, arg3: T3) => void, + value1: T1 +): + /** @memo */ + (arg2: T2, arg3: T3) => void +{ + return ( + /** @memo */ + (arg2: T2, arg3: T3) => { item(value1, arg2, arg3) } + ) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/memo/changeListener.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/memo/changeListener.ts new file mode 100644 index 0000000000000000000000000000000000000000..b4fd4b1d35e4a3849f5cb47e023afee7db2a079b --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/memo/changeListener.ts @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { KoalaCallsiteKey } from "@koalaui/common" +import { scheduleCallback } from "../states/GlobalStateManager" +import { StateContext } from "../states/State" +import { __context, __id } from "../internals" + +/** + * Executes the specified function if the given value has changed. + * Unlike {@link RunEffect}, the specified function is not executed at the first pass during initialization. + * @param value - a trackable value to listen changes + * @param listener - a function to perform if the given value has changed + */ +/** @memo:intrinsic */ +export function OnChange(value: Value, listener: (value: Value) => void) { + watch(__context(), __id(), false, value, listener) +} + +/** + * Executes the specified function if the given value has changed or initialized. + * Unlike {@link OnChange} this function is also executed from the first pass. + * @param value - a value controlling if effect shall run + * @param effect - a function to perform if the given value has changed or initialized + */ +/** @memo:intrinsic */ +export function RunEffect(value: Value, effect: (value: Value) => void) { + watch(__context(), __id(), true, value, effect) +} + +function watch(context: StateContext, id: KoalaCallsiteKey, modified: boolean, value: Value, listener: (value: Value) => void) { + const scope = context.scope(id, 1) + const state = scope.param(0, value) + if (scope.unchanged) { + scope.cached + } else { + if (state.modified || modified) scheduleCallback(() => listener(value)) + scope.recache() + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/memo/contextLocal.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/memo/contextLocal.ts new file mode 100644 index 0000000000000000000000000000000000000000..756ed0ae2560ded078dd0065ec26ec441fad6be2 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/memo/contextLocal.ts @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { __context, __id } from "../internals" +import { State } from "../states/State" + +/** + * @param name - a name of a context state + * @returns the named context state or `undefined` if it does not exist + */ +/** @memo:intrinsic */ +export function contextLocal(name: string): State | undefined { + return __context().stateBy(name) +} + +/** + * @param name - a name of a context state + * @returns a value of a context state + * @throws Error if a named context state does not exist + */ +/** @memo:intrinsic */ +export function contextLocalValue(name: string): Value { + return __context().valueBy(name) +} + +/** + * Creates a named state with the specified value in the context scope. + * The specified value will be propagated immediately during recomposition. + * Note that the state name must not be dynamically changed. + * + * @param name - a name of a context state + * @param value - a value of a named state to share within the given content + * @param content - a scope content in which a named state is available + */ +/** @memo:intrinsic */ +export function contextLocalScope( + name: string, + value: Value, + /** @memo */ + content: () => void +) { + const scope = __context().scope(__id(), 1) + scope.param(0, value, undefined, name, true) // can be found by name + if (scope.unchanged) { + scope.cached + } else { + content() + scope.recache() + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/memo/entry.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/memo/entry.ts new file mode 100644 index 0000000000000000000000000000000000000000..894dece8796dd5c22b7835b3b9755e14df792417 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/memo/entry.ts @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { KoalaCallsiteKey, KoalaCallsiteKeys, KoalaProfiler } from "@koalaui/common" +import { GlobalStateManager } from "../states/GlobalStateManager" +import { ComputableState, StateContext, StateManager } from "../states/State" +import { IncrementalNode } from "../tree/IncrementalNode" + +/** + * @param node - a root node for the composition + * @param update - a memo-function to build and update the composition + * @param manager - a state manager + * @returns updatable state with the given node as the composition root + * @internal + */ +export function memoRoot( + node: Node, + /** @memo */ + update: (node: Node) => void, + manager: StateManager = GlobalStateManager.instance +): ComputableState { + return manager.updatableNode(node, (context: StateContext) => { + KoalaProfiler.counters?.buildRootEnter() + const frozen = manager.frozen + manager.frozen = true // states are frozen during recomposition + memoEntry1(context, KoalaCallsiteKeys.empty, update, node) + manager.frozen = frozen + KoalaProfiler.counters?.buildRootExit() + }) +} + +/** + * This is where regular code can enter the memo realm. + * This function allows to run a memo function in a non-memo context. + * @internal + */ +/** @memo:entry */ +export function memoEntry( + __memo_context: StateContext, + __memo_id: KoalaCallsiteKey, + /** @memo */ + entry: () => R, +): R { + return entry() +} + +/** + * This is where regular code can enter the memo realm. + * This function allows to run a memo function in a non-memo context. + * @internal + */ +/** @memo:entry */ +export function memoEntry1( + __memo_context: StateContext, + __memo_id: KoalaCallsiteKey, + /** @memo */ + entry: (arg: T) => R, + arg: T, +): R { + return entry(arg) +} + +/** + * This is where regular code can enter the memo realm. + * This function allows to run a memo function in a non-memo context. + * @internal + */ +/** @memo:entry */ +export function memoEntry2( + __memo_context: StateContext, + __memo_id: KoalaCallsiteKey, + /** @memo */ + entry: (arg1: T1, arg2: T2) => R, + arg1: T1, + arg2: T2, +): R { + return entry(arg1, arg2) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/memo/node.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/memo/node.ts new file mode 100644 index 0000000000000000000000000000000000000000..73d13de3f68a630ec4f239ca220dc2db63f4f6b7 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/memo/node.ts @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { className, uint32 } from "@koalaui/common" +import { __context, __id } from "../internals" +import { IncrementalNode } from "../tree/IncrementalNode" +import { memoEntry } from "./entry" + +/** + * @param create - the node constructor is invoked only once, + * then the created node is attached to the hierarchy + * @param update - the node updater is invoked right after the node constructor, + * than it can be invoked again if the values of the used states have changed + * @internal + */ +/** @memo:intrinsic */ +export function NodeAttach( + create: () => Node, + /** @memo */ + update: (node: Node) => void, + reuseKey?: string +): void { + const scope = + __context().scope(__id(), 0, create, undefined, undefined, undefined, reuseKey) + if (scope.unchanged) { + scope.cached + } else try { + if (!reuseKey) + update(__context().node as Node) + else + // reset ID addition to 0 to simplify the reuse process later + memoEntry(__context(), 0, () => { update(__context().node as Node) }) + } finally { + scope.recache() + } +} + +/** + * @param kind - expected kind of current node + * @param name - description of a call site to use in exception + * @returns current node + * @throws Error with the given name if node kind is not expected + * @internal + */ +/** @memo:intrinsic */ +export function contextNode(kind: uint32 = 1, name?: string): T { + const node = __context().node + if (node?.isKind(kind) == true) return node as T + throw new Error(name + ? (name + " cannot be used in context of " + className(node)) + : ("current " + className(node) + " does not contain the specified kind: " + kind) + ) +} + +/** + * @internal + */ +export class DataNode extends IncrementalNode { + private data: Data | undefined = undefined + + constructor(kind: uint32 = 1) { + super(kind) + } + + /** @memo:intrinsic */ + static attach( + kind: uint32, + data: Data, + onDataChange?: () => void + ): void { + const scope = __context().scope(__id(), 1, (): IncrementalNode => new DataNode(kind)) + const state = scope.param(0, data) + if (scope.unchanged) { + scope.cached + } else try { + const node = __context().node as DataNode + if (node.kind != kind) throw new Error("data node kind changed unexpectedly from " + node.kind + " to " + kind) + node.data = state.value as Data // subscribe to the parameter change + onDataChange?.() + } finally { + scope.recache() + } + } + + static extract(kind: uint32, node: IncrementalNode): Data | undefined { + return node.isKind(kind) ? (node as DataNode).data : undefined + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/memo/remember.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/memo/remember.ts new file mode 100644 index 0000000000000000000000000000000000000000..9627e44516a1906a269a49447b0cb76860f227e9 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/memo/remember.ts @@ -0,0 +1,226 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { functionOverValue } from "@koalaui/common" +import { __context, __id } from "../internals" +import { scheduleCallback } from "../states/GlobalStateManager" +import { ArrayState, ControlledScope, MutableState } from "../states/State" + +/** + * It calculates the value of the given lambda and caches its result. + * In contrast to the `remember` function, the given lambda can be recalculated + * if it uses values of states (including parameters of memo-functions). + * If the given lambda does not use any state, it will be calculated only once. + * + * @param compute - a function to compute cacheable result + * @returns the last calculated value + * @see remember + * @experimental + */ +/** @memo:intrinsic */ +export function memoize(compute: () => Value): Value { + const scope = __context().scope(__id(), 0) + return scope.unchanged ? scope.cached : scope.recache(compute()) +} + +/** + * This side effect invokes `onAttach` once when attaching to the composition. + * Also, it invokes `onDetach` once when detaching from the composition. + * Note that both callbacks are invoked during recomposition. + * Therefore, it is recommended to use {@link scheduleCallback}. + * + * @param onAttach - a function to run on attach + * @param onDetach - a function to run on detach + * @see once + * @see remember + * @internal + */ +/** @memo:intrinsic */ +export function memoLifecycle(onAttach: () => void, onDetach: () => void): void { + const scope = __context().scope(__id(), 0, undefined, undefined, (_: undefined) => onDetach(), true) // do not recalculate if used states were updated + if (scope.unchanged) { + scope.cached + } else { + onAttach() + scope.recache() + } +} + +/** + * This side effect invokes `callback` once when attaching to the composition. + * Note that the given callback is invoked during recomposition. + * Therefore, it is recommended to use {@link scheduleCallback}. + * @param callback - a function to run on attach + * @see remember + */ +/** @memo:intrinsic */ +export function once(callback: () => void): void { + const scope = __context().scope(__id(), 0, undefined, undefined, undefined, true) // do not recalculate if used states were updated + if (scope.unchanged) { + scope.cached + } else { + callback() + scope.recache() + } +} + +/** + * It calculates the value of the given lambda and caches its result. + * In contrast to the `memo` function, the given lambda is calculated only once + * even if it uses values of states (including parameters of memo-functions). + * + * @param compute - a function to compute cacheable result + * @returns the last calculated value + * @see memoize + */ +/** @memo:intrinsic */ +export function remember(compute: () => Value): Value { + const scope = __context().scope(__id(), 0, undefined, undefined, undefined, true) // do not recalculate if used states were updated + return scope.unchanged ? scope.cached : scope.recache(compute()) +} + +/** + * It calculates the value of the given lambda, caches its result, + * and notifies, that this method is removed from the composition. + * + * @param compute - a function to compute cacheable result + * @param cleanup - a function to clean up computed result on dispose + * @returns the last calculated value + * @see remember + */ +/** @memo:intrinsic */ +export function rememberDisposable(compute: () => Value, cleanup: (value: Value | undefined) => void): Value { + const scope = __context().scope(__id(), 0, undefined, undefined, cleanup, true) // do not recalculate if used states were updated + return scope.unchanged ? scope.cached : scope.recache(compute()) +} + +/** + * Creates remembered state which can be updated from anywhere, + * and if changed - all dependent memo functions recache automatically. + * Note that you can specify the value directly for primitive values, + * which do not require computations or memory allocation. + * It is highly recommended to provide a lambda for all others values. + * + * @param initial - initial value supplier used on the state creation + * @returns a state remembered for the current code position + */ +/** @memo:intrinsic */ +export function rememberMutableState(initial: (() => Value) | Value): MutableState { + const scope = __context().scope>(__id(), 0, undefined, undefined, undefined, true) // do not recalculate if used states were updated + return scope.unchanged ? scope.cached : scope.recache(__context() + .mutableState( + functionOverValue(initial) ? + (initial as (() => Value))() : + (initial as Value)) + ) +} + +/** + * Creates remembered array state which can be updated from anywhere, + * and if changed - all dependent memo functions recache automatically. + * @param initial - initial array supplier used on the state creation + * @returns an array state remembered for the current code position + */ +/** @memo:intrinsic */ +export function rememberArrayState(initial?: () => ReadonlyArray): ArrayState { + const scope = __context().scope>(__id(), 0, undefined, undefined, undefined, true) // do not recalculate if used states were updated + return scope.unchanged ? scope.cached : scope.recache(__context().arrayState(initial?.())) +} + +/** + * @param promise - result of asynchronous function + * @param state - state to receive computed value on success or `undefined` value on error + * @param onError - custom callback to handle error cause + */ +function applyPromiseToState(promise: Promise, state: MutableState, onError?: (error: Error) => void): void { + promise + .then((value: Value): Value => { + state.value = value + return value + }) + .catch((error: Error): void => { + state.value = undefined + onError?.(error) + }) +} + +/** + * Remember mutable state which is computed in async way and is undefined if promise + * is not fulfilled. + * + * @param compute function returning promise to compute the state + * @param initial value stored to the state + * @param onError callback called if promise was rejected + */ +/** @memo */ +export function rememberMutableAsyncState(compute: () => Promise, initial?: Value, onError?: (error: Error) => void): MutableState { + const result = rememberMutableState(initial) + once(() => { applyPromiseToState(compute(), result, onError) }) + return result +} + +/** + * Remember mutable state which is + * re-computed in async way if key has changed + * and undefined while promise is not fulfilled. + * + * @param key a value to trigger state recomputation + * @param compute function returning promise to compute the state + * @param initial value stored to the state + * @param onError callback called if promise was rejected + */ +/** @memo */ +export function rememberComputableState( + key: Key, + /** @skip:memo */ + compute: (key: Key) => Promise, + initial?: Value, + onError?: (error: Error) => void +): MutableState { + const result = rememberMutableState(initial) + const keyLocal: Key = key // subscribe to a key changes + scheduleCallback(() => { applyPromiseToState(compute(keyLocal), result, onError) }) + return result +} + +/** + * Remember a value which is + * re-computed in async way if key has changed + * and undefined while promise is not fulfilled. + * + * @param key a value to trigger state recomputation + * @param compute function returning promise to compute the state + * @param initial value stored to the state + * @param onError callback called if promise was rejected + */ +/** @memo */ +export function rememberComputableValue( + key: Key, + /** @skip:memo */ + compute: (key: Key) => Promise, + initial?: Value, + onError?: (e: Error) => void +): Value | undefined { + return rememberComputableState(key, compute, initial, onError).value +} + +/** + * @param invalidate - callback that will be notified when any state is modified within the scope + * @return a user-controlled scope which can be used outside of the incremental update + */ +/** @memo:intrinsic */ +export function rememberControlledScope(invalidate: () => void): ControlledScope { + return __context().controlledScope(__id(), invalidate) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/memo/repeat.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/memo/repeat.ts new file mode 100644 index 0000000000000000000000000000000000000000..150595d369d835479efcec112335bfc0ece0e78c --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/memo/repeat.ts @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { KoalaCallsiteKey, int32 } from "@koalaui/common" +import { __context, __id } from "../internals" +import { memoEntry1, memoEntry2 } from "./entry" + +/** + * Sequentially repeats the {@link action}. + * + * An {@link action} unit accepts a sequential index as an argument. + * + * @param count the number of {@link action}'s to repeat, 0 by default + * @param action an action to repeat + * + * @see RepeatWithKey + * @see RepeatByArray + * @see Items + */ +/** @memo */ +export function Repeat( + count: int32, + /** @memo */ + action: (index: int32) => void +) { + for (let i = 0; i < count; i++) { + memoEntry1(__context(), i, action, i) + } +} + +/** + * Sequentially repeats the {@link action} using the {@link key} callback. + * + * By default, each {@link action} has an implicit key which provides the {@link action}'s + * result uniqueness. The {@link key} callback can be used to provide a custom key per + * {@link action}, based on the {@link action}'s index accepted as an argument. + * + * @param count the number of {@link action}'s to repeat, 0 by default + * @param key a callback to provide custom keys + * @param action an action to repeat + * + * @see Repeat + */ +/** @memo */ +export function RepeatWithKey( + count: int32, + key: (index: int32) => KoalaCallsiteKey, + /** @memo */ + action: (index: int32) => void +) { + for (let i = 0; i < count; i++) { + memoEntry1(__context(), key(i), action, i) + } +} + +/** + * Sequentially repeats the {@link action} by iterating the {@link array}, + * passing an element of the {@link array} as the {@link action}'s argument. + * + * @param array the array to iterate + * @param key a callback to provide custom keys + * @param action an action to repeat + * + * @see RepeatWithKey + */ +/** @memo */ +export function RepeatByArray( + array: ReadonlyArray, + key: (element: T, index: int32) => KoalaCallsiteKey, + /** @memo */ + action: (element: T, index: int32) => void +) { + const length = array.length + for (let i = 0; i < length; i++) { + const e: T = array[i] + memoEntry2(__context(), key(e, i), action, e, i) + } +} + +/** + * Sequentially repeats the {@link action} for every element in the given range. + * + * @param start - the start index, inclusive + * @param end - the end index, exclusive + * @param element - the function to provide an element by its index + * @param key - the function to provide a key for the element + * @param action - the memo function to be invoked for every element + */ +/** @memo */ +export function RepeatRange( + start: int32, + end: int32, + element: (index: int32) => T, + key: (element: T, index: int32) => KoalaCallsiteKey, + /** @memo */ + action: (element: T, index: int32) => void +) { + for (let i: int32 = start; i < end; i++) { + const e: T = element(i) + memoEntry2(__context(), key(e, i), action, e, i) + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/memo/testing.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/memo/testing.ts new file mode 100644 index 0000000000000000000000000000000000000000..8feb948669160c1c16018716c0f738f2c94098f1 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/memo/testing.ts @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { uint32 } from "@koalaui/common" +import { GlobalStateManager } from "../states/GlobalStateManager" +import { ComputableState, State, StateManager } from "../states/State" +import { IncrementalNode } from "../tree/IncrementalNode" +import { Disposable } from "../states/Disposable" +import { memoRoot } from "./entry" +import { NodeAttach } from "./node" + +/** @internal */ +export class TestNode extends IncrementalNode { + content: string = "" + + constructor(kind: uint32 = 1) { + super(kind) + } + + toString(): string { + return this.content + } + + static create( + /** @memo */ + content: (node: TestNode) => void + ): ComputableState { + return memoRoot(new TestNode(), content) + } + + /** @memo:intrinsic */ + static attach( + /** @memo */ + content: (node: TestNode) => void + ) { + NodeAttach(() => new TestNode(), content) + } + +} + +/* parent node that has a Reusable pool */ +export class ReusableTestNode extends TestNode { + reusePool = new Map>() + + override reuse(reuseKey: string): Disposable | undefined { + if (this.reusePool!.has(reuseKey)) { + const scopes = this.reusePool!.get(reuseKey)!; + return scopes.pop(); + } + return undefined; + } + + override recycle(reuseKey: string, child: Disposable): boolean { + if (!this.reusePool!.has(reuseKey)) { + this.reusePool!.set(reuseKey, new Array()); + } + this.reusePool!.get(reuseKey)!.push(child); + return true + } + + override dispose(): void { + super.dispose() + for (const scopes of this.reusePool.values()) { + for (const scope of scopes) { + scope.dispose() + } + } + this.reusePool.clear() + } +} + +/** @internal */ +export function testRoot( + /** @memo */ + content: (node: TestNode) => void +): State { + const root = TestNode.create(content) + root.value + return root +} + +/** @internal */ +export function testUpdate(withCallbacks: boolean = true, manager: StateManager = GlobalStateManager.instance): uint32 { + if (withCallbacks) manager.callCallbacks() + manager.syncChanges() + return manager.updateSnapshot() +} + +/** @internal */ +export function testTick(root: State, withCallbacks: boolean = true) { + testUpdate(withCallbacks) + root.value +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/states/Dependency.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/states/Dependency.ts new file mode 100644 index 0000000000000000000000000000000000000000..ac791e5cd4961fcf2efb1b7b40ebafc0566750e7 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/states/Dependency.ts @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const SKIP_FRAMES = 10 + +/** This interface represents an unique observer that can be notified that some changes. */ +export interface Dependency { + /** Returns `true` if the dependency is no longer actual. */ + readonly obsolete: boolean + + /** Notifies the dependency that it should be invalidated. */ + invalidate(): void +} + +/** This class allows to store and update all dependencies. */ +export class Dependencies { + private frame = 0 + private dependencies: Set | undefined = undefined + private latest: Dependency | undefined = undefined + + /** Returns `true` if there are no dependencies to invalidate. */ + get empty(): boolean { + const dependencies = this.dependencies + return dependencies + ? (dependencies.size == 0) + : (this.latest === undefined) + } + + /** @param dependency - a dependency to invalidate */ + register(dependency?: Dependency): void { + if (dependency === undefined || dependency == this.latest || dependency.obsolete) return + let dependencies = this.dependencies + if (dependencies) { + dependencies.add(dependency) + } else { + const latest = this.latest + if (latest) { + dependencies = new Set() + dependencies.add(latest) + dependencies.add(dependency) + this.dependencies = dependencies + } + } + this.latest = dependency + } + + /** Invalidates all dependencies and removes obsolete ones. */ + updateDependencies(invalidate: boolean): void { + if (++this.frame < SKIP_FRAMES && !invalidate) return + this.frame = 0 + const dependencies = this.dependencies + if (dependencies) { + let disposed: Array | undefined = undefined + const it = dependencies.values() + while (true) { + const result = it.next() + if (result.done) break + const dependency = result.value as Dependency + if (!updateDependency(invalidate, dependency)) { + if (disposed) { + disposed.push(dependency) + } else { + disposed = Array.of(dependency) + } + } + } + if (disposed) { + let index = disposed.length + while (0 < index--) dependencies.delete(disposed[index]) + } + } else { + const latest = this.latest + if (latest !== undefined && !updateDependency(invalidate, latest)) { + this.latest = undefined + } + } + } +} + +function updateDependency(invalidate: boolean, dependency: Dependency): boolean { + if (dependency.obsolete) return false + if (invalidate) dependency.invalidate() + return true +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/states/Disposable.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/states/Disposable.ts new file mode 100644 index 0000000000000000000000000000000000000000..81bdb2c36c21b63a16429bfcb24018b1706ff172 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/states/Disposable.ts @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * A marker for objects that require some work done for cleaning up. + */ +export interface Disposable { + /** + * Returns `true` if the object should no longer be used. + */ + readonly disposed: boolean + /** + * Invoked when all resources owned by the object can safely be released. + * Once disposed of the object should no longer be considered to be usable. + */ + dispose(): void +} + +/** + * @param array - an array whose elements will be disposed from the first to the last + */ +export function disposeContentForward(array: ReadonlyArray) { + const length = array.length + for (let i = 0; i < length; i++) { + array[i]?.dispose() + } +} + +/** + * @param array - an array whose elements will be disposed from the last to the first + */ +export function disposeContentBackward(array: ReadonlyArray) { + let i = array.length + while (0 < i--) { + array[i]?.dispose() + } +} + +/** + * @param it - an iterator that provides elements to dispose one by one + */ +export function disposeContent(it: IterableIterator) { + while (true) { + const result = it.next() + if (result.done) break + result.value?.dispose() + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/states/GlobalStateManager.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/states/GlobalStateManager.ts new file mode 100644 index 0000000000000000000000000000000000000000..fed60f1cf51534e7c25fbd4e18488c2621f10127 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/states/GlobalStateManager.ts @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ArrayState, Equivalent, MutableState, StateManager, ValueTracker, createStateManager } from "./State" + +/** + * This class provides an access to the global state manager of the application. + * @internal + */ +export class GlobalStateManager { + private static current: StateManager | undefined = undefined + + /** + * The current instance of a global state manager. + * Note that it will be recreated after reset. + */ + static get instance(): StateManager { + let current = GlobalStateManager.current + if (current === undefined) { + current = createStateManager() + GlobalStateManager.current = current + } + return current + } + + /** + * Drops the current instance to recreate a global state manager. + * @internal + */ + static reset() { + GlobalStateManager.current?.reset() + } +} + +/** + * Updates all states in the specified state manager. + * If the manager is not specified, the global state manager will be updated. + * @param manager - a state manager to update + * @internal + */ +export function updateStateManager(manager: StateManager = GlobalStateManager.instance): void { + manager.syncChanges() + manager.updateSnapshot() +} + +/** + * Calls all scheduled callbacks in the specified state manager. + * If the manager is not specified, the global state manager will be used. + * @param manager - a state manager to use + * @internal + */ +export function callScheduledCallbacks(manager: StateManager = GlobalStateManager.instance): void { + manager.callCallbacks() + manager.syncChanges() +} + +/** + * Performs the specified callback function later + * (before the next recomposition and after the current one). + * @param callback - a function to perform between recompositions + */ +export function scheduleCallback(callback?: () => void, manager: StateManager = GlobalStateManager.instance) { + if (callback) manager.scheduleCallback(callback) +} + +/** + * Creates new mutable state in the global state manager. + * This state is valid until it is manually detached from the manager. + * It will be detached automatically if it is in the {@link remember}. + * Note that thoughtless state disposing can lead to memory leaks. + * @param value - initial value to initialize the created state + * @param equivalent - optional value comparator for a state + * @param tracker - optional tracker of values assigned to a state + * @returns new mutable state trackable by memo-functions + */ +export function mutableState(value: T, equivalent?: Equivalent, tracker?: ValueTracker): MutableState { + return GlobalStateManager.instance.mutableState(value, undefined, equivalent, tracker) +} + +/** + * Creates new mutable array state in the global state manager. + * This state is valid until it is manually detached from the manager. + * It will be detached automatically if it is in the {@link remember}. + * Note that thoughtless state disposing can lead to memory leaks. + * @param array - initial array to initialize the created state + * @param equivalent - optional value comparator for a state + * @returns new mutable array state trackable by memo-functions + */ +export function arrayState(array?: ReadonlyArray, equivalent?: Equivalent): ArrayState { + return GlobalStateManager.instance.arrayState(array, undefined, equivalent) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/states/Journal.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/states/Journal.ts new file mode 100644 index 0000000000000000000000000000000000000000..dc11866949fee4d9f0a8f806a415ebe38881bc55 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/states/Journal.ts @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AtomicRef } from "@koalaui/common" + +export interface Changes { + /** + * Finds the latest value change for the given state. + * @param state - the state to search + * @returns a reference to the latest value change for the given state, + * or `undefined` if there is no any registered changes + */ + getChange(state: Object): AtomicRef | undefined + + /** + * Removes all changes. + */ + clear(): void +} + +export class Journal implements Changes { + private readonly current = new AtomicRef(new Chunk()) + + /** + * Sets the journal marker to separate changes. + */ + setMarker(): void { + if (this.current.value.map.size > 0) { + const chunk = new Chunk() + chunk.previous.value = this.current.getAndSet(chunk) + } + } + + /** + * Registers the value change for the given state. + * @param state - the state to update + * @param value - the new value for the given state + */ + addChange(state: Object, value: Value): void { + this.current.value.map.set(state, new AtomicRef(value)) + } + + /** + * @returns all marked changes to process, + * or `undefined` if there is no any registered changes + */ + getChanges(): Changes | undefined { + const reference = this.current.value.previous + return reference.value ? new ChunkChanges(reference) : undefined + } + + /** + * Finds the latest value change for the given state. + * @param state - the state to search + * @returns a reference to the latest value change for the given state, + * or `undefined` if there is no any registered changes + */ + getChange(state: Object): AtomicRef | undefined { + return find(state, this.current.value) + } + + /** + * Removes all changes. + */ + clear(): void { + this.current.value = new Chunk() + } + + /** + * Returns the cached array to store changes. + * The copy of the given array is created on first change. + * @param state - the corresponding array state + * @param array - current snapshot of the array state + * @returns the cached array registered for the given state + * @experimental + */ + getCachedArray(state: Object, array: Array): Array { + const chunk = this.current.value + const change = chunk.get>(state) + if (change) return change.value + const copy = Array.from(find>(state, chunk.previous.value)?.value ?? array) + chunk.map.set(state, new AtomicRef>(copy)) + return copy + } +} + +class ChunkChanges implements Changes { + private reference: AtomicRef + + constructor(reference: AtomicRef) { + this.reference = reference + } + + getChange(state: Object): AtomicRef | undefined { + return find(state, this.reference.value) + } + + clear(): void { + this.reference.value = undefined + } +} + +class Chunk { + readonly previous = new AtomicRef(undefined) + readonly map = new Map() + + get(state: Object): AtomicRef | undefined { + const change = this.map.get(state) + if (change) return change as AtomicRef + return undefined + } +} + +/** + * Finds the latest value change for the given state starting from the specified chunk. + * @param state - the state to search + * @param chunk - the chunk of changes to start search from + * @returns a reference to the latest value change for the given state, + * or `undefined` if there is no any registered changes + */ +function find(state: Object, chunk?: Chunk): AtomicRef | undefined { + while (chunk) { + const change = chunk?.get(state) + if (change) return change + chunk = chunk?.previous.value + } + return undefined +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/states/State.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/states/State.ts new file mode 100644 index 0000000000000000000000000000000000000000..60395b0706b552380d53ca3b0d80661449707b41 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/states/State.ts @@ -0,0 +1,1163 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Array_from_set, className, int32, KoalaCallsiteKey, KoalaCallsiteKeys, KoalaProfiler, markableQueue, Observable, ObservableHandler, refEqual, uint32 } from "@koalaui/common" +import { Dependencies, Dependency } from "./Dependency" +import { Disposable, disposeContent, disposeContentBackward } from "./Disposable" +import { Changes, Journal } from "./Journal" +import { IncrementalNode } from "../tree/IncrementalNode" +import { ReadonlyTreeNode } from "../tree/ReadonlyTreeNode" + +export const CONTEXT_ROOT_SCOPE = "ohos.koala.context.root.scope" +export const CONTEXT_ROOT_NODE = "ohos.koala.context.root.node" + +/** + * Compares two different values and returns true + * if a corresponding state (or parameter) should not be modified. + */ +export type Equivalent = (oldV: Value, newV: Value) => boolean + +/** + * Create new instance of state manager. + * @returns an instance of the state manager + */ +export function createStateManager(): StateManager { + return new StateManagerImpl() +} + +/** + * State manager, core of incremental runtime engine. + * + * Internal interface of state manager, please do not use directly in + * applications. + */ +export interface StateManager extends StateContext { + syncChanges(): void + isUpdateNeeded(): boolean + updateSnapshot(): uint32 + updatableNode(node: Node, update: (context: StateContext) => void, cleanup?: () => void): ComputableState + scheduleCallback(callback: () => void): void + callCallbacks(): void + frozen: boolean + reset(): void +} + +/** + * Individual state, wrapping a value of type `Value`. + */ +export interface State { + /** + * If state was modified since last UI computations. + */ + readonly modified: boolean + /** + * Current value of the state. + * State value doesn't change during memo code execution. + */ + readonly value: Value +} + +/** + * Individual mutable state, wrapping a value of type `Value`. + */ +export interface MutableState extends Disposable, State { + /** + * Current value of the state as a mutable value. + * You should not change state value from a memo code. + * State value doesn't change during memo code execution. + * In the event handlers and other non-memo code + * a changed value is immediately visible. + */ + value: Value +} + +/** + * Individual mutable state, wrapping an array of elements with the specified type. + */ +export interface ArrayState extends State> { + length: number + at(index: number): Item + get(index: number): Item + set(index: number, item: Item): void + copyWithin(target: number, start: number, end?: number): Array + fill(value: Item, start?: number, end?: number): Array + pop(): Item | undefined + push(...items: Item[]): number + reverse(): Array + shift(): Item | undefined + sort(comparator?: (a: Item, b: Item) => number): Array + splice(start: number, deleteCount: number | undefined, ...items: Item[]): Array + unshift(...items: Item[]): number +} + +/** + * Individual computable state that provides recomputable value of type `Value`. + */ +export interface ComputableState extends Disposable, State { + /** + * If value will be recomputed on access. + */ + readonly recomputeNeeded: boolean +} + +/** + * Context of a state, keeping track of changes in the given scope. + * + * Internal interface of state manager, please do not use directly in + * applications. + */ +export interface StateContext { + readonly node: IncrementalNode | undefined // defined for all scopes within the scope that creates a node + attach(id: KoalaCallsiteKey, create: () => Node, update: () => void, cleanup?: () => void): void + compute(id: KoalaCallsiteKey, compute: () => Value, cleanup?: (value: Value | undefined) => void, once?: boolean): Value + computableState(compute: (context: StateContext) => Value, cleanup?: (context: StateContext, value: Value | undefined) => void): ComputableState + mutableState(initial: Value, global?: boolean, equivalent?: Equivalent, tracker?: ValueTracker): MutableState + arrayState(initial?: ReadonlyArray, global?: boolean, equivalent?: Equivalent): ArrayState + namedState(name: string, create: () => Value, global?: boolean, equivalent?: Equivalent, tracker?: ValueTracker): MutableState + stateBy(name: string, global?: boolean): MutableState | undefined + valueBy(name: string, global?: boolean): Value + /** @internal */ + scope( + id: KoalaCallsiteKey, + paramCount: int32, + create?: () => IncrementalNode, + compute?: () => Value, + cleanup?: (value: Value | undefined) => void, + once?: boolean, + reuseKey?: string + ): InternalScope + controlledScope(id: KoalaCallsiteKey, invalidate: () => void): ControlledScope +} + +/** + * The interface allows to track the values assigned to a state. + */ +export interface ValueTracker { + /** + * Tracks state creation. + * @param value - an initial state value + * @returns the same value or a modified one + */ + onCreate(value: Value): Value + /** + * Tracks state updates. + * @param value - a value to set to state + * @returns the same value or a modified one + */ + onUpdate(value: Value): Value +} + +/** @internal */ +export interface InternalScope { + /** @returns true if internal value can be returned as is */ + readonly unchanged: boolean + /** @returns internal value if it is already computed */ + readonly cached: Value + /** @returns internal value updated after the computation */ + recache(newValue?: Value): Value + /** @returns internal state for parameter */ + param(index: int32, value: V, equivalent?: Equivalent, name?: string, contextLocal?: boolean): State +} + +/** + * The interface represents a user-controlled scope, + * that can be used outside of the incremental update. + * @internal + */ +export interface ControlledScope { + /** must be called to enter the controlled scope */ + enter(): void + /** must be called to leave the controlled scope */ + leave(): void +} + +// IMPLEMENTATION DETAILS: DO NOT USE IT DIRECTLY + +interface ManagedState extends Disposable { + /** + * `true` - global state is added to the manager and is valid until it is disposed, + * `false` - local state is added to the current scope and is valid as long as this scope is valid. + */ + readonly global: boolean + readonly modified: boolean + updateStateSnapshot(changes?: Changes): void +} + +interface ManagedScope extends Disposable, Dependency, ReadonlyTreeNode { + hasDependencies(): boolean + readonly id: KoalaCallsiteKey + readonly node: IncrementalNode | undefined + readonly nodeRef: IncrementalNode | undefined + readonly once: boolean + readonly modified: boolean + readonly parent: ManagedScope | undefined + readonly reuseKey: string | undefined + next: ManagedScope | undefined + recomputeNeeded: boolean + addCreatedState(state: Disposable): void + getNamedState(name: string): MutableState | undefined + setNamedState(name: string, state: Disposable): void + /** + * @param reuseKey to categorize different templates of reusable nodes + */ + getChildScope( + id: KoalaCallsiteKey, + paramCount: int32, + create?: () => IncrementalNode, + compute?: () => Value, + cleanup?: (value: Value | undefined) => void, + once?: boolean, + reuseKey?: string + ): ScopeImpl + increment(count: uint32, skip: boolean): void +} + +class StateImpl implements Observable, ManagedState, MutableState { + protected manager: StateManagerImpl | undefined = undefined + private dependencies: Dependencies | undefined = undefined + protected snapshot: Value + protected myModified = false + protected myUpdated = true + private readonly myGlobal: boolean + protected equivalent: Equivalent | undefined = undefined + private tracker: ValueTracker | undefined = undefined + private name: string | undefined = undefined + + /** + * @param manager - current state manager to register with + * @param initial - initial state value + * @param global - type of the state + * @param name - name defined for named states only + * @see StateManagerImpl.namedState + */ + constructor(manager: StateManagerImpl, initial: Value, global: boolean, equivalent?: Equivalent, tracker?: ValueTracker, name?: string) { + if (tracker) initial = tracker.onCreate(initial) + this.myGlobal = global + this.equivalent = equivalent + this.tracker = tracker + this.name = name + this.manager = manager + this.dependencies = new Dependencies() + this.snapshot = initial + ObservableHandler.attach(initial, this) + manager.addCreatedState(this) + } + + get global(): boolean { + return this.myGlobal + } + + get modified(): boolean { + this.onAccess() + return this.myModified + } + + get value(): Value { + this.onAccess() + const manager = this.manager + return manager === undefined || manager.frozen ? this.snapshot : this.current(manager.journal) + } + + set value(value: Value) { + this.checkSetProhibited() + const tracker = this.tracker + if (tracker) value = tracker.onUpdate(value) + const manager = this.manager + if (manager) { + manager.updateNeeded = true + manager.journal.addChange(this, value) + this.myUpdated = false + } else { + this.applyStateSnapshot(value) + } + } + + onAccess(): void { + this.dependencies?.register(this.manager?.dependency) + } + + onModify(): void { + const manager = this.manager + if (manager) { + manager.updateNeeded = true + this.myUpdated = false + } else { + this.applyStateSnapshot(this.snapshot) + } + } + + checkSetProhibited() { + if (this.dependencies?.empty != false) return // no dependencies + const scope = this.manager?.current + if (scope === undefined) return // outside the incremental update + if (scope?.node === undefined && scope?.parent === undefined) return // during animation + throw new Error("prohibited to modify a state when updating a call tree") + } + + private current(changes?: Changes): Value { + const change = changes?.getChange(this) + return change ? change.value : this.snapshot + } + + updateStateSnapshot(changes?: Changes): void { + if (this.myUpdated) { + this.myModified = false + } + else { + this.applyStateSnapshot(this.current(changes)) + this.myUpdated = true + } + this.dependencies?.updateDependencies(this.myModified) + } + + protected applyStateSnapshot(newValue: Value) { + const oldValue = this.snapshot + const isModified = ObservableHandler.dropModified(oldValue) + if (!refEqual(oldValue, newValue)) { + ObservableHandler.detach(oldValue, this) + ObservableHandler.attach(newValue, this) + this.snapshot = newValue + this.myModified = isModified || (this.equivalent?.(oldValue, newValue) != true) + } else { + this.myModified = isModified + } + } + + get disposed(): boolean { + return this.manager === undefined + } + + dispose(): void { + const manager = this.manager + if (manager === undefined) return // already disposed + manager.checkForStateDisposing() + this.manager = undefined + this.tracker = undefined + this.dependencies = undefined + manager.removeCreatedState(this, this.name) + } + + toString(): string { + let str = this.global ? "GlobalState" : "LocalState" + if (this.name !== undefined) str += "(" + this.name + ")" + if (this.disposed) str += ",disposed" + if (this.myModified) str += ",modified" + if (this.manager?.frozen == true) str += ",frozen" + return str + "=" + this.value + } +} + +class ArrayStateImpl extends StateImpl> implements ArrayState { + constructor(manager: StateManagerImpl, initial: Array, global: boolean, equivalent?: Equivalent) { + super(manager, initial, global, (oldArray: Array, newArray: Array): boolean => { + let i = oldArray.length + if (i != newArray.length) return false + while (0 < i--) { + if (isModified(oldArray[i], newArray[i], equivalent)) return false + } + return true + }) + } + + protected override applyStateSnapshot(newValue: Array) { + const modified = isModified>(this.snapshot, newValue, this.equivalent) + if (modified) this.snapshot = newValue + this.myModified = modified + } + + get length(): number { + return this.value.length + } + + set length(value: number) { + this.mutable.length = value + } + + at(index: number): Item { + const array = this.value + return array[index < 0 ? array.length + index : index] + } + + get(index: number): Item { + return this.value[index] + } + + set(index: number, item: Item): void { + this.mutable[index] = item + } + + copyWithin(target: number, start: number, end?: number): Array { + return this.mutable.copyWithin(target, start, end) + } + + fill(value: Item, start?: number, end?: number): Array { + return this.mutable.fill(value, start, end) + } + + pop(): Item | undefined { + return this.mutable.pop() + } + + push(...items: Item[]): number { + return this.mutable.push(...items) + } + + reverse(): Array { + return this.mutable.reverse() + } + + shift(): Item | undefined { + return this.mutable.shift() + } + + sort(comparator?: (a: Item, b: Item) => number): Array { + return this.mutable.sort(comparator) + } + + splice(start: number, deleteCount: number | undefined, ...items: Item[]): Array { + const array = this.mutable + return array.splice(start, deleteCount ?? array.length, ...items) + } + + unshift(...items: Item[]): number { + return this.mutable.unshift(...items) + } + + private get mutable(): Array { + super.checkSetProhibited() + const manager = this.manager + if (manager) { + manager.updateNeeded = true + this.myUpdated = false + return manager.journal.getCachedArray(this, this.snapshot) + } else { + this.myModified = true + return this.snapshot + } + } +} + +class ParameterImpl implements MutableState { + private manager: StateManagerImpl | undefined = undefined + private dependencies: Dependencies | undefined = undefined + private name: string | undefined = undefined + private _value: Value + private _modified = false + + /** + * @param manager - current state manager to register with + * @param value - initial state value + * @param name - name defined for named states only + */ + constructor(manager: StateManagerImpl, value: Value, name?: string) { + this.manager = manager + this.dependencies = new Dependencies() + this.name = name + this._value = value + } + + get modified(): boolean { + this.dependencies?.register(this.manager?.dependency) + return this._modified + } + + get value(): Value { + this.dependencies?.register(this.manager?.dependency) + return this._value + } + + set value(value: Value) { + this.update(value) + } + + update(value: Value, equivalent?: Equivalent): void { + const isModified = ObservableHandler.dropModified(this._value) + if (!refEqual(this._value, value)) { + this._value = value + this._modified = isModified || (equivalent?.(this._value, value) != true) + } else { + this._modified = isModified + } + this.dependencies?.updateDependencies(this._modified) + } + + get disposed(): boolean { + return this.manager === undefined + } + + dispose(): void { + const manager = this.manager + if (manager === undefined) return // already disposed + manager.checkForStateDisposing() + this.manager = undefined + this.dependencies = undefined + } + + toString(): string { + let str = "Parameter" + if (this.name !== undefined) str += "(" + this.name + ")" + if (this.disposed) str += ",disposed" + if (this._modified) str += ",modified" + return str + "=" + this._value + } +} + +class StateManagerImpl implements StateManager { + private stateCreating: string | undefined = undefined + private readonly statesNamed = new Map() + private readonly statesCreated = new Set() + private readonly dirtyScopes = new Set() + current: ManagedScope | undefined = undefined + external: Dependency | undefined = undefined + updateNeeded = false + frozen: boolean = false + private readonly callbacks = markableQueue() + readonly journal = new Journal() + + constructor() { + } + + reset(): void { + if (this.statesNamed.size > 0) { + disposeContent(this.statesNamed.values()) + this.statesNamed.clear() + } + if (this.statesCreated.size > 0) { + disposeContent(this.statesCreated.keys()) + this.statesCreated.clear() + } + this.dirtyScopes.clear() + this.callbacks.clear() + this.journal.clear() + this.updateNeeded = false + this.frozen = false + } + + toString(): string { + const scope = this.current + return scope ? scope.toHierarchy() : "" + } + + syncChanges(): void { + this.journal.setMarker() + } + + isUpdateNeeded(): boolean { + return this.updateNeeded + } + + updateSnapshot(): uint32 { + KoalaProfiler.counters?.updateSnapshotEnter() + this.checkForStateComputing() + // optimization: all states are valid and not modified + if (!this.updateNeeded) return 0 + let modified: uint32 = 0 + // try to update snapshot for every state, except for parameter states + const changes = this.journal.getChanges() + const created = this.statesCreated.size as int32 // amount of created states to update + if (created > 0) { + const it = this.statesCreated.keys() + while (true) { + const result = it.next() + if (result.done) break + result.value?.updateStateSnapshot(changes) + if (result.value?.modified == true) modified++ + } + } + changes?.clear() + KoalaProfiler.counters?.updateSnapshot(modified, created) + // recompute dirty scopes only + while (this.dirtyScopes.size > 0) { + const scopes = Array_from_set(this.dirtyScopes) + this.dirtyScopes.clear() + const length = scopes.length + for (let i = 0; i < length; i++) { + if (scopes[i].modified) modified++ + } + } + KoalaProfiler.counters?.updateSnapshot(modified) + this.updateNeeded = modified > 0 // reset modified on next update + KoalaProfiler.counters?.updateSnapshotExit() + return modified + } + + updatableNode(node: Node, update: (context: StateContext) => void, cleanup?: () => void): ComputableState { + this.checkForStateComputing() + const scope = new ScopeImpl(KoalaCallsiteKeys.empty, 0, (): Node => { + update(this) + return node + }, cleanup === undefined ? undefined : (value: Node | undefined): void => { + cleanup?.() + }) + scope.manager = this + scope.node = node + scope.nodeRef = node + scope.dependencies = new Dependencies() + scope.setNamedState(CONTEXT_ROOT_SCOPE, new StateImpl>(this, scope, false)) + scope.setNamedState(CONTEXT_ROOT_NODE, new StateImpl(this, node, false)) + return scope + } + + computableState(compute: (context: StateContext) => Value, cleanup?: (context: StateContext, value: Value | undefined) => void): ComputableState { + if (this.current?.once == false) throw new Error("computable state created in memo-context without remember") + this.checkForStateCreating() + const scope = new ScopeImpl(KoalaCallsiteKeys.empty, 0, (): Value => compute(this), cleanup === undefined ? undefined : (value: Value | undefined): void => { + cleanup?.(this, value) + }) + scope.manager = this + scope.dependencies = new Dependencies() + this.current?.addCreatedState(scope) + return scope + } + + scheduleCallback(callback: () => void): void { + this.callbacks.addCallback(callback) + } + + callCallbacks(): void { + this.callbacks.setMarker() + this.callbacks.callCallbacks() + } + + private isGlobal(global?: boolean): boolean { + if (global == true) return true // allow to create global state everywhere + const remember = this.current?.once // true: remember // false: memo // undefined: global + if (remember == false) throw new Error("unnamed local state created in memo-context without remember") + if (global === undefined) return remember != true // create local state within remember only + if (remember === undefined) throw new Error("unnamed local state created in global context") + return false + } + + mutableState(initial: Value, global?: boolean, equivalent?: Equivalent, tracker?: ValueTracker): MutableState { + return new StateImpl(this, initial, this.isGlobal(global), equivalent, tracker) + } + + arrayState(initial?: ReadonlyArray, global?: boolean, equivalent?: Equivalent): ArrayState { + return new ArrayStateImpl(this, initial === undefined ? new Array() : Array.from(initial), this.isGlobal(global), equivalent) + } + + get node(): IncrementalNode | undefined { + return this.current?.nodeRef + } + + /** + * Returns the current context scope if it can be invalidated later. + * This method must have maximal performance, + * as it is called for each access to a state value. + * An externally controlled scope takes precedence over the current scope, + * except for computable scopes used for animation. + */ + get dependency(): Dependency | undefined { + if (this.stateCreating === undefined) { + const scope = this.current + if (scope?.once == false && (scope?.nodeRef === undefined || this.external === undefined)) { + return scope + } + } + return this.external + } + + scope(id: KoalaCallsiteKey, paramCount: int32, create?: () => IncrementalNode, compute?: () => Value, cleanup?: (value: Value | undefined) => void, once?: boolean, reuseKey?: string): InternalScope { + const counters = KoalaProfiler.counters + if (counters) { + create ? counters.build() : counters.compute() + } + const scope = this.current + if (scope) return scope.getChildScope(id, paramCount, create, compute, cleanup, once, reuseKey) + throw new Error("prohibited to create scope(" + KoalaCallsiteKeys.asString(id) + ") for the top level") + } + + controlledScope(id: KoalaCallsiteKey, invalidate: () => void): ControlledScope { + const scope = this.scope(id, 0, undefined, undefined, ControlledScopeImpl.cleanup, true) + return scope.unchanged ? scope.cached : scope.recache(new ControlledScopeImpl(this, invalidate)) + } + + attach(id: KoalaCallsiteKey, create: () => Node, update: () => void, cleanup?: () => void): void { + const scope = this.scope(id, 0, create, undefined, cleanup === undefined ? undefined : (value: undefined): void => { + cleanup?.() + }) + if (scope.unchanged) { + scope.cached + } else { + update() + scope.recache(undefined) + } + } + + compute(id: KoalaCallsiteKey, compute: () => Value, cleanup?: (value: Value | undefined) => void, once?: boolean): Value { + const scope = this.scope(id, 0, undefined, undefined, cleanup, once) + return scope.unchanged ? scope.cached : scope.recache(compute()) + } + + /** + * @param name - unique state name for this context + * @param create - the factory to create the initial state value + * @returns + */ + namedState(name: string, create: () => Value, global?: boolean, equivalent?: Equivalent, tracker?: ValueTracker): MutableState { + const scope = this.current + if (global === undefined) global = scope === undefined + let state = global ? this.getNamedState(name) : scope?.getNamedState(name) + if (state) return state // named state is already exist + this.checkForStateCreating() + this.stateCreating = name + let initial = create() + this.stateCreating = undefined + state = new StateImpl(this, initial, global, equivalent, tracker, name) + if (global) this.statesNamed.set(name, state) + else if (scope) scope.setNamedState(name, state) + else throw new Error("local state '" + name + "' created in global context") + return state + } + + stateBy(name: string, global?: boolean): MutableState | undefined { + if (global == true) return this.getNamedState(name) + for (let scope = this.current; scope; scope = scope!.parent) { + const state = scope!.getNamedState(name) + if (state) return state + } + return (global == false) ? undefined : this.getNamedState(name) + } + + valueBy(name: string, global?: boolean): Value { + const state = this.stateBy(name, global) + if (state) return state.value + const scope = this.current + throw new Error(scope + ? ("state(" + name + ") is not defined in scope(" + KoalaCallsiteKeys.asString(scope.id) + ")") + : ("global state(" + name + ") is not defined")) + } + + addDirtyScope(state: ManagedScope): void { + this.dirtyScopes.add(state) + } + + addCreatedState(state: ManagedState): void { + this.statesCreated.add(state) + if (!state.global) this.current?.addCreatedState(state) + } + + removeCreatedState(state: ManagedState, name?: string): void { + if (state.global && name !== undefined) this.statesNamed.delete(name) + this.statesCreated.delete(state) + } + + getNamedState(name: string): StateImpl | undefined { + const state = this.statesNamed.get(name) + return state instanceof StateImpl ? state as Object as StateImpl : undefined + } + + checkForStateDisposing(): void { + this.current?.disposed == false + ? this.checkForStateComputing() + : this.checkForStateCreating() + } + + checkForStateCreating(): void { + const name = this.stateCreating + if (name === undefined) return + const scope = this.current + throw new Error(scope + ? ("prohibited when creating state(" + name + ") in scope(" + KoalaCallsiteKeys.asString(scope.id) + ")") + : ("prohibited when creating global state(" + name + ")")) + } + + private checkForStateComputing(): void { + this.checkForStateCreating() + const scope = this.current + if (scope) throw new Error("prohibited when computing scope(" + KoalaCallsiteKeys.asString(scope.id) + ")") + } +} + +class ScopeImpl implements ManagedScope, InternalScope, ComputableState { + recomputeNeeded: boolean = true + manager: StateManagerImpl | undefined = undefined + dependencies: Dependencies | undefined = undefined + + private myCompute: (() => Value) | undefined = undefined + private myCleanup: ((value: Value | undefined) => void) | undefined = undefined + private myValue: Value | undefined = undefined + private myModified = false + private myComputed = false + + private params: Array | undefined = undefined + private statesNamed: Map | undefined = undefined + private statesCreated: Array | undefined = undefined + + private scopeInternal: ManagedScope | undefined = undefined + private incremental: ManagedScope | undefined = undefined + private child: ManagedScope | undefined = undefined + + parentScope: ManagedScope | undefined = undefined + next: ManagedScope | undefined = undefined + + private _id: KoalaCallsiteKey + private _once: boolean = false + private _node: IncrementalNode | undefined = undefined + private _nodeRef: IncrementalNode | undefined = undefined + private readonly _reuseKey?: string /** need to store on Scope because not obtainable in every @method recache */ + nodeCount: uint32 = 0 + + constructor(id: KoalaCallsiteKey, paramCount: int32, compute?: () => Value, cleanup?: (value: Value | undefined) => void, reuseKey?: string) { + this._id = id // special type to distinguish scopes + this.params = paramCount > 0 ? new Array(paramCount) : undefined + this.myCompute = compute + this.myCleanup = cleanup + this._reuseKey = reuseKey + } + + hasDependencies(): boolean { + return this.dependencies?.empty == false + } + + get id(): KoalaCallsiteKey { + return this._id + } + + get node(): IncrementalNode | undefined { + return this._node + } + + set node(value: IncrementalNode | undefined) { + this._node = value + } + + get nodeRef(): IncrementalNode | undefined { + return this._nodeRef + } + + set nodeRef(value: IncrementalNode | undefined) { + this._nodeRef = value + } + + public get once(): boolean { + return this._once + } + + get parent(): ManagedScope | undefined { + return this.parentScope + } + + get reuseKey(): string | undefined { + return this._reuseKey + } + + addCreatedState(state: Disposable): void { + let statesCreated = this.statesCreated + if (statesCreated === undefined) { + statesCreated = new Array() + this.statesCreated = statesCreated + } + statesCreated.push(state) + } + + setNamedState(name: string, state: Disposable): void { + let statesNamed = this.statesNamed + if (statesNamed === undefined) { + statesNamed = new Map() + this.statesNamed = statesNamed + } + statesNamed.set(name, state) + } + + getNamedState(name: string): MutableState | undefined { + const state = this.statesNamed?.get(name) + return state ? state as MutableState : undefined + } + + getChildScope(id: KoalaCallsiteKey, paramCount: int32, create?: () => IncrementalNode, compute?: () => Value, cleanup?: (value: Value | undefined) => void, once?: boolean, reuseKey?: string): ScopeImpl { + const manager = this.manager + if (manager === undefined) throw new Error("prohibited to create scope(" + KoalaCallsiteKeys.asString(id) + ") within the disposed scope(" + KoalaCallsiteKeys.asString(this.id) + ")") + manager.checkForStateCreating() + const inc = this.incremental + const next = inc ? inc.next : this.child + for (let child = next; child; child = child!.next) { + if (child!.id == id) { + this.detachChildScopes(child) + this.incremental = child + return child as ScopeImpl + } + } + if (once != true && this.once) throw new Error("prohibited to create scope(" + KoalaCallsiteKeys.asString(id) + ") within the remember scope(" + KoalaCallsiteKeys.asString(this.id) + ")") + let reused = reuseKey ? this.nodeRef?.reuse(reuseKey) : undefined + const scope = reused ? reused as ScopeImpl : new ScopeImpl(id, paramCount, compute, cleanup, reuseKey) + scope.manager = manager + if (reused) { + scope.recomputeNeeded = true + scope._id = id // children scope IDs are independent from Reusable parent + } else if (create) { + // create node within a scope + scope._once = true + manager.current = scope + if (this.nodeRef === undefined) throw new Error("prohibited to add nodes into computable state") + scope.node = create() + manager.current = this + } + scope.nodeRef = scope.node ?? this.nodeRef + scope._once = once == true + scope.parentScope = this + scope.next = next + if (inc) { + inc.next = scope + } else { + this.child = scope + } + this.incremental = scope + return scope + } + + private detachChildScopes(last?: ManagedScope): void { + const inc = this.incremental + let child = inc ? inc.next : this.child + if (child === last) return + if (inc) { + inc.next = last + } else { + this.child = last + } + const manager = this.manager + if (manager === undefined) throw new Error("unexpected") + const scope = manager.current + manager.current = undefined // allow to dispose children during recomputation + while (child != last) { + if (child === undefined) throw new Error("unexpected") + this.recycleOrDispose(child!!) + child = child.next + } + manager.current = scope + } + + increment(count: uint32, skip: boolean): void { + if (count > 0) { + this.nodeCount += count + if (skip) this.nodeRef!.incrementalUpdateSkip(count) + } + } + + get value(): Value { + if (this.unchanged) return this.cached + let value = this.myValue + try { + const compute = this.myCompute + if (compute === undefined) throw new Error("Wrong use of Internal API") + value = compute() + } finally { + this.recache(value) + } + return value as Value + } + + get unchanged(): boolean { + if (this.recomputeNeeded) { + this.incremental = undefined + this.nodeCount = 0 + const manager = this.manager + if (manager) { + this.scopeInternal = manager.current + manager.current = this + } + return false + } else { + this.parent?.increment(this.node ? 1 : this.nodeCount, true) + return true + } + } + + recache(newValue?: Value): Value { + const manager = this.manager + if (manager) manager.current = this.scopeInternal + const oldValue = this.myValue + this.myValue = newValue + this.myModified = this.myComputed && !refEqual(newValue, oldValue) + this.myComputed = true + this.recomputeNeeded = false + this.detachChildScopes() + this.parent?.increment(this.node ? 1 : this.nodeCount, false) + this.node?.incrementalUpdateDone(this.parent?.nodeRef) + return this.cached + } + + get cached(): Value { + this.dependencies?.register(this.manager?.dependency) + this.dependencies?.updateDependencies(this.myModified) + return this.myValue as Value + } + + param(index: int32, value: V, equivalent?: Equivalent, name?: string, contextLocal?: boolean): State { + const manager = this.manager + const params = this.params + if (manager === undefined || params === undefined) throw new Error("Wrong use of Internal API") + const param = params[index] + if (param instanceof ParameterImpl) { + const state = param as Object as ParameterImpl + if (contextLocal == true && name != undefined && state != this.getNamedState(name)) throw new Error("name was unexpectedly changed to " + name) + state.update(value, equivalent) + return state + } else { + const state = new ParameterImpl(manager, value, name) + params[index] = state + if (contextLocal == true && name != undefined) this.setNamedState(name, state) + return state + } + } + + get modified(): boolean { + if (this.recomputeNeeded) this.value + else this.dependencies?.register(this.manager?.dependency) + return this.myModified + } + + get obsolete(): boolean { + return this.manager === undefined + } + + invalidate(): void { + const current = this.manager?.current // parameters can update snapshot during recomposition + let scope: ManagedScope = this + while (true) { + if (scope === current) break // parameters should not invalidate whole hierarchy + if (!scope.recomputeNeeded) KoalaProfiler.counters?.invalidation() + else if (current === undefined) break // all parent scopes were already invalidated + scope.recomputeNeeded = true + const parent = scope.parent + if (parent) { + // TODO/DEBUG: investigate a case when invalid node has valid parent + // Button.IsHovered does not work properly with the optimization above + // if (this.myRecomputeNeeded && !parent.myRecomputeNeeded) console.log("parent of invalid scope is valid unexpectedly") + scope = parent + } else { + // mark top-level computable state as dirty if it has dependencies. + // they will be recomputed during the snapshot updating. + // we do not recompute other computable states and updatable nodes. + if (scope.hasDependencies()) { + this.manager?.addDirtyScope(scope) + } + break + } + } + } + + private recycleOrDispose(child: ManagedScope): void { + // TEMP: explicit compares to avoid compiler bug + const recycled = child.reuseKey !== undefined && this._nodeRef?.recycle(child.reuseKey!!, child) == true + if (recycled) { + // if parent node is also disposed, the recycled scopes would dispose in the ReusablePool + if (!child.node) throw Error("reusable scope doesn't have a node") + child.node!.detach() + } else { + child.dispose() + } + } + + get disposed(): boolean { + return this.manager === undefined + } + + dispose(): void { + const manager = this.manager + if (manager === undefined) return // already disposed + manager.checkForStateDisposing() + let error: Error | undefined = undefined + this.manager = undefined + this.dependencies = undefined + const scope = manager.current + manager.current = this + try { + this.myCleanup?.(this.myValue) + } catch (cause) { + error = cause as Error + } + for (let child = this.child; child; child = child!.next) { + this.recycleOrDispose(child!!) + } + this.child = undefined + this.parentScope = undefined + this.node?.dispose() + this.node = undefined + this.nodeRef = undefined + this.scopeInternal = undefined + const statesCreated = this.statesCreated + if (statesCreated) { + disposeContentBackward(statesCreated) + this.statesCreated = undefined + } + const params = this.params + if (params) { + disposeContentBackward(params) + this.params = undefined + } + manager.current = scope + this.myModified = false + if (error) throw error + } + + toString(): string { + let str: string = KoalaCallsiteKeys.asString(this.id) + if (this.once) str += " remember..." + if (this.node) str += " " + className(this.node) + if (this === this.manager?.current) str += " (*)" + return str + } + + toHierarchy(): string { + let str = "" + for (let node = this.parent; node; node = node!.parent) str += " " + str += this.toString() + for (let node = this.child; node; node = node!.next) str += "\n" + node!.toHierarchy() + return str + } +} + +class ControlledScopeImpl implements Dependency, ControlledScope { + private manager: StateManagerImpl | undefined + private old: Dependency | undefined = undefined + private readonly _invalidate: () => void + + constructor(manager: StateManagerImpl, invalidate: () => void) { + this.manager = manager + this._invalidate = invalidate + } + + invalidate(): void { + this._invalidate() + } + + static cleanup(scope?: ControlledScopeImpl): void { + if (scope) scope.manager = undefined + } + + get obsolete(): boolean { + return this.manager === undefined + } + + enter(): void { + const manager = this.manager + if (manager === undefined) throw new Error("ControlledScope is already disposed") + this.old = manager.external + manager.external = this + } + + leave(): void { + const manager = this.manager + if (manager === undefined) throw new Error("ControlledScope is already disposed") + if (manager.external !== this) throw new Error("ControlledScope is not valid") + manager.external = this.old + this.old = undefined + } +} + +function isModified(oldV: Value, newV: Value, equivalent?: Equivalent): boolean { + return !refEqual(oldV, newV) && (equivalent?.(oldV, newV) != true) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/tree/IncrementalNode.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/tree/IncrementalNode.ts new file mode 100644 index 0000000000000000000000000000000000000000..646060d3197206d4a90a7f050b76839c312dfce3 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/tree/IncrementalNode.ts @@ -0,0 +1,222 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { className, uint32 } from "@koalaui/common" +import { Disposable } from "../states/Disposable" +import { ReadonlyTreeNode } from "./ReadonlyTreeNode" + +/** + * This is a node implementation for a tree, which is represented as a pair of bidirectional lists. + * It allows nodes to be added or removed incrementally using the state manager. + */ +export class IncrementalNode implements Disposable, ReadonlyTreeNode { + private _disposed = false + private _child: IncrementalNode | undefined = undefined + private _prev: IncrementalNode | undefined = undefined + private _next: IncrementalNode | undefined = undefined + private _parent: IncrementalNode | undefined = undefined + private _incremental: IncrementalNode | undefined = undefined + + /** + * This callback is called when a child node is added to this parent. + */ + protected onChildInserted: ((node: IncrementalNode) => void) | undefined = undefined + + /** + * This callback is called when a child node is removed from this parent. + */ + protected onChildRemoved: ((node: IncrementalNode) => void) | undefined = undefined + + /** + * This kind can be used to distinguish nodes. + * @see isKind + */ + readonly kind: uint32 + + /** + * @param kind - the kind of this instance + * @see PrimeNumbers + */ + constructor(kind: uint32 = 1) { + this.kind = kind + } + + /** + * Use this method instead of standard instanceof for the sake of speed and reliability. + * @param kind - a kind of this or parent instance to check against + * @returns `true` if this node is an instance of the expected kind + * @see PrimeNumbers + */ + isKind(kind: uint32): boolean { + return this.kind % kind == 0 + } + + /** + * Reuse a scope from the pool. + * @param reuseKey - The type of the scope to reuse. + * @returns A recycled scope, or undefined if none is available. + */ + reuse(reuseKey: string): Disposable | undefined { + return undefined + } + + /** + * Recycle a scope by adding it to the recycler pool for reuse. + * @param scope - The scope to recycle. + * @param reuseKey - The type of the scope (used as the key in the pool). + * @return true if child is successfully recycled + */ + recycle(reuseKey: string, child: Disposable): boolean { + return false + } + + /** + * @returns `true` if this node should no longer be used + */ + get disposed(): boolean { + return this._disposed + } + + /** + * This method is called to remove this node from the hierarchy and cleanup related resources. + */ + dispose(): void { + if (this._disposed) return + this._disposed = true + this.detach() + } + + /** + * This method is called to remove this node from the hierarchy. + * @internal + */ + detach(): void { + const prev = this._prev + const next = this._next + const parent = this._parent + if (prev) { + this._prev = undefined + prev._next = next + } + if (next) { + this._next = undefined + next._prev = prev + } + if (parent) { + this._parent = undefined + if (parent._child === this) { + parent._child = next + } + parent.onChildRemoved?.(this) + } + } + + /** + * @returns a parent node if it is exist + */ + get parent(): IncrementalNode | undefined { + return this._parent + } + + /** + * @returns text representation of the node + */ + toString(): string { + return className(this) + ": " + this.kind + } + + /** + * @returns text representation of a tree hierarchy starting from this node + */ + toHierarchy(): string { + let str = "" + for (let node = this._parent; node; node = node!._parent) str += " " + str += this.toString() + for (let node = this._child; node; node = node!._next) str += "\n" + node!.toHierarchy() + return str + } + + /** + * @returns the first child node contained in this node if it is exist + */ + get firstChild(): IncrementalNode | undefined { + return this._child + } + + /** + * @returns the next sibling of this node if it is exist + */ + get nextSibling(): IncrementalNode | undefined { + return this._next + } + + /** + * @returns the previous sibling of this node if it is exist + */ + get previousSibling(): IncrementalNode | undefined { + return this._prev + } + + /** + * This method is called by the state manager + * when the incremental update should skip several unchanged child nodes. + * @param count - a number of child nodes to skip during the incremental update + * @internal + */ + incrementalUpdateSkip(count: uint32) { + if (count > 0) { + const prev = this._incremental + let next = prev ? prev._next : this._child + while (1 < count--) { + if (next === undefined) throw new Error("child node is expected here") + next = next._next + } + this._incremental = next + } + else throw new Error("unexpected count of child nodes to skip: " + count) + } + + /** + * This method is called by the state manager + * when the incremental update of all children of this node is completed. + * @internal + */ + incrementalUpdateDone(parent?: IncrementalNode) { + if (this._disposed) throw new Error("child node is already disposed") + this._incremental = undefined + if (parent) { + const prev = parent._incremental + const next = prev ? prev._next : parent._child + if (this._parent) { + if (this._parent != parent) throw new Error("child node belongs to another parent") + if (this != next) throw new Error("child node is not expected here") + parent._incremental = this + } else { + parent._incremental = this + this._prev = prev + this._next = next + this._parent = parent + if (next) next._prev = this + if (prev) prev._next = this + else parent._child = this; + + // TODO: this is to workaround ast dumper bug #24055 + if (0) {} else {} + + parent.onChildInserted?.(this) + } + } + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/tree/PrimeNumbers.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/tree/PrimeNumbers.ts new file mode 100644 index 0000000000000000000000000000000000000000..e765e787b31d104744125cecd16c0bb2ab6888b0 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/tree/PrimeNumbers.ts @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { uint32 } from "@koalaui/common" + +/** + * An array of prime numbers that can be used as a kind of IncrementalNode. + */ +export const PrimeNumbers: ReadonlyArray = Array.of( + // prime numbers from 1st to 100th index: + 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, + 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, + 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, + 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, + 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, + 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, + 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, + 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, + 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, + 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, + // prime numbers from 101st to 200th index: + 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, + 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, + 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, + 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, + 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, + 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, + 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, + 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, + 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, + 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, + // prime numbers from 201st to 300th index: + 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, + 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, + 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, + 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, + 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, + 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, + 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, + 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, + 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, + 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, + // prime numbers from 301st to 400th index: + 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, + 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, + 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, + 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, + 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, + 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, + 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, + 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, + 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, + 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, +) diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/tree/ReadonlyTreeNode.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/tree/ReadonlyTreeNode.ts new file mode 100644 index 0000000000000000000000000000000000000000..00e4e7a7d9c9dc670043d502e643d5f8900896d8 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/tree/ReadonlyTreeNode.ts @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export interface ReadonlyTreeNode { + /** + * @returns a parent tree node if it is exist + */ + readonly parent: ReadonlyTreeNode|undefined + /** + * @returns text representation of a tree hierarchy starting from the tree node + */ + toHierarchy(): string +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/tree/TreeNode.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/tree/TreeNode.ts new file mode 100644 index 0000000000000000000000000000000000000000..40e24f1bf8ff52f7c0e1c92b7a7e88894e49310a --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/tree/TreeNode.ts @@ -0,0 +1,304 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { className, float64, int32, KoalaProfiler, uint32 } from "@koalaui/common" +import { Disposable } from "../states/Disposable" +import { ReadonlyTreeNode } from "./ReadonlyTreeNode" + +/** + * A tree node used to build an incremental runtime and a component tree. + */ +export class TreeNode implements Disposable, ReadonlyTreeNode { + private myIndex: int32 = -1 + private myParent: TreeNode | undefined = undefined + private myChildren = new Array() + private myIndicesValid: boolean = true + private myDisposed: boolean = false + + readonly kind: uint32 + + protected onChildInserted: ((node: TreeNode, index: int32) => void) | undefined + protected onChildRemoved: ((node: TreeNode, index: int32) => void) | undefined + + constructor(kind: uint32 = 1) { + this.kind = kind + KoalaProfiler.nodeCreated(this.kind, this) + KoalaProfiler.counters?.node() + } + + get disposed(): boolean { + return this.myDisposed + } + + /** + * This method may be called to notify this node that it + * is completely removed from the hierarchy and is no longer in use. + */ + dispose(): void { + this.myDisposed = true + KoalaProfiler.nodeDisposed(this.kind, this) + } + + /** + * Returns the parent node. + */ + get parent(): TreeNode | undefined { + return this.myParent + } + + /** + * Returns the depth of this node relative to the root node. + * The root node returns 0. + */ + get depth(): uint32 { + let count: uint32 = 0 + let parent = this.myParent + while (parent !== undefined) { + parent = parent!.myParent + count++ + } + return count + } + + /** + * Returns the number of children of this node. + */ + get childrenCount(): uint32 { + return this.myChildren.length as uint32 + } + + /** + * Returns all children of this node. + * Note that this array is updated automatically. + */ + get children(): ReadonlyArray { + return this.myChildren + } + + /** + * Returns the index of this node in the parent's children. + * The root node returns -1. + */ + get index(): int32 { + const parent = this.myParent + if (parent?.myIndicesValid == false) { + parent!.myIndicesValid = true + // recalculate indices of all children + const children = parent!.myChildren + const length = children.length + for (let i = 0; i < length; i++) { + children[i].myIndex = i + } + } + return this.myIndex + } + + /** + * @internal + * + * Use this method instead of standard instanceof for the sake of speed and reliability. + * @param kind - kind id of this or parent instance to check against. + * @returns true if this TreeNode is instance of given kind. + */ + isKind(kind: uint32): boolean { + return this.kind % kind == 0 + } + + /** + * Iterates through the child nodes and returns the first defined value. + */ + find(valueOf: (node: TreeNode, index: int32) => V | undefined): V | undefined { + const children = this.myChildren + const length = children.length + for (let i = 0; i < length; i++) { + let value = valueOf(children[i], i) + if (value !== undefined) return value + } + return undefined + } + + /** + * Performs the specified action for each child node. + */ + forEach(action: (node: TreeNode, index: float64) => void): void { + // must be int32, but ArkTS array.forEach requires index to be float64 + this.myChildren.forEach(action) + } + + /** + * Determines whether all child nodes satisfy the specified predicate. + */ + every(predicate: (node: TreeNode, index: float64) => boolean): boolean { + // must be int32, but ArkTS array.every requires index to be float64 + return this.myChildren.every(predicate) + } + + /** + * Determines whether any child node satisfies the specified predicate. + */ + some(predicate: (node: TreeNode, index: float64) => boolean): boolean { + // must be int32, but ArkTS array.some requires index to be float64 + return this.myChildren.some(predicate) + } + + /** + * Returns a child node at the specified index. + */ + childAt(index: int32): TreeNode | undefined { + if (!this.accessible(index)) return undefined // index out of bounds + return this.myChildren[index] + } + + /** + * Adds the given node after existing children if possible. + */ + appendChild(node: TreeNode): boolean { + return this.insertChildAt(this.childrenCount, node) + } + + /** + * Inserts the given node at the specified index if possible. + */ + insertChildAt(index: int32, node: TreeNode): boolean { + if (!this.accessible(index, 0)) return false // index out of bounds + if (!this.insertable(node)) return false // cannot be inserted + this.insertNodeAt(index, node) + return true + } + + /** + * Adds several nodes after existing children if possible. + */ + appendChildren(...nodes: TreeNode[]): boolean { + return this.insertChildrenAt(this.childrenCount, ...nodes) + } + + /** + * Inserts several nodes at the specified index if possible. + */ + insertChildrenAt(index: int32, ...nodes: TreeNode[]): boolean { + if (!this.accessible(index, 0)) return false // index out of bounds + if (nodes.length < 1) return false // nothing to insert + const length = nodes.length + for (let i = 0; i < length; i++) { + if (!this.insertable(nodes[i])) return false // cannot be inserted + } + for (let i = 0; i < length; i++) { + this.insertNodeAt(index + i, nodes[i]) + } + return true + } + + /** + * Removes a child node at the specified index if possible. + */ + removeChildAt(index: int32): TreeNode | undefined { + if (!this.accessible(index)) return undefined // index out of bounds + return this.removeNodes(index, 1)[0] + } + + /** + * Removes several nodes at the specified index if possible. + */ + removeChildrenAt(index: int32, count?: uint32): Array { + if (count === undefined) count = this.childrenCount - index + if (count < 1 || !this.accessible(index, count)) return new Array() // index out of bounds + return this.removeNodes(index, count) + } + + /** + * Removes a child node if possible. + */ + removeChild(node: TreeNode): boolean { + if (node.myParent !== this) return false // not in hierarchy + const index: int32 = this.myIndicesValid ? node.index : this.myChildren.indexOf(node) as int32 + return undefined !== this.removeChildAt(index) + } + + /** + * Removes this node from its parent. + */ + removeFromParent(): void { + this.myParent?.removeChild(this) + } + + private removeNodes(index: int32, count: uint32): Array { + const nodes = this.myChildren.splice(index, count) + if (index < this.childrenCount) this.myIndicesValid = false + const length = nodes.length + for (let i = 0; i < length; i++) { + const current = nodes[i] + current.myIndex = -1 + current.myParent = undefined + this.onChildRemoved?.(current, index) + } + return nodes + } + + private insertNodeAt(index: int32, node: TreeNode): void { + node.myIndex = index + node.myParent = this + if (index < this.childrenCount) this.myIndicesValid = false + this.myChildren.splice(index, 0, node) + this.onChildInserted?.(node, index) + } + + private insertable(node: TreeNode): boolean { + // We decided to remove the check for cyclic dependency to improve performance. + // Attention! Now it is possible to create a tree with a cyclic dependencies. + // So you have to be sure that the inserting node is not the root of this node. + return node.parent === undefined + } + + private accessible(index: int32, count: uint32 = 1): boolean { + return Number.isInteger(index) && 0 <= index + && Number.isInteger(count) && index <= this.childrenCount - count // integer index within range + } + + toString(): string { + return className(this) + } + + toHierarchy(): string { + return this.collectNodes().map((node: TreeNode) => " ".repeat(node.depth) + node.toString()).join("\n") + } + + collectNodes(): Array { + const array = new Array() + this.collectParentsTo(array) + array.push(this) + this.collectChildrenTo(array, true) + return array + } + + collectParentsTo(array: Array): void { + const index = array.length as int32 + let parent = this.myParent + while (parent !== undefined) { + array.splice(index, 0, parent!) + parent = parent!.myParent + } + } + + collectChildrenTo(array: Array, deep: boolean = false): void { + const children = this.myChildren + const length = children.length + for (let i = 0; i < length; i++) { + const current = children[i] + array.push(current) + if (deep) current.collectChildrenTo(array, deep) + } + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/tree/TreePath.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/tree/TreePath.ts new file mode 100644 index 0000000000000000000000000000000000000000..6b1ef728571cea048baeac7461236beebeb0da64 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/tree/TreePath.ts @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { uint32 } from "@koalaui/common" + +/** + * This class represents a path to a node in a tree. + */ +export class TreePath { + readonly node: Node + readonly parent: TreePath | undefined + + /** + * Creates a tree path to the given node relative to the specified parent path. + * The path represents a root node if parent path is undefined. + * + * @param node a node in a tree + * @param parent a path to a parent node or undefined for the root + */ + constructor(node: Node, parent?: TreePath) { + this.node = node + this.parent = parent + } + + /** + * Creates a tree path to the specified child node. + * + * @param node a node in a tree + */ + child(node: Node): TreePath { + return new TreePath(node, this) + } + + /** + * Returns the tree path that represents the root node. + * The root path returns itself. + */ + get root(): TreePath { + return this.parent?.root ?? this + } + + /** + * Returns the depth of the tree path relative to the root node. + * The root path returns 0. + */ + get depth(): uint32 { + let count: uint32 = 0 + let parent = this.parent + while (parent !== undefined) { + parent = parent!.parent + count++ + } + return count + } + + toString(): string { + let parent = this.parent ?? "" + return `${parent}/${this.node}` + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/tree/TreeUpdater.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/tree/TreeUpdater.ts new file mode 100644 index 0000000000000000000000000000000000000000..cbf7f4a4ba6c0a79ec0f69825a93cf75c6e16838 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/src/tree/TreeUpdater.ts @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { int32, uint32 } from "@koalaui/common" +import { TreePath } from "./TreePath" + +/** + * This class provides basic functionality for tree building or incremental tree updating. + */ +export abstract class TreeUpdater { + private current: TreePath + readonly reverse: boolean + + /** + * @param root the tree root that always exists + * @param reverse `false` builds a tree top-down, `true` build a tree bottom-up + */ + constructor(root: Node, reverse: boolean = false) { + this.current = new TreePath(root) + this.reverse = reverse + } + + /** + * Returns the path to the selected node. + */ + get path(): TreePath { + return this.current + } + + /** + * Returns the selected node to perform tree change operations. + */ + get node(): Node { + return this.current.node + } + + /** + * Selects the specified child node when the updater is getting traversed down the tree. + */ + down(node: Node): void { + this.current = this.current.child(node) + } + + /** + * Selects the parent node when the updater is getting traversed up the tree. + */ + up(): void { + let parent = this.current.parent + if (parent === undefined) throw new Error("unexpected") + this.current = parent + } + + /** + * Selects the root node to prepare the updater to traversing a tree. + */ + clear(): void { + this.current = this.current.root + } + + /** + * Inserts the specified node as a child of a selected node at the given index. + */ + abstract insert(index: int32, node: Node): void + + /** + * Removes the specified amount of children from the given index. + */ + abstract remove(index: int32, amount: uint32): void + + /** + * Moves the specified amount of children from the indexFrom to the indexTo. + */ + abstract move(indexFrom: int32, indexTo: int32, amount: uint32): void +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test-arkts/animation/Easing.test.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test-arkts/animation/Easing.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..45bfb1445f392e42fe6db30137b3b122fddf27fd --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test-arkts/animation/Easing.test.ts @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// TODO: the real chai exports 'assert', but 'assert' is still a keyword in ArkTS +import { Assert, suite, test } from "@koalaui/harness" +import { float64, int32 } from "@koalaui/common" +import { Easing, EasingCurve, EasingStepJump } from "../../src/animation/Easing" + +function assertEasing(easing: EasingCurve, ...expected: int32[]) { + const last = expected.length - 1 + for (let i = 0; i <= last; i++) { + Assert.equal( + Math.round(100 * easing((i as float64) / last)) as int32, + expected[i] as int32, + `i=${i}: expected=${expected[i]} - ${i / last} => ${easing(i / last)} => ${Math.round(100 * easing(i / last))}` + ) + } +} + +suite("Easing", () => { + test("Linear", () => { assertEasing(Easing.Linear, 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100) }) + test("Linear.inverted", () => { assertEasing(Easing.inverted(Easing.Linear), 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100) }) + test("Linear.reversed", () => { assertEasing(Easing.reversed(Easing.Linear), 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0) }) + test("Linear.restarted", () => { assertEasing(Easing.restarted(Easing.Linear), 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 0) }) + test("Linear.repeated twice", () => { assertEasing(Easing.repeated(Easing.Linear, 2), 0, 20, 40, 60, 80, 0, 20, 40, 60, 80, 100) }) + test("Linear.repeated 4 times", () => { assertEasing(Easing.repeated(Easing.Linear, 4), 0, 40, 80, 20, 60, 0, 40, 80, 20, 60, 100) }) + test("Linear.joined with Linear.reversed", () => { assertEasing(Easing.joined(Easing.Linear, Easing.reversed(Easing.Linear)), 0, 20, 40, 60, 80, 100, 80, 60, 40, 20, 0) }) + test("Linear.thereAndBackAgain (as above)", () => { assertEasing(Easing.thereAndBackAgain(Easing.Linear), 0, 20, 40, 60, 80, 100, 80, 60, 40, 20, 0) }) + test("EaseInSine", () => { assertEasing(Easing.EaseInSine, 0, 1, 5, 11, 19, 29, 41, 55, 69, 84, 100) }) + test("EaseInSine.inverted", () => { assertEasing(Easing.inverted(Easing.EaseInSine), 0, 16, 31, 45, 59, 71, 81, 89, 95, 99, 100) }) + test("EaseInSine.reversed", () => { assertEasing(Easing.reversed(Easing.EaseInSine), 100, 84, 69, 55, 41, 29, 19, 11, 5, 1, 0) }) + test("EaseOutSine", () => { assertEasing(Easing.EaseOutSine, 0, 16, 31, 45, 59, 71, 81, 89, 95, 99, 100) }) + test("EaseOutSine.inverted", () => { assertEasing(Easing.inverted(Easing.EaseOutSine), 0, 1, 5, 11, 19, 29, 41, 55, 69, 84, 100) }) + test("EaseOutSine.reversed", () => { assertEasing(Easing.reversed(Easing.EaseOutSine), 100, 99, 95, 89, 81, 71, 59, 45, 31, 16, 0) }) + test("EaseInOutSine", () => { assertEasing(Easing.EaseInOutSine, 0, 2, 10, 21, 35, 50, 65, 79, 90, 98, 100) }) + test("EaseInOutSine.inverted", () => { assertEasing(Easing.inverted(Easing.EaseInOutSine), 0, 2, 10, 21, 35, 50, 65, 79, 90, 98, 100) }) + test("EaseInOutSine.reversed", () => { assertEasing(Easing.reversed(Easing.EaseInOutSine), 100, 98, 90, 79, 65, 50, 35, 21, 10, 2, 0) }) + test("Ease", () => { assertEasing(Easing.Ease, 0, 10, 30, 51, 68, 80, 89, 94, 98, 99, 100) }) + test("Ease.inverted", () => { assertEasing(Easing.inverted(Easing.Ease), 0, 1, 2, 6, 11, 20, 32, 49, 70, 90, 100) }) + test("Ease.reversed", () => { assertEasing(Easing.reversed(Easing.Ease), 100, 99, 98, 94, 89, 80, 68, 51, 30, 10, 0) }) + test("EaseIn", () => { assertEasing(Easing.EaseIn, 0, 2, 6, 13, 21, 32, 43, 55, 69, 84, 100) }) + test("EaseIn.inverted", () => { assertEasing(Easing.inverted(Easing.EaseIn), 0, 16, 31, 45, 57, 68, 79, 87, 94, 98, 100) }) + test("EaseIn.reversed", () => { assertEasing(Easing.reversed(Easing.EaseIn), 100, 84, 69, 55, 43, 32, 21, 13, 6, 2, 0) }) + test("EaseOut", () => { assertEasing(Easing.EaseOut, 0, 16, 31, 45, 57, 69, 79, 87, 94, 98, 100) }) + test("EaseOut.inverted", () => { assertEasing(Easing.inverted(Easing.EaseOut), 0, 2, 6, 13, 21, 31, 43, 55, 69, 84, 100) }) + test("EaseOut.reversed", () => { assertEasing(Easing.reversed(Easing.EaseOut), 100, 98, 94, 87, 79, 69, 57, 45, 31, 16, 0) }) + test("EaseInOut", () => { assertEasing(Easing.EaseInOut, 0, 2, 8, 19, 33, 50, 67, 81, 92, 98, 100) }) + test("EaseInOut.inverted", () => { assertEasing(Easing.inverted(Easing.EaseInOut), 0, 2, 8, 19, 33, 50, 67, 81, 92, 98, 100) }) + test("EaseInOut.reversed", () => { assertEasing(Easing.reversed(Easing.EaseInOut), 100, 98, 92, 81, 67, 50, 33, 19, 8, 2, 0) }) + test("custom bezier with small overflow", () => { assertEasing(Easing.cubicBezier(.3, -.3, .7, 1.3), 0, -4, 3, 15, 32, 50, 68, 85, 97, 104, 100) }) + test("custom bezier with large overflow", () => { assertEasing(Easing.cubicBezier(.3, -.7, .7, 1.7), 0, -13, -9, 6, 26, 50, 74, 95, 109, 113, 100) }) + test("6 steps with EasingStepJump.None", () => { assertEasing(Easing.steps(6, EasingStepJump.None), 0, 0, 20, 20, 40, 40, 60, 60, 80, 80, 100, 100) }) + test("11 steps with EasingStepJump.None", () => { assertEasing(Easing.steps(11, EasingStepJump.None), 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100) }) + test("10 steps with EasingStepJump.Start", () => { assertEasing(Easing.steps(10, EasingStepJump.Start), 10, 20, 30, 40, 50, 60, 70, 80, 90, 100) }) + test("10 steps with EasingStepJump.End", () => { assertEasing(Easing.steps(10, EasingStepJump.End), 0, 10, 20, 30, 40, 50, 60, 70, 80, 90) }) + test("9 steps with EasingStepJump.Both", () => { assertEasing(Easing.steps(9, EasingStepJump.Both), 10, 20, 30, 40, 50, 60, 70, 80, 90) }) +}) +export const __ARKTEST__ = "animation/Easing.test" diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test-arkts/common/MarkableQueue.test.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test-arkts/common/MarkableQueue.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..ad7177e86f18914415c60d4b9b90dec9a76eca55 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test-arkts/common/MarkableQueue.test.ts @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// TODO: the real chai exports 'assert', but 'assert' is still a keyword in ArkTS +import { Assert, suite, test } from "@koalaui/harness" +import { MarkableQueue, markableQueue } from "@koalaui/common" + +const collector = new Array() + +function testQueue(queue: MarkableQueue, expected: Array) { + collector.length = 0 + queue.callCallbacks() + Assert.deepEqual(collector, expected) +} + +suite("MarkableQueue tests", () => { + + test("nothing to call without marker", () => { + const queue = markableQueue() + queue.addCallback(() => { collector.push("1a") }) + queue.addCallback(() => { collector.push("1b") }) + queue.addCallback(() => { collector.push("1c") }) + testQueue(queue, Array.of()) + }) + + test("call only marked callbacks", () => { + const queue = markableQueue() + queue.addCallback(() => { collector.push("1a") }) + queue.addCallback(() => { collector.push("1b") }) + queue.addCallback(() => { collector.push("1c") }) + queue.setMarker() + queue.addCallback(() => { collector.push("2a") }) + queue.addCallback(() => { collector.push("2b") }) + queue.addCallback(() => { collector.push("2c") }) + testQueue(queue, Array.of("1a", "1b", "1c")) + testQueue(queue, Array.of()) // called only once + }) + + test("call marked callbacks to the latest marker", () => { + const queue = markableQueue() + queue.addCallback(() => { collector.push("1a") }) + queue.addCallback(() => { collector.push("1b") }) + queue.addCallback(() => { collector.push("1c") }) + queue.setMarker() + queue.addCallback(() => { collector.push("2a") }) + queue.addCallback(() => { collector.push("2b") }) + queue.addCallback(() => { collector.push("2c") }) + queue.setMarker() + queue.addCallback(() => { collector.push("3a") }) + queue.addCallback(() => { collector.push("3b") }) + queue.addCallback(() => { collector.push("3c") }) + testQueue(queue, Array.of("1a", "1b", "1c", "2a", "2b", "2c")) + testQueue(queue, Array.of()) // called only once + }) +}) + +suite("MarkableQueue reversed tests", () => { + + test("nothing to call without marker", () => { + const queue = markableQueue(true) + queue.addCallback(() => { collector.push("1a") }) + queue.addCallback(() => { collector.push("1b") }) + queue.addCallback(() => { collector.push("1c") }) + testQueue(queue, Array.of()) + }) + + test("call only marked callbacks", () => { + const queue = markableQueue(true) + queue.addCallback(() => { collector.push("1a") }) + queue.addCallback(() => { collector.push("1b") }) + queue.addCallback(() => { collector.push("1c") }) + queue.setMarker() + queue.addCallback(() => { collector.push("2a") }) + queue.addCallback(() => { collector.push("2b") }) + queue.addCallback(() => { collector.push("2c") }) + testQueue(queue, Array.of("1c", "1b", "1a")) + testQueue(queue, Array.of()) // called only once + }) + + test("call marked callbacks from the latest marker", () => { + const queue = markableQueue(true) + queue.addCallback(() => { collector.push("1a") }) + queue.addCallback(() => { collector.push("1b") }) + queue.addCallback(() => { collector.push("1c") }) + queue.setMarker() + queue.addCallback(() => { collector.push("2a") }) + queue.addCallback(() => { collector.push("2b") }) + queue.addCallback(() => { collector.push("2c") }) + queue.setMarker() + queue.addCallback(() => { collector.push("3a") }) + queue.addCallback(() => { collector.push("3b") }) + queue.addCallback(() => { collector.push("3c") }) + testQueue(queue, Array.of("2c", "2b", "2a", "1c", "1b", "1a")) + testQueue(queue, Array.of()) // called only once + }) +}) +export const __ARKTEST__ = "common/MarkableQueue.test" diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test-arkts/memo/bind.test.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test-arkts/memo/bind.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..dc50176642320421d089e181a0edbd8f1d6d7319 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test-arkts/memo/bind.test.ts @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// TODO: the real chai exports 'assert', but 'assert' is still a keyword in ArkTS +import { Assert, suite, test } from "@koalaui/harness" +import { asArray } from "@koalaui/common" +import { + GlobalStateManager, + State, + TestNode, + memoBind, + testTick, +} from "../../src" + +const collector = new Array() + +function testExpected(root: State, ...expected: string[]) { + collector.length = 0 + testTick(root) + Assert.deepEqual(collector, asArray(expected)) + if (expected.length > 0) testExpected(root) +} + +/** @memo */ +function sample(arg: string): void { + collector.push(arg) +} + +suite("memo tests", () => { + test("memoBind trivial test", () => { + GlobalStateManager.reset() + const root = TestNode.create((_) => { + /** @memo */ + const bind = memoBind(sample, "red") + bind() + }) + testExpected(root, "red") + }) +}) +export const __ARKTEST__ = "memo/bind.test" diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test-arkts/memo/changeListener.test.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test-arkts/memo/changeListener.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..493358a9f4f414b4181ad6a334a9b9f6d4b4d904 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test-arkts/memo/changeListener.test.ts @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// TODO: the real chai exports 'assert', but 'assert' is still a keyword in ArkTS +import { Assert, suite, test } from "@koalaui/harness" +import { + GlobalStateManager, + OnChange, + RunEffect, + State, + TestNode, + mutableState, + testTick, +} from "../../src" + +const collector = new Array() + +function testExpected(root: State, expected?: string) { + collector.length = 0 + testTick(root, false) + Assert.equal(collector.length, 0) + GlobalStateManager.instance.callCallbacks() + if (expected === undefined) { + Assert.equal(collector.length, 0) + } else { + Assert.equal(collector.length, 1) + Assert.equal(collector[0], expected) + } +} + +export function testChange( + /** @memo */ + content: (value: string) => void, + expected?: string +) { + GlobalStateManager.reset() + const state = mutableState("first") + const root = TestNode.create((node) => { content(state.value) }) + testExpected(root, expected) + state.value = "f" + "i" + "r" + "s" + "t" + testExpected(root) + state.value = "second" + testExpected(root, "second") + state.value = "third" + testExpected(root, "third") +} + +suite("changeListener tests", () => { + + test("RunEffect", () => { testChange((value: string) => { RunEffect(value, (change: string) => { collector.push(change) }) }, "first") }) + + test("OnChange", () => { testChange((value: string) => { OnChange(value, (change: string) => { collector.push(change) }) }) }) +}) +export const __ARKTEST__ = "memo/changeListeners.test" diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test-arkts/memo/contextLocal.test.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test-arkts/memo/contextLocal.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..b27f09358f025bf06de9ba72ba622793ca85edbe --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test-arkts/memo/contextLocal.test.ts @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// TODO: the real chai exports 'assert', but 'assert' is still a keyword in ArkTS +import { Assert, suite, test } from "@koalaui/harness" +import { asArray } from "@koalaui/common" +import { + State, + TestNode, + contextLocalScope, + contextLocalValue, + mutableState, + testTick, +} from "../../src" + +const collector = new Array() + +function testExpected(root: State, ...expected: string[]) { + collector.length = 0 + testTick(root) + Assert.deepEqual(collector, asArray(expected)) + if (expected.length > 0) testExpected(root) +} + +suite("contextLocal tests", () => { + + test("contextLocalScope ensures name is not changed", () => { + const state = mutableState("first") + const root = TestNode.create((node) => { + contextLocalScope(state.value, "value", () => { + collector.push(contextLocalValue(state.value)) + }) + }) + testExpected(root, "value") + state.value = "second" + Assert.throws(() => { testTick(root) }) + }) + + test("contextLocalScope propagates state immediately", () => { + const state = mutableState("first") + const root = TestNode.create((node) => { + const str = state.value + collector.push("ui:" + str) + contextLocalScope("parameter", state.value, () => { + collector.push("state:" + contextLocalValue("parameter")) + }) + }) + testExpected(root, "ui:first", "state:first") + state.value = "second" + testExpected(root, "ui:second", "state:second") + state.value = "third" + testExpected(root, "ui:third", "state:third") + }) +}) +export const __ARKTEST__ = "memo/contextLocal.test" diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test-arkts/memo/remember.test.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test-arkts/memo/remember.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..bbdbf96ba3fd6ea6a890a9178b8f1a98144f2953 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test-arkts/memo/remember.test.ts @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// TODO: the real chai exports 'assert', but 'assert' is still a keyword in ArkTS +import { Assert, suite, test } from "@koalaui/harness" +import { asArray, float64, int32 } from "@koalaui/common" +import { + GlobalStateManager, + State, + TestNode, + memoLifecycle, + mutableState, + once, + remember, + rememberDisposable, + rememberMutableState, + testTick, +} from "../../src" + +const collector = new Array() + +function testExpected(root: State, ...expected: string[]) { + collector.length = 0 + testTick(root) + Assert.deepEqual(collector, asArray(expected)) + if (expected.length > 0) testExpected(root) +} + +suite("remember tests", () => { + + test("memoLifecycle runs when attaching and detaching", () => { + GlobalStateManager.reset() + const state = mutableState(0) + const root = TestNode.create((node) => { + if (state.value > 0) { + memoLifecycle( + () => { collector.push("attach") }, + () => { collector.push("detach") } + ) + collector.push("update") + } + }) + testExpected(root) + state.value = 1 + testExpected(root, "attach", "update") + state.value = 2 + testExpected(root, "update") + state.value = 0 + testExpected(root, "detach") + }) + + test("once runs once when attaching to composition", () => { + GlobalStateManager.reset() + const state = mutableState(0) + const root = TestNode.create((node) => { + once(() => { collector.push("once" + state.value) }) + collector.push("update" + state.value) + }) + testExpected(root, "once0", "update0") + state.value = 1 + testExpected(root, "update1") + state.value = 2 + testExpected(root, "update2") + }) + + test("remember computes once", () => { + GlobalStateManager.reset() + const root = TestNode.create((node) => { + remember(() => collector.push("inner")) + collector.push("outer") + }) + testExpected(root, "inner", "outer") + }) + + test("remember computes once even if inner state changed", () => { + GlobalStateManager.reset() + const state = mutableState(false) + const root = TestNode.create((node) => { + remember(() => { + collector.push("inner") + return state.value // not depended // TODO: remember cannot be void + }) + collector.push("outer") + }) + testExpected(root, "inner", "outer") + state.value = true + testExpected(root) + }) + + test("remember computes once even if outer state changed", () => { + GlobalStateManager.reset() + const state = mutableState(false) + const root = TestNode.create((node) => { + remember(() => collector.push("inner")) + state.value // depended + collector.push("outer") + }) + testExpected(root, "inner", "outer") + state.value = true + testExpected(root, "outer") + }) + + test("intrinsic remember should not conflict each other", () => { + GlobalStateManager.reset() + const state = mutableState(false) + const root = TestNode.create((node) => { + state.value + ? remember(() => collector.push("positive")) + : remember(() => collector.push("negative")) + }) + testExpected(root, "negative") + state.value = true + testExpected(root, "positive") + state.value = false + testExpected(root, "negative") + state.value = false + testExpected(root) + }) + + test("rememberDisposable created and disposed accordingly", () => { + GlobalStateManager.reset() + const state = mutableState(false) + const root = TestNode.create((node) => { + if (state.value) { + rememberDisposable( + () => collector.push("create"), + (_: float64 | undefined) => { collector.push("dispose") }) + } + }) + testExpected(root) + state.value = true + testExpected(root, "create") + state.value = false + testExpected(root, "dispose") + state.value = false + testExpected(root) + }) + + test("rememberMutableState computes once even if initial state changed", () => { + GlobalStateManager.reset() + const global = mutableState(0) + const root = TestNode.create((node) => { + const local = rememberMutableState(global.value) + collector.push("global=" + global.value) + collector.push("local=" + local.value) + }) + testExpected(root, "global=0", "local=0") + global.value++ + testExpected(root, "global=1", "local=0") + global.value++ + testExpected(root, "global=2", "local=0") + }) +}) +export const __ARKTEST__ = "memo/remember.test" diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test-arkts/memo/repeat.test.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test-arkts/memo/repeat.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..bd567d258e2ff475729a1d4cd10fd3a73d1e7c6e --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test-arkts/memo/repeat.test.ts @@ -0,0 +1,232 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// TODO: the real chai exports 'assert', but 'assert' is still a keyword in ArkTS +import { Assert, suite, test } from "@koalaui/harness" +import { asArray, int32, KoalaCallsiteKey } from "@koalaui/common" +import { + GlobalStateManager, + Repeat, + RepeatByArray, + RepeatRange, + RepeatWithKey, + State, + TestNode, + memoLifecycle, + mutableState, + testTick, +} from "../../src" + +// For tests we compute positional ids from strings. +export function key(name: string): KoalaCallsiteKey { + let key: KoalaCallsiteKey = 0 + for (let i = 0; i < name.length; i++) { + key = (key << 3) | (key >> 29) ^ (name[i] as int32) + } + return key +} + +const collector = new Array() + +class Page { + readonly id: KoalaCallsiteKey + private readonly name: string + constructor(name: string) { + this.id = key(name) + this.name = name + } + /** @memo */ + page(): void { + memoLifecycle( + () => { collector.push("+" + this.name) }, + () => { collector.push("-" + this.name) }) + } +} + +function createPages(...names: string[]): ReadonlyArray { + return asArray(names).map((name: string) => new Page(name)) +} + +function testExpected(root: State, ...expected: string[]) { + collector.length = 0 + testTick(root) + Assert.deepEqual(collector, asArray(expected)) + if (expected.length > 0) testExpected(root) +} + +function testInsert( + /** @memo */ + content: (array: ReadonlyArray) => void +) { + GlobalStateManager.reset() + const state = mutableState(createPages()) + const root = TestNode.create((_) => { content(state.value) }) + testExpected(root) + state.value = createPages("three") + testExpected(root, "+three") + state.value = createPages("one", "three") + testExpected(root, "+one") + state.value = createPages("one", "three", "five") + testExpected(root, "+five") + state.value = createPages("one", "two", "three", "four", "five") + testExpected(root, "+two", "+four") +} + +function testRemove( + /** @memo */ + content: (array: ReadonlyArray) => void +) { + GlobalStateManager.reset() + const state = mutableState(createPages("one", "two", "three", "four", "five")) + const root = TestNode.create((_) => { content(state.value) }) + testExpected(root, "+one", "+two", "+three", "+four", "+five") + state.value = createPages("one", "three", "five") + testExpected(root, "-two", "-four") + state.value = createPages("three", "five") + testExpected(root, "-one") + state.value = createPages("three") + testExpected(root, "-five") + state.value = createPages() + testExpected(root, "-three") +} + +function testSwap( + /** @memo */ + content: (array: ReadonlyArray) => void +) { + GlobalStateManager.reset() + const state = mutableState(createPages("one", "two", "three", "four", "five")) + const root = TestNode.create((_) => { content(state.value) }) + testExpected(root, "+one", "+two", "+three", "+four", "+five") + state.value = createPages("two", "one", "three", "four", "five") + testExpected(root, "-one", "+one") + state.value = createPages("two", "four", "one", "three", "five") + testExpected(root, "-one", "-three", "+one", "+three") +} + +suite("repeat tests", () => { + + test("Repeat", () => { + GlobalStateManager.reset() + const state = mutableState(createPages()) + const root = TestNode.create((_) => { + Repeat(state.value.length as int32, (index: int32) => { + state.value[index].page() // index-based key + }) + }) + testExpected(root) + state.value = createPages("one") + testExpected(root, "+one") + state.value = createPages("one", "two", "three") + testExpected(root, "+two", "+three") + state.value = createPages("one", "two") + testExpected(root, "-three") + state.value = createPages("two") + testExpected(root, "-two") // because of index-based key; should be "-one" + state.value = createPages("one", "two") + testExpected(root, "+two") // because of index-based key; should be "+one" + }) + + + test("RepeatWithKey.insert", () => { + testInsert((array) => { + RepeatWithKey( + array.length as int32, + (index: int32) => array[index].id, + (index: int32) => { array[index].page() }) + }) + }) + + test("RepeatByArray.insert", () => { + testInsert((array) => { + RepeatByArray( + array, + (element: Page, _: int32) => element.id, + (element: Page, _: int32) => { element.page() }) + }) + }) + + test("RepeatRange.insert", () => { + testInsert((array) => { + RepeatRange( + 0, + array.length as int32, + (index: int32) => array[index], + (element: Page, _: int32) => element.id, + (element: Page, _: int32) => { element.page() }) + }) + }) + + + test("RepeatWithKey.remove", () => { + testRemove((array) => { + RepeatWithKey( + array.length as int32, + (index: int32) => array[index].id, + (index: int32) => { array[index].page() }) + }) + }) + + test("RepeatByArray.remove", () => { + testRemove((array) => { + RepeatByArray( + array, + (element: Page, _: int32) => element.id, + (element: Page, _: int32) => { element.page() }) + }) + }) + + test("RepeatRange.remove", () => { + testRemove((array) => { + RepeatRange( + 0, + array.length as int32, + (index: int32) => array[index], + (element: Page, _: int32) => element.id, + (element: Page, _: int32) => { element.page() }) + }) + }) + + + test("RepeatWithKey.swap", () => { + testSwap((array) => { + RepeatWithKey( + array.length as int32, + (index: int32) => array[index].id, + (index: int32) => { array[index].page() }) + }) + }) + + test("RepeatByArray.swap", () => { + testSwap((array) => { + RepeatByArray( + array, + (element: Page, _: int32) => element.id, + (element: Page, _: int32) => { element.page() }) + }) + }) + + test("RepeatRange.swap", () => { + testSwap((array) => { + RepeatRange( + 0, + array.length as int32, + (index: int32) => array[index], + (element: Page, _: int32) => element.id, + (element: Page, _: int32) => { element.page() }) + }) + }) +}) +export const __ARKTEST__ = "memo/repeat.test" diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test-arkts/states/Journal.test.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test-arkts/states/Journal.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..e6ccf772ac696d30cd7755195495f4bfc53cc079 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test-arkts/states/Journal.test.ts @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// TODO: the real chai exports 'assert', but 'assert' is still a keyword in ArkTS +import { Assert, suite, test } from "@koalaui/harness" +import { Changes, Journal } from "../../src/states/Journal" + +function assertChange(changes: Changes | undefined, state: Object, expected: Value) { + const change = changes?.getChange(state) + Assert.isDefined(change) + Assert.equal(change?.value, expected) +} + +function assertNoChange(changes: Changes | undefined, state: Object) { + const change = changes?.getChange(state) + Assert.isUndefined(change) +} + +function assertNoChanges(journal: Journal) { + Assert.isUndefined(journal.getChanges()) +} + +suite("Journal tests", () => { + + test("new journal has no any changes", () => { + const journal = new Journal() + assertNoChanges(journal) + }) + + test("add changes to journal", () => { + const state = new Object() + const journal = new Journal() + journal.addChange(state, "value1") + journal.addChange(state, "value2") + assertChange(journal, state, "value2") + assertNoChanges(journal) + }) + + test("add marked changes to journal", () => { + const state = new Object() + const journal = new Journal() + journal.addChange(state, "value1") + journal.addChange(state, "value2") + journal.setMarker() + assertChange(journal, state, "value2") + assertChange(journal.getChanges(), state, "value2") + }) + + test("add changes to journal after marker", () => { + const state = new Object() + const journal = new Journal() + journal.addChange(state, "value1") + journal.addChange(state, "value2") + journal.setMarker() + journal.addChange(state, "value3") + journal.addChange(state, "value4") + assertChange(journal, state, "value4") + assertChange(journal.getChanges(), state, "value2") + }) + + test("remove all changes from journal", () => { + const state = new Object() + const journal = new Journal() + journal.addChange(state, "value1") + journal.addChange(state, "value2") + journal.setMarker() + journal.addChange(state, "value3") + journal.addChange(state, "value4") + journal.clear() + assertNoChange(journal, state) + assertNoChanges(journal) + }) + + test("remove marked changes from journal", () => { + const state = new Object() + const journal = new Journal() + journal.addChange(state, "value1") + journal.addChange(state, "value2") + journal.setMarker() + journal.addChange(state, "value3") + journal.addChange(state, "value4") + const changes = journal.getChanges() + Assert.isDefined(changes) + changes?.clear() + assertChange(journal, state, "value4") + assertNoChanges(journal) + }) +}) +export const __ARKTEST__ = "states/Journal.test" diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test-arkts/states/State.test.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test-arkts/states/State.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..21e6ec9bcc01b73d56053277a4c816556a1f8d9f --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test-arkts/states/State.test.ts @@ -0,0 +1,1810 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// TODO: the real chai exports 'assert', but 'assert' is still a keyword in ArkTS +import { Assert, suite, test } from "@koalaui/harness" +import { KoalaCallsiteKey, float64, int32 } from "@koalaui/common" +import { IncrementalNode, State, StateContext, TestNode, testUpdate, ValueTracker } from "../../src" +import { createStateManager } from "../../src/states/State" + +// For tests we compute positional ids from strings. +export function key(name: string): KoalaCallsiteKey { + let key: KoalaCallsiteKey = 0 + for (let i = 0; i < name.length; i++) { + key = (key << 3) | (key >> 29) ^ (name[i] as int32) + } + return key +} + +function assertNode(state: State, presentation: string) { + Assert.isFalse(state.modified) // the same node + Assert.equal(state.value.toHierarchy(), presentation) +} + +function assertState(state: State, value: Value, modified: boolean = false) { + Assert.equal(state.modified, modified) + Assert.equal(state.value, value) + Assert.equal(state.modified, modified) +} + +function assertModifiedState(state: State, value: Value) { + assertState(state, value, true) +} + +function assertStringsAndCleanup(array: Array, presentation: string) { + Assert.isNotEmpty(array) + Assert.equal(array.join(" ; "), presentation) + array.splice(0, array.length) +} + +suite("State", () => { + test("initial state is not modified", () => { + let manager = createStateManager() + let state = manager.mutableState(200) + assertState(state, 200) + }) + test("unmanaged state is modified immediately", () => { + let manager = createStateManager() + manager.frozen = true + let state = manager.mutableState(200) + state.dispose() + state.value = 404 + assertModifiedState(state, 404) + // check that modified state is updated + state.value = 404 + assertState(state, 404) + }) + test("managed state is not modified immediately", () => { + let manager = createStateManager() + manager.frozen = true + let state = manager.mutableState(200) + state.value = 404 + assertState(state, 200) + }) + test("managed state is modified on first snapshot update", () => { + let manager = createStateManager() + let state = manager.mutableState(200) + state.value = 404 + Assert.equal(testUpdate(false, manager), 1) + assertModifiedState(state, 404) + }) + test("managed state is not modified on next snapshot update", () => { + let manager = createStateManager() + let state = manager.mutableState(200) + state.value = 404 + Assert.equal(testUpdate(false, manager), 1) + Assert.equal(testUpdate(false, manager), 0) + assertState(state, 404) + }) + test("managed state is not modified if the same value is set", () => { + let manager = createStateManager() + let state = manager.mutableState(200) + for (let index = 0; index <= 200; index++) { + state.value = index + } + Assert.equal(testUpdate(false, manager), 0) + assertState(state, 200) + }) + test("unmanaged named state does not exist anymore", () => { + let manager = createStateManager() + const state = manager.namedState("named", (): float64 => 200) + Assert.equal(state, manager.stateBy("named")!) + Assert.isDefined(manager.stateBy("named")) + state.dispose() + Assert.isUndefined(manager.stateBy("named")) + state.dispose() + Assert.isUndefined(manager.stateBy("named")) + }) + test("managed named state is not modified immediately", () => { + let manager = createStateManager() + manager.frozen = true + manager.namedState("named", (): float64 => 200) + manager.stateBy("named")!.value = 404 + Assert.equal(manager.valueBy("named"), 200) + Assert.isFalse(manager.stateBy("named")?.modified) + }) + test("managed named state is modified on first snapshot update", () => { + let manager = createStateManager() + manager.namedState("named", (): float64 => 200) + manager.stateBy("named")!.value = 404 + Assert.equal(testUpdate(false, manager), 1) + Assert.equal(manager.valueBy("named"), 404) + Assert.isTrue(manager.stateBy("named")?.modified) + }) + test("managed named state is not modified on next snapshot update", () => { + let manager = createStateManager() + manager.namedState("named", (): float64 => 200) + manager.stateBy("named")!.value = 404 + Assert.equal(testUpdate(false, manager), 1) + Assert.equal(testUpdate(false, manager), 0) + Assert.equal(manager.valueBy("named"), 404) + Assert.isFalse(manager.stateBy("named")?.modified) + }) + test("managed named state is not modified if the same value is set", () => { + let manager = createStateManager() + manager.namedState("named", (): float64 => 200) + for (let index = 0; index <= 200; index++) { + manager.stateBy("named")!.value = index + } + Assert.equal(testUpdate(false, manager), 0) + Assert.equal(manager.valueBy("named"), 200) + Assert.isFalse(manager.stateBy("named")?.modified) + }) + test("do not allow to dispose parameter state", () => { + const name = "parameter" + const manager = createStateManager() + manager.computableState((context: StateContext) => { + const scope = context.scope(0, 1) + const param = scope.param(0, 200, undefined, name, true) // can be found by name + if (scope.unchanged) { scope.cached } else { + const state = manager.stateBy(name)! + Assert.isDefined(state) + Assert.equal>(state, param) + Assert.throws(() => { state.dispose() }) + scope.recache() + } + return undefined + }).value + }) + test("managed parameter state is modified immediately", () => { + const name = "parameter" + const manager = createStateManager() + manager.computableState((context: StateContext) => { + const scope = context.scope(0, 1) + const param = scope.param(0, 200, undefined, name, true) // can be found by name + if (scope.unchanged) { scope.cached } else { + const state = manager.stateBy(name)! + Assert.isDefined(state) + Assert.equal>(state, param) + state.value = 404 + assertModifiedState(state, 404) + // check that modified state is updated + state.value = 404 + assertState(state, 404) + scope.recache() + } + return undefined + }).value + }) + test("updatable node should be recomputable state", () => { + const manager = createStateManager() + const mutableState = manager.mutableState(true) + const updatableNode = manager.updatableNode(new IncrementalNode(), (_: StateContext) => { mutableState.value }) + // updatable node needs to be recomputed after creation + Assert.isTrue(updatableNode.recomputeNeeded) + updatableNode.value + // updatable node is already computed after accessing + Assert.isFalse(updatableNode.recomputeNeeded) + Assert.equal(testUpdate(false, manager), 0) + // updatable node is already computed because nothing is changed + Assert.isFalse(updatableNode.recomputeNeeded) + mutableState.value = !mutableState.value + // updatable node does not know that the mutable state is changed + Assert.isFalse(updatableNode.recomputeNeeded) + Assert.equal(testUpdate(false, manager), 1) + // updatable node needs to be recomputed because the mutable state is changed + Assert.isTrue(updatableNode.recomputeNeeded) + }) + test("updatable node should not use StateManager.updateSnapshot()", () => { + const manager = createStateManager() + const state = manager.updatableNode(new IncrementalNode(), (_: StateContext) => { + manager.updateSnapshot() + }) + Assert.throws(() => { state.value }) + }) + test("updatable node should not use StateManager.updatableNode(...)", () => { + const manager = createStateManager() + const state = manager.updatableNode(new IncrementalNode(), (_: StateContext) => { + manager.updatableNode(new IncrementalNode(), (_: StateContext) => { }) + }) + Assert.throws(() => { state.value }) + }) + test("updatable node should not use StateManager.computableState(...)", () => { + const manager = createStateManager() + const state = manager.updatableNode(new IncrementalNode(), (_: StateContext) => { manager.updateSnapshot() }) + Assert.throws(() => { state.value }) + }) + test("computable state should be recomputable state", () => { + const manager = createStateManager() + const mutableState = manager.mutableState(true) + const computableState = manager.computableState((_: StateContext) => mutableState.value) + // computable state needs to be recomputed after creation + Assert.isTrue(computableState.recomputeNeeded) + computableState.value + // computable state is already computed after accessing + Assert.isFalse(computableState.recomputeNeeded) + Assert.equal(testUpdate(false, manager), 0) + // computable state is already computed because nothing is changed + Assert.isFalse(computableState.recomputeNeeded) + mutableState.value = !mutableState.value + // computable state does not know that the mutable state is changed + Assert.isFalse(computableState.recomputeNeeded) + Assert.equal(testUpdate(false, manager), 1) + // computable state needs to be recomputed because the mutable state is changed + Assert.isTrue(computableState.recomputeNeeded) + }) + test("computable state should not use StateManager.updateSnapshot()", () => { + const manager = createStateManager() + const state = manager.computableState((_: StateContext) => { + manager.updateSnapshot() + return undefined + }) + Assert.throws(() => { state.value }) + }) + test("computable state should not use StateManager.updatableNode(...)", () => { + const manager = createStateManager() + const state = manager.computableState((_: StateContext) => manager.updatableNode(new IncrementalNode(), (_: StateContext) => { })) + Assert.throws(() => { state.value }) + }) + test("computable state depends on managed state", () => { + let manager = createStateManager() + let name = manager.mutableState("NAME") + // create computable state that tracks computing inner scopes + let computing = new Array() + let result = manager.computableState((context: StateContext) => { + computing.push("main") + return context.compute(key("left"), () => { + computing.push("left") + return "<= " + }) + context.compute(key("name"), () => { + computing.push("name") + return name.value + }) + context.compute(key("right"), () => { + computing.push("right") + return " =>" + }) + }) + // initial computation + assertState(result, "<= NAME =>") + assertStringsAndCleanup(computing, "main ; left ; name ; right") + // computable state is not modified + Assert.equal(testUpdate(false, manager), 0) + assertState(result, "<= NAME =>") + Assert.isEmpty(computing) + // compute state only when snapshot updated + name.value = "Sergey Malenkov" + Assert.equal(testUpdate(false, manager), 1) + assertModifiedState(result, "<= Sergey Malenkov =>") + assertStringsAndCleanup(computing, "main ; name") + }) + test("computable state depends on named state managed globally", () => { + let manager = createStateManager() + // create named scope managed globally and schedule its updating + manager.namedState("global", () => "NAME") + // create computable state that tracks computing inner scopes + let computing = new Array() + let result = manager.computableState((context: StateContext) => { + computing.push("main") + return context.compute(key("left"), () => { + computing.push("left") + return "<= " + }) + context.compute(key("name"), () => { + computing.push("name") + return context.valueBy("global") + }) + context.compute(key("right"), () => { + computing.push("right") + return " =>" + }) + }) + // initial computation + assertState(result, "<= NAME =>") + assertStringsAndCleanup(computing, "main ; left ; name ; right") + // computable state is not modified + Assert.equal(testUpdate(false, manager), 0) + assertState(result, "<= NAME =>") + Assert.isEmpty(computing) + // compute state only when snapshot updated + manager.stateBy("global")!.value = "Sergey Malenkov" + Assert.equal(testUpdate(false, manager), 1) + assertModifiedState(result, "<= Sergey Malenkov =>") + assertStringsAndCleanup(computing, "main ; name") + }) + test("computable state depends on named state managed locally", () => { + let manager = createStateManager() + // create computable state that tracks computing inner scopes + let computing = new Array() + let result = manager.computableState((context: StateContext) => { + computing.push("main") + return context.compute(key("left"), () => { + computing.push("left") + return "<= " + }) + context.compute(key("name"), () => { + computing.push("name") + const state = context.namedState("local", (): float64 => 1) + manager.scheduleCallback(() => { state.value++ }) + return state.value + }) + context.compute(key("right"), () => { + computing.push("right") + return " =>" + }) + }) + // initial computation + assertState(result, "<= 1 =>") + assertStringsAndCleanup(computing, "main ; left ; name ; right") + // computable state is not modified + assertState(result, "<= 1 =>") + Assert.isEmpty(computing) + // compute state only when snapshot updated + Assert.equal(testUpdate(true, manager), 1) + assertModifiedState(result, "<= 2 =>") + assertStringsAndCleanup(computing, "main ; name") + // compute state on next snapshot update + Assert.equal(testUpdate(true, manager), 1) + assertModifiedState(result, "<= 3 =>") + assertStringsAndCleanup(computing, "main ; name") + }) + test("computable state depends on named state managed locally from managed inner scope", () => { + let manager = createStateManager() + let computing = new Array() + let result = manager.computableState((context: StateContext) => { + context.namedState("local", (): float64 => 1) + computing.push("main") + return context.compute(key("left"), () => { + computing.push("left") + return "<= " + }) + context.compute(key("name"), () => { + computing.push("name") + const state = context.stateBy("local")! + manager.scheduleCallback(() => { state.value++ }) + return context.valueBy("local") + }) + context.compute(key("right"), () => { + computing.push("right") + return " =>" + }) + }) + // initial computation + assertState(result, "<= 1 =>") + assertStringsAndCleanup(computing, "main ; left ; name ; right") + // computable state is not modified + assertState(result, "<= 1 =>") + Assert.isEmpty(computing) + // compute state only when snapshot updated + Assert.equal(testUpdate(true, manager), 1) + assertModifiedState(result, "<= 2 =>") + assertStringsAndCleanup(computing, "main ; name") + // compute state on next snapshot update + Assert.equal(testUpdate(true, manager), 1) + assertModifiedState(result, "<= 3 =>") + assertStringsAndCleanup(computing, "main ; name") + }) + test("computable state allows to cleanup disposed scopes", () => { + let manager = createStateManager() + let computing = new Array() + let result = manager.computableState((context: StateContext) => { + let name = context.compute(key("value"), () => { + computing.push("compute:value") + return "value" + }) + let condition = context.compute(key("condition"), () => { + computing.push("compute:condition") + return context.valueBy("condition") + }) + let value = condition + ? context.compute(key("true"), () => { + computing.push("compute:true") + return context.compute(key("true"), () => { + context.namedState("true", () => true) + computing.push("compute:inner:true") + return "true" + }, (old: string | undefined) => { + Assert.isUndefined(context.stateBy("false")) + Assert.isDefined(context.stateBy("true")) + Assert.isTrue(context.valueBy("true")) + Assert.equal(old, "true") + computing.push("cleanup:inner:true") + }) + }, (_: string | undefined) => { computing.push("cleanup:true") }) + : context.compute(key("false"), () => { + computing.push("compute:false") + return context.compute(key("false"), () => { + context.namedState("false", () => false) + computing.push("compute:inner:false") + return "false" + }, (old: string | undefined) => { + Assert.isUndefined(context.stateBy("true")) + Assert.isDefined(context.stateBy("false")) + Assert.isFalse(context.valueBy("false")) + Assert.equal(old, "false") + computing.push("cleanup:inner:false") + }) + }, (_: string | undefined) => { computing.push("cleanup:false") }) + return name + " is " + value + }) + let condition = manager.namedState("condition", () => true) + // initial computation + Assert.equal(result.value, "value is true") + assertStringsAndCleanup(computing, "compute:value ; compute:condition ; compute:true ; compute:inner:true") + // condition changed from true to false + condition.value = false + Assert.equal(testUpdate(false, manager), 1) + Assert.equal(result.value, "value is false") + assertStringsAndCleanup(computing, "compute:condition ; compute:false ; compute:inner:false ; cleanup:true ; cleanup:inner:true") + // condition changed from false to true + condition.value = true + Assert.equal(testUpdate(false, manager), 1) + Assert.equal(result.value, "value is true") + assertStringsAndCleanup(computing, "compute:condition ; compute:true ; compute:inner:true ; cleanup:false ; cleanup:inner:false") + }) + test("global named state must be created only once", () => { + let manager = createStateManager() + let created = manager.namedState("named", (): int32 => 200) + let existed = manager.namedState("named", (): int32 => { + Assert.fail() + return 200 + }) + Assert.equal(created, existed) + Assert.equal(created, manager.stateBy("named")!) + Assert.equal(existed, manager.stateBy("named")!) + }) + test("local named state must be created only once", () => { + createStateManager().computableState((context: StateContext) => { + let created = context.namedState("named", (): int32 => 200) + let existed = context.namedState("named", (): int32 => { + Assert.fail() + return 200 + }) + Assert.equal(created, existed) + Assert.equal(created, context.stateBy("named")!) + Assert.equal(existed, context.stateBy("named")!) + return undefined + }).value + }) + test("global named state must not be created when creating another one", () => { + let manager = createStateManager() + manager.namedState("named", () => { + Assert.throws(() => { + manager.namedState("unnamed", () => 200) + }) + return 200 + }) + }) + test("local named state must not be created when creating another one", () => { + createStateManager().computableState((context: StateContext) => { + context.namedState("named", (): float64 => { + Assert.throws(() => { + context.namedState("unnamed", (): float64 => 200) + }) + return 200 + }) + return undefined + }).value + }) + test("do not allow to dispose global mutable state when creating global named state", () => { + const manager = createStateManager() + const mutable = manager.mutableState("value") + manager.namedState("prohibited", () => { + Assert.throws(() => { mutable.dispose() }) + return mutable.value + }) + }) + test("do not allow to dispose global mutable state when creating local named state", () => { + const manager = createStateManager() + const mutable = manager.mutableState("value") + const state = manager.computableState((context: StateContext) => { + context.namedState("prohibited", () => { + Assert.throws(() => { mutable.dispose() }) + return mutable.value + }) + return undefined + }) + state.value + state.dispose() + }) + test("do not allow to dispose global named state when creating global named state", () => { + const manager = createStateManager() + const named = manager.namedState("state", () => "value") + manager.namedState("prohibited", () => { + Assert.equal(named, manager.stateBy("state")!) + Assert.throws(() => { named.dispose() }) + return named.value + }) + }) + test("do not allow to dispose local named state when creating local named state", () => { + const manager = createStateManager() + const state = manager.computableState((context: StateContext) => { + const named = context.namedState("state", () => "") + context.namedState("prohibited", () => { + Assert.equal(named, manager.stateBy("state")!) + Assert.throws(() => { named.dispose() }) + return named.value + }) + return undefined + }) + state.value + state.dispose() + }) + test("do not allow to dispose global mutable state when updating computable state", () => { + const manager = createStateManager() + const mutable = manager.mutableState("value") + const state = manager.computableState((_: StateContext) => { + Assert.throws(() => { mutable.dispose() }) + return undefined + }) + state.value + state.dispose() + }) + test("do not allow to dispose global named state when updating computable state", () => { + const manager = createStateManager() + const named = manager.namedState("state", () => "") + const state = manager.computableState((_: StateContext) => { + Assert.throws(() => { named.dispose() }) + return undefined + }) + state.value + state.dispose() + }) + test("do not allow to dispose local named state when updating computable state", () => { + const manager = createStateManager() + const state = manager.computableState((context: StateContext) => { + const named = context.namedState("state", () => "") + Assert.throws(() => { named.dispose() }) + return undefined + }) + state.value + state.dispose() + }) + test("do not allow to update snapshot when updating computable state", () => { + const manager = createStateManager() + const state = manager.computableState((context: StateContext) => { + Assert.equal(context, manager) + Assert.throws(() => { manager.updateSnapshot() }) + return undefined + }) + state.value + state.dispose() + }) + test("do not allow to create updatable node when updating computable state", () => { + const manager = createStateManager() + const state = manager.computableState((context: StateContext) => { + Assert.equal(context, manager) + Assert.throws(() => { manager.updatableNode(new TestNode(), (_: StateContext) => { }) }) + return undefined + }) + state.value + state.dispose() + }) + test("computable state must not compute something when creating local named state", () => { + createStateManager().computableState((context: StateContext) => { + context.namedState("name", () => { + Assert.throws(() => { + context.compute(key("compute"), () => 200) + }) + return "NAME" + }) + return context.valueBy("name") + }).value + }) + test("computable state must not depend on managed state when creating another one", () => { + let manager = createStateManager() + let mutable = manager.mutableState("NAME") + let computable = manager.computableState((context: StateContext) => { + context.namedState("name", () => mutable.value) + return context.valueBy("name") + }) + // initial computation + assertState(computable, "NAME") + // do not update result when snapshot updated + mutable.value = "Sergey Malenkov" + Assert.equal(testUpdate(false, manager), 1) + assertState(computable, "NAME") + }) + test("computable state from specific scope must be forgotten on dispose automatically", () => { + const manager = createStateManager() + const state = manager.mutableState(-1) + const selector = manager.mutableState(true) + const computable = manager.computableState((context: StateContext) => selector.value + ? context.compute(key("first"), () => context.computableState((_: StateContext): int32 => state.value), undefined, true) + : context.compute(key("second"), () => context.computableState((_: StateContext): int32 => state.value), undefined, true)) + // initial computation + const initial = computable.value + assertState(initial, -1) + // ensure that initial state is managed + state.value = -10 + assertState(initial, -1) + Assert.equal(testUpdate(false, manager), 1) + assertModifiedState(state, -10) + assertModifiedState(initial, -10) + // dispose first inner scope + Assert.strictEqual(computable.value, initial) + selector.value = false + Assert.equal(testUpdate(false, manager), 1) + Assert.notStrictEqual(computable.value, initial) + // ensure that initial state is not managed + assertState(initial, -10) + state.value = -100 + Assert.equal(testUpdate(false, manager), 1) + assertState(initial, -10) + }) + test("named state from specific scope must be forgotten on dispose automatically", () => { + const manager = createStateManager() + manager.frozen = true + const selector = manager.mutableState(true) + const computable = manager.computableState((context: StateContext) => selector.value + ? context.compute(key("first"), () => context.namedState("name", (): int32 => -1)) + : context.compute(key("second"), () => context.namedState("name", (): int32 => 1))) + // initial computation + const initial = computable.value + assertState(initial, -1) + // ensure that initial state is managed + initial.value = -10 + assertState(initial, -1) + Assert.equal(testUpdate(false, manager), 1) + assertModifiedState(initial, -10) + // dispose first inner scope + Assert.strictEqual(computable.value, initial) + selector.value = false + Assert.equal(testUpdate(false, manager), 1) + Assert.notStrictEqual(computable.value, initial) + // ensure that initial state is not managed + assertState(initial, -10) + initial.value = -100 + assertModifiedState(initial, -100) + }) + test("mutable state from specific scope must be forgotten on dispose too", () => { + const manager = createStateManager() + manager.frozen = true + const selector = manager.mutableState(true) + const computable = manager.computableState((context: StateContext) => selector.value + ? context.compute(key("first"), () => context.mutableState(-1), undefined, true) + : context.compute(key("second"), () => context.mutableState(1), undefined, true)) + // initial computation + const initial = computable.value + assertState(initial, -1) + // ensure that initial state is managed + initial.value = -10 + assertState(initial, -1) + Assert.equal(testUpdate(false, manager), 1) + assertModifiedState(initial, -10) + // dispose first inner scope + Assert.strictEqual(computable.value, initial) + selector.value = false + Assert.equal(testUpdate(false, manager), 1) + Assert.notStrictEqual(computable.value, initial) + // ensure that initial state is not managed + assertState(initial, -10) + initial.value = -100 + assertModifiedState(initial, -100) + }) + test("mutable state must not be changed during recomposition", () => { + const manager = createStateManager() + const state = manager.mutableState(0 as float64) + const increment = () => { + Assert.throws(() => { state.value++ }) + return state.value + } + const computable = manager.computableState((context: StateContext): float64 => + context.compute(key("a"), increment) + + context.compute(key("b"), increment) + + context.compute(key("c"), increment)) + Assert.equal(computable.value, 0) + Assert.equal(testUpdate(false, manager), 0) + Assert.equal(computable.value, 0) + state.value++ + Assert.equal(testUpdate(false, manager), 1) + Assert.equal(computable.value, 3) + }) + test("allow to compute once within a leaf scope", () => { + const computable = createStateManager().computableState((context: StateContext) => + context.compute(key("leaf"), () => + context.compute(key("allowed"), (): float64 => 0, undefined, true), + undefined, true)) + Assert.equal(computable.value, 0) + }) + test("create global mutable state in local context", () => { + const manager = createStateManager() + const computable = manager.computableState((context: StateContext) => context.mutableState(0 as float64, true)) + const globalState = computable.value + Assert.equal("GlobalState=0", globalState.toString()) + globalState.value = 1 + Assert.equal(testUpdate(false, manager), 1) + Assert.equal("GlobalState,modified=1", globalState.toString()) + Assert.equal(testUpdate(false, manager), 0) + computable.dispose() + Assert.equal("GlobalState=1", globalState.toString()) + globalState.dispose() + Assert.equal("GlobalState,disposed=1", globalState.toString()) + }) + test("create local mutable state in local context within remember", () => { + const manager = createStateManager() + const computable = manager.computableState((context: StateContext) => context.compute(0, () => context.mutableState(0 as float64, false), undefined, true)) + const localState = computable.value + Assert.equal("LocalState=0", localState.toString()) + localState.value = 1 + Assert.equal(testUpdate(false, manager), 1) + Assert.equal("LocalState,modified=1", localState.toString()) + Assert.equal(testUpdate(false, manager), 0) + computable.dispose() + Assert.equal("LocalState,disposed=1", localState.toString()) + localState.dispose() + Assert.equal("LocalState,disposed=1", localState.toString()) + }) + test("create global named state in local context", () => { + const manager = createStateManager() + const computable = manager.computableState((context: StateContext) => { + const state = context.namedState("global", (): int32 => 0, true) + Assert.equal(state, manager.stateBy("global")!) + Assert.isDefined(manager.stateBy("global", true)) + Assert.isUndefined(manager.stateBy("global", false)) + return state + }) + const globalState = computable.value + Assert.equal(globalState, manager.stateBy("global")!) + Assert.equal("GlobalState(global)=0", globalState.toString()) + globalState.value = 1 + Assert.equal(testUpdate(false, manager), 1) + Assert.equal("GlobalState(global),modified=1", globalState.toString()) + Assert.equal(testUpdate(false, manager), 0) + computable.dispose() + Assert.equal("GlobalState(global)=1", globalState.toString()) + globalState.dispose() + Assert.equal("GlobalState(global),disposed=1", globalState.toString()) + }) + test("create local named state in local context", () => { + const manager = createStateManager() + const globalState = manager.namedState("global", (): float64 => Number.MAX_SAFE_INTEGER + 1) + const computable = manager.computableState((context: StateContext) => { + Assert.equal(globalState, manager.stateBy("global")!) + Assert.isDefined(manager.stateBy("global", true)) + Assert.isUndefined(manager.stateBy("global", false)) + const state = context.namedState("local", (): float64 => 0, false) + Assert.equal(state, manager.stateBy("local")!) + Assert.isUndefined(manager.stateBy("local", true)) + Assert.isDefined(manager.stateBy("local", false)) + return state + }) + const localState = computable.value + Assert.isUndefined(manager.stateBy("local")) + Assert.equal("LocalState(local)=0", localState.toString()) + localState.value = 1 + Assert.equal(testUpdate(false, manager), 1) + Assert.equal("LocalState(local),modified=1", localState.toString()) + Assert.equal(testUpdate(false, manager), 0) + computable.dispose() + Assert.equal("LocalState(local),disposed=1", localState.toString()) + localState.dispose() + Assert.equal("LocalState(local),disposed=1", localState.toString()) + }) + test("prohibit to create local mutable state in global context", () => { + Assert.throws(() => { createStateManager().mutableState(0, false) }) + }) + test("prohibit to create local named state in global context", () => { + Assert.throws(() => { createStateManager().namedState("name", (): int32 => 0, false) }) + }) + test("prohibit to create local mutable state in local context", () => { + const computable = createStateManager().computableState((context: StateContext) => context.mutableState(0, false)) + Assert.throws(() => { computable.value }) + }) + test("prohibit to compute within a leaf scope", () => { + const computable = createStateManager().computableState((context: StateContext) => + context.compute(key("leaf"), () => + context.compute(key("prohibit"), (): float64 => 0), + undefined, true)) + Assert.throws(() => { computable.value }) + }) + test("prohibit to build tree within a leaf scope", () => { + const computable = createStateManager().updatableNode(new TestNode(), (context: StateContext) => { + context.compute(key("leaf"), () => { + context.attach(key("prohibit"), () => new TestNode(), () => { }) + return undefined + }, undefined, true) + }) + Assert.throws(() => { computable.value }) + }) + test("prohibit to build tree within a computable state", () => { + const computable = createStateManager().computableState((context: StateContext) => { + context.attach(key("prohibit"), () => new TestNode(), () => { }) + return undefined + }) + Assert.throws(() => { computable.value }) + }) + test("leaf scope must not depend on managed state", () => { + const manager = createStateManager() + const state = manager.mutableState(0) + const computing = new Array() + const computable = manager.computableState((context: StateContext) => { + computing.push("computable") + return context.compute(key("name"), () => { + computing.push("name") + return state.value + }, undefined, true) + }) + // initial computation + assertState(computable, 0) + assertStringsAndCleanup(computing, "computable ; name") + // compute state only when snapshot updated + state.value = -1 + Assert.equal(testUpdate(false, manager), 1) + assertState(computable, 0) + Assert.isEmpty(computing) + }) + test("0. amount of modified states including computable states that have dependants", () => { + const manager = createStateManager() + const mutable = manager.mutableState(false) + let computableCounter = 0 + const computable = manager.computableState((_: StateContext) => { + computableCounter++ + return mutable.value + }) + let stateCounter = 0 + const state = manager.computableState((_: StateContext) => { + stateCounter++ + return computable.value + }) + Assert.equal(testUpdate(false, manager), 0) + Assert.equal(computableCounter, 0) // computable is not recomputed + Assert.equal(stateCounter, 0) // state is not recomputed + assertState(state, false) + Assert.equal(computableCounter, 1) // computable is recomputed + Assert.equal(stateCounter, 1) // state is recomputed + mutable.value = true + Assert.equal(testUpdate(false, manager), 2) + Assert.equal(computableCounter, 2) // computable is recomputed automatically + Assert.equal(stateCounter, 1) // state is not recomputed + assertModifiedState(state, true) + Assert.equal(computableCounter, 2) // computable is not recomputed + Assert.equal(stateCounter, 2) // state is recomputed by request + }) + test("1. amount of modified states including computable states that have dependants", () => { + const manager = createStateManager() + const mutable = manager.mutableState(false) + let computableCounter = 0 + const computable = manager.computableState((_: StateContext) => { + computableCounter++ + const value = mutable.value + return value && false + }) + let stateCounter = 0 + const state = manager.computableState((_: StateContext) => { + stateCounter++ + return computable.value + }) + Assert.equal(testUpdate(false, manager), 0) + Assert.equal(computableCounter, 0) // computable is not recomputed + Assert.equal(stateCounter, 0) // state is not recomputed + assertState(state, false) + Assert.equal(computableCounter, 1) // computable is recomputed + Assert.equal(stateCounter, 1) // state is recomputed + mutable.value = true + Assert.equal(testUpdate(false, manager), 1) + Assert.equal(computableCounter, 2) // computable is recomputed automatically + Assert.equal(stateCounter, 1) // state is not recomputed + assertState(state, false) + Assert.equal(computableCounter, 2) // computable is not recomputed + Assert.equal(stateCounter, 1) // state is not recomputed because computable is not modified + }) + test("2. amount of modified states including computable states that have dependants", () => { + const manager = createStateManager() + const mutable = manager.mutableState(false) + let computableCounter = 0 + const computable = manager.computableState((_: StateContext) => { + computableCounter++ + return mutable.value + }) + let stateCounter = 0 + const state = manager.computableState((_: StateContext) => { + stateCounter++ + const value = computable.value + return value && false + }) + Assert.equal(testUpdate(false, manager), 0) + Assert.equal(computableCounter, 0) // computable is not recomputed + Assert.equal(stateCounter, 0) // state is not recomputed + assertState(state, false) + Assert.equal(computableCounter, 1) // computable is recomputed + Assert.equal(stateCounter, 1) // state is recomputed + mutable.value = true + Assert.equal(testUpdate(false, manager), 2) + Assert.equal(computableCounter, 2) // computable is recomputed automatically + Assert.equal(stateCounter, 1) // state is not recomputed + assertState(state, false) + Assert.equal(computableCounter, 2) // computable is not recomputed + Assert.equal(stateCounter, 2) // state is recomputed by request but it is not modified + }) + test("build and update simple tree", () => { + let manager = createStateManager() + let count = manager.mutableState(30) + let first = manager.mutableState("first node") + let second = manager.mutableState("second node") + let computing = new Array() + const rootNode = new TestNode() + let firstNode: TestNode + let secondNode: TestNode + let root = manager.updatableNode(rootNode, (context: StateContext) => { + computing.push("update root") + Assert.equal(context.node, rootNode) + context.compute(key("init"), () => { + computing.push("init root") + Assert.equal(context.node, rootNode) + rootNode.content = "root" + return undefined + }) + if (count.value < 40) { + context.attach(key("first"), () => { + computing.push("create first") + Assert.equal(context.node, undefined) + return firstNode = new TestNode() + }, () => { + computing.push("update first") + Assert.equal(context.node, firstNode) + context.compute(key("init"), () => { + computing.push("init first") + Assert.equal(context.node, firstNode) + firstNode.content = first.value + return undefined + }) + }, () => { + computing.push("detach&dispose first") + Assert.equal(context.node, firstNode) + }) + } + if (count.value > 20) { + context.attach(key("second"), () => { + computing.push("create second") + Assert.equal(context.node, undefined) + return secondNode = new TestNode() + }, () => { + computing.push("update second") + Assert.equal(context.node, secondNode) + context.compute(key("init"), () => { + computing.push("init second") + Assert.equal(context.node, secondNode) + secondNode.content = second.value + return undefined + }) + }, () => { + computing.push("detach&dispose second") + Assert.equal(context.node, secondNode) + }) + } + }) + assertNode(root, + "root\n" + + " first node\n" + + " second node") + + assertStringsAndCleanup(computing, "update root ; init root ; create first ; update first ; init first ; create second ; update second ; init second") + + Assert.equal(testUpdate(false, manager), 0) + assertNode(root, + "root\n" + + " first node\n" + + " second node") + + Assert.isEmpty(computing) + + count.value = 20 + Assert.equal(testUpdate(false, manager), 1) + assertNode(root, + "root\n" + + " first node") + + assertStringsAndCleanup(computing, "update root ; detach&dispose second") + + second.value = "last node" + Assert.equal(testUpdate(false, manager), 1) + assertNode(root, + "root\n" + + " first node") + + Assert.isEmpty(computing) + + count.value = 40 + Assert.equal(testUpdate(false, manager), 1) + assertNode(root, + "root\n" + + " last node") + + assertStringsAndCleanup(computing, "update root ; create second ; update second ; init second ; detach&dispose first") + + count.value = 30 + Assert.equal(testUpdate(false, manager), 1) + assertNode(root, + "root\n" + + " first node\n" + + " last node") + + assertStringsAndCleanup(computing, "update root ; create first ; update first ; init first") + + count.value = 40 + Assert.equal(testUpdate(false, manager), 1) + assertNode(root, + "root\n" + + " last node") + + assertStringsAndCleanup(computing, "update root ; detach&dispose first") + + second.value = "second node" + Assert.equal(testUpdate(false, manager), 1) + assertNode(root, + "root\n" + + " second node") + + assertStringsAndCleanup(computing, "update root ; update second ; init second") + }) + test("build and update deep tree", () => { + let manager = createStateManager() + manager.namedState("parent", () => "parent") + manager.namedState("child", () => "child") + manager.namedState("leaf", () => "leaf") + let computing = new Array() + const rootNode = new TestNode() + let parentNode: TestNode + let childNode: TestNode + let leafNode: TestNode + let root = manager.updatableNode(rootNode, (context: StateContext) => { + computing.push("update root") + Assert.equal(context.node, rootNode) + context.compute(key("init"), () => { + computing.push("init root") + Assert.equal(context.node, rootNode) + rootNode.content = "root" + return undefined + }) + if (context.valueBy("parent").length > 0) { + context.attach(key("parent"), () => { + computing.push("create parent") + Assert.equal(context.node, undefined) + return parentNode = new TestNode() + }, () => { + computing.push("update parent") + Assert.equal(context.node, parentNode) + context.compute(key("init"), () => { + computing.push("init parent") + Assert.equal(context.node, parentNode) + parentNode.content = context.valueBy("parent") + return undefined + }) + if (context.valueBy("child").length > 0) { + context.attach(key("child"), () => { + computing.push("create child") + Assert.equal(context.node, undefined) + return childNode = new TestNode() + }, () => { + computing.push("update child") + Assert.equal(context.node, childNode) + context.compute(key("init"), () => { + computing.push("init child") + Assert.equal(context.node, childNode) + childNode.content = context.valueBy("child") + return undefined + }) + if (context.valueBy("leaf").length > 0) { + context.attach(key("leaf"), () => { + computing.push("create leaf") + Assert.equal(context.node, undefined) + return leafNode = new TestNode() + }, () => { + computing.push("update leaf") + Assert.equal(context.node, leafNode) + context.compute(key("init"), () => { + computing.push("init leaf") + Assert.equal(context.node, leafNode) + leafNode.content = context.valueBy("leaf") + return undefined + }) + }, () => { + computing.push("detach&dispose leaf") + Assert.equal(context.node, leafNode) + }) + } + }, () => { + computing.push("detach&dispose child") + Assert.equal(context.node, childNode) + }) + } + }, () => { + computing.push("detach&dispose parent") + Assert.equal(context.node, parentNode) + }) + } + }) + assertNode(root, + "root\n" + + " parent\n" + + " child\n" + + " leaf") + + assertStringsAndCleanup(computing, "update root ; init root ; create parent ; update parent ; init parent ; create child ; update child ; init child ; create leaf ; update leaf ; init leaf") + + Assert.equal(testUpdate(false, manager), 0) + assertNode(root, + "root\n" + + " parent\n" + + " child\n" + + " leaf") + + Assert.isEmpty(computing) + + manager.stateBy("leaf")!.value = "leaf node" + Assert.equal(testUpdate(false, manager), 1) + assertNode(root, + "root\n" + + " parent\n" + + " child\n" + + " leaf node") + + assertStringsAndCleanup(computing, "update root ; update parent ; update child ; update leaf ; init leaf") + + manager.stateBy("parent")!.value = "" + Assert.equal(testUpdate(false, manager), 1) + assertNode(root, + "root") + + assertStringsAndCleanup(computing, "update root ; detach&dispose parent ; detach&dispose child ; detach&dispose leaf") + + manager.stateBy("child")!.value = "child node" + Assert.equal(testUpdate(false, manager), 1) + assertNode(root, + "root") + + Assert.isEmpty(computing) + + manager.stateBy("parent")!.value = "parent node" + Assert.equal(testUpdate(false, manager), 1) + assertNode(root, + "root\n" + + " parent node\n" + + " child node\n" + + " leaf node") + + assertStringsAndCleanup(computing, "update root ; create parent ; update parent ; init parent ; create child ; update child ; init child ; create leaf ; update leaf ; init leaf") + + manager.stateBy("leaf")!.value = "" + Assert.equal(testUpdate(false, manager), 1) + assertNode(root, + "root\n" + + " parent node\n" + + " child node") + + assertStringsAndCleanup(computing, "update root ; update parent ; update child ; detach&dispose leaf") + }) + test("schedule state updating to the next frame", () => { + const manager = createStateManager() + const state = manager.mutableState(0) + manager.scheduleCallback(() => { state.value = 10 }) + assertState(state, 0) + // first frame + Assert.equal(testUpdate(true, manager), 1) + assertModifiedState(state, 10) + }) + test("schedule state updating to the second next frame", () => { + const manager = createStateManager() + const state = manager.mutableState(0) + manager.scheduleCallback(() => { manager.scheduleCallback(() => { state.value = 10 }) }) + assertState(state, 0) + // first frame + Assert.equal(testUpdate(true, manager), 0) + assertState(state, 0) + // second frame + Assert.equal(testUpdate(true, manager), 1) + assertModifiedState(state, 10) + }) + test("schedule state updating to the third next frame", () => { + const manager = createStateManager() + const state = manager.mutableState(0) + manager.scheduleCallback(() => { manager.scheduleCallback(() => { manager.scheduleCallback(() => { state.value = 10 }) }) }) + assertState(state, 0) + // first frame + Assert.equal(testUpdate(true, manager), 0) + assertState(state, 0) + // second frame + Assert.equal(testUpdate(true, manager), 0) + assertState(state, 0) + // third frame + Assert.equal(testUpdate(true, manager), 1) + assertModifiedState(state, 10) + }) +}) + + +class Data { + name: string + value: float64 + + constructor(name: string, value: float64) { + this.name = name + this.value = value + } + + static equivalent(oldD: Data, newD: Data): boolean { + return oldD.name == newD.name && oldD.value == newD.value + } +} + +suite("Equivalent", () => { + const age16 = new Data("age", 16) + test("initial state is not modified", () => { + const manager = createStateManager() + const state = manager.mutableState(age16, undefined, Data.equivalent) + assertState(state, age16) + Assert.equal(testUpdate(false, manager), 0) + assertState(state, age16) + }) + test("state is modified on first snapshot update", () => { + const manager = createStateManager() + const state = manager.mutableState(age16, undefined, Data.equivalent) + assertState(state, age16) + const age64 = new Data("age", 64) + Assert.notEqual(age16, age64) + state.value = age64 + Assert.equal(testUpdate(false, manager), 1) + assertModifiedState(state, age64) + Assert.notEqual(state.value, age16) + }) + test("state is not modified on next snapshot update", () => { + const manager = createStateManager() + const state = manager.mutableState(age16, undefined, Data.equivalent) + assertState(state, age16) + const age64 = new Data("age", 64) + state.value = age64 + Assert.equal(testUpdate(false, manager), 1) + assertModifiedState(state, age64) + Assert.notEqual(state.value, age16) + Assert.equal(testUpdate(false, manager), 0) + assertState(state, age64) + }) + test("state is not modified if values are equivalent, but returns new value", () => { + const manager = createStateManager() + const state = manager.mutableState(age16, undefined, Data.equivalent) + assertState(state, age16) + const equal = new Data("age", 16) + Assert.notEqual(equal, age16) + Assert.isTrue(Data.equivalent(equal, age16)) + state.value = equal + Assert.equal(testUpdate(false, manager), 0) + assertState(state, equal) + Assert.notEqual(state.value, age16) + }) + test("frozen state is not modified if values are equivalent, but returns new value", () => { + const manager = createStateManager() + manager.frozen = true // NB! + const state = manager.mutableState(age16, undefined, Data.equivalent) + assertState(state, age16) + const equal = new Data("age", 16) + Assert.notEqual(equal, age16) + Assert.isTrue(Data.equivalent(equal, age16)) + state.value = equal + Assert.equal(testUpdate(false, manager), 0) + assertState(state, equal) + Assert.notEqual(state.value, age16) + }) + test("state is not modified if the equivalent value is set, but returns new value", () => { + const manager = createStateManager() + const state = manager.mutableState(age16, undefined, Data.equivalent) + assertState(state, age16) + let value = age16 + for (let age = 0; age <= 16; age++) { + state.value = value = new Data("age", age) + } + Assert.equal(testUpdate(false, manager), 0) + assertState(state, value) + }) + test("frozen state is not modified if the equivalent value is set, but returns new value", () => { + const manager = createStateManager() + manager.frozen = true // NB! + const state = manager.mutableState(age16, undefined, Data.equivalent) + assertState(state, age16) + let value = age16 + for (let age = 0; age <= 16; age++) { + state.value = value = new Data("age", age) + } + Assert.equal(testUpdate(false, manager), 0) + assertState(state, value) + }) +}) + +class Tracker implements ValueTracker { + private readonly onCreateFunc: (value: Value) => Value + private readonly onUpdateFunc: (value: Value) => Value + constructor(onCreate: (value: Value) => Value, onUpdate: (value: Value) => Value) { + this.onCreateFunc = onCreate + this.onUpdateFunc = onUpdate + } + onCreate(value: Value): Value { + return this.onCreateFunc(value) + } + onUpdate(value: Value): Value { + return this.onUpdateFunc(value) + } +} + +function onCreate(onCreate: (value: Value) => Value): ValueTracker { + return new Tracker(onCreate, (value: Value): Value => value) +} + +function onUpdate(onUpdate: (value: Value) => Value): ValueTracker { + return new Tracker((value: Value): Value => value, onUpdate) +} + +suite("ValueTracker", () => { + test("track state creation", () => { + const manager = createStateManager() + const state = manager.mutableState(5, undefined, undefined, onCreate((value: int32) => value * value)) + assertState(state, 25) + }) + test("disable state modification", () => { + const manager = createStateManager() + const state = manager.mutableState(5, undefined, undefined, onUpdate((value: int32): int32 => { + throw new Error("cannot set " + value) + })) + assertState(state, 5) + Assert.throws(() => { state.value = 404 }) + Assert.equal(testUpdate(false, manager), 0) + assertState(state, 5) + }) + test("disable state modification silently", () => { + const manager = createStateManager() + const state = manager.mutableState(5, undefined, undefined, onUpdate((_: int32) => 5)) + assertState(state, 5) + state.value = 404 + Assert.equal(testUpdate(false, manager), 0) + assertState(state, 5) + }) + test("disposed state ignores tracker", () => { + const manager = createStateManager() + const state = manager.mutableState(5, undefined, undefined, onUpdate((_: int32) => 5)) + assertState(state, 5) + state.value = 404 + Assert.equal(testUpdate(false, manager), 0) + assertState(state, 5) + state.dispose() + state.value = 999 + assertModifiedState(state, 999) + }) +}) + +suite("ArrayState", () => { + test("managed array state supports #at getter", () => { + const manager = createStateManager() + const array = manager.arrayState(Array.of("one", "two", "three")) + Assert.equal(array.length, 3) + Assert.equal(array.at(0), "one") + Assert.equal(array.at(1), "two") + Assert.equal(array.at(2), "three") + Assert.equal(array.at(-1), "three") + Assert.equal(array.at(-2), "two") + Assert.equal(array.at(-3), "one") + }) + test("computable state depends on managed array state", () => { + const manager = createStateManager() + const state = manager.mutableState(1) + const array = manager.arrayState(Array.of("item")) + // create computable state that tracks computing inner scopes + const computing = new Array() + const result = manager.computableState((context: StateContext) => { + computing.push("outer") + return context.compute(key("left"), () => { + computing.push("left") + return "<= " + }) + context.compute(key("center"), () => { + computing.push("center") + const prefix = state.value + ": " + return prefix + context.compute(key("inner"), () => { + computing.push("inner") + return array.value.join(" ") + }) + }) + context.compute(key("right"), () => { + computing.push("right") + return " =>" + }) + }) + // initial computation + assertState(result, "<= 1: item =>") + assertStringsAndCleanup(computing, "outer ; left ; center ; inner ; right") + // computable state is not modified + Assert.equal(testUpdate(false, manager), 0) + Assert.equal(result.value, "<= 1: item =>") + Assert.isEmpty(computing) + // compute state only when snapshot updated + state.value = 2 + array.set(0, "value") + Assert.equal(testUpdate(false, manager), 2) + Assert.equal(result.value, "<= 2: value =>") + assertStringsAndCleanup(computing, "outer ; center ; inner") + // compute state only when snapshot updated + state.value = 3 + array.set(0, "value") + Assert.equal(testUpdate(false, manager), 1) + Assert.equal(result.value, "<= 3: value =>") + assertStringsAndCleanup(computing, "outer ; center") + // compute state only when snapshot updated + state.value = 4 + array.length = 0 + Assert.equal(testUpdate(false, manager), 2) + Assert.equal(result.value, "<= 4: =>") + assertStringsAndCleanup(computing, "outer ; center ; inner") + // computable state is not modified + Assert.equal(testUpdate(false, manager), 0) + Assert.equal(result.value, "<= 4: =>") + Assert.isEmpty(computing) + }) + test("computable state depends on managed array state #copyWithin", () => { + const manager = createStateManager() + const array = manager.arrayState(Array.of("one", "two", "three")) + // create computable state that tracks computing inner scopes + const computing = new Array() + const result = manager.computableState((context: StateContext) => { + computing.push("outer") + return context.compute(key("left"), () => { + computing.push("left") + return "<= " + }) + context.compute(key("center"), () => { + computing.push("center") + return context.compute(key("inner"), () => { + computing.push("inner") + return array.value.join(" ") + }) + }) + context.compute(key("right"), () => { + computing.push("right") + return " =>" + }) + }) + // initial computation + assertState(result, "<= one two three =>") + assertStringsAndCleanup(computing, "outer ; left ; center ; inner ; right") + // computable state is not modified + Assert.equal(testUpdate(false, manager), 0) + Assert.equal(result.value, "<= one two three =>") + Assert.isEmpty(computing) + // compute state only when snapshot updated + array.copyWithin(0, 1, 2) + Assert.equal(testUpdate(false, manager), 1) + Assert.equal(result.value, "<= two two three =>") + assertStringsAndCleanup(computing, "outer ; center ; inner") + // compute state only when snapshot updated + array.copyWithin(2, 0, 1) + Assert.equal(testUpdate(false, manager), 1) + Assert.equal(result.value, "<= two two two =>") + assertStringsAndCleanup(computing, "outer ; center ; inner") + // compute state only when snapshot updated + array.copyWithin(1, 2, 0) + Assert.equal(testUpdate(false, manager), 0) + Assert.equal(result.value, "<= two two two =>") + Assert.isEmpty(computing) + // computable state is not modified + Assert.equal(testUpdate(false, manager), 0) + Assert.equal(result.value, "<= two two two =>") + Assert.isEmpty(computing) + }) + test("computable state depends on managed array state #fill", () => { + const manager = createStateManager() + const array = manager.arrayState(Array.of("one", "two", "three")) + // create computable state that tracks computing inner scopes + const computing = new Array() + const result = manager.computableState((context: StateContext) => { + computing.push("outer") + return context.compute(key("left"), () => { + computing.push("left") + return "<= " + }) + context.compute(key("center"), () => { + computing.push("center") + return context.compute(key("inner"), () => { + computing.push("inner") + return array.value.join(" ") + }) + }) + context.compute(key("right"), () => { + computing.push("right") + return " =>" + }) + }) + // initial computation + assertState(result, "<= one two three =>") + assertStringsAndCleanup(computing, "outer ; left ; center ; inner ; right") + // computable state is not modified + Assert.equal(testUpdate(false, manager), 0) + Assert.equal(result.value, "<= one two three =>") + Assert.isEmpty(computing) + // compute state only when snapshot updated + array.fill("X", 1, 2) + Assert.equal(testUpdate(false, manager), 1) + Assert.equal(result.value, "<= one X three =>") + assertStringsAndCleanup(computing, "outer ; center ; inner") + // compute state only when snapshot updated + array.fill("X") + Assert.equal(testUpdate(false, manager), 1) + Assert.equal(result.value, "<= X X X =>") + assertStringsAndCleanup(computing, "outer ; center ; inner") + // compute state only when snapshot updated + array.fill("X", 1) + Assert.equal(testUpdate(false, manager), 0) + Assert.equal(result.value, "<= X X X =>") + Assert.isEmpty(computing) + // computable state is not modified + Assert.equal(testUpdate(false, manager), 0) + Assert.equal(result.value, "<= X X X =>") + Assert.isEmpty(computing) + }) + test("computable state depends on managed array state #pop", () => { + const manager = createStateManager() + const array = manager.arrayState(Array.of("first", "last")) + // create computable state that tracks computing inner scopes + const computing = new Array() + const result = manager.computableState((context: StateContext) => { + computing.push("outer") + return context.compute(key("left"), () => { + computing.push("left") + return "<= " + }) + context.compute(key("center"), () => { + computing.push("center") + return context.compute(key("inner"), () => { + computing.push("inner") + return array.value.join(" ") + }) + }) + context.compute(key("right"), () => { + computing.push("right") + return " =>" + }) + }) + // initial computation + assertState(result, "<= first last =>") + assertStringsAndCleanup(computing, "outer ; left ; center ; inner ; right") + // computable state is not modified + Assert.equal(testUpdate(false, manager), 0) + Assert.equal(result.value, "<= first last =>") + Assert.isEmpty(computing) + // compute state only when snapshot updated + Assert.equal(array.pop(), "last") + Assert.equal(testUpdate(false, manager), 1) + Assert.equal(result.value, "<= first =>") + assertStringsAndCleanup(computing, "outer ; center ; inner") + // compute state only when snapshot updated + Assert.equal(array.pop(), "first") + Assert.equal(testUpdate(false, manager), 1) + Assert.equal(result.value, "<= =>") + assertStringsAndCleanup(computing, "outer ; center ; inner") + // compute state only when snapshot updated + Assert.isUndefined(array.pop()) + Assert.equal(testUpdate(false, manager), 0) + Assert.equal(result.value, "<= =>") + Assert.isEmpty(computing) + // computable state is not modified + Assert.equal(testUpdate(false, manager), 0) + Assert.equal(result.value, "<= =>") + Assert.isEmpty(computing) + }) + test("computable state depends on managed array state #push", () => { + const manager = createStateManager() + const array = manager.arrayState() + // create computable state that tracks computing inner scopes + const computing = new Array() + const result = manager.computableState((context: StateContext) => { + computing.push("outer") + return context.compute(key("left"), () => { + computing.push("left") + return "<= " + }) + context.compute(key("center"), () => { + computing.push("center") + return context.compute(key("inner"), () => { + computing.push("inner") + return array.value.join(" ") + }) + }) + context.compute(key("right"), () => { + computing.push("right") + return " =>" + }) + }) + // initial computation + assertState(result, "<= =>") + assertStringsAndCleanup(computing, "outer ; left ; center ; inner ; right") + // computable state is not modified + Assert.equal(testUpdate(false, manager), 0) + Assert.equal(result.value, "<= =>") + Assert.isEmpty(computing) + // compute state only when snapshot updated + Assert.equal(array.push(), 0) + Assert.equal(testUpdate(false, manager), 0) + Assert.equal(result.value, "<= =>") + Assert.isEmpty(computing) + // compute state only when snapshot updated + Assert.equal(array.push("one"), 1) + Assert.equal(testUpdate(false, manager), 1) + Assert.equal(result.value, "<= one =>") + assertStringsAndCleanup(computing, "outer ; center ; inner") + // compute state only when snapshot updated + Assert.equal(array.push("two", "three"), 3) + Assert.equal(testUpdate(false, manager), 1) + Assert.equal(result.value, "<= one two three =>") + assertStringsAndCleanup(computing, "outer ; center ; inner") + // computable state is not modified + Assert.equal(testUpdate(false, manager), 0) + Assert.equal(result.value, "<= one two three =>") + Assert.isEmpty(computing) + }) + test("computable state depends on managed array state #reverse", () => { + const manager = createStateManager() + const array = manager.arrayState(Array.of("one", "two", "three")) + // create computable state that tracks computing inner scopes + const computing = new Array() + const result = manager.computableState((context: StateContext) => { + computing.push("outer") + return context.compute(key("left"), () => { + computing.push("left") + return "<= " + }) + context.compute(key("center"), () => { + computing.push("center") + return context.compute(key("inner"), () => { + computing.push("inner") + return array.value.join(" ") + }) + }) + context.compute(key("right"), () => { + computing.push("right") + return " =>" + }) + }) + // initial computation + assertState(result, "<= one two three =>") + assertStringsAndCleanup(computing, "outer ; left ; center ; inner ; right") + // computable state is not modified + Assert.equal(testUpdate(false, manager), 0) + Assert.equal(result.value, "<= one two three =>") + Assert.isEmpty(computing) + // compute state only when snapshot updated + array.reverse() + Assert.equal(testUpdate(false, manager), 1) + Assert.equal(result.value, "<= three two one =>") + assertStringsAndCleanup(computing, "outer ; center ; inner") + // computable state is not modified + Assert.equal(testUpdate(false, manager), 0) + Assert.equal(result.value, "<= three two one =>") + Assert.isEmpty(computing) + }) + test("computable state depends on managed array state #shift", () => { + const manager = createStateManager() + const array = manager.arrayState(Array.of("first", "last")) + // create computable state that tracks computing inner scopes + const computing = new Array() + const result = manager.computableState((context: StateContext) => { + computing.push("outer") + return context.compute(key("left"), () => { + computing.push("left") + return "<= " + }) + context.compute(key("center"), () => { + computing.push("center") + return context.compute(key("inner"), () => { + computing.push("inner") + return array.value.join(" ") + }) + }) + context.compute(key("right"), () => { + computing.push("right") + return " =>" + }) + }) + // initial computation + assertState(result, "<= first last =>") + assertStringsAndCleanup(computing, "outer ; left ; center ; inner ; right") + // computable state is not modified + Assert.equal(testUpdate(false, manager), 0) + Assert.equal(result.value, "<= first last =>") + Assert.isEmpty(computing) + // compute state only when snapshot updated + Assert.equal(array.shift(), "first") + Assert.equal(testUpdate(false, manager), 1) + Assert.equal(result.value, "<= last =>") + assertStringsAndCleanup(computing, "outer ; center ; inner") + // compute state only when snapshot updated + Assert.equal(array.shift(), "last") + Assert.equal(testUpdate(false, manager), 1) + Assert.equal(result.value, "<= =>") + assertStringsAndCleanup(computing, "outer ; center ; inner") + // compute state only when snapshot updated + Assert.isUndefined(array.shift()) + Assert.equal(testUpdate(false, manager), 0) + Assert.equal(result.value, "<= =>") + Assert.isEmpty(computing) + // computable state is not modified + Assert.equal(testUpdate(false, manager), 0) + Assert.equal(result.value, "<= =>") + Assert.isEmpty(computing) + }) + test("computable state depends on managed array state #sort", () => { + const manager = createStateManager() + const array = manager.arrayState(Array.of("one", "two", "three")) + // create computable state that tracks computing inner scopes + const computing = new Array() + const result = manager.computableState((context: StateContext) => { + computing.push("outer") + return context.compute(key("left"), () => { + computing.push("left") + return "<= " + }) + context.compute(key("center"), () => { + computing.push("center") + return context.compute(key("inner"), () => { + computing.push("inner") + return array.value.join(" ") + }) + }) + context.compute(key("right"), () => { + computing.push("right") + return " =>" + }) + }) + // initial computation + assertState(result, "<= one two three =>") + assertStringsAndCleanup(computing, "outer ; left ; center ; inner ; right") + // computable state is not modified + Assert.equal(testUpdate(false, manager), 0) + Assert.equal(result.value, "<= one two three =>") + Assert.isEmpty(computing) + // compute state only when snapshot updated + array.sort() + Assert.equal(testUpdate(false, manager), 1) + Assert.equal(result.value, "<= one three two =>") + assertStringsAndCleanup(computing, "outer ; center ; inner") + // compute state only when snapshot updated + array.sort() + Assert.equal(testUpdate(false, manager), 0) + Assert.equal(result.value, "<= one three two =>") + Assert.isEmpty(computing) +/* TODO: [TID 00edbb] F/ets: Failed to create the collator for en (US) + // compute state only when snapshot updated + array.sort((s1: string, s2: string) => s1.length < s2.length ? -1 : s1.length > s2.length ? 1 : s1.localeCompare(s2)) + Assert.equal(testUpdate(false, manager), 1) + Assert.equal(result.value, "<= one two three =>") + assertStringsAndCleanup(computing, "outer ; center ; inner") + // computable state is not modified + Assert.equal(testUpdate(false, manager), 0) + Assert.equal(result.value, "<= one two three =>") + Assert.isEmpty(computing) +*/ + }) + test("computable state depends on managed array state #unshift", () => { + const manager = createStateManager() + const array = manager.arrayState() + // create computable state that tracks computing inner scopes + const computing = new Array() + const result = manager.computableState((context: StateContext) => { + computing.push("outer") + return context.compute(key("left"), () => { + computing.push("left") + return "<= " + }) + context.compute(key("center"), () => { + computing.push("center") + return context.compute(key("inner"), () => { + computing.push("inner") + return array.value.join(" ") + }) + }) + context.compute(key("right"), () => { + computing.push("right") + return " =>" + }) + }) + // initial computation + assertState(result, "<= =>") + assertStringsAndCleanup(computing, "outer ; left ; center ; inner ; right") + // computable state is not modified + Assert.equal(testUpdate(false, manager), 0) + Assert.equal(result.value, "<= =>") + Assert.isEmpty(computing) + // compute state only when snapshot updated + Assert.equal(array.unshift(), 0) + Assert.equal(testUpdate(false, manager), 0) + Assert.equal(result.value, "<= =>") + Assert.isEmpty(computing) + // compute state only when snapshot updated + Assert.equal(array.unshift("one"), 1) + Assert.equal(testUpdate(false, manager), 1) + Assert.equal(result.value, "<= one =>") + assertStringsAndCleanup(computing, "outer ; center ; inner") + // compute state only when snapshot updated + Assert.equal(array.unshift("two", "three"), 3) + Assert.equal(testUpdate(false, manager), 1) + Assert.equal(result.value, "<= two three one =>") + assertStringsAndCleanup(computing, "outer ; center ; inner") + // computable state is not modified + Assert.equal(testUpdate(false, manager), 0) + Assert.equal(result.value, "<= two three one =>") + Assert.isEmpty(computing) + }) +}) +export const __ARKTEST__ = "states/State.test" diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test-arkts/states/state_basics.test.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test-arkts/states/state_basics.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..713426c0e4d9a7ccdeb59b33c420c06c5c6667e8 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test-arkts/states/state_basics.test.ts @@ -0,0 +1,378 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// TODO: the real chai exports 'assert', but 'assert' is still a keyword in ArkTS +import { Assert, suite, test } from "@koalaui/harness" +import { asArray, int32, uint32 } from "@koalaui/common" +import { + GlobalStateManager, + NodeAttach, + TestNode, + mutableState, + testRoot, + testTick, +} from "../../src" + +function assertResultArray(actual: Array, ...expected: T[]) { + Assert.deepEqual(actual, asArray(expected)) +} + +suite("State management basics", () => { + test("for loop computes the same id", () => { + let addend = mutableState(0) + let log = new Array() + + const ui = + /** @memo */ + (node: TestNode): void => { + let addon = addend.value + for (let i = addon; i < 3 + addon; i++) { + TestNode.attach((node: TestNode) => { + node.content = `${i} ${addon}` + log.push(node.content) + }) + } + } + const root = testRoot(ui) + + assertResultArray(log, "0 0", "1 0", "2 0") + + log = new Array() + addend.value = 10; + testTick(root) + assertResultArray(log) + + log = new Array() + addend.value = 200; + testTick(root) + assertResultArray(log) + }) + + test("Function identity is a part of positional key", () => { + let log = new Array() + + const f1 = + /** @memo */ + (): void => { + log.push("f1") + } + + const f2 = + /** @memo */ + (): void => { + log.push("f2") + } + + let f = mutableState(f1) + + const ui = + /** @memo */ + (node: TestNode): void => { + /** @memo */ + let y = f.value + y() + } + + log = new Array() + let root = testRoot(ui) + assertResultArray(log, "f1") + + log = new Array() + testTick(root) + assertResultArray(log) + + f.value = f2 + + log = new Array() + testTick(root) + assertResultArray(log, "f2") + + log = new Array() + testTick(root) + assertResultArray(log) + }) + + test("The same test as above but without __distinct", () => { + let log = new Array() + + const f1 = + /** @memo */ + (): void => { + log.push("f1") + } + const f2 = + /** @memo */ + (): void => { + log.push("f2") + } + const f3 = + /** @memo */ + (): void => { + log.push("f3") + } + + let sequence = mutableState(asArray([f1, f2, f3])) + + const ui = + /** @memo */ + (node: TestNode): void => { + for (let i = 0; i < 3; i++) { + /** @memo */ + let f = sequence.value[i] + f() + } + } + + log = new Array() + const root = testRoot(ui) + assertResultArray(log, "f1", "f2", "f3") + + log = new Array() + testTick(root) + assertResultArray(log) + + sequence.value = asArray([f3, f2, f1]) + + log = new Array() + testTick(root) + // Compare this test with the previous one + // Without distinct we just compare the subsequent iterations. + // + // f1 first time + // f2 recomputes + // f3 recomputes + // + // f3 the same! + // f2 recomputes + // f1 recomputes + assertResultArray(log, "f2", "f1") + + log = new Array() + testTick(root) + assertResultArray(log) + }) + + /* + These two tests are no longer relevant, as we forbid state mutations in UI functions. + + test("mutable state dereference causes recomputes", () => { + let peekNode = "" + + // @memo + function ui() { + const x = remember(() => mutableState(true)) + StringNode(node => { + if (x.value) { + node.content = "head" + } else { + node.content = "tail" + } + peekNode = node.content + }) + x.value = !x.value + } + + const root = testRoot(ui) + + Assert.equal(peekNode, "head") + + testTick(root) + + Assert.equal(peekNode, "tail") + + testTick(root) + + Assert.equal(peekNode, "head") + }) + + test("mutable state dereference doesn't affect nested scopes", () => { + let peekNode = "" + + // @memo + function ui() { + const x = remember(() => mutableState(true)) + + const y = x.value + + StringNode(node => { + if (y) { + node.content = "head" + } else { + node.content = "tail" + } + peekNode = node.content + }) + x.value = !x.value + } + const root = testRoot(ui) + + Assert.equal(peekNode, "head") + + testTick(root) + + Assert.equal(peekNode, "head") + + testTick(root) + + Assert.equal(peekNode, "head") + }) + */ + + test("Argument change causes recomposition", () => { + let peekNode = "" + let peekY: boolean | undefined = undefined + let peekX: boolean | undefined = undefined + const y = mutableState(true) + + /** @memo */ + const child = + /** @memo */ + (x: boolean): void => { + peekX = x + TestNode.attach((node: TestNode) => { + if (x) { + node.content = "head" + } else { + node.content = "tail" + } + peekNode = node.content + }) + } + + const ui = + /** @memo */ + (node: TestNode): void => { + peekY = y.value + child(y.value) + } + + const root = testRoot(ui) + + Assert.equal(peekY, true) + Assert.equal(peekX, true) + Assert.equal(peekNode, "head") + y.value = !y.value + + testTick(root) + + Assert.equal(peekY, false) + Assert.equal(peekX, false) + Assert.equal(peekNode, "tail") + y.value = !y.value + + testTick(root) + + Assert.equal(peekY, true) + Assert.equal(peekX, true) + Assert.equal(peekNode, "head") + }) + + test("Value seen immediately if not in @memo", () => { + const x = mutableState(true) + Assert.equal(x.value, true) + x.value = !x.value + Assert.equal(x.value, false) + }) + + test("Value seen later if in @memo", () => { + GlobalStateManager.instance.frozen = true + const x = mutableState(true) + Assert.equal(x.value, true) + x.value = !x.value + Assert.equal(x.value, true) + GlobalStateManager.instance.frozen = false + }) + + class fooNode extends TestNode { + constructor(kind: uint32 = 1) { + super(kind) + } + } + + test("Static member @memo", () => { + const s = mutableState(11) + const result = new Array() + class X { + /** @memo */ + static foo( + /** @memo */ + content?: () => void + ) { + NodeAttach((): TestNode => new fooNode(), (_: TestNode) => { + result.push(s.value) + content?.() + }) + } + } + + const ui = + /** @memo */ + (node: TestNode): void => { + X.foo(() => { + result.push(-1) + }) + } + + const root = testRoot(ui) + testTick(root) + testTick(root) + s.value = 17 + testTick(root) + testTick(root) + s.value = 41 + testTick(root) + testTick(root) + + assertResultArray(result, 11, -1, 17, 41) + }) + + test("Receiver change triggers method recompute", () => { + + const peek = new Array() + class X { + value: int32 + constructor(value: int32) { + this.value = value + } + /** @memo */ + method(arg?: int32) { + peek.push(this.value) + } + } + + const x = mutableState(new X(11)) + + const ui = + /** @memo */ + (node: TestNode): void => { + x.value.method() + } + + const root = testRoot(ui) + assertResultArray(peek, 11) + + testTick(root) + assertResultArray(peek, 11) + + x.value = new X(22) + testTick(root) + assertResultArray(peek, 11, 22) + + testTick(root) + assertResultArray(peek, 11, 22) + + }) +}) +export const __ARKTEST__ = "states/state_basics.test" diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test-arkts/tests.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test-arkts/tests.ts new file mode 100644 index 0000000000000000000000000000000000000000..0c015540a299d36111e10809d79be9bf6dc1d074 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test-arkts/tests.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { suite } from "@koalaui/harness" +import { __ARKTEST__ as Easing } from "./animation/Easing.test" +import { __ARKTEST__ as MarkableQueue } from "./common/MarkableQueue.test" +import { __ARKTEST__ as bind } from "./memo/bind.test" +import { __ARKTEST__ as changeListener } from "./memo/changeListener.test" +import { __ARKTEST__ as contextLocal } from "./memo/contextLocal.test" +import { __ARKTEST__ as remember } from "./memo/remember.test" +import { __ARKTEST__ as repeat } from "./memo/repeat.test" +import { __ARKTEST__ as Journal } from "./states/Journal.test" +import { __ARKTEST__ as state_basics } from "./states/state_basics.test" +import { __ARKTEST__ as State } from "./states/State.test" +import { __ARKTEST__ as TreeNode } from "./tree/TreeNode.test" +import { __ARKTEST__ as TreePath } from "./tree/TreePath.test" +import { __ARKTEST__ as basic_test } from "./exec/basic.test" + +suite("runtime", () => { + Array.of(basic_test, Easing, MarkableQueue, bind, changeListener, contextLocal, remember, repeat, Journal, /* state_basics, */State, TreeNode, TreePath) +}) diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test-arkts/tree/TreeNode.test.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test-arkts/tree/TreeNode.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..f852bce5fa6a4a844169cf0901e94c0ce0a2379f --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test-arkts/tree/TreeNode.test.ts @@ -0,0 +1,354 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// TODO: the real chai exports 'assert', but 'assert' is still a keyword in ArkTS +import { Assert, suite, test } from "@koalaui/harness" +import { float64, int32, uint32 } from "@koalaui/common" +import { TreeNode } from "../../src/tree/TreeNode" + +class StringNode extends TreeNode { + readonly content: string + + constructor(content: string, ...children: TreeNode[]) { + super() + this.content = content + this.appendChildren(...children) + } + + toString(): string { + return this.content + } +} + +function contentOf(node: TreeNode): string | undefined { + return (node as StringNode)?.content +} + +function assertContent(node: TreeNode, content: string) { + Assert.equal(contentOf(node), content) +} + +function assertRoot(node: TreeNode) { + Assert.isUndefined(node.parent) + Assert.equal(node.depth, 0) + Assert.equal(node.index, -1) +} + +function assertLeaf(node: TreeNode) { + Assert.equal(node.childrenCount, 0) +} + +function assertNoChildAt(parent: TreeNode, index: int32) { + Assert.isUndefined(parent.childAt(index)) +} + +function assertChildAt(parent: TreeNode, index: int32): TreeNode { + let child = parent.childAt(index) + Assert.isDefined(child) + Assert.equal(child?.parent, parent) + Assert.equal(child?.index, index) + return child! +} + +function assertToString(root: TreeNode, expected: string) { + Assert.equal(root.toHierarchy(), expected) +} + +function assertRemoveChildrenAt(root: TreeNode, index: int32, count: uint32, expected: int32) { + let childrenCount = root.childrenCount + let children = root.removeChildrenAt(index, count) + Assert.equal(children.length, expected) + Assert.equal(root.childrenCount, childrenCount - expected) + for (let i = 0; i < expected; i++) { + assertRoot(children[i]) + } +} + +function createRoot() { + return new StringNode("root", + new StringNode("first"), + new StringNode("second"), + new StringNode("third")) +} + +function createDigitsRoot() { + return new StringNode("digits", + new StringNode("0"), + new StringNode("1"), + new StringNode("2"), + new StringNode("3"), + new StringNode("4"), + new StringNode("5"), + new StringNode("6"), + new StringNode("7"), + new StringNode("8"), + new StringNode("9")) +} + +suite("TreeNode", () => { + test("single node", () => { + let node = new StringNode("node") + assertContent(node, "node") + assertRoot(node) + assertLeaf(node) + }) + test("simple root", () => { + let root = createRoot() + assertContent(root, "root") + assertRoot(root) + Assert.equal(root.childrenCount, 3) + assertNoChildAt(root, -1) + assertNoChildAt(root, 3) + let node0 = assertChildAt(root, 0) + assertContent(node0, "first") + assertLeaf(node0) + let node1 = assertChildAt(root, 1) + assertContent(node1, "second") + assertLeaf(node1) + let node2 = assertChildAt(root, 2) + assertContent(node2, "third") + assertLeaf(node2) + const children = root.children.slice() + Assert.equal(children.length, 3) + Assert.equal(children[0], node0) + Assert.equal(children[1], node1) + Assert.equal(children[2], node2) + assertToString(root, + "root\n" + + " first\n" + + " second\n" + + " third") + }) + test("iterate for each child", () => { + let root = createRoot() + let count = 0 + let children = ["first", "second", "third"] + root.forEach((node, index) => { + Assert.equal(children[count], contentOf(node)) + count++ + }) + Assert.equal(count, 3) + }) + test("iterate for each child with index", () => { + let root = createRoot() + let count = 0 + root.forEach((node, index) => { + Assert.equal(index, count) + count++ + }) + Assert.equal(count, 3) + }) + test("iterate through not every child", () => { + let root = createRoot() + let count = 0 + Assert.isFalse(root.every((node, index) => { + count++ + return contentOf(node)?.length == 5 + })) + Assert.equal(count, 2) + }) + test("iterate through every child with index", () => { + let root = createRoot() + let count = 0 + let children = ["first", "second", "third"] + Assert.isTrue(root.every((node, index) => { + Assert.equal(index, count) + count++ + return children[index as int32] === contentOf(node) + })) + Assert.equal(count, 3) + }) + test("iterate through some children", () => { + let root = createRoot() + let count = 0 + Assert.isTrue(root.some((node, index) => { + count++ + return contentOf(node)?.length == 6 + })) + Assert.equal(count, 2) + }) + test("iterate through some children with index", () => { + let root = createRoot() + let count = 0 + Assert.isTrue(root.some((node, index) => { + Assert.equal(index, count) + count++ + return index == 0 + })) + Assert.equal(count, 1) + }) + test("find child by content", () => { + let root = createRoot() + Assert.equal(root.find((node, index): TreeNode | undefined => contentOf(node) == "second" ? node : undefined), assertChildAt(root, 1)) + }) + test("find child by index", () => { + let root = createRoot() + Assert.equal(root.find((node, index): TreeNode | undefined => index == 1 ? node : undefined), assertChildAt(root, 1)) + }) + test("insert, move and remove children", () => { + let root = createRoot() + Assert.isFalse(root.removeChild(new StringNode("second"))) // non-existent node + assertToString(root, + "root\n" + + " first\n" + + " second\n" + + " third") + let second = assertChildAt(root, 1) + second.appendChildren(new StringNode("1"), new StringNode("2"), new StringNode("3")) + assertToString(root, + "root\n" + + " first\n" + + " second\n" + + " 1\n" + + " 2\n" + + " 3\n" + + " third") + second.removeFromParent() + assertRoot(second) + assertToString(second, + "second\n" + + " 1\n" + + " 2\n" + + " 3") + assertToString(root, + "root\n" + + " first\n" + + " third") + Assert.isFalse(root.removeChild(second)) // cannot remove twice + Assert.isTrue(root.insertChildAt(0, second)) + assertToString(root, + "root\n" + + " second\n" + + " 1\n" + + " 2\n" + + " 3\n" + + " first\n" + + " third") + let first = root.removeChildAt(1) + Assert.isDefined(first) + assertRoot(first!) + assertContent(first!, "first") + root.appendChild(first!) + assertToString(root, + "root\n" + + " second\n" + + " 1\n" + + " 2\n" + + " 3\n" + + " third\n" + + " first") + }) + test("insert several children at once", () => { + let root = createRoot() + let children: Array = [new StringNode("second.1"), new StringNode("second.2"), new StringNode("second.3")] + Assert.isFalse(root.insertChildrenAt(-1, ...children)) + Assert.isFalse(root.insertChildrenAt(4, ...children)) + Assert.isTrue(root.insertChildrenAt(2, ...children)) + assertToString(root, + "root\n" + + " first\n" + + " second\n" + + " second.1\n" + + " second.2\n" + + " second.3\n" + + " third") + Assert.isTrue(root.insertChildrenAt(0, new StringNode("zero"))) + assertToString(root, + "root\n" + + " zero\n" + + " first\n" + + " second\n" + + " second.1\n" + + " second.2\n" + + " second.3\n" + + " third") + Assert.isTrue(root.insertChildrenAt(root.childrenCount, new StringNode("third.A"), new StringNode("third.B"))) + assertToString(root, + "root\n" + + " zero\n" + + " first\n" + + " second\n" + + " second.1\n" + + " second.2\n" + + " second.3\n" + + " third\n" + + " third.A\n" + + " third.B") + }) + test("remove several children at once", () => { + let root = createDigitsRoot() + assertToString(root, + "digits\n" + + " 0\n" + + " 1\n" + + " 2\n" + + " 3\n" + + " 4\n" + + " 5\n" + + " 6\n" + + " 7\n" + + " 8\n" + + " 9") + assertRemoveChildrenAt(root, -1, 1, 0) + assertRemoveChildrenAt(root, root.childrenCount, 1, 0) + // remove leading nodes + assertRemoveChildrenAt(root, 0, 1 + root.childrenCount, 0) + assertRemoveChildrenAt(root, 0, 2, 2) + assertToString(root, + "digits\n" + + " 2\n" + + " 3\n" + + " 4\n" + + " 5\n" + + " 6\n" + + " 7\n" + + " 8\n" + + " 9") + // remove trailing nodes + assertRemoveChildrenAt(root, root.childrenCount - 1, 2, 0) + assertRemoveChildrenAt(root, root.childrenCount - 2, 2, 2) + assertToString(root, + "digits\n" + + " 2\n" + + " 3\n" + + " 4\n" + + " 5\n" + + " 6\n" + + " 7") + // remove inner nodes + assertRemoveChildrenAt(root, 1, root.childrenCount, 0) + assertRemoveChildrenAt(root, 1, 4, 4) + assertToString(root, + "digits\n" + + " 2\n" + + " 7") + }) + test("remove trailing children at once", () => { + let root = createDigitsRoot() + Assert.equal(root.childrenCount, 10) + Assert.equal(root.removeChildrenAt(-1).length, 0) + Assert.equal(root.removeChildrenAt(root.childrenCount).length, 0) + Assert.equal(root.childrenCount, 10) + Assert.equal(root.removeChildrenAt(7).length, 3) + Assert.equal(root.childrenCount, 7) + Assert.equal(root.removeChildrenAt(6).length, 1) + Assert.equal(root.childrenCount, 6) + Assert.equal(root.removeChildrenAt(1).length, 5) + Assert.equal(root.childrenCount, 1) + Assert.equal(root.removeChildrenAt(0).length, 1) + Assert.equal(root.childrenCount, 0) + }) +}) +export const __ARKTEST__ = "tree/TreeNode.test" diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test-arkts/tree/TreePath.test.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test-arkts/tree/TreePath.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..62fb6b067e99252ffbe0e4f622a1f220e0779f1c --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test-arkts/tree/TreePath.test.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// TODO: the real chai exports 'assert', but 'assert' is still a keyword in ArkTS +import { Assert, suite, test } from "@koalaui/harness" +import { TreePath } from "../../src/tree/TreePath" + +suite("TreePath", () => { + + let root = new TreePath("root") + + test("root path is root", () => Assert.strictEqual(root.root, root)) + test("root path depth", () => Assert.equal(root.depth, 0)) + test("root path has undefined parent", () => Assert.strictEqual(root.parent, undefined)) + test("root path to string", () => Assert.equal(root.toString(), "/root")) + + let parent = root.child("parent") + let current = parent.child("node") + + test("tree path has root", () => Assert.strictEqual(current.root, root)) + test("tree path has parent", () => Assert.strictEqual(current.parent, parent)) + test("tree path depth", () => Assert.equal(current.depth, 2)) + test("tree path parent depth", () => Assert.equal(current.parent?.depth, 1)) + test("tree path to string", () => Assert.equal(current.toString(), "/root/parent/node")) + + let sibling = parent.child("sibling") + + test("siblings has the same parents", () => Assert.strictEqual(current.parent, sibling.parent)) +}) +export const __ARKTEST__ = "tree/TreePath.test" diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test/animation/Easing.test.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test/animation/Easing.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..8b41c853c6aa1d207c4f42e4fce6b688922a8d31 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test/animation/Easing.test.ts @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Assert as assert, suite, test } from "@koalaui/harness" +import { Easing, EasingCurve, EasingStepJump } from "../../src/animation/Easing" + +function assertEasing(easing: EasingCurve, ...expected: number[]) { + const last = expected.length - 1 + for (let i = 0; i <= last; i++) { + assert.equal(Math.round(100 * easing(i / last)), expected[i]) + } +} + +suite("Easing", () => { + test("Linear", () => assertEasing(Easing.Linear, 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100)) + test("Linear.inverted", () => assertEasing(Easing.inverted(Easing.Linear), 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100)) + test("Linear.reversed", () => assertEasing(Easing.reversed(Easing.Linear), 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0)) + test("Linear.restarted", () => assertEasing(Easing.restarted(Easing.Linear), 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 0)) + test("Linear.repeated twice", () => assertEasing(Easing.repeated(Easing.Linear, 2), 0, 20, 40, 60, 80, 0, 20, 40, 60, 80, 100)) + test("Linear.repeated 4 times", () => assertEasing(Easing.repeated(Easing.Linear, 4), 0, 40, 80, 20, 60, 0, 40, 80, 20, 60, 100)) + test("Linear.joined with Linear.reversed", () => assertEasing(Easing.joined(Easing.Linear, Easing.reversed(Easing.Linear)), 0, 20, 40, 60, 80, 100, 80, 60, 40, 20, 0)) + test("Linear.thereAndBackAgain (as above)", () => assertEasing(Easing.thereAndBackAgain(Easing.Linear), 0, 20, 40, 60, 80, 100, 80, 60, 40, 20, 0)) + test("EaseInSine", () => assertEasing(Easing.EaseInSine, 0, 1, 5, 11, 19, 29, 41, 55, 69, 84, 100)) + test("EaseInSine.inverted", () => assertEasing(Easing.inverted(Easing.EaseInSine), 0, 16, 31, 45, 59, 71, 81, 89, 95, 99, 100)) + test("EaseInSine.reversed", () => assertEasing(Easing.reversed(Easing.EaseInSine), 100, 84, 69, 55, 41, 29, 19, 11, 5, 1, 0)) + test("EaseOutSine", () => assertEasing(Easing.EaseOutSine, 0, 16, 31, 45, 59, 71, 81, 89, 95, 99, 100)) + test("EaseOutSine.inverted", () => assertEasing(Easing.inverted(Easing.EaseOutSine), 0, 1, 5, 11, 19, 29, 41, 55, 69, 84, 100)) + test("EaseOutSine.reversed", () => assertEasing(Easing.reversed(Easing.EaseOutSine), 100, 99, 95, 89, 81, 71, 59, 45, 31, 16, 0)) + test("EaseInOutSine", () => assertEasing(Easing.EaseInOutSine, 0, 2, 10, 21, 35, 50, 65, 79, 90, 98, 100)) + test("EaseInOutSine.inverted", () => assertEasing(Easing.inverted(Easing.EaseInOutSine), 0, 2, 10, 21, 35, 50, 65, 79, 90, 98, 100)) + test("EaseInOutSine.reversed", () => assertEasing(Easing.reversed(Easing.EaseInOutSine), 100, 98, 90, 79, 65, 50, 35, 21, 10, 2, 0)) + test("Ease", () => assertEasing(Easing.Ease, 0, 10, 30, 51, 68, 80, 89, 94, 98, 99, 100)) + test("Ease.inverted", () => assertEasing(Easing.inverted(Easing.Ease), 0, 1, 2, 6, 11, 20, 32, 49, 70, 90, 100)) + test("Ease.reversed", () => assertEasing(Easing.reversed(Easing.Ease), 100, 99, 98, 94, 89, 80, 68, 51, 30, 10, 0)) + test("EaseIn", () => assertEasing(Easing.EaseIn, 0, 2, 6, 13, 21, 32, 43, 55, 69, 84, 100)) + test("EaseIn.inverted", () => assertEasing(Easing.inverted(Easing.EaseIn), 0, 16, 31, 45, 57, 68, 79, 87, 94, 98, 100)) + test("EaseIn.reversed", () => assertEasing(Easing.reversed(Easing.EaseIn), 100, 84, 69, 55, 43, 32, 21, 13, 6, 2, 0)) + test("EaseOut", () => assertEasing(Easing.EaseOut, 0, 16, 31, 45, 57, 69, 79, 87, 94, 98, 100)) + test("EaseOut.inverted", () => assertEasing(Easing.inverted(Easing.EaseOut), 0, 2, 6, 13, 21, 31, 43, 55, 69, 84, 100)) + test("EaseOut.reversed", () => assertEasing(Easing.reversed(Easing.EaseOut), 100, 98, 94, 87, 79, 69, 57, 45, 31, 16, 0)) + test("EaseInOut", () => assertEasing(Easing.EaseInOut, 0, 2, 8, 19, 33, 50, 67, 81, 92, 98, 100)) + test("EaseInOut.inverted", () => assertEasing(Easing.inverted(Easing.EaseInOut), 0, 2, 8, 19, 33, 50, 67, 81, 92, 98, 100)) + test("EaseInOut.reversed", () => assertEasing(Easing.reversed(Easing.EaseInOut), 100, 98, 92, 81, 67, 50, 33, 19, 8, 2, 0)) + test("custom bezier with small overflow", () => assertEasing(Easing.cubicBezier(.3, -.3, .7, 1.3), 0, -4, 3, 15, 32, 50, 68, 85, 97, 104, 100)) + test("custom bezier with large overflow", () => assertEasing(Easing.cubicBezier(.3, -.7, .7, 1.7), 0, -13, -9, 6, 26, 50, 74, 95, 109, 113, 100)) + test("6 steps with EasingStepJump.None", () => assertEasing(Easing.steps(6, EasingStepJump.None), 0, 0, 20, 20, 40, 40, 60, 60, 80, 80, 100, 100)) + test("11 steps with EasingStepJump.None", () => assertEasing(Easing.steps(11, EasingStepJump.None), 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100)) + test("10 steps with EasingStepJump.Start", () => assertEasing(Easing.steps(10, EasingStepJump.Start), 10, 20, 30, 40, 50, 60, 70, 80, 90, 100)) + test("10 steps with EasingStepJump.End", () => assertEasing(Easing.steps(10, EasingStepJump.End), 0, 10, 20, 30, 40, 50, 60, 70, 80, 90)) + test("9 steps with EasingStepJump.Both", () => assertEasing(Easing.steps(9, EasingStepJump.Both), 10, 20, 30, 40, 50, 60, 70, 80, 90)) +}) diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test/common/MarkableQueue.test.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test/common/MarkableQueue.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..7d7aa326defda98956dc478aaa585564b6bd3437 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test/common/MarkableQueue.test.ts @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Assert, suite, test } from "@koalaui/harness" +import { MarkableQueue, markableQueue } from "@koalaui/common" + +const collector = new Array() + +function testQueue(queue: MarkableQueue, expected: Array) { + collector.length = 0 + queue.callCallbacks() + Assert.deepEqual(collector, expected) +} + +suite("MarkableQueue tests", () => { + + test("nothing to call without marker", () => { + const queue = markableQueue() + queue.addCallback(() => collector.push("1a")) + queue.addCallback(() => collector.push("1b")) + queue.addCallback(() => collector.push("1c")) + testQueue(queue, Array.of()) + }) + + test("call only marked callbacks", () => { + const queue = markableQueue() + queue.addCallback(() => collector.push("1a")) + queue.addCallback(() => collector.push("1b")) + queue.addCallback(() => collector.push("1c")) + queue.setMarker() + queue.addCallback(() => collector.push("2a")) + queue.addCallback(() => collector.push("2b")) + queue.addCallback(() => collector.push("2c")) + testQueue(queue, Array.of("1a", "1b", "1c")) + testQueue(queue, Array.of()) // called only once + }) + + test("call marked callbacks to the latest marker", () => { + const queue = markableQueue() + queue.addCallback(() => collector.push("1a")) + queue.addCallback(() => collector.push("1b")) + queue.addCallback(() => collector.push("1c")) + queue.setMarker() + queue.addCallback(() => collector.push("2a")) + queue.addCallback(() => collector.push("2b")) + queue.addCallback(() => collector.push("2c")) + queue.setMarker() + queue.addCallback(() => collector.push("3a")) + queue.addCallback(() => collector.push("3b")) + queue.addCallback(() => collector.push("3c")) + testQueue(queue, Array.of("1a", "1b", "1c", "2a", "2b", "2c")) + testQueue(queue, Array.of()) // called only once + }) +}) + +suite("MarkableQueue reversed tests", () => { + + test("nothing to call without marker", () => { + const queue = markableQueue(true) + queue.addCallback(() => collector.push("1a")) + queue.addCallback(() => collector.push("1b")) + queue.addCallback(() => collector.push("1c")) + testQueue(queue, Array.of()) + }) + + test("call only marked callbacks", () => { + const queue = markableQueue(true) + queue.addCallback(() => collector.push("1a")) + queue.addCallback(() => collector.push("1b")) + queue.addCallback(() => collector.push("1c")) + queue.setMarker() + queue.addCallback(() => collector.push("2a")) + queue.addCallback(() => collector.push("2b")) + queue.addCallback(() => collector.push("2c")) + testQueue(queue, Array.of("1c", "1b", "1a")) + testQueue(queue, Array.of()) // called only once + }) + + test("call marked callbacks from the latest marker", () => { + const queue = markableQueue(true) + queue.addCallback(() => collector.push("1a")) + queue.addCallback(() => collector.push("1b")) + queue.addCallback(() => collector.push("1c")) + queue.setMarker() + queue.addCallback(() => collector.push("2a")) + queue.addCallback(() => collector.push("2b")) + queue.addCallback(() => collector.push("2c")) + queue.setMarker() + queue.addCallback(() => collector.push("3a")) + queue.addCallback(() => collector.push("3b")) + queue.addCallback(() => collector.push("3c")) + testQueue(queue, Array.of("2c", "2b", "2a", "1c", "1b", "1a")) + testQueue(queue, Array.of()) // called only once + }) +}) diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test/memo/bind.test.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test/memo/bind.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..d889d47fce5e2e25f021efae255f89a204d534ab --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test/memo/bind.test.ts @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Assert as assert, suite, test } from "@koalaui/harness" +import { + GlobalStateManager, + State, + TestNode, + memoBind, + testTick, +} from "../../src" + +const collector = new Array() + +function testExpected(root: State, ...expected: string[]) { + collector.length = 0 + testTick(root) + assert.deepEqual(collector, expected) + if (expected.length > 0) testExpected(root) +} + +/** @memo */ +function sample(arg: string): void { + collector.push(arg) +} + +suite("memo tests", () => { + test("memoBind trivial test", () => { + GlobalStateManager.reset() + const root = TestNode.create(() => { + /** @memo */ + const bind = memoBind(sample, "red") + bind() + }) + testExpected(root, "red") + }) +}) diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test/memo/changeListener.test.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test/memo/changeListener.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..e200f0d9b2e57556380c030afe8d636f8283687f --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test/memo/changeListener.test.ts @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Assert as assert, suite, test } from "@koalaui/harness" +import { + GlobalStateManager, + OnChange, + RunEffect, + State, + TestNode, + mutableState, + testTick, +} from "../../src" + +const collector = new Array() + +function testExpected(root: State, ...expected: string[]) { + collector.length = 0 + testTick(root, false) + assert.deepEqual(collector, []) + GlobalStateManager.instance.callCallbacks() + assert.deepEqual(collector, expected) +} + +export function testChange( + /** @memo */ + content: (value: string) => void, + ...expected: string[] +) { + GlobalStateManager.reset() + const state = mutableState("first") + const root = TestNode.create(() => content(state.value)) + testExpected(root, ...expected) + state.value = "f" + "i" + "r" + "s" + "t" + testExpected(root) + state.value = "second" + testExpected(root, "second") + state.value = "third" + testExpected(root, "third") +} + +suite("changeListener tests", () => { + + test("RunEffect", () => testChange((value: string) => RunEffect(value, change => collector.push(change)), "first")) + + test("OnChange", () => testChange((value: string) => OnChange(value, change => collector.push(change)))) +}) diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test/memo/contextLocal.test.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test/memo/contextLocal.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..b0cc6cfc9c346b507fbac074988d9128a3dd6d0c --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test/memo/contextLocal.test.ts @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Assert as assert, suite, test } from "@koalaui/harness" +import { + State, + TestNode, + contextLocalScope, + contextLocalValue, + mutableState, + testTick, +} from "../../src" + +const collector = new Array() + +function testExpected(root: State, ...expected: string[]) { + collector.length = 0 + testTick(root) + assert.deepEqual(collector, expected) + if (expected.length > 0) testExpected(root) +} + +suite("contextLocal tests", () => { + + test("contextLocalScope ensures name is not changed", () => { + const state = mutableState("first") + const root = TestNode.create(() => { + contextLocalScope(state.value, "value", () => { + collector.push(contextLocalValue(state.value)) + }) + }) + testExpected(root, "value") + state.value = "second" + assert.throws(() => testTick(root)) + }) + + test("contextLocalScope propagates state immediately", () => { + const state = mutableState("first") + const root = TestNode.create(() => { + collector.push("ui:" + state.value) + contextLocalScope("parameter", state.value, () => { + collector.push("state:" + contextLocalValue("parameter")) + }) + }) + testExpected(root, "ui:first", "state:first") + state.value = "second" + testExpected(root, "ui:second", "state:second") + state.value = "third" + testExpected(root, "ui:third", "state:third") + }) +}) diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test/memo/remember.test.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test/memo/remember.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..3596bb8dfdc4c4c1958f6c2e748bf916b1c9291d --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test/memo/remember.test.ts @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Assert as assert, suite, test } from "@koalaui/harness" +import { + GlobalStateManager, + State, + TestNode, + memoLifecycle, + mutableState, + once, + remember, + rememberDisposable, + rememberMutableState, + testTick, +} from "../../src" + +const collector = new Array() + +function testExpected(root: State, ...expected: string[]) { + collector.length = 0 + testTick(root) + assert.deepEqual(collector, expected) + if (expected.length > 0) testExpected(root) +} + +suite("remember tests", () => { + + test("memoLifecycle runs when attaching and detaching", () => { + GlobalStateManager.reset() + const state = mutableState(0) + const root = TestNode.create(() => { + if (state.value > 0) { + memoLifecycle( + () => collector.push("attach"), + () => collector.push("detach") + ) + collector.push("update") + } + }) + testExpected(root) + state.value = 1 + testExpected(root, "attach", "update") + state.value = 2 + testExpected(root, "update") + state.value = 0 + testExpected(root, "detach") + }) + + test("once runs once when attaching to composition", () => { + GlobalStateManager.reset() + const state = mutableState(0) + const root = TestNode.create(() => { + once(() => collector.push("once" + state.value)) + collector.push("update" + state.value) + }) + testExpected(root, "once0", "update0") + state.value = 1 + testExpected(root, "update1") + state.value = 2 + testExpected(root, "update2") + }) + + test("remember computes once", () => { + GlobalStateManager.reset() + const root = TestNode.create(() => { + remember(() => collector.push("inner")) + collector.push("outer") + }) + testExpected(root, "inner", "outer") + }) + + test("remember computes once even if inner state changed", () => { + GlobalStateManager.reset() + const state = mutableState(false) + const root = TestNode.create(() => { + remember(() => { + collector.push("inner") + state.value // not depended + }) + collector.push("outer") + }) + testExpected(root, "inner", "outer") + state.value = true + testExpected(root) + }) + + test("remember computes once even if outer state changed", () => { + GlobalStateManager.reset() + const state = mutableState(false) + const root = TestNode.create(() => { + remember(() => collector.push("inner")) + state.value // depended + collector.push("outer") + }) + testExpected(root, "inner", "outer") + state.value = true + testExpected(root, "outer") + }) + + test("intrinsic remember should not conflict each other", () => { + GlobalStateManager.reset() + const state = mutableState(false) + const root = TestNode.create(() => { + state.value + ? remember(() => collector.push("positive")) + : remember(() => collector.push("negative")) + }) + testExpected(root, "negative") + state.value = true + testExpected(root, "positive") + state.value = false + testExpected(root, "negative") + state.value = false + testExpected(root) + }) + + test("rememberDisposable created and disposed accordingly", () => { + GlobalStateManager.reset() + const state = mutableState(false) + const root = TestNode.create(() => { + if (state.value) { + rememberDisposable( + () => collector.push("create"), + () => collector.push("dispose")) + } + }) + testExpected(root) + state.value = true + testExpected(root, "create") + state.value = false + testExpected(root, "dispose") + state.value = false + testExpected(root) + }) + + test("rememberMutableState computes once even if initial state changed", () => { + GlobalStateManager.reset() + const global = mutableState(0) + const root = TestNode.create(() => { + const local = rememberMutableState(global.value) + collector.push("global=" + global.value) + collector.push("local=" + local.value) + }) + testExpected(root, "global=0", "local=0") + global.value++ + testExpected(root, "global=1", "local=0") + global.value++ + testExpected(root, "global=2", "local=0") + }) +}) diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test/memo/repeat.test.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test/memo/repeat.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..f489f8a4baef5d1abfa1565a535dbf8c5bf1f7fe --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test/memo/repeat.test.ts @@ -0,0 +1,183 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Assert as assert, suite, test } from "@koalaui/harness" +import { UniqueId, KoalaCallsiteKey } from "@koalaui/common" +import { + GlobalStateManager, + Repeat, + RepeatByArray, + RepeatRange, + RepeatWithKey, + State, + TestNode, + memoLifecycle, + mutableState, + testTick, +} from "../../src" + +const collector = new Array() + +interface Page { + /** @memo */ + readonly page: () => void + readonly id: KoalaCallsiteKey +} + +function createPage(name: string): Page { + return { + id: parseInt(new UniqueId().addString(name).compute().slice(0, 10), 16), + page: + /** @memo */ + () => memoLifecycle( + () => collector.push("+" + name), + () => collector.push("-" + name)) + } +} + +function createPages(...names: string[]): ReadonlyArray { + return names.map(createPage) +} + +function testExpected(root: State, ...expected: string[]) { + collector.length = 0 + testTick(root) + assert.deepEqual(collector, expected) + if (expected.length > 0) testExpected(root) +} + +function testInsert( + /** @memo */ + content: (array: ReadonlyArray) => void +) { + GlobalStateManager.reset() + const state = mutableState(createPages()) + const root = TestNode.create(() => content(state.value)) + testExpected(root) + state.value = createPages("three") + testExpected(root, "+three") + state.value = createPages("one", "three") + testExpected(root, "+one") + state.value = createPages("one", "three", "five") + testExpected(root, "+five") + state.value = createPages("one", "two", "three", "four", "five") + testExpected(root, "+two", "+four") +} + +function testRemove( + /** @memo */ + content: (array: ReadonlyArray) => void +) { + GlobalStateManager.reset() + const state = mutableState(createPages("one", "two", "three", "four", "five")) + const root = TestNode.create(() => content(state.value)) + testExpected(root, "+one", "+two", "+three", "+four", "+five") + state.value = createPages("one", "three", "five") + testExpected(root, "-two", "-four") + state.value = createPages("three", "five") + testExpected(root, "-one") + state.value = createPages("three") + testExpected(root, "-five") + state.value = createPages() + testExpected(root, "-three") +} + +function testSwap( + /** @memo */ + content: (array: ReadonlyArray) => void +) { + GlobalStateManager.reset() + const state = mutableState(createPages("one", "two", "three", "four", "five")) + const root = TestNode.create(() => content(state.value)) + testExpected(root, "+one", "+two", "+three", "+four", "+five") + state.value = createPages("two", "one", "three", "four", "five") + testExpected(root, "-one", "+one") + state.value = createPages("two", "four", "one", "three", "five") + testExpected(root, "-one", "-three", "+one", "+three") +} + +suite("repeat tests", () => { + + test("Repeat", () => { + GlobalStateManager.reset() + const state = mutableState(createPages()) + const root = TestNode.create(() => Repeat(state.value.length, index => state.value[index].page())) // index-based key + testExpected(root) + state.value = createPages("one") + testExpected(root, "+one") + state.value = createPages("one", "two", "three") + testExpected(root, "+two", "+three") + state.value = createPages("one", "two") + testExpected(root, "-three") + state.value = createPages("two") + testExpected(root, "-two") // because of index-based key; should be "-one" + state.value = createPages("one", "two") + testExpected(root, "+two") // because of index-based key; should be "+one" + }) + + + test("RepeatWithKey.insert", () => testInsert(array => RepeatWithKey( + array.length, + index => array[index].id, + index => array[index].page()))) + + test("RepeatByArray.insert", () => testInsert(array => RepeatByArray( + array, + element => element.id, + element => element.page()))) + + test("RepeatRange.insert", () => testInsert(array => RepeatRange( + 0, + array.length, + index => array[index], + element => element.id, + element => element.page()))) + + + test("RepeatWithKey.remove", () => testRemove(array => RepeatWithKey( + array.length, + index => array[index].id, + index => array[index].page()))) + + test("RepeatByArray.remove", () => testRemove(array => RepeatByArray( + array, + element => element.id, + element => element.page()))) + + test("RepeatRange.remove", () => testRemove(array => RepeatRange( + 0, + array.length, + index => array[index], + element => element.id, + element => element.page()))) + + + test("RepeatWithKey.swap", () => testSwap(array => RepeatWithKey( + array.length, + index => array[index].id, + index => array[index].page()))) + + test("RepeatByArray.swap", () => testSwap(array => RepeatByArray( + array, + element => element.id, + element => element.page()))) + + test("RepeatRange.swap", () => testSwap(array => RepeatRange( + 0, + array.length, + index => array[index], + element => element.id, + element => element.page()))) +}) diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test/states/Journal.test.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test/states/Journal.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..74439ca867d8efd6ef36cf98fa712a5a35108037 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test/states/Journal.test.ts @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Assert, suite, test } from "@koalaui/harness" +import { Changes, Journal } from "../../src/states/Journal" + +function assertChange(changes: Changes | undefined, state: Object, expected: Value) { + const change = changes?.getChange(state) + Assert.isDefined(change) + Assert.equal(change?.value, expected) +} + +function assertNoChange(changes: Changes | undefined, state: Object) { + const change = changes?.getChange(state) + Assert.isUndefined(change) +} + +function assertNoChanges(journal: Journal) { + Assert.isUndefined(journal.getChanges()) +} + +suite("Journal tests", () => { + + test("new journal has no any changes", () => { + const journal = new Journal() + assertNoChanges(journal) + }) + + test("add changes to journal", () => { + const state = new Object() + const journal = new Journal() + journal.addChange(state, "value1") + journal.addChange(state, "value2") + assertChange(journal, state, "value2") + assertNoChanges(journal) + }) + + test("add marked changes to journal", () => { + const state = new Object() + const journal = new Journal() + journal.addChange(state, "value1") + journal.addChange(state, "value2") + journal.setMarker() + assertChange(journal, state, "value2") + assertChange(journal.getChanges(), state, "value2") + }) + + test("add changes to journal after marker", () => { + const state = new Object() + const journal = new Journal() + journal.addChange(state, "value1") + journal.addChange(state, "value2") + journal.setMarker() + journal.addChange(state, "value3") + journal.addChange(state, "value4") + assertChange(journal, state, "value4") + assertChange(journal.getChanges(), state, "value2") + }) + + test("remove all changes from journal", () => { + const state = new Object() + const journal = new Journal() + journal.addChange(state, "value1") + journal.addChange(state, "value2") + journal.setMarker() + journal.addChange(state, "value3") + journal.addChange(state, "value4") + journal.clear() + assertNoChange(journal, state) + assertNoChanges(journal) + }) + + test("remove marked changes from journal", () => { + const state = new Object() + const journal = new Journal() + journal.addChange(state, "value1") + journal.addChange(state, "value2") + journal.setMarker() + journal.addChange(state, "value3") + journal.addChange(state, "value4") + const changes = journal.getChanges() + Assert.isDefined(changes) + changes?.clear() + assertChange(journal, state, "value4") + assertNoChanges(journal) + }) +}) diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test/states/Reusable.test.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test/states/Reusable.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..203590881eb525d765cd2a3953efc4c1b530a4f6 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test/states/Reusable.test.ts @@ -0,0 +1,194 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Assert as assert, suite, test } from "@koalaui/harness" +import { TestNode, ReusableTestNode, testUpdate, memoEntry, __id } from "../../src" +import { createStateManager, InternalScope } from "../../src/states/State" +import { assertNode } from "./State.test" +suite("State", () => { + test("reuse nodes basic", () => { + const manager = createStateManager() + const changed = manager.mutableState(false) + + let reusedScope: InternalScope + const rootNode = new ReusableTestNode(); rootNode.content = "root" + const root = manager.updatableNode(rootNode, context => { + assert.equal(rootNode, context.node) + if (!changed.value) { + reusedScope = + context.scope(5, 0, () => { const node = new TestNode(); node.content = "first node"; return node }, undefined, undefined, undefined, "reuse") + if (!reusedScope.unchanged) + reusedScope.recache() + const scope = context.scope(6, 0, () => { const node = new TestNode(); node.content = "second node"; return node }, undefined, undefined, undefined, "reuse") + if (!scope.unchanged) + scope.recache() + } else { + const scope3 = context.scope(6, 0, () => { const node = new TestNode(); node.content = "third node"; return node }, undefined, undefined, undefined, "reuse") + if (!scope3.unchanged) + scope3.recache() + let scope4 = context.scope(7, 0, () => { const node = new TestNode(); node.content = "fourth node"; return node }, undefined, undefined, undefined, "reuse") + assert.equal(reusedScope, scope4) + if (!scope4.unchanged) + scope4.recache() + } + }) + assertNode(root, + "root\n" + + " first node\n" + + " second node") + changed.value = true + assert.equal(testUpdate(false, manager), 1) + assertNode(root, + "root\n" + + " second node\n" + + " first node") + }) + + test("reuse nodes after disposing all", () => { + const manager = createStateManager() + const phase = manager.mutableState(0) + + let reusedScope1: InternalScope + let reusedScope2: InternalScope + const rootNode = new ReusableTestNode(); rootNode.content = "root" + const root = manager.updatableNode(rootNode, context => { + assert.equal(rootNode, context.node) + if (phase.value == 0) { + reusedScope1 = + context.scope(5, 0, () => { const node = new TestNode(); node.content = "first node"; return node }, undefined, undefined, undefined, "reuse") + if (!reusedScope1.unchanged) + reusedScope1.recache() + reusedScope2 = context.scope(6, 0, () => { const node = new TestNode(); node.content = "second node"; return node }, undefined, undefined, undefined, "reuse") + if (!reusedScope2.unchanged) + reusedScope2.recache() + } else if (phase.value == 1) { + // remove all + } else { + const scope3 = context.scope(8, 0, () => new TestNode(), undefined, undefined, undefined, "reuse") + assert.equal(reusedScope2, scope3) + if (!scope3.unchanged) + scope3.recache() + const scope4 = context.scope(9, 0, () => new TestNode(), undefined, undefined, undefined, "reuse") + assert.equal(reusedScope1, scope4) + if (!scope4.unchanged) + scope4.recache() + // scope 5 is brand new + const scope5 = context.scope(10, 0, () => new TestNode(), undefined, undefined, undefined, "reuse") + if (!scope5.unchanged) + scope5.recache() + } + }) + assertNode(root, + "root\n" + + " first node\n" + + " second node") + ++phase.value + assert.equal(testUpdate(false, manager), 1) + assertNode(root, "root") + ++phase.value + assert.equal(testUpdate(false, manager), 1) + assertNode(root, + "root\n" + + " second node\n" + + " first node\n" + + " ") + }) + + test("dispose root", () => { + const manager = createStateManager() + + const rootNode = new ReusableTestNode(); rootNode.content = "root" + const firstNode = new TestNode(); firstNode.content = "first node"; + const secondNode = new TestNode(); secondNode.content = "second node"; + const root = manager.updatableNode(rootNode, context => { + assert.equal(rootNode, context.node) + const scope1 = + context.scope(5, 0, () => firstNode, undefined, undefined, undefined, "reuse") + if (!scope1.unchanged) + scope1.recache() + const scope2 = context.scope(6, 0, () => secondNode, undefined, undefined, undefined, "reuse") + if (!scope2.unchanged) + scope2.recache() + }) + assertNode(root, + "root\n" + + " first node\n" + + " second node") + root.dispose() + assert(root.disposed) + assert(firstNode.disposed) + assert(secondNode.disposed) + }) + + test("reuse nested", () => { + const manager = createStateManager() + const version = manager.mutableState(0) + + let reusedScope: InternalScope + const rootNode = new ReusableTestNode(); rootNode.content = "root" + const root = manager.updatableNode(rootNode, context => { + assert.equal(rootNode, context.node) + if (version.value == 0) { + memoEntry(context, 2, () => { + reusedScope = + context.scope(5, 0, () => { const node = new TestNode(); node.content = "first node"; return node }, undefined, undefined, undefined, "reuse") + if (!reusedScope.unchanged) + reusedScope.recache() + }) + memoEntry(context, 3, () => { + const scope = context.scope(6, 0, () => { const node = new TestNode(); node.content = "second node"; return node }, undefined, undefined, undefined, "reuse") + if (!scope.unchanged) + scope.recache() + }) + } else if (version.value == 1) { + // remove all + } else { + let id = 0 + memoEntry(context, 3, () => { + id = __id() + console.log(`scope3`) + const scope3 = context.scope(6, 0, () => { const node = new TestNode(); node.content = "third node"; return node }, undefined, undefined, undefined, "reuse") + if (!scope3.unchanged) { + // assert.equal(__id(), 0) + scope3.recache() + } + }) + console.log(`after scope 3`) + memoEntry(context, 0, () => { + assert.equal(__id(), id - 3) + console.log(`scope4`) + let scope4 = context.scope(7, 0, () => { const node = new TestNode(); node.content = "fourth node"; return node }, undefined, undefined, undefined, "reuse") + assert.equal(reusedScope, scope4) + if (!scope4.unchanged) + scope4.recache() + }) + } + }) + assertNode(root, + "root\n" + + " first node\n" + + " second node") + version.value++ + assert.equal(testUpdate(false, manager), 1) + assertNode(root, "root") + version.value++ + assert.equal(testUpdate(false, manager), 1) + assertNode(root, + "root\n" + + " second node\n" + + " first node") + }) +} +) \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test/states/State.test.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test/states/State.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..b21d0a4b60606ecc60047fd531380bfc896859cf --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test/states/State.test.ts @@ -0,0 +1,1816 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Assert as assert, suite, test } from "@koalaui/harness" +import { UniqueId, KoalaCallsiteKey } from "@koalaui/common" +import { IncrementalNode, MutableState, State, TestNode, testUpdate, ValueTracker } from "../../src" +import { createStateManager } from "../../src/states/State" + +// For tests we compute positional ids from strings. +export function key(value: string): KoalaCallsiteKey { + let hash = (new UniqueId()).addString(value).compute().slice(0, 10) + return parseInt(hash, 16) +} + +export function assertNode(state: State, presentation: string) { + assert.isFalse(state.modified) // the same node + assert.equal(state.value.toHierarchy(), presentation) +} + +function assertState(state: State, value: Value, modified = false) { + assert.equal(state.modified, modified) + assert.equal(state.value, value) + assert.equal(state.modified, modified) +} + +function assertModifiedState(state: State, value: Value, modified = false) { + assertState(state, value, true) +} + +function assertStringsAndCleanup(array: string[], presentation: string) { + assert.isNotEmpty(array) + assert.equal(array.join(" ; "), presentation) + array.splice(0, array.length) +} + +suite("State", () => { + test("initial state is not modified", () => { + let manager = createStateManager() + let state = manager.mutableState(200) + assertState(state, 200) + }) + test("unmanaged state is modified immediately", () => { + let manager = createStateManager() + manager.frozen = true + let state = manager.mutableState(200) + state.dispose() + state.value = 404 + assertModifiedState(state, 404) + // check that modified state is updated + state.value = 404 + assertState(state, 404) + }) + test("managed state is not modified immediately", () => { + let manager = createStateManager() + manager.frozen = true + let state = manager.mutableState(200) + state.value = 404 + assertState(state, 200) + }) + test("managed state is modified on first snapshot update", () => { + let manager = createStateManager() + let state = manager.mutableState(200) + state.value = 404 + assert.equal(testUpdate(false, manager), 1) + assertModifiedState(state, 404) + }) + test("managed state is not modified on next snapshot update", () => { + let manager = createStateManager() + let state = manager.mutableState(200) + state.value = 404 + assert.equal(testUpdate(false, manager), 1) + assert.equal(testUpdate(false, manager), 0) + assertState(state, 404) + }) + test("managed state is not modified if the same value is set", () => { + let manager = createStateManager() + let state = manager.mutableState(200) + for (let index = 0; index <= 200; index++) { + state.value = index + } + assert.equal(testUpdate(false, manager), 0) + assertState(state, 200) + }) + test("unmanaged named state does not exist anymore", () => { + let manager = createStateManager() + const state = manager.namedState("named", () => 200) + assert.equal(state, manager.stateBy("named")!) + assert.isDefined>(manager.stateBy("named")!) + state.dispose() + assert.isUndefined(manager.stateBy("named")!) + state.dispose() + assert.isUndefined(manager.stateBy("named")!) + }) + test("managed named state is not modified immediately", () => { + let manager = createStateManager() + manager.frozen = true + manager.namedState("named", () => 200) + manager.stateBy("named")!.value = 404 + assert.equal(manager.valueBy("named"), 200) + assert.isFalse(manager.stateBy("named")?.modified) + }) + test("managed named state is modified on first snapshot update", () => { + let manager = createStateManager() + manager.namedState("named", () => 200) + manager.stateBy("named")!.value = 404 + assert.equal(testUpdate(false, manager), 1) + assert.equal(manager.valueBy("named"), 404) + assert.isTrue(manager.stateBy("named")?.modified) + }) + test("managed named state is not modified on next snapshot update", () => { + let manager = createStateManager() + manager.namedState("named", () => 200) + manager.stateBy("named")!.value = 404 + assert.equal(testUpdate(false, manager), 1) + assert.equal(testUpdate(false, manager), 0) + assert.equal(manager.valueBy("named"), 404) + assert.isFalse(manager.stateBy("named")?.modified) + }) + test("managed named state is not modified if the same value is set", () => { + let manager = createStateManager() + manager.namedState("named", () => 200) + for (let index = 0; index <= 200; index++) { + manager.stateBy("named")!.value = index + } + assert.equal(testUpdate(false, manager), 0) + assert.equal(manager.valueBy("named"), 200) + assert.isFalse(manager.stateBy("named")?.modified) + }) + test("do not allow to dispose parameter state", () => { + const name = "parameter" + const manager = createStateManager() + manager.computableState(context => { + const scope = context.scope(0, 1) + const param = scope.param(0, 200, undefined, name, true) // can be found by name + if (scope.unchanged) return scope.cached + const state = manager.stateBy(name)! + assert.isDefined(state) + assert.equal(state, param) + assert.throws(() => state.dispose()) + scope.recache() + }).value + }) + test("managed parameter state is modified immediately", () => { + const name = "parameter" + const manager = createStateManager() + manager.computableState(context => { + const scope = context.scope(0, 1) + const param = scope.param(0, 200, undefined, name, true) // can be found by name + if (scope.unchanged) return scope.cached + const state = manager.stateBy(name)! + assert.isDefined(state) + assert.equal(state, param) + state.value = 404 + assertModifiedState(state, 404) + // check that modified state is updated + state.value = 404 + assertState(state, 404) + scope.recache() + }).value + }) + test("updatable node should be recomputable state", () => { + const manager = createStateManager() + const mutableState = manager.mutableState(true) + const updatableNode = manager.updatableNode(new IncrementalNode(), () => mutableState.value) + // updatable node needs to be recomputed after creation + assert.isTrue(updatableNode.recomputeNeeded) + updatableNode.value + // updatable node is already computed after accessing + assert.isFalse(updatableNode.recomputeNeeded) + assert.equal(testUpdate(false, manager), 0) + // updatable node is already computed because nothing is changed + assert.isFalse(updatableNode.recomputeNeeded) + mutableState.value = !mutableState.value + // updatable node does not know that the mutable state is changed + assert.isFalse(updatableNode.recomputeNeeded) + assert.equal(testUpdate(false, manager), 1) + // updatable node needs to be recomputed because the mutable state is changed + assert.isTrue(updatableNode.recomputeNeeded) + }) + test("updatable node should not use StateManager.updateSnapshot()", () => { + const manager = createStateManager() + const state = manager.updatableNode(new IncrementalNode(), () => manager.updateSnapshot()) + assert.throws(() => state.value) + }) + test("updatable node should not use StateManager.updatableNode(...)", () => { + const manager = createStateManager() + const state = manager.updatableNode(new IncrementalNode(), () => manager.updatableNode(new IncrementalNode(), () => { })) + assert.throws(() => state.value) + }) + test("updatable node should not use StateManager.computableState(...)", () => { + const manager = createStateManager() + const state = manager.updatableNode(new IncrementalNode(), () => manager.updateSnapshot()) + assert.throws(() => state.value) + }) + test("computable state should be recomputable state", () => { + const manager = createStateManager() + const mutableState = manager.mutableState(true) + const computableState = manager.computableState(() => mutableState.value) + // computable state needs to be recomputed after creation + assert.isTrue(computableState.recomputeNeeded) + computableState.value + // computable state is already computed after accessing + assert.isFalse(computableState.recomputeNeeded) + assert.equal(testUpdate(false, manager), 0) + // computable state is already computed because nothing is changed + assert.isFalse(computableState.recomputeNeeded) + mutableState.value = !mutableState.value + // computable state does not know that the mutable state is changed + assert.isFalse(computableState.recomputeNeeded) + assert.equal(testUpdate(false, manager), 1) + // computable state needs to be recomputed because the mutable state is changed + assert.isTrue(computableState.recomputeNeeded) + }) + test("computable state should not use StateManager.updateSnapshot()", () => { + const manager = createStateManager() + const state = manager.computableState(() => manager.updateSnapshot()) + assert.throws(() => state.value) + }) + test("computable state should not use StateManager.updatableNode(...)", () => { + const manager = createStateManager() + const state = manager.computableState(() => manager.updatableNode(new IncrementalNode(), () => { })) + assert.throws(() => state.value) + }) + test("computable state depends on managed state", () => { + let manager = createStateManager() + let name = manager.mutableState("NAME") + // create computable state that tracks computing inner scopes + let computing: string[] = [] + let result = manager.computableState(context => { + computing.push("main") + return context.compute(key("left"), () => { + computing.push("left") + return "<= " + }) + context.compute(key("name"), () => { + computing.push("name") + return name.value + }) + context.compute(key("right"), () => { + computing.push("right") + return " =>" + }) + }) + // initial computation + assertState(result, "<= NAME =>") + assertStringsAndCleanup(computing, "main ; left ; name ; right") + // computable state is not modified + assert.equal(testUpdate(false, manager), 0) + assertState(result, "<= NAME =>") + assert.isEmpty(computing) + // compute state only when snapshot updated + name.value = "Sergey Malenkov" + assert.equal(testUpdate(false, manager), 1) + assertModifiedState(result, "<= Sergey Malenkov =>") + assertStringsAndCleanup(computing, "main ; name") + }) + test("computable state depends on named state managed globally", () => { + let manager = createStateManager() + // create named scope managed globally and schedule its updating + manager.namedState("global", () => "NAME") + // create computable state that tracks computing inner scopes + let computing: string[] = [] + let result = manager.computableState(context => { + computing.push("main") + return context.compute(key("left"), () => { + computing.push("left") + return "<= " + }) + context.compute(key("name"), () => { + computing.push("name") + return context.valueBy("global") + }) + context.compute(key("right"), () => { + computing.push("right") + return " =>" + }) + }) + // initial computation + assertState(result, "<= NAME =>") + assertStringsAndCleanup(computing, "main ; left ; name ; right") + // computable state is not modified + assert.equal(testUpdate(false, manager), 0) + assertState(result, "<= NAME =>") + assert.isEmpty(computing) + // compute state only when snapshot updated + manager.stateBy("global")!.value = "Sergey Malenkov" + assert.equal(testUpdate(false, manager), 1) + assertModifiedState(result, "<= Sergey Malenkov =>") + assertStringsAndCleanup(computing, "main ; name") + }) + test("computable state depends on named state managed locally", () => { + let manager = createStateManager() + // create computable state that tracks computing inner scopes + let computing: string[] = [] + let result = manager.computableState(context => { + computing.push("main") + return context.compute(key("left"), () => { + computing.push("left") + return "<= " + }) + context.compute(key("name"), () => { + computing.push("name") + const state = context.namedState("local", () => 1) + manager.scheduleCallback(() => state.value++) + return state.value + }) + context.compute(key("right"), () => { + computing.push("right") + return " =>" + }) + }) + // initial computation + assertState(result, "<= 1 =>") + assertStringsAndCleanup(computing, "main ; left ; name ; right") + // computable state is not modified + assertState(result, "<= 1 =>") + assert.isEmpty(computing) + // compute state only when snapshot updated + assert.equal(testUpdate(true, manager), 1) + assertModifiedState(result, "<= 2 =>") + assertStringsAndCleanup(computing, "main ; name") + // compute state on next snapshot update + assert.equal(testUpdate(true, manager), 1) + assertModifiedState(result, "<= 3 =>") + assertStringsAndCleanup(computing, "main ; name") + }) + test("computable state depends on named state managed locally from managed inner scope", () => { + let manager = createStateManager() + let computing: string[] = [] + let result = manager.computableState(context => { + context.namedState("local", () => 1) + computing.push("main") + return context.compute(key("left"), () => { + computing.push("left") + return "<= " + }) + context.compute(key("name"), () => { + computing.push("name") + const state = context.stateBy("local")! + manager.scheduleCallback(() => state.value++) + return context.valueBy("local").toString() + }) + context.compute(key("right"), () => { + computing.push("right") + return " =>" + }) + }) + // initial computation + assertState(result, "<= 1 =>") + assertStringsAndCleanup(computing, "main ; left ; name ; right") + // computable state is not modified + assertState(result, "<= 1 =>") + assert.isEmpty(computing) + // compute state only when snapshot updated + assert.equal(testUpdate(true, manager), 1) + assertModifiedState(result, "<= 2 =>") + assertStringsAndCleanup(computing, "main ; name") + // compute state on next snapshot update + assert.equal(testUpdate(true, manager), 1) + assertModifiedState(result, "<= 3 =>") + assertStringsAndCleanup(computing, "main ; name") + }) + test("computable state allows to cleanup disposed scopes", () => { + let manager = createStateManager() + let computing: string[] = [] + let result = manager.computableState(context => { + let name = context.compute(key("value"), () => { + computing.push("compute:value") + return "value" + }) + let condition = context.compute(key("condition"), () => { + computing.push("compute:condition") + return context.valueBy("condition") + }) + let value = condition + ? context.compute(key("true"), () => { + computing.push("compute:true") + return context.compute(key("true"), () => { + context.namedState("true", () => true) + computing.push("compute:inner:true") + return "true" + }, old => { + assert.isUndefined(context.stateBy("false")!) + assert.isDefined>(context.stateBy("true")!) + assert.isTrue(context.valueBy("true")) + assert.equal(old, "true") + computing.push("cleanup:inner:true") + }) + }, () => computing.push("cleanup:true")) + : context.compute(key("false"), () => { + computing.push("compute:false") + return context.compute(key("false"), () => { + context.namedState("false", () => false) + computing.push("compute:inner:false") + return "false" + }, old => { + assert.isUndefined(context.stateBy("true")!) + assert.isDefined>(context.stateBy("false")!) + assert.isFalse(context.valueBy("false")) + assert.equal(old, "false") + computing.push("cleanup:inner:false") + }) + }, () => computing.push("cleanup:false")) + return name + " is " + value + }) + let condition = manager.namedState("condition", () => true) + // initial computation + assert.equal(result.value, "value is true") + assertStringsAndCleanup(computing, "compute:value ; compute:condition ; compute:true ; compute:inner:true") + // condition changed from true to false + condition.value = false + assert.equal(testUpdate(false, manager), 1) + assert.equal(result.value, "value is false") + assertStringsAndCleanup(computing, "compute:condition ; compute:false ; compute:inner:false ; cleanup:true ; cleanup:inner:true") + // condition changed from false to true + condition.value = true + assert.equal(testUpdate(false, manager), 1) + assert.equal(result.value, "value is true") + assertStringsAndCleanup(computing, "compute:condition ; compute:true ; compute:inner:true ; cleanup:false ; cleanup:inner:false") + }) + test.skip("computable state does not support non-unique ids on add", () => { + let manager = createStateManager() + let computing: string[] = [] + let result = manager.computableState(context => { + let condition = context.compute(key("condition"), () => { + computing.push("compute:condition") + return context.valueBy("condition") + }) + let first = condition ? undefined : context.compute(key(""), () => { + computing.push("compute:first") + return "first" + }) + let second = context.compute(key(""), () => { + computing.push("compute:second") + return "second" + }) + return (first ? first + " & " : "only ") + second + }) + let condition = manager.namedState("condition", () => true) + // initial computation + assert.equal(result.value, "only second") + assertStringsAndCleanup(computing, "compute:condition ; compute:second") + // condition changed from true to false + condition.value = false + assert.equal(testUpdate(false, manager), 1) + assert.equal(result.value, "first & second") + assertStringsAndCleanup(computing, "compute:condition ; compute:first") + }) + test.skip("computable state does not support non-unique ids on remove", () => { + let manager = createStateManager() + let computing: string[] = [] + let result = manager.computableState(context => { + let condition = context.compute(key("condition"), () => { + computing.push("compute:condition") + return context.valueBy("condition") + }) + let first = condition ? undefined : context.compute(key(""), () => { + computing.push("compute:first") + return "first" + }) + let second = context.compute(key(""), () => { + computing.push("compute:second") + return "second" + }) + return (first ? first + " & " : "only ") + second + }) + let condition = manager.namedState("condition", () => false) + // initial computation + assert.equal(result.value, "first & second") + assertStringsAndCleanup(computing, "compute:condition ; compute:first ; compute:second") + // condition changed from false to true + condition.value = true + assert.equal(testUpdate(false, manager), 1) + assert.equal(result.value, "only second") + assertStringsAndCleanup(computing, "compute:condition") + }) + test("global named state must be created only once", () => { + let manager = createStateManager() + let created = manager.namedState("named", () => 200) + let existed = manager.namedState("named", () => { + assert.fail() + return 200 + }) + assert.equal(created, existed) + assert.equal(created, manager.stateBy("named")) + assert.equal(existed, manager.stateBy("named")) + }) + test("local named state must be created only once", () => { + createStateManager().computableState(context => { + let created = context.namedState("named", () => 200) + let existed = context.namedState("named", () => { + assert.fail() + return 200 + }) + assert.equal(created, existed) + assert.equal(created, context.stateBy("named")) + assert.equal(existed, context.stateBy("named")) + }).value + }) + test("global named state must not be created when creating another one", () => { + let manager = createStateManager() + manager.namedState("named", () => { + assert.throws(() => { + manager.namedState("unnamed", () => 200) + }) + return 200 + }) + }) + test("local named state must not be created when creating another one", () => { + createStateManager().computableState(context => { + context.namedState("named", () => { + assert.throws(() => { + context.namedState("unnamed", () => 200) + }) + return 200 + }) + }).value + }) + test("do not allow to dispose global mutable state when creating global named state", () => { + const manager = createStateManager() + const mutable = manager.mutableState("value") + manager.namedState("prohibited", () => { + assert.throws(() => mutable.dispose()) + return mutable.value + }) + }) + test("do not allow to dispose global mutable state when creating local named state", () => { + const manager = createStateManager() + const mutable = manager.mutableState("value") + const state = manager.computableState(context => { + context.namedState("prohibited", () => { + assert.throws(() => mutable.dispose()) + return mutable.value + }) + }) + state.value + state.dispose() + }) + test("do not allow to dispose global named state when creating global named state", () => { + const manager = createStateManager() + const named = manager.namedState("state", () => "value") + manager.namedState("prohibited", () => { + assert.equal(named, manager.stateBy("state")) + assert.throws(() => named.dispose()) + return named.value + }) + }) + test("do not allow to dispose local named state when creating local named state", () => { + const manager = createStateManager() + const state = manager.computableState(context => { + const named = context.namedState("state", () => "") + context.namedState("prohibited", () => { + assert.equal(named, manager.stateBy("state")) + assert.throws(() => named.dispose()) + return named.value + }) + }) + state.value + state.dispose() + }) + test("do not allow to dispose global mutable state when updating computable state", () => { + const manager = createStateManager() + const mutable = manager.mutableState("value") + const state = manager.computableState(context => { + assert.throws(() => mutable.dispose()) + }) + state.value + state.dispose() + }) + test("do not allow to dispose global named state when updating computable state", () => { + const manager = createStateManager() + const named = manager.namedState("state", () => "") + const state = manager.computableState(context => { + assert.throws(() => named.dispose()) + }) + state.value + state.dispose() + }) + test("do not allow to dispose local named state when updating computable state", () => { + const manager = createStateManager() + const state = manager.computableState(context => { + const named = context.namedState("state", () => "") + assert.throws(() => named.dispose()) + }) + state.value + state.dispose() + }) + test("do not allow to update snapshot when updating computable state", () => { + const manager = createStateManager() + const state = manager.computableState(context => { + assert.equal(context, manager) + assert.throws(() => manager.updateSnapshot()) + }) + state.value + state.dispose() + }) + test("do not allow to create updatable node when updating computable state", () => { + const manager = createStateManager() + const state = manager.computableState(context => { + assert.equal(context, manager) + assert.throws(() => manager.updatableNode(new TestNode(), () => { })) + }) + state.value + state.dispose() + }) + test("computable state must not compute something when creating local named state", () => { + createStateManager().computableState(context => { + context.namedState("name", () => { + assert.throws(() => { + context.compute(key("compute"), () => 200) + }) + return "NAME" + }) + return context.valueBy("name") + }).value + }) + test("computable state must not depend on managed state when creating another one", () => { + let manager = createStateManager() + let mutable = manager.mutableState("NAME") + let computable = manager.computableState(context => { + context.namedState("name", () => mutable.value) + return context.valueBy("name") + }) + // initial computation + assertState(computable, "NAME") + // do not update result when snapshot updated + mutable.value = "Sergey Malenkov" + assert.equal(testUpdate(false, manager), 1) + assertState(computable, "NAME") + }) + test("computable state from specific scope must be forgotten on dispose automatically", () => { + const manager = createStateManager() + const state = manager.mutableState(-1) + const selector = manager.mutableState(true) + const computable = manager.computableState(context => selector.value + ? context.compute(key("first"), () => context.computableState(() => state.value), undefined, true) + : context.compute(key("second"), () => context.computableState(() => state.value), undefined, true)) + // initial computation + const initial = computable.value + assertState(initial, -1) + // ensure that initial state is managed + state.value = -10 + assertState(initial, -1) + assert.equal(testUpdate(false, manager), 1) + assertModifiedState(state, -10) + assertModifiedState(initial, -10) + // dispose first inner scope + assert.strictEqual(computable.value, initial) + selector.value = false + assert.equal(testUpdate(false, manager), 1) + assert.notStrictEqual(computable.value, initial) + // ensure that initial state is not managed + assertState(initial, -10) + state.value = -100 + assert.equal(testUpdate(false, manager), 1) + assertState(initial, -10) + }) + test("named state from specific scope must be forgotten on dispose automatically", () => { + const manager = createStateManager() + manager.frozen = true + const selector = manager.mutableState(true) + const computable = manager.computableState(context => selector.value + ? context.compute(key("first"), () => context.namedState("name", () => -1)) + : context.compute(key("second"), () => context.namedState("name", () => 1))) + // initial computation + const initial = computable.value + assertState(initial, -1) + // ensure that initial state is managed + initial.value = -10 + assertState(initial, -1) + assert.equal(testUpdate(false, manager), 1) + assertModifiedState(initial, -10) + // dispose first inner scope + assert.strictEqual(computable.value, initial) + selector.value = false + assert.equal(testUpdate(false, manager), 1) + assert.notStrictEqual(computable.value, initial) + // ensure that initial state is not managed + assertState(initial, -10) + initial.value = -100 + assertModifiedState(initial, -100) + }) + test("mutable state from specific scope must be forgotten on dispose too", () => { + const manager = createStateManager() + manager.frozen = true + const selector = manager.mutableState(true) + const computable = manager.computableState(context => selector.value + ? context.compute(key("first"), () => context.mutableState(-1), undefined, true) + : context.compute(key("second"), () => context.mutableState(1), undefined, true)) + // initial computation + const initial = computable.value + assertState(initial, -1) + // ensure that initial state is managed + initial.value = -10 + assertState(initial, -1) + assert.equal(testUpdate(false, manager), 1) + assertModifiedState(initial, -10) + // dispose first inner scope + assert.strictEqual(computable.value, initial) + selector.value = false + assert.equal(testUpdate(false, manager), 1) + assert.notStrictEqual(computable.value, initial) + // ensure that initial state is not managed + assertState(initial, -10) + initial.value = -100 + assertModifiedState(initial, -100) + }) + test("mutable state must not be changed during recomposition", () => { + const manager = createStateManager() + const state = manager.mutableState(0) + const increment = () => { + assert.throws(() => state.value++) + return state.value + } + const computable = manager.computableState(context => + context.compute(key("a"), increment) + + context.compute(key("b"), increment) + + context.compute(key("c"), increment)) + assert.equal(computable.value, 0) + assert.equal(testUpdate(false, manager), 0) + assert.equal(computable.value, 0) + state.value++ + assert.equal(testUpdate(false, manager), 1) + assert.equal(computable.value, 3) + }) + test("allow to compute once within a leaf scope", () => { + const computable = createStateManager().computableState(context => + context.compute(key("leaf"), () => + context.compute(key("allowed"), () => 0, undefined, true), + undefined, true)) + assert.equal(computable.value, 0) + }) + test("create global mutable state in local context", () => { + const manager = createStateManager() + const computable = manager.computableState(context => context.mutableState(0, true)) + const globalState = computable.value + assert.equal("GlobalState=0", globalState.toString()) + globalState.value = 1 + assert.equal(testUpdate(false, manager), 1) + assert.equal("GlobalState,modified=1", globalState.toString()) + assert.equal(testUpdate(false, manager), 0) + computable.dispose() + assert.equal("GlobalState=1", globalState.toString()) + globalState.dispose() + assert.equal("GlobalState,disposed=1", globalState.toString()) + }) + test("create local mutable state in local context within remember", () => { + const manager = createStateManager() + const computable = manager.computableState(context => context.compute(0, () => context.mutableState(0, false), undefined, true)) + const localState = computable.value + assert.equal("LocalState=0", localState.toString()) + localState.value = 1 + assert.equal(testUpdate(false, manager), 1) + assert.equal("LocalState,modified=1", localState.toString()) + assert.equal(testUpdate(false, manager), 0) + computable.dispose() + assert.equal("LocalState,disposed=1", localState.toString()) + localState.dispose() + assert.equal("LocalState,disposed=1", localState.toString()) + }) + test("create global named state in local context", () => { + const manager = createStateManager() + const computable = manager.computableState>(context => { + const state = context.namedState("global", () => 0, true) + assert.equal(state, manager.stateBy("global")!) + assert.isDefined>(manager.stateBy("global", true)!) + assert.isUndefined(manager.stateBy("global", false)!) + return state + }) + const globalState = computable.value + assert.equal(globalState, manager.stateBy("global")) + assert.equal("GlobalState(global)=0", globalState.toString()) + globalState.value = 1 + assert.equal(testUpdate(false, manager), 1) + assert.equal("GlobalState(global),modified=1", globalState.toString()) + assert.equal(testUpdate(false, manager), 0) + computable.dispose() + assert.equal("GlobalState(global)=1", globalState.toString()) + globalState.dispose() + assert.equal("GlobalState(global),disposed=1", globalState.toString()) + }) + test("create local named state in local context", () => { + const manager = createStateManager() + const globalState = manager.namedState("global", () => Number.MAX_SAFE_INTEGER + 1) + const computable = manager.computableState>(context => { + assert.equal(globalState, manager.stateBy("global")!) + assert.isDefined>(manager.stateBy("global", true)!) + assert.isUndefined(manager.stateBy("global", false)!) + const state = context.namedState("local", () => 0, false) + assert.equal(state, manager.stateBy("local")!) + assert.isUndefined(manager.stateBy("local", true)!) + assert.isDefined>(manager.stateBy("local", false)!) + return state + }) + const localState = computable.value + assert.isUndefined(manager.stateBy("local")!) + assert.equal("LocalState(local)=0", localState.toString()) + localState.value = 1 + assert.equal(testUpdate(false, manager), 1) + assert.equal("LocalState(local),modified=1", localState.toString()) + assert.equal(testUpdate(false, manager), 0) + computable.dispose() + assert.equal("LocalState(local),disposed=1", localState.toString()) + localState.dispose() + assert.equal("LocalState(local),disposed=1", localState.toString()) + }) + test("prohibit to create local mutable state in global context", () => { + assert.throws(() => createStateManager().mutableState(0, false)) + }) + test("prohibit to create local named state in global context", () => { + assert.throws(() => createStateManager().namedState("name", () => 0, false)) + }) + test("prohibit to create local mutable state in local context", () => { + const computable = createStateManager().computableState(context => context.mutableState(0, false)) + assert.throws(() => computable.value) + }) + test("prohibit to compute within a leaf scope", () => { + const computable = createStateManager().computableState(context => + context.compute(key("leaf"), () => + context.compute(key("prohibit"), () => 0), + undefined, true)) + assert.throws(() => computable.value) + }) + test("prohibit to build tree within a leaf scope", () => { + const computable = createStateManager().updatableNode(new TestNode(), context => + context.compute(key("leaf"), () => + context.attach(key("prohibit"), () => new TestNode(), () => { }), + undefined, true)) + assert.throws(() => computable.value) + }) + test("prohibit to build tree within a computable state", () => { + const computable = createStateManager().computableState(context => + context.attach(key("prohibit"), () => new TestNode(), () => { })) + assert.throws(() => computable.value) + }) + test("leaf scope must not depend on managed state", () => { + const manager = createStateManager() + const state = manager.mutableState(0) + const computing: string[] = [] + const computable = manager.computableState(context => { + computing.push("computable") + return context.compute(key("name"), () => { + computing.push("name") + return state.value + }, undefined, true) + }) + // initial computation + assertState(computable, 0) + assertStringsAndCleanup(computing, "computable ; name") + // compute state only when snapshot updated + state.value = -1 + assert.equal(testUpdate(false, manager), 1) + assertState(computable, 0) + assert.isEmpty(computing) + }) + test("0. amount of modified states including computable states that have dependants", () => { + const manager = createStateManager() + const mutable = manager.mutableState(false) + let computableCounter = 0 + const computable = manager.computableState(context => { + computableCounter++ + return mutable.value + }) + let stateCounter = 0 + const state = manager.computableState(context => { + stateCounter++ + return computable.value + }) + assert.equal(testUpdate(false, manager), 0) + assert.equal(computableCounter, 0) // computable is not recomputed + assert.equal(stateCounter, 0) // state is not recomputed + assertState(state, false) + assert.equal(computableCounter, 1) // computable is recomputed + assert.equal(stateCounter, 1) // state is recomputed + mutable.value = true + assert.equal(testUpdate(false, manager), 2) + assert.equal(computableCounter, 2) // computable is recomputed automatically + assert.equal(stateCounter, 1) // state is not recomputed + assertModifiedState(state, true) + assert.equal(computableCounter, 2) // computable is not recomputed + assert.equal(stateCounter, 2) // state is recomputed by request + }) + test("1. amount of modified states including computable states that have dependants", () => { + const manager = createStateManager() + const mutable = manager.mutableState(false) + let computableCounter = 0 + const computable = manager.computableState(context => { + computableCounter++ + return mutable.value && false + }) + let stateCounter = 0 + const state = manager.computableState(context => { + stateCounter++ + return computable.value + }) + assert.equal(testUpdate(false, manager), 0) + assert.equal(computableCounter, 0) // computable is not recomputed + assert.equal(stateCounter, 0) // state is not recomputed + assertState(state, false) + assert.equal(computableCounter, 1) // computable is recomputed + assert.equal(stateCounter, 1) // state is recomputed + mutable.value = true + assert.equal(testUpdate(false, manager), 1) + assert.equal(computableCounter, 2) // computable is recomputed automatically + assert.equal(stateCounter, 1) // state is not recomputed + assertState(state, false) + assert.equal(computableCounter, 2) // computable is not recomputed + assert.equal(stateCounter, 1) // state is not recomputed because computable is not modified + }) + test("2. amount of modified states including computable states that have dependants", () => { + const manager = createStateManager() + const mutable = manager.mutableState(false) + let computableCounter = 0 + const computable = manager.computableState(context => { + computableCounter++ + return mutable.value + }) + let stateCounter = 0 + const state = manager.computableState(context => { + stateCounter++ + return computable.value && false + }) + assert.equal(testUpdate(false, manager), 0) + assert.equal(computableCounter, 0) // computable is not recomputed + assert.equal(stateCounter, 0) // state is not recomputed + assertState(state, false) + assert.equal(computableCounter, 1) // computable is recomputed + assert.equal(stateCounter, 1) // state is recomputed + mutable.value = true + assert.equal(testUpdate(false, manager), 2) + assert.equal(computableCounter, 2) // computable is recomputed automatically + assert.equal(stateCounter, 1) // state is not recomputed + assertState(state, false) + assert.equal(computableCounter, 2) // computable is not recomputed + assert.equal(stateCounter, 2) // state is recomputed by request but it is not modified + }) + test("build and update simple tree", () => { + let manager = createStateManager() + let count = manager.mutableState(30) + let first = manager.mutableState("first node") + let second = manager.mutableState("second node") + let computing: string[] = [] + const rootNode = new TestNode() + let firstNode: TestNode + let secondNode: TestNode + let root = manager.updatableNode(rootNode, context => { + computing.push("update root") + assert.equal(context.node, rootNode) + context.compute(key("init"), () => { + computing.push("init root") + assert.equal(context.node, rootNode) + rootNode.content = "root" + }) + if (count.value < 40) { + context.attach(key("first"), () => { + computing.push("create first") + assert.equal(context.node, undefined) + return firstNode = new TestNode() + }, () => { + computing.push("update first") + assert.equal(context.node, firstNode) + context.compute(key("init"), () => { + computing.push("init first") + assert.equal(context.node, firstNode) + firstNode.content = first.value + }) + }, () => { + computing.push("detach&dispose first") + assert.equal(context.node, firstNode) + }) + } + if (count.value > 20) { + context.attach(key("second"), () => { + computing.push("create second") + assert.equal(context.node, undefined) + return secondNode = new TestNode() + }, () => { + computing.push("update second") + assert.equal(context.node, secondNode) + context.compute(key("init"), () => { + computing.push("init second") + assert.equal(context.node, secondNode) + secondNode.content = second.value + }) + }, () => { + computing.push("detach&dispose second") + assert.equal(context.node, secondNode) + }) + } + }) + assertNode(root, + "root\n" + + " first node\n" + + " second node") + + assertStringsAndCleanup(computing, "update root ; init root ; create first ; update first ; init first ; create second ; update second ; init second") + + assert.equal(testUpdate(false, manager), 0) + assertNode(root, + "root\n" + + " first node\n" + + " second node") + + assert.isEmpty(computing) + + count.value = 20 + assert.equal(testUpdate(false, manager), 1) + assertNode(root, + "root\n" + + " first node") + + assertStringsAndCleanup(computing, "update root ; detach&dispose second") + + second.value = "last node" + assert.equal(testUpdate(false, manager), 1) + assertNode(root, + "root\n" + + " first node") + + assert.isEmpty(computing) + + count.value = 40 + assert.equal(testUpdate(false, manager), 1) + assertNode(root, + "root\n" + + " last node") + + assertStringsAndCleanup(computing, "update root ; create second ; update second ; init second ; detach&dispose first") + + count.value = 30 + assert.equal(testUpdate(false, manager), 1) + assertNode(root, + "root\n" + + " first node\n" + + " last node") + + assertStringsAndCleanup(computing, "update root ; create first ; update first ; init first") + + count.value = 40 + assert.equal(testUpdate(false, manager), 1) + assertNode(root, + "root\n" + + " last node") + + assertStringsAndCleanup(computing, "update root ; detach&dispose first") + + second.value = "second node" + assert.equal(testUpdate(false, manager), 1) + assertNode(root, + "root\n" + + " second node") + + assertStringsAndCleanup(computing, "update root ; update second ; init second") + }) + test("build and update deep tree", () => { + let manager = createStateManager() + manager.namedState("parent", () => "parent") + manager.namedState("child", () => "child") + manager.namedState("leaf", () => "leaf") + let computing: string[] = [] + const rootNode = new TestNode() + let parentNode: TestNode + let childNode: TestNode + let leafNode: TestNode + let root = manager.updatableNode(rootNode, context => { + computing.push("update root") + assert.equal(context.node, rootNode) + context.compute(key("init"), () => { + computing.push("init root") + assert.equal(context.node, rootNode) + rootNode.content = "root" + }) + if (context.valueBy("parent").length > 0) { + context.attach(key("parent"), () => { + computing.push("create parent") + assert.equal(context.node, undefined) + return parentNode = new TestNode() + }, () => { + computing.push("update parent") + assert.equal(context.node, parentNode) + context.compute(key("init"), () => { + computing.push("init parent") + assert.equal(context.node, parentNode) + parentNode.content = context.valueBy("parent") + }) + if (context.valueBy("child").length > 0) { + context.attach(key("child"), () => { + computing.push("create child") + assert.equal(context.node, undefined) + return childNode = new TestNode() + }, () => { + computing.push("update child") + assert.equal(context.node, childNode) + context.compute(key("init"), () => { + computing.push("init child") + assert.equal(context.node, childNode) + childNode.content = context.valueBy("child") + }) + if (context.valueBy("leaf").length > 0) { + context.attach(key("leaf"), () => { + computing.push("create leaf") + assert.equal(context.node, undefined) + return leafNode = new TestNode() + }, () => { + computing.push("update leaf") + assert.equal(context.node, leafNode) + context.compute(key("init"), () => { + computing.push("init leaf") + assert.equal(context.node, leafNode) + leafNode.content = context.valueBy("leaf") + }) + }, () => { + computing.push("detach&dispose leaf") + assert.equal(context.node, leafNode) + }) + } + }, () => { + computing.push("detach&dispose child") + assert.equal(context.node, childNode) + }) + } + }, () => { + computing.push("detach&dispose parent") + assert.equal(context.node, parentNode) + }) + } + }) + assertNode(root, + "root\n" + + " parent\n" + + " child\n" + + " leaf") + + assertStringsAndCleanup(computing, "update root ; init root ; create parent ; update parent ; init parent ; create child ; update child ; init child ; create leaf ; update leaf ; init leaf") + + assert.equal(testUpdate(false, manager), 0) + assertNode(root, + "root\n" + + " parent\n" + + " child\n" + + " leaf") + + assert.isEmpty(computing) + + manager.stateBy("leaf")!.value = "leaf node" + assert.equal(testUpdate(false, manager), 1) + assertNode(root, + "root\n" + + " parent\n" + + " child\n" + + " leaf node") + + assertStringsAndCleanup(computing, "update root ; update parent ; update child ; update leaf ; init leaf") + + manager.stateBy("parent")!.value = "" + assert.equal(testUpdate(false, manager), 1) + assertNode(root, + "root") + + assertStringsAndCleanup(computing, "update root ; detach&dispose parent ; detach&dispose child ; detach&dispose leaf") + + manager.stateBy("child")!.value = "child node" + assert.equal(testUpdate(false, manager), 1) + assertNode(root, + "root") + + assert.isEmpty(computing) + + manager.stateBy("parent")!.value = "parent node" + assert.equal(testUpdate(false, manager), 1) + assertNode(root, + "root\n" + + " parent node\n" + + " child node\n" + + " leaf node") + + assertStringsAndCleanup(computing, "update root ; create parent ; update parent ; init parent ; create child ; update child ; init child ; create leaf ; update leaf ; init leaf") + + manager.stateBy("leaf")!.value = "" + assert.equal(testUpdate(false, manager), 1) + assertNode(root, + "root\n" + + " parent node\n" + + " child node") + + assertStringsAndCleanup(computing, "update root ; update parent ; update child ; detach&dispose leaf") + }) + test("schedule state updating to the next frame", () => { + const manager = createStateManager() + const state = manager.mutableState(0) + manager.scheduleCallback(() => state.value = 10) + assertState(state, 0) + // first frame + assert.equal(testUpdate(true, manager), 1) + assertModifiedState(state, 10) + }) + test("schedule state updating to the second next frame", () => { + const manager = createStateManager() + const state = manager.mutableState(0) + manager.scheduleCallback(() => manager.scheduleCallback(() => state.value = 10)) + assertState(state, 0) + // first frame + assert.equal(testUpdate(true, manager), 0) + assertState(state, 0) + // second frame + assert.equal(testUpdate(true, manager), 1) + assertModifiedState(state, 10) + }) + test("schedule state updating to the third next frame", () => { + const manager = createStateManager() + const state = manager.mutableState(0) + manager.scheduleCallback(() => manager.scheduleCallback(() => manager.scheduleCallback(() => state.value = 10))) + assertState(state, 0) + // first frame + assert.equal(testUpdate(true, manager), 0) + assertState(state, 0) + // second frame + assert.equal(testUpdate(true, manager), 0) + assertState(state, 0) + // third frame + assert.equal(testUpdate(true, manager), 1) + assertModifiedState(state, 10) + }) +}) + + +class Data { + name: string + value: number + + constructor(name: string, value: number) { + this.name = name + this.value = value + } + + static equivalent(oldD: Data, newD: Data): boolean { + return oldD.name === newD.name && oldD.value === newD.value + } +} + +suite("Equivalent", () => { + const age16 = new Data("age", 16) + test("initial state is not modified", () => { + const manager = createStateManager() + const state = manager.mutableState(age16, undefined, Data.equivalent) + assertState(state, age16) + assert.equal(testUpdate(false, manager), 0) + assertState(state, age16) + }) + test("state is modified on first snapshot update", () => { + const manager = createStateManager() + const state = manager.mutableState(age16, undefined, Data.equivalent) + assertState(state, age16) + const age64 = new Data("age", 64) + assert.notEqual(age16, age64) + state.value = age64 + assert.equal(testUpdate(false, manager), 1) + assertModifiedState(state, age64) + assert.notEqual(state.value, age16) + }) + test("state is not modified on next snapshot update", () => { + const manager = createStateManager() + const state = manager.mutableState(age16, undefined, Data.equivalent) + assertState(state, age16) + const age64 = new Data("age", 64) + state.value = age64 + assert.equal(testUpdate(false, manager), 1) + assertModifiedState(state, age64) + assert.notEqual(state.value, age16) + assert.equal(testUpdate(false, manager), 0) + assertState(state, age64) + }) + test("state is not modified if values are equivalent, but returns new value", () => { + const manager = createStateManager() + const state = manager.mutableState(age16, undefined, Data.equivalent) + assertState(state, age16) + const equal = new Data("age", 16) + assert.notEqual(equal, age16) + assert.isTrue(Data.equivalent(equal, age16)) + state.value = equal + assert.equal(testUpdate(false, manager), 0) + assertState(state, equal) + assert.notEqual(state.value, age16) + }) + test("frozen state is not modified if values are equivalent, but returns new value", () => { + const manager = createStateManager() + manager.frozen = true // NB! + const state = manager.mutableState(age16, undefined, Data.equivalent) + assertState(state, age16) + const equal = new Data("age", 16) + assert.notEqual(equal, age16) + assert.isTrue(Data.equivalent(equal, age16)) + state.value = equal + assert.equal(testUpdate(false, manager), 0) + assertState(state, equal) + assert.notEqual(state.value, age16) + }) + test("state is not modified if the equivalent value is set, but returns new value", () => { + const manager = createStateManager() + const state = manager.mutableState(age16, undefined, Data.equivalent) + assertState(state, age16) + let value = age16 + for (let age = 0; age <= 16; age++) { + state.value = value = new Data("age", age) + } + assert.equal(testUpdate(false, manager), 0) + assertState(state, value) + }) + test("frozen state is not modified if the equivalent value is set, but returns new value", () => { + const manager = createStateManager() + manager.frozen = true // NB! + const state = manager.mutableState(age16, undefined, Data.equivalent) + assertState(state, age16) + let value = age16 + for (let age = 0; age <= 16; age++) { + state.value = value = new Data("age", age) + } + assert.equal(testUpdate(false, manager), 0) + assertState(state, value) + }) +}) + + +function tracker(onCreate: (value: Value) => Value, onUpdate: (value: Value) => Value): ValueTracker { + return { onCreate, onUpdate } +} + +function onCreate(onCreate: (value: Value) => Value): ValueTracker { + return tracker(onCreate, value => value) +} + +function onUpdate(onUpdate: (value: Value) => Value): ValueTracker { + return tracker(value => value, onUpdate) +} + +suite("ValueTracker", () => { + test("track state creation", () => { + const manager = createStateManager() + const state = manager.mutableState(5, undefined, undefined, onCreate(value => value * value)) + assertState(state, 25) + }) + test("disable state modification", () => { + const manager = createStateManager() + const state = manager.mutableState(5, undefined, undefined, onUpdate(value => { + throw new Error("cannot set " + value) + })) + assertState(state, 5) + assert.throws(() => state.value = 404) + assert.equal(testUpdate(false, manager), 0) + assertState(state, 5) + }) + test("disable state modification silently", () => { + const manager = createStateManager() + const state = manager.mutableState(5, undefined, undefined, onUpdate(() => 5)) + assertState(state, 5) + state.value = 404 + assert.equal(testUpdate(false, manager), 0) + assertState(state, 5) + }) + test("disposed state ignores tracker", () => { + const manager = createStateManager() + const state = manager.mutableState(5, undefined, undefined, onUpdate(() => 5)) + assertState(state, 5) + state.value = 404 + assert.equal(testUpdate(false, manager), 0) + assertState(state, 5) + state.dispose() + state.value = 999 + assertModifiedState(state, 999) + }) +}) + +suite("ArrayState", () => { + test("managed array state supports #at getter", () => { + const manager = createStateManager() + const array = manager.arrayState(["one", "two", "three"]) + assert.equal(array.length, 3) + assert.equal(array.at(0), "one") + assert.equal(array.at(1), "two") + assert.equal(array.at(2), "three") + assert.equal(array.at(-1), "three") + assert.equal(array.at(-2), "two") + assert.equal(array.at(-3), "one") + }) + test("computable state depends on managed array state", () => { + const manager = createStateManager() + const state = manager.mutableState(1) + const array = manager.arrayState(["item"]) + // create computable state that tracks computing inner scopes + const computing: string[] = [] + const result = manager.computableState(context => { + computing.push("outer") + return context.compute(key("left"), () => { + computing.push("left") + return "<= " + }) + context.compute(key("center"), () => { + computing.push("center") + const prefix = state.value + ": " + return prefix + context.compute(key("inner"), () => { + computing.push("inner") + return array.value.join(" ") + }) + }) + context.compute(key("right"), () => { + computing.push("right") + return " =>" + }) + }) + // initial computation + assertState(result, "<= 1: item =>") + assertStringsAndCleanup(computing, "outer ; left ; center ; inner ; right") + // computable state is not modified + assert.equal(testUpdate(false, manager), 0) + assert.equal(result.value, "<= 1: item =>") + assert.isEmpty(computing) + // compute state only when snapshot updated + state.value = 2 + array.set(0, "value") + assert.equal(testUpdate(false, manager), 2) + assert.equal(result.value, "<= 2: value =>") + assertStringsAndCleanup(computing, "outer ; center ; inner") + // compute state only when snapshot updated + state.value = 3 + array.set(0, "value") + assert.equal(testUpdate(false, manager), 1) + assert.equal(result.value, "<= 3: value =>") + assertStringsAndCleanup(computing, "outer ; center") + // compute state only when snapshot updated + state.value = 4 + array.length = 0 + assert.equal(testUpdate(false, manager), 2) + assert.equal(result.value, "<= 4: =>") + assertStringsAndCleanup(computing, "outer ; center ; inner") + // computable state is not modified + assert.equal(testUpdate(false, manager), 0) + assert.equal(result.value, "<= 4: =>") + assert.isEmpty(computing) + }) + test("computable state depends on managed array state #copyWithin", () => { + const manager = createStateManager() + const array = manager.arrayState(["one", "two", "three"]) + // create computable state that tracks computing inner scopes + const computing: string[] = [] + const result = manager.computableState(context => { + computing.push("outer") + return context.compute(key("left"), () => { + computing.push("left") + return "<= " + }) + context.compute(key("center"), () => { + computing.push("center") + return context.compute(key("inner"), () => { + computing.push("inner") + return array.value.join(" ") + }) + }) + context.compute(key("right"), () => { + computing.push("right") + return " =>" + }) + }) + // initial computation + assertState(result, "<= one two three =>") + assertStringsAndCleanup(computing, "outer ; left ; center ; inner ; right") + // computable state is not modified + assert.equal(testUpdate(false, manager), 0) + assert.equal(result.value, "<= one two three =>") + assert.isEmpty(computing) + // compute state only when snapshot updated + array.copyWithin(0, 1, 2) + assert.equal(testUpdate(false, manager), 1) + assert.equal(result.value, "<= two two three =>") + assertStringsAndCleanup(computing, "outer ; center ; inner") + // compute state only when snapshot updated + array.copyWithin(2, 0, 1) + assert.equal(testUpdate(false, manager), 1) + assert.equal(result.value, "<= two two two =>") + assertStringsAndCleanup(computing, "outer ; center ; inner") + // compute state only when snapshot updated + array.copyWithin(1, 2, 0) + assert.equal(testUpdate(false, manager), 0) + assert.equal(result.value, "<= two two two =>") + assert.isEmpty(computing) + // computable state is not modified + assert.equal(testUpdate(false, manager), 0) + assert.equal(result.value, "<= two two two =>") + assert.isEmpty(computing) + }) + test("computable state depends on managed array state #fill", () => { + const manager = createStateManager() + const array = manager.arrayState(["one", "two", "three"]) + // create computable state that tracks computing inner scopes + const computing: string[] = [] + const result = manager.computableState(context => { + computing.push("outer") + return context.compute(key("left"), () => { + computing.push("left") + return "<= " + }) + context.compute(key("center"), () => { + computing.push("center") + return context.compute(key("inner"), () => { + computing.push("inner") + return array.value.join(" ") + }) + }) + context.compute(key("right"), () => { + computing.push("right") + return " =>" + }) + }) + // initial computation + assertState(result, "<= one two three =>") + assertStringsAndCleanup(computing, "outer ; left ; center ; inner ; right") + // computable state is not modified + assert.equal(testUpdate(false, manager), 0) + assert.equal(result.value, "<= one two three =>") + assert.isEmpty(computing) + // compute state only when snapshot updated + array.fill("X", 1, 2) + assert.equal(testUpdate(false, manager), 1) + assert.equal(result.value, "<= one X three =>") + assertStringsAndCleanup(computing, "outer ; center ; inner") + // compute state only when snapshot updated + array.fill("X") + assert.equal(testUpdate(false, manager), 1) + assert.equal(result.value, "<= X X X =>") + assertStringsAndCleanup(computing, "outer ; center ; inner") + // compute state only when snapshot updated + array.fill("X", 1) + assert.equal(testUpdate(false, manager), 0) + assert.equal(result.value, "<= X X X =>") + assert.isEmpty(computing) + // computable state is not modified + assert.equal(testUpdate(false, manager), 0) + assert.equal(result.value, "<= X X X =>") + assert.isEmpty(computing) + }) + test("computable state depends on managed array state #pop", () => { + const manager = createStateManager() + const array = manager.arrayState(["first", "last"]) + // create computable state that tracks computing inner scopes + const computing: string[] = [] + const result = manager.computableState(context => { + computing.push("outer") + return context.compute(key("left"), () => { + computing.push("left") + return "<= " + }) + context.compute(key("center"), () => { + computing.push("center") + return context.compute(key("inner"), () => { + computing.push("inner") + return array.value.join(" ") + }) + }) + context.compute(key("right"), () => { + computing.push("right") + return " =>" + }) + }) + // initial computation + assertState(result, "<= first last =>") + assertStringsAndCleanup(computing, "outer ; left ; center ; inner ; right") + // computable state is not modified + assert.equal(testUpdate(false, manager), 0) + assert.equal(result.value, "<= first last =>") + assert.isEmpty(computing) + // compute state only when snapshot updated + assert.equal(array.pop(), "last") + assert.equal(testUpdate(false, manager), 1) + assert.equal(result.value, "<= first =>") + assertStringsAndCleanup(computing, "outer ; center ; inner") + // compute state only when snapshot updated + assert.equal(array.pop(), "first") + assert.equal(testUpdate(false, manager), 1) + assert.equal(result.value, "<= =>") + assertStringsAndCleanup(computing, "outer ; center ; inner") + // compute state only when snapshot updated + assert.isUndefined(array.pop()) + assert.equal(testUpdate(false, manager), 0) + assert.equal(result.value, "<= =>") + assert.isEmpty(computing) + // computable state is not modified + assert.equal(testUpdate(false, manager), 0) + assert.equal(result.value, "<= =>") + assert.isEmpty(computing) + }) + test("computable state depends on managed array state #push", () => { + const manager = createStateManager() + const array = manager.arrayState() + // create computable state that tracks computing inner scopes + const computing: string[] = [] + const result = manager.computableState(context => { + computing.push("outer") + return context.compute(key("left"), () => { + computing.push("left") + return "<= " + }) + context.compute(key("center"), () => { + computing.push("center") + return context.compute(key("inner"), () => { + computing.push("inner") + return array.value.join(" ") + }) + }) + context.compute(key("right"), () => { + computing.push("right") + return " =>" + }) + }) + // initial computation + assertState(result, "<= =>") + assertStringsAndCleanup(computing, "outer ; left ; center ; inner ; right") + // computable state is not modified + assert.equal(testUpdate(false, manager), 0) + assert.equal(result.value, "<= =>") + assert.isEmpty(computing) + // compute state only when snapshot updated + assert.equal(array.push(), 0) + assert.equal(testUpdate(false, manager), 0) + assert.equal(result.value, "<= =>") + assert.isEmpty(computing) + // compute state only when snapshot updated + assert.equal(array.push("one"), 1) + assert.equal(testUpdate(false, manager), 1) + assert.equal(result.value, "<= one =>") + assertStringsAndCleanup(computing, "outer ; center ; inner") + // compute state only when snapshot updated + assert.equal(array.push("two", "three"), 3) + assert.equal(testUpdate(false, manager), 1) + assert.equal(result.value, "<= one two three =>") + assertStringsAndCleanup(computing, "outer ; center ; inner") + // computable state is not modified + assert.equal(testUpdate(false, manager), 0) + assert.equal(result.value, "<= one two three =>") + assert.isEmpty(computing) + }) + test("computable state depends on managed array state #reverse", () => { + const manager = createStateManager() + const array = manager.arrayState(["one", "two", "three"]) + // create computable state that tracks computing inner scopes + const computing: string[] = [] + const result = manager.computableState(context => { + computing.push("outer") + return context.compute(key("left"), () => { + computing.push("left") + return "<= " + }) + context.compute(key("center"), () => { + computing.push("center") + return context.compute(key("inner"), () => { + computing.push("inner") + return array.value.join(" ") + }) + }) + context.compute(key("right"), () => { + computing.push("right") + return " =>" + }) + }) + // initial computation + assertState(result, "<= one two three =>") + assertStringsAndCleanup(computing, "outer ; left ; center ; inner ; right") + // computable state is not modified + assert.equal(testUpdate(false, manager), 0) + assert.equal(result.value, "<= one two three =>") + assert.isEmpty(computing) + // compute state only when snapshot updated + array.reverse() + assert.equal(testUpdate(false, manager), 1) + assert.equal(result.value, "<= three two one =>") + assertStringsAndCleanup(computing, "outer ; center ; inner") + // computable state is not modified + assert.equal(testUpdate(false, manager), 0) + assert.equal(result.value, "<= three two one =>") + assert.isEmpty(computing) + }) + test("computable state depends on managed array state #shift", () => { + const manager = createStateManager() + const array = manager.arrayState(["first", "last"]) + // create computable state that tracks computing inner scopes + const computing: string[] = [] + const result = manager.computableState(context => { + computing.push("outer") + return context.compute(key("left"), () => { + computing.push("left") + return "<= " + }) + context.compute(key("center"), () => { + computing.push("center") + return context.compute(key("inner"), () => { + computing.push("inner") + return array.value.join(" ") + }) + }) + context.compute(key("right"), () => { + computing.push("right") + return " =>" + }) + }) + // initial computation + assertState(result, "<= first last =>") + assertStringsAndCleanup(computing, "outer ; left ; center ; inner ; right") + // computable state is not modified + assert.equal(testUpdate(false, manager), 0) + assert.equal(result.value, "<= first last =>") + assert.isEmpty(computing) + // compute state only when snapshot updated + assert.equal(array.shift(), "first") + assert.equal(testUpdate(false, manager), 1) + assert.equal(result.value, "<= last =>") + assertStringsAndCleanup(computing, "outer ; center ; inner") + // compute state only when snapshot updated + assert.equal(array.shift(), "last") + assert.equal(testUpdate(false, manager), 1) + assert.equal(result.value, "<= =>") + assertStringsAndCleanup(computing, "outer ; center ; inner") + // compute state only when snapshot updated + assert.isUndefined(array.shift()) + assert.equal(testUpdate(false, manager), 0) + assert.equal(result.value, "<= =>") + assert.isEmpty(computing) + // computable state is not modified + assert.equal(testUpdate(false, manager), 0) + assert.equal(result.value, "<= =>") + assert.isEmpty(computing) + }) + test("computable state depends on managed array state #sort", () => { + const manager = createStateManager() + const array = manager.arrayState(["one", "two", "three"]) + // create computable state that tracks computing inner scopes + const computing: string[] = [] + const result = manager.computableState(context => { + computing.push("outer") + return context.compute(key("left"), () => { + computing.push("left") + return "<= " + }) + context.compute(key("center"), () => { + computing.push("center") + return context.compute(key("inner"), () => { + computing.push("inner") + return array.value.join(" ") + }) + }) + context.compute(key("right"), () => { + computing.push("right") + return " =>" + }) + }) + // initial computation + assertState(result, "<= one two three =>") + assertStringsAndCleanup(computing, "outer ; left ; center ; inner ; right") + // computable state is not modified + assert.equal(testUpdate(false, manager), 0) + assert.equal(result.value, "<= one two three =>") + assert.isEmpty(computing) + // compute state only when snapshot updated + array.sort() + assert.equal(testUpdate(false, manager), 1) + assert.equal(result.value, "<= one three two =>") + assertStringsAndCleanup(computing, "outer ; center ; inner") + // compute state only when snapshot updated + array.sort() + assert.equal(testUpdate(false, manager), 0) + assert.equal(result.value, "<= one three two =>") + assert.isEmpty(computing) + // compute state only when snapshot updated + array.sort((s1, s2) => s1.length < s2.length ? -1 : s1.length > s2.length ? 1 : s1.localeCompare(s2)) + assert.equal(testUpdate(false, manager), 1) + assert.equal(result.value, "<= one two three =>") + assertStringsAndCleanup(computing, "outer ; center ; inner") + // computable state is not modified + assert.equal(testUpdate(false, manager), 0) + assert.equal(result.value, "<= one two three =>") + assert.isEmpty(computing) + }) + test("computable state depends on managed array state #unshift", () => { + const manager = createStateManager() + const array = manager.arrayState() + // create computable state that tracks computing inner scopes + const computing: string[] = [] + const result = manager.computableState(context => { + computing.push("outer") + return context.compute(key("left"), () => { + computing.push("left") + return "<= " + }) + context.compute(key("center"), () => { + computing.push("center") + return context.compute(key("inner"), () => { + computing.push("inner") + return array.value.join(" ") + }) + }) + context.compute(key("right"), () => { + computing.push("right") + return " =>" + }) + }) + // initial computation + assertState(result, "<= =>") + assertStringsAndCleanup(computing, "outer ; left ; center ; inner ; right") + // computable state is not modified + assert.equal(testUpdate(false, manager), 0) + assert.equal(result.value, "<= =>") + assert.isEmpty(computing) + // compute state only when snapshot updated + assert.equal(array.unshift(), 0) + assert.equal(testUpdate(false, manager), 0) + assert.equal(result.value, "<= =>") + assert.isEmpty(computing) + // compute state only when snapshot updated + assert.equal(array.unshift("one"), 1) + assert.equal(testUpdate(false, manager), 1) + assert.equal(result.value, "<= one =>") + assertStringsAndCleanup(computing, "outer ; center ; inner") + // compute state only when snapshot updated + assert.equal(array.unshift("two", "three"), 3) + assert.equal(testUpdate(false, manager), 1) + assert.equal(result.value, "<= two three one =>") + assertStringsAndCleanup(computing, "outer ; center ; inner") + // computable state is not modified + assert.equal(testUpdate(false, manager), 0) + assert.equal(result.value, "<= two three one =>") + assert.isEmpty(computing) + }) +}) diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test/states/state_basics.test.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test/states/state_basics.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..13f667e59e0c772c57240071c94e0b75e6a1a360 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test/states/state_basics.test.ts @@ -0,0 +1,356 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Assert as assert, suite, test } from "@koalaui/harness" +import { uint32 } from "@koalaui/common" +import { + GlobalStateManager, + NodeAttach, + TestNode, + mutableState, + testRoot, + testTick, +} from "../../src" + +suite("State management basics", () => { + test("for loop computes the same id", () => { + let storage: any[] = [] + let addend = mutableState(0) + let log: string[] = [] + + /** @memo */ + function ui() { + let addon = addend.value + for (let i = addon; i < 3 + addon; i++) { + TestNode.attach((node: TestNode) => { + node.content = `${i} ${addon}` + log.push(node.content) + }) + } + } + const root = testRoot(ui) + + assert.deepEqual(log, ["0 0", "1 0", "2 0"]) + + log = [] + addend.value = 10; + testTick(root) + assert.deepEqual(log, []) + + log = [] + addend.value = 200; + testTick(root) + assert.deepEqual(log, []) + }) + + test("Function identity is a part of positional key", () => { + let log: string[] = [] + + /** @memo */ + function f1() { + log.push("f1") + } + + /** @memo */ + function f2() { + log.push("f2") + } + + let f = mutableState(f1) + + /** @memo */ + function ui() { + /** @memo */ + let y = f.value + y() + } + + log = [] + let root = testRoot(ui) + assert.deepEqual(log, ["f1"]) + + log = [] + testTick(root) + assert.deepEqual(log, []) + + f.value = f2 + + log = [] + testTick(root) + assert.deepEqual(log, ["f2"]) + + log = [] + testTick(root) + assert.deepEqual(log, []) + }) + + test("The same test as above but without __distinct", () => { + let log: string[] = [] + + /** @memo */ + function f1() { + log.push("f1") + } + /** @memo */ + function f2() { + log.push("f2") + } + /** @memo */ + function f3() { + log.push("f3") + } + + let sequence = mutableState([f1, f2, f3]) + + /** @memo */ + function ui() { + for (let i = 0; i < 3; i++) { + /** @memo */ + let f = sequence.value[i] + f() + } + } + + log = [] + const root = testRoot(ui) + assert.deepEqual(log, ["f1", "f2", "f3"]) + + log = [] + testTick(root) + assert.deepEqual(log, []) + + sequence.value = [f3, f2, f1] + + log = [] + testTick(root) + // Compare this test with the previous one + // Without distinct we just compare the subsequent iterations. + // + // f1 first time + // f2 recomputes + // f3 recomputes + // + // f3 the same! + // f2 recomputes + // f1 recomputes + assert.deepEqual(log, ["f2", "f1"]) + + log = [] + testTick(root) + assert.deepEqual(log, []) + }) + + /* + These two tests are no longer relevant, as we forbid state mutations in UI functions. + + test("mutable state dereference causes recomputes", () => { + let peekNode = "" + + // @memo + function ui() { + const x = remember(() => mutableState(true)) + StringNode(node => { + if (x.value) { + node.content = "head" + } else { + node.content = "tail" + } + peekNode = node.content + }) + x.value = !x.value + } + + const root = testRoot(ui) + + assert.equal(peekNode, "head") + + testTick(root) + + assert.equal(peekNode, "tail") + + testTick(root) + + assert.equal(peekNode, "head") + }) + + test("mutable state dereference doesn't affect nested scopes", () => { + let peekNode = "" + + // @memo + function ui() { + const x = remember(() => mutableState(true)) + + const y = x.value + + StringNode(node => { + if (y) { + node.content = "head" + } else { + node.content = "tail" + } + peekNode = node.content + }) + x.value = !x.value + } + const root = testRoot(ui) + + assert.equal(peekNode, "head") + + testTick(root) + + assert.equal(peekNode, "head") + + testTick(root) + + assert.equal(peekNode, "head") + }) + */ + + test("Argument change causes recomposition", () => { + let peekNode = "" + let peekY: boolean | undefined = undefined + let peekX: boolean | undefined = undefined + const y = mutableState(true) + + /** @memo */ + function ui() { + peekY = y.value + child(y.value) + } + + /** @memo */ + function child(x: boolean) { + peekX = x + TestNode.attach((node: TestNode) => { + if (x) { + node.content = "head" + } else { + node.content = "tail" + } + peekNode = node.content + }) + } + const root = testRoot(ui) + + assert.equal(peekY, true) + assert.equal(peekX, true) + assert.equal(peekNode, "head") + y.value = !y.value + + testTick(root) + + assert.equal(peekY, false) + assert.equal(peekX, false) + assert.equal(peekNode, "tail") + y.value = !y.value + + testTick(root) + + assert.equal(peekY, true) + assert.equal(peekX, true) + assert.equal(peekNode, "head") + }) + + test("Value seen immediately if not in @memo", () => { + const x = mutableState(true) + assert.equal(x.value, true) + x.value = !x.value + assert.equal(x.value, false) + }) + + test("Value seen later if in @memo", () => { + GlobalStateManager.instance.frozen = true + const x = mutableState(true) + assert.equal(x.value, true) + x.value = !x.value + assert.equal(x.value, true) + GlobalStateManager.instance.frozen = false + }) + + class fooNode extends TestNode { + constructor(kind: uint32 = 1) { + super(kind) + } + } + + test("Static member @memo", () => { + const s = mutableState(11) + const result: Array = [] + class X { + /** @memo */ + static foo( + /** @memo */ + content?: () => void + ) { + NodeAttach(() => new fooNode(), () => { + result.push(s.value) + content?.() + }) + } + } + + /** @memo */ + function ui() { + X.foo(() => { + result.push(-1) + }) + } + + const root = testRoot(ui) + testTick(root) + testTick(root) + s.value = 17 + testTick(root) + testTick(root) + s.value = 41 + testTick(root) + testTick(root) + + assert.deepEqual(result, [11, -1, 17, 41]) + }) + + test("Receiver change triggers method recompute", () => { + + class X { + constructor(public value: number) { } + /** @memo */ + method(arg?: number) { + peek.push(this.value) + } + } + + const x = mutableState(new X(11)) + const peek: number[] = [] + + /** @memo */ + function ui() { + x.value.method() + } + + const root = testRoot(ui) + assert.deepEqual(peek, [11]) + + testTick(root) + assert.deepEqual(peek, [11]) + + x.value = new X(22) + testTick(root) + assert.deepEqual(peek, [11, 22]) + + testTick(root) + assert.deepEqual(peek, [11, 22]) + + }) +}) diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test/tree/TreeNode.test.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test/tree/TreeNode.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..3fae69b18d5d780d10f20d87ec14ad533d34a3aa --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test/tree/TreeNode.test.ts @@ -0,0 +1,375 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Assert as assert, suite, test } from "@koalaui/harness" +import { TreeNode } from "../../src/tree/TreeNode" + +class StringNode extends TreeNode { + readonly content: string + + constructor(content: string, ...children: StringNode[]) { + super() + this.content = content + this.appendChildren(...children) + } + + toString(): string { + return this.content + } +} + +function contentOf(node: TreeNode) { + return (node as StringNode)?.content +} + +function assertContent(node: TreeNode, content: string) { + assert.equal(contentOf(node), content) +} + +function assertRoot(node: TreeNode) { + assert.isUndefined(node.parent) + assert.equal(node.depth, 0) + assert.equal(node.index, -1) +} + +function assertLeaf(node: TreeNode) { + assert.equal(node.childrenCount, 0) +} + +function assertNoChildAt(parent: TreeNode, index: number) { + assert.isUndefined(parent.childAt(index)) +} + +function assertChildAt(parent: TreeNode, index: number): TreeNode { + let child = parent.childAt(index) + assert.isDefined(child) + assert.equal(child?.parent, parent) + assert.equal(child?.index, index) + return child! +} + +function assertToString(root: TreeNode, expected: string) { + assert.equal(root.toHierarchy(), expected) +} + +function assertRemoveChildrenAt(root: TreeNode, index: number, count: number, expected: number) { + let childrenCount = root.childrenCount + let children = root.removeChildrenAt(index, count) + assert.equal(children.length, expected) + assert.equal(root.childrenCount, childrenCount - expected) + for (let i = 0; i < expected; i++) { + assertRoot(children[i]) + } +} + +function createRoot() { + return new StringNode("root", + new StringNode("first"), + new StringNode("second"), + new StringNode("third")) +} + +function createDigitsRoot() { + return new StringNode("digits", + new StringNode("0"), + new StringNode("1"), + new StringNode("2"), + new StringNode("3"), + new StringNode("4"), + new StringNode("5"), + new StringNode("6"), + new StringNode("7"), + new StringNode("8"), + new StringNode("9")) +} + +suite("TreeNode", () => { + test("single node", () => { + let node = new StringNode("node") + assertContent(node, "node") + assertRoot(node) + assertLeaf(node) + }) + test("simple root", () => { + let root = createRoot() + assertContent(root, "root") + assertRoot(root) + assert.equal(root.childrenCount, 3) + assertNoChildAt(root, Number.MIN_VALUE) + assertNoChildAt(root, Number.MAX_VALUE) + assertNoChildAt(root, Number.MIN_SAFE_INTEGER) + assertNoChildAt(root, Number.MAX_SAFE_INTEGER) + assertNoChildAt(root, -1) + assertNoChildAt(root, 3) + assertNoChildAt(root, 0.1) + assertNoChildAt(root, 2.9) + let node0 = assertChildAt(root, 0) + assertContent(node0, "first") + assertLeaf(node0) + let node1 = assertChildAt(root, 1) + assertContent(node1, "second") + assertLeaf(node1) + let node2 = assertChildAt(root, 2) + assertContent(node2, "third") + assertLeaf(node2) + const children = root.children.slice() + assert.equal(children.length, 3) + assert.equal(children[0], node0) + assert.equal(children[1], node1) + assert.equal(children[2], node2) + assertToString(root, + "root\n" + + " first\n" + + " second\n" + + " third") + }) + test("iterate for each child", () => { + let root = createRoot() + let count = 0 + let children = ["first", "second", "third"] + root.forEach(node => { + assert.equal(children[count], contentOf(node)) + count++ + }) + assert.equal(count, 3) + }) + test("iterate for each child with index", () => { + let root = createRoot() + let count = 0 + root.forEach((node, index) => { + assert.equal(index, count) + count++ + }) + assert.equal(count, 3) + }) + test("iterate through not every child", () => { + let root = createRoot() + let count = 0 + assert.isFalse(root.every(node => { + count++ + return contentOf(node)?.length == 5 + })) + assert.equal(count, 2) + }) + test("iterate through every child with index", () => { + let root = createRoot() + let count = 0 + let children = ["first", "second", "third"] + assert.isTrue(root.every((node, index) => { + assert.equal(index, count) + count++ + return children[index] === contentOf(node) + })) + assert.equal(count, 3) + }) + test("iterate through some children", () => { + let root = createRoot() + let count = 0 + assert.isTrue(root.some(node => { + count++ + return contentOf(node)?.length == 6 + })) + assert.equal(count, 2) + }) + test("iterate through some children with index", () => { + let root = createRoot() + let count = 0 + assert.isTrue(root.some((node, index) => { + assert.equal(index, count) + count++ + return index == 0 + })) + assert.equal(count, 1) + }) + test("find child by content", () => { + let root = createRoot() + assert.equal(root.find((node):TreeNode|undefined => contentOf(node) == "second" ? node : undefined), assertChildAt(root, 1)) + }) + test("find child by index", () => { + let root = createRoot() + assert.equal(root.find((node, index):TreeNode|undefined => index == 1 ? node : undefined), assertChildAt(root, 1)) + }) + test("insert, move and remove children", () => { + let root = createRoot() + assert.isFalse(root.removeChild(new StringNode("second"))) // non-existent node + assertToString(root, + "root\n" + + " first\n" + + " second\n" + + " third") + let second = assertChildAt(root, 1) + second.appendChildren(new StringNode("1"), new StringNode("2"), new StringNode("3")) + assertToString(root, + "root\n" + + " first\n" + + " second\n" + + " 1\n" + + " 2\n" + + " 3\n" + + " third") + second.removeFromParent() + assertRoot(second) + assertToString(second, + "second\n" + + " 1\n" + + " 2\n" + + " 3") + assertToString(root, + "root\n" + + " first\n" + + " third") + assert.isFalse(root.removeChild(second)) // cannot remove twice + assert.isTrue(root.insertChildAt(0, second)) + assertToString(root, + "root\n" + + " second\n" + + " 1\n" + + " 2\n" + + " 3\n" + + " first\n" + + " third") + let first = root.removeChildAt(1) + assert.isDefined(first) + assertRoot(first!) + assertContent(first!, "first") + root.appendChild(first!) + assertToString(root, + "root\n" + + " second\n" + + " 1\n" + + " 2\n" + + " 3\n" + + " third\n" + + " first") + }) + test("insert several children at once", () => { + let root = createRoot() + let children = [new StringNode("second.1"), new StringNode("second.2"), new StringNode("second.3")] + assert.isFalse(root.insertChildrenAt(Number.MIN_VALUE, ...children)) + assert.isFalse(root.insertChildrenAt(Number.MAX_VALUE, ...children)) + assert.isFalse(root.insertChildrenAt(Number.MIN_SAFE_INTEGER, ...children)) + assert.isFalse(root.insertChildrenAt(Number.MAX_SAFE_INTEGER, ...children)) + assert.isFalse(root.insertChildrenAt(-1, ...children)) + assert.isFalse(root.insertChildrenAt(4, ...children)) + assert.isFalse(root.insertChildrenAt(0.1, ...children)) + assert.isFalse(root.insertChildrenAt(2.9, ...children)) + assert.isTrue(root.insertChildrenAt(2, ...children)) + assertToString(root, + "root\n" + + " first\n" + + " second\n" + + " second.1\n" + + " second.2\n" + + " second.3\n" + + " third") + assert.isTrue(root.insertChildrenAt(0, new StringNode("zero"))) + assertToString(root, + "root\n" + + " zero\n" + + " first\n" + + " second\n" + + " second.1\n" + + " second.2\n" + + " second.3\n" + + " third") + assert.isTrue(root.insertChildrenAt(root.childrenCount, new StringNode("third.A"), new StringNode("third.B"))) + assertToString(root, + "root\n" + + " zero\n" + + " first\n" + + " second\n" + + " second.1\n" + + " second.2\n" + + " second.3\n" + + " third\n" + + " third.A\n" + + " third.B") + }) + test("remove several children at once", () => { + let root = createDigitsRoot() + assertToString(root, + "digits\n" + + " 0\n" + + " 1\n" + + " 2\n" + + " 3\n" + + " 4\n" + + " 5\n" + + " 6\n" + + " 7\n" + + " 8\n" + + " 9") + assertRemoveChildrenAt(root, Number.MIN_VALUE, 1, 0) + assertRemoveChildrenAt(root, Number.MAX_VALUE, 1, 0) + assertRemoveChildrenAt(root, Number.MIN_SAFE_INTEGER, 1, 0) + assertRemoveChildrenAt(root, Number.MAX_SAFE_INTEGER, 1, 0) + assertRemoveChildrenAt(root, -1, 1, 0) + assertRemoveChildrenAt(root, root.childrenCount, 1, 0) + assertRemoveChildrenAt(root, 0.1, 1, 0) + assertRemoveChildrenAt(root, 2.9, 1, 0) + // remove leading nodes + assertRemoveChildrenAt(root, 0, 1 + root.childrenCount, 0) + assertRemoveChildrenAt(root, 0, 2, 2) + assertToString(root, + "digits\n" + + " 2\n" + + " 3\n" + + " 4\n" + + " 5\n" + + " 6\n" + + " 7\n" + + " 8\n" + + " 9") + // remove trailing nodes + assertRemoveChildrenAt(root, root.childrenCount - 1, 2, 0) + assertRemoveChildrenAt(root, root.childrenCount - 2, 2, 2) + assertToString(root, + "digits\n" + + " 2\n" + + " 3\n" + + " 4\n" + + " 5\n" + + " 6\n" + + " 7") + // remove inner nodes + assertRemoveChildrenAt(root, 1, root.childrenCount, 0) + assertRemoveChildrenAt(root, 1, 4, 4) + assertToString(root, + "digits\n" + + " 2\n" + + " 7") + }) + test("remove trailing children at once", () => { + let root = createDigitsRoot() + assert.equal(root.childrenCount, 10) + assert.equal(root.removeChildrenAt(Number.MIN_VALUE).length, 0) + assert.equal(root.removeChildrenAt(Number.MAX_VALUE).length, 0) + assert.equal(root.removeChildrenAt(Number.MIN_SAFE_INTEGER).length, 0) + assert.equal(root.removeChildrenAt(Number.MAX_SAFE_INTEGER).length, 0) + assert.equal(root.removeChildrenAt(-1).length, 0) + assert.equal(root.removeChildrenAt(root.childrenCount).length, 0) + assert.equal(root.removeChildrenAt(0.1).length, 0) + assert.equal(root.removeChildrenAt(2.9).length, 0) + assert.equal(root.childrenCount, 10) + assert.equal(root.removeChildrenAt(7).length, 3) + assert.equal(root.childrenCount, 7) + assert.equal(root.removeChildrenAt(6).length, 1) + assert.equal(root.childrenCount, 6) + assert.equal(root.removeChildrenAt(1).length, 5) + assert.equal(root.childrenCount, 1) + assert.equal(root.removeChildrenAt(0).length, 1) + assert.equal(root.childrenCount, 0) + }) +}) diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test/tree/TreePath.test.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test/tree/TreePath.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..f13e34178282acc8b9a340f77058baeea7e91835 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test/tree/TreePath.test.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Assert as assert, suite, test } from "@koalaui/harness" +import { TreePath } from "../../src/tree/TreePath" + +suite("TreePath", () => { + + let root = new TreePath("root") + + test("root path is root", () => assert.strictEqual(root.root, root)) + test("root path depth", () => assert.equal(root.depth, 0)) + test("root path has undefined parent", () => assert.strictEqual(root.parent, undefined)) + test("root path to string", () => assert.equal(root.toString(), "/root")) + + let parent = root.child("parent") + let current = parent.child("node") + + test("tree path has root", () => assert.strictEqual(current.root, root)) + test("tree path has parent", () => assert.strictEqual(current.parent, parent)) + test("tree path depth", () => assert.equal(current.depth, 2)) + test("tree path parent depth", () => assert.equal(current.parent?.depth, 1)) + test("tree path to string", () => assert.equal(current.toString(), "/root/parent/node")) + + let sibling = parent.child("sibling") + + test("siblings has the same parents", () => assert.strictEqual(current.parent, sibling.parent)) +}) diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test/tsconfig.json b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test/tsconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..88cfa1678b44ba23484419c31c3a5fd78df0376f --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/test/tsconfig.json @@ -0,0 +1,13 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "baseUrl": "./", + "outDir": "build/test", + "module": "CommonJS", + "plugins": [ + { "transform": "@koalaui/compiler-plugin/build/lib/src/koala-transformer.js", "contextImport": "../../src/internals", "trace": false } + ] + }, + "include": ["../**/*"], + "exclude": ["../build"] +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/tsconfig-run-unmemoized.json b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/tsconfig-run-unmemoized.json new file mode 100644 index 0000000000000000000000000000000000000000..ce60b1b3bdcae66e50ff46209a169b0cab2066e1 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/tsconfig-run-unmemoized.json @@ -0,0 +1,15 @@ +{ + "extends": "@koalaui/build-common/tsconfig.json", + "compilerOptions": { + "outDir": "build/lib/unmemoized", + "rootDir": "./build/unmemoized", + "rootDirs": ["./build/unmemoized/src", "./build/unmemoized/test"], + "module": "CommonJS" + }, + "include": ["./build/unmemoized/src/**/*"], + "references": [ + { "path": "../compiler-plugin" }, + { "path": "../common" }, + { "path": "../compat" } + ] +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/tsconfig-unmemoize-with-tests.json b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/tsconfig-unmemoize-with-tests.json new file mode 100644 index 0000000000000000000000000000000000000000..4fdea441bead5a29828b828085165ab29565b645 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/tsconfig-unmemoize-with-tests.json @@ -0,0 +1,9 @@ +{ + "extends": "./tsconfig-unmemoize.json", + "include": [ "src/**/*.ts", "test/**/*.ts", "test-arkts/**/*.ts" ], + "references": [ + { "path": "../compiler-plugin" }, + { "path": "../common" }, + { "path": "../harness" } + ] +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/tsconfig-unmemoize.json b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/tsconfig-unmemoize.json new file mode 100644 index 0000000000000000000000000000000000000000..27497fbb2a69c3ae9937184cb1859c755ec4803d --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/tsconfig-unmemoize.json @@ -0,0 +1,22 @@ +{ + "extends": "@koalaui/build-common/tsconfig.json", + "compilerOptions": { + "outDir": "build/unmemoized/lib", + "rootDir": ".", + "module": "CommonJS", + "plugins": [ + { + "transform": "@koalaui/compiler-plugin/build/lib/src/koala-transformer.js", + "contextImport": "../../src/internals", + "unmemoizeDir": "./build/unmemoized", + "only_unmemoize": true, + "trace": false + } + ] + }, + "include": [ "src/**/*.ts" ], + "references": [ + { "path": "../compiler-plugin" }, + { "path": "../common" } + ] +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/tsconfig-with-tests.json b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/tsconfig-with-tests.json new file mode 100644 index 0000000000000000000000000000000000000000..e347105d2fa79ad34a554e67b6a2d01f7fab12dc --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/tsconfig-with-tests.json @@ -0,0 +1,9 @@ +{ + "extends": "./tsconfig.json", + "include": [ "src/**/*.ts", "test/**/*.ts" ], + "references": [ + { "path": "../compiler-plugin" }, + { "path": "../common" }, + { "path": "../harness" } + ] +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/tsconfig.json b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/tsconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..e7b1a4b006936ba3cf02e9f493e1760ad0b88e96 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/tsconfig.json @@ -0,0 +1,20 @@ +{ + "extends": "@koalaui/build-common/tsconfig.json", + "compilerOptions": { + "outDir": "build/lib", + "rootDir": ".", + "module": "CommonJS", + "plugins": [ + { + "transform": "@koalaui/compiler-plugin/build/lib/src/koala-transformer.js", + "contextImport": "../../src/internals", + "trace": false + } + ] + }, + "include": [ "src/**/*.ts" ], + "references": [ + { "path": "../compiler-plugin" }, + { "path": "../common" } + ] +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/ui2abcconfig-only-restart.json b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/ui2abcconfig-only-restart.json new file mode 100644 index 0000000000000000000000000000000000000000..38dda067fbe6462e15e0dc3a8cf92713811747d4 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/ui2abcconfig-only-restart.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "package": "@koalaui/runtime", + "outDir": "build", + "baseUrl": "./src", + "paths": { + "@koalaui/common": ["../../common/src"], + "@koalaui/compat": ["../../compat/src/arkts"] + }, + "plugins": [ + { + "transform": "@koalaui/libarkts/plugins/no-visitor", + "stage": "parsed", + "name": "no" + } + ] + }, + "include": ["./src/**/*.ts"] +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/ui2abcconfig.json b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/ui2abcconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..7d76ecdaeacebc741f036bca1d18a5d7f47c883c --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/runtime/ui2abcconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "package": "@koalaui/runtime", + "outDir": "build", + "baseUrl": "./ets", + "paths": { + "@koalaui/common": ["../../common/src"], + "@koalaui/compat": ["../../compat/src/arkts"], + "@koalaui/runtime/annotations": ["../annotations"] + }, + "plugins": [ + { + "transform": "@koalaui/memo-plugin", + "stage": "checked", + "contextImport": "../internals", + "name": "memo" + } + ] + }, + "include": ["ets/**/*.ts"] +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/link_prebuilts.js b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/link_prebuilts.js new file mode 100644 index 0000000000000000000000000000000000000000..6d43fdc37862ce6812d95ee9964ca3e46e08a729 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/link_prebuilts.js @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const fs = require('fs') +const path = require('path') +const os = require('os'); + +const dir = path.join(process.cwd(), '.runtime-prebuilt') + +function install_pkg(file) { + + const absolutePrebuiltPath = path.resolve('.runtime-prebuilt/', file) + const packageJsonPath = path.join(absolutePrebuiltPath, "package.json") + + if (!(fs.existsSync(packageJsonPath))) return 0 + + const packageJson = fs.readFileSync(packageJsonPath, {encoding: 'utf-8'}).trim() + const name = JSON.parse(packageJson).name + packageDir = `node_modules/${name}` + + if (fs.existsSync(packageDir)) { + fs.rmSync(packageDir, { recursive: true}) + } + + if (os.type() === 'Windows_NT') { + fs.mkdirSync(packageDir, { recursive: true }) + fs.cpSync(absolutePrebuiltPath + "/", packageDir, { recursive: true, force: true }) + } else { + fs.symlinkSync(absolutePrebuiltPath, packageDir, 'dir') + } + +} + +if (fs.existsSync(dir)) { + var files = fs.readdirSync(dir) + files.forEach(file => { + install_pkg(file) + }) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/arkts/ark b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/arkts/ark new file mode 100755 index 0000000000000000000000000000000000000000..87c7674caadecbed2e23a05cffcc62f4290a857d --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/arkts/ark @@ -0,0 +1,17 @@ +#!/bin/bash + +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +SCRIPT_DIR=`dirname "${BASH_SOURCE[0]}"` +node $SCRIPT_DIR/ark.js "$@" diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/arkts/ark.js b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/arkts/ark.js new file mode 100644 index 0000000000000000000000000000000000000000..d742192138ce6b495542c05bfc881fd1a7bab69a --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/arkts/ark.js @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const child_process = require('child_process') +const path = require("node:path") +const fs = require("fs") +const { formatCommand, + extractArgs, + DEFAULT_DRIVER_FLAGS, + PANDA_SDK, + ARCH_TOOLS, + getUsage, + checkForHelp } = require('./common') + +const ARK_BOOT_FILE_SEP = ":" +const ARK_OBJ_FILE_EXT = ".abc" + +ark_path = process.env.ARK_PATH +ark_path = ark_path ?? path.join(PANDA_SDK, ARCH_TOOLS, 'bin', 'ark') + +const ARGS_SPEC = [ + { + flag: '--ark-bin', + help: 'Path to ark binary', + domain: 'string', + default: ark_path + }, + { + flag: '--ark-ets-stdlib', + help: 'ETS stdlib to use for launch', + domain: 'string', + default: path.join(PANDA_SDK, 'ets', 'etsstdlib.abc') + }, + { + flag: '--ark-boot-files', + help: 'Boot panda files to use (either list of files separated by `:` or a single directory)', + domain: 'string', + default: '' + }, + { + flag: '--ark-entry-point', + help: 'Entry point function in format like `ETSGLOBAL::main`', + domain: 'string', + default: 'ETSGLOBAL::main' + }, + ...DEFAULT_DRIVER_FLAGS, +] +const USAGE = getUsage("This runs ark to load and run panda bytecode", ARGS_SPEC) + +checkForHelp(USAGE) +const { recognized: args, unknown: rest } = extractArgs(ARGS_SPEC, process.argv.slice(2)) + +const arkBootFiles = + args.flag('--ark-boot-files') + .split(ARK_BOOT_FILE_SEP) + .flatMap(filePath => fs.statSync(filePath).isDirectory() + ? fs.readdirSync(filePath, {recursive: true, withFileTypes: true}) + .filter(it => path.parse(it.name).ext === ARK_OBJ_FILE_EXT) + .map(it => path.join(it.path, it.name)) + : filePath) + .join(ARK_BOOT_FILE_SEP) + +let cmd = [ + args.flag('--ark-bin'), + '--load-runtimes=ets', + '--boot-panda-files', + args.flag('--ark-ets-stdlib') + ':' + arkBootFiles, + ...rest, + args.flag('--ark-entry-point'), +] +if (args.flag('--driver-log') === 'info') { + console.log(formatCommand(cmd.join(' '), process.cwd())) +} +// console.log(`start ${cmd.join(' ')}`) +const child = child_process.spawn(cmd[0], [...cmd.slice(1)]) +child.stdout.on('data', (data) => { + process.stdout.write(data); +}) +child.stderr.on('data', (data) => { + process.stderr.write(data); +}) +child.on('close', (code) => { + if (code) { + if (args.flag('--driver-log') === 'info') { + console.log(`Command ${formatCommand(cmd.join(' '), process.cwd())} failed with return code ${code}`) + } + process.exit(code) + } +}) +child.on('exit', (code, signal) => { + if (signal) { + console.log(`Received signal: ${signal} from '${formatCommand(cmd.join(' '), process.cwd())}'`) + process.exit(1) + } +}) diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/arkts/arkdisasm b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/arkts/arkdisasm new file mode 100755 index 0000000000000000000000000000000000000000..15253bba6e1795a8b89cc1e085b66954adb3f84d --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/arkts/arkdisasm @@ -0,0 +1,17 @@ +#!/bin/bash + +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +SCRIPT_DIR=`dirname "${BASH_SOURCE[0]}"` +node $SCRIPT_DIR/arkdisasm.js "$@" diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/arkts/arkdisasm.js b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/arkts/arkdisasm.js new file mode 100644 index 0000000000000000000000000000000000000000..b5f24d3d6662420d6c8e87e41eb0f6626d782bd9 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/arkts/arkdisasm.js @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const child_process = require('child_process') +const path = require("node:path") +const { formatCommand, + extractArgs, + DEFAULT_DRIVER_FLAGS, + PANDA_SDK, + ARCH_TOOLS, + getUsage, + checkForHelp } = require('./common') + +ark_disasm_path = process.env.ARKDISASM_PATH +ark_disasm_path = ark_disasm_path ?? path.join(PANDA_SDK, ARCH_TOOLS, 'bin', 'ark_disasm') + +const ARGS_SPEC = [ + { + flag: '--arkdisasm-bin', + help: 'Path to arkdisasm binary', + domain: 'string', + default: ark_disasm_path + }, + ...DEFAULT_DRIVER_FLAGS, +] +const USAGE = getUsage("This runs ark_disasm to disassemble .abc file", ARGS_SPEC) + +checkForHelp(USAGE) +const { recognized: args, unknown: rest } = extractArgs(ARGS_SPEC, process.argv.slice(2)) +if (rest.length === 1) { + rest.push(rest[0] + ".disasm") +} +let cmd = [ + args.flag('--arkdisasm-bin'), + ...rest +] +if (args.flag('--driver-log') === 'info') { + console.log(formatCommand(cmd.join(' '), process.cwd())) +} +const child = child_process.spawn(cmd[0], [...cmd.slice(1)]) +child.stdout.on('data', (data) => { + process.stdout.write(data); +}) +child.stderr.on('data', (data) => { + process.stderr.write(data); +}) +child.on('close', (code) => { + if (code) { + if (args.flag('--driver-log') === 'info') { + console.log(`Command ${formatCommand(cmd.join(' '), process.cwd())} failed with return code ${code}`) + } + process.exit(code) + } +}) diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/arkts/arklink b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/arkts/arklink new file mode 100755 index 0000000000000000000000000000000000000000..59570af44a89043f8aa4901fa8cc97d8a4c01281 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/arkts/arklink @@ -0,0 +1,17 @@ +#!/bin/bash + +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +SCRIPT_DIR=`dirname "${BASH_SOURCE[0]}"` +node $SCRIPT_DIR/arklink.js "$@" diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/arkts/arklink.js b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/arkts/arklink.js new file mode 100644 index 0000000000000000000000000000000000000000..cc6c3d93ea3a6212f8b49f88a2927fe822dc0c2e --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/arkts/arklink.js @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const child_process = require('child_process') +const path = require("node:path") +const { formatCommand, + extractArgs, + DEFAULT_DRIVER_FLAGS, + PANDA_SDK, + ARCH_TOOLS, + getUsage, + checkForHelp } = require('./common') + +ark_link_path = process.env.ARKLINK_PATH +ark_link_path = ark_link_path ?? path.join(PANDA_SDK, ARCH_TOOLS, 'bin', 'ark_link') + +const ARGS_SPEC = [ + { + flag: '--arklink-bin', + help: 'Path to arklink binary', + domain: 'string', + default: ark_link_path + }, + ...DEFAULT_DRIVER_FLAGS, +] +const USAGE = getUsage("This runs ark_link to link several .abc files into one", ARGS_SPEC) + +checkForHelp(USAGE) +const { recognized: args, unknown: rest } = extractArgs(ARGS_SPEC, process.argv.slice(2)) +let cmd = [ + args.flag('--arklink-bin'), + ...rest +] +if (args.flag('--driver-log') === 'info') { + console.log(formatCommand(cmd.join(' '), process.cwd())) +} +const child = child_process.spawn(cmd[0], [...cmd.slice(1)]) +child.stdout.on('data', (data) => { + process.stdout.write(data); +}) +child.stderr.on('data', (data) => { + process.stderr.write(data); +}) +child.on('close', (code) => { + if (code) { + if (args.flag('--driver-log') === 'info') { + console.log(`Command ${formatCommand(cmd.join(' '), process.cwd())} failed with return code ${code}`) + } + process.exit(code) + } +}) diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/arkts/arktsc b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/arkts/arktsc new file mode 100755 index 0000000000000000000000000000000000000000..a0edacd77e234bd887801c9242ab79b097af675a --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/arkts/arktsc @@ -0,0 +1,17 @@ +#!/bin/bash + +# Copyright (c) 2022-2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +SCRIPT_DIR=`dirname "${BASH_SOURCE[0]}"` +node $SCRIPT_DIR/arktsc.js "$@" diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/arkts/arktsc.js b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/arkts/arktsc.js new file mode 100644 index 0000000000000000000000000000000000000000..4fd2919dda8b650cb105b9178e9448f5c5105bf2 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/arkts/arktsc.js @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const child_process = require('child_process') +const path = require("node:path") +const { formatCommand, + extractArgs, + DEFAULT_DRIVER_FLAGS, + PANDA_SDK, + ARCH_TOOLS, + getUsage, + checkForHelp } = require('./common') + +es2panda_path = process.env.ES2PANDA_PATH +es2panda_path = es2panda_path ?? path.join(PANDA_SDK, ARCH_TOOLS, 'bin', 'es2panda') +stdlib_path = process.env.ETS_STDLIB_PATH +stdlib_path = stdlib_path ?? path.join(PANDA_SDK, 'ets', 'stdlib') + +const ARGS_SPEC = [ + { + flag: '--es2panda-bin', + help: 'Path to es2panda binary', + domain: 'string', + default: es2panda_path + }, + { + flag: '--es2panda-stdlib', + help: 'Path to es2panda stdlib directory', + domain: 'string', + default: stdlib_path + }, + ...DEFAULT_DRIVER_FLAGS, +] +const USAGE = getUsage("This runs es2panda to compile ts/arkts files to panda bytecode", ARGS_SPEC) + +checkForHelp(USAGE) +const { recognized: args, unknown: rest } = extractArgs(ARGS_SPEC, process.argv.slice(2)) +let cmd = [ + args.flag('--es2panda-bin'), + '--stdlib', args.flag('--es2panda-stdlib'), + '--extension', 'ets', + '--list-files', + ...rest +] +if (args.flag('--driver-log') === 'info') { + console.log(formatCommand(cmd.join(' '), process.cwd())) +} +const child = child_process.spawn(cmd[0], [...cmd.slice(1)]) +child.stdout.on('data', (data) => { + process.stdout.write(data); +}) +child.stderr.on('data', (data) => { + process.stderr.write(data); +}) +child.on('close', (code) => { + if (code) { + if (args.flag('--driver-log') === 'info') { + console.log(`Command ${formatCommand(cmd.join(' '), process.cwd())} failed with return code ${code}`) + } + process.exit(code) + } +}) +child.on('exit', (code, signal) => { + if (signal) { + console.log(`Received signal: ${signal} from '${formatCommand(cmd.join(' '), process.cwd())}'`) + process.exit(1) + } +}) + diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/arkts/common.js b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/arkts/common.js new file mode 100644 index 0000000000000000000000000000000000000000..6a7c77463c1d1bc012a7a84db37557c731fb471a --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/arkts/common.js @@ -0,0 +1,205 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const child_process = require('child_process') +const path = require('node:path') + +const TOOLS_PANDA_ROOT = path.join(__dirname, "..") +const PANDA_SDK = path.join(TOOLS_PANDA_ROOT, "node_modules/@panda/sdk") +const ARCH_TOOLS = (() => { + const arch = process.arch + let sdkArch = ""; + switch (arch) { + case "x64": sdkArch = ""; + break; + case "arm64": sdkArch = "arm64"; + break; + default: throw new Error("Unexpected arch: ", arch); + + } + const p = process.platform + let sdkPlatform = "" + switch (p) { + case "linux": sdkPlatform = "linux" + break; + case "win32": sdkPlatform = "windows" + break; + case "darwin": sdkPlatform = "macos" + break; + default: throw new Error(`Unsupported platform ${p}`) + } + const suffix = "host_tools" + return [sdkPlatform, sdkArch, suffix].filter(it => it != "").join("_") +})() +const DEFAULT_DRIVER_FLAGS = [ + { + flag: '--driver-log', + help: 'Define verbosity for output', + domain: ['default', 'info'], + default: 'default' + }, +] + +function getUsage(usage, args) { + let strings = [ + usage, + "All arguments (except ones that are captured by the script) are passed to the underlying tool.", + "", + "Flags:", + ] + for (const arg of args) { + strings.push(`${arg.flag} [${arg.domain}] Default: '${arg.default}'`) + strings.push(` ${arg.help}`) + } + return strings.join('\n') +} +function checkForHelp(usage) { + if (process.argv.length === 3 && + (process.argv.includes('-h') || process.argv.includes('--help'))) { + console.log(usage) + process.exit(1) + } +} + +class Recognized { + constructor(recognized) { + this.recognized = recognized + } + + flag(name) { + const found = this.recognized.get(name) + if (!found) { + throw new Error(`Flag ${name} not specified`) + } + return found + } +} + +function extractArgs(argsSpec, args) { + let flags = args + const parsed = [] + function parseArg(flag) { + if (flags.length === 0) { + parsed.push({ type: 'flag', value: flag }) + } else { + const peek = flags[0] + if (!peek.startsWith('--')) { + const top = flags.shift() + parsed.push({ type: 'option', value: [flag, top] }) + } else { + parsed.push({ type: 'flag', value: flag }) + } + } + } + function parseVal(val) { + parsed.push({ type: 'value', value: val }); + } + function parseArgs() { + if (!flags || flags.length === 0) { + return + } + + const top = flags.shift() + if (top.startsWith('--')) { + parseArg(top) + } else { + parseVal(top) + } + parseArgs() + } + + function classify(flag) { + const { type, value } = flag + if (type === 'value') { + return { type: 'unknown', value: [value] } + } else { + if (type === 'flag') { + const found = argsSpec.find((el) => el.flag === value) + if (found) { + return { type: 'recognized', flag: value, value: true, spec: found } + } else { + return { type: 'unknown', value: [value] } + } + } else { + const [f, arg] = value + const found = argsSpec.find((el) => el.flag === f) + if (found) { + return { type: 'recognized', flag: f, value: arg, spec: found } + } else { + return { type: 'unknown', value: [f, arg] } + } + } + } + } + + function validate(c) { + const { flag, value, spec } = c + const domain = spec.domain + if (Array.isArray(domain)) { + if (!domain.includes(value)) { + return `Flag ${flag} with ${value} is invalid, possible values are: ${domain}` + } + } else if (typeof value !== domain) { + return `Flag ${flag} with ${value} is invalid, type must be ${domain}` + } + return null + } + + parseArgs() + const classified = parsed.map(classify) + classified.filter(c => c.type == 'recognized').forEach(c => { + const result = validate(c) + if (result !== null) { + throw new Error(result) + } + }) + + let unknown = [] + let recognized = new Map() + classified.forEach(r => { + switch (r.type) { + case 'unknown': + unknown.push(...r.value) + break + case 'recognized': + recognized.set(r.flag, r.value) + } + }) + + argsSpec.forEach(s => { + const { flag, default: default_ } = s + if (!recognized.has(flag)) { + recognized.set(flag, default_) + } + }) + + return { recognized: new Recognized(recognized), unknown } +} + +function formatCommand(cmd, cwd) { + const c = typeof cmd === "string" ? cmd : cmd.join(' ') + return `$ ${cwd}> ` + c +} + +module.exports = { + extractArgs, + formatCommand, + getUsage, + checkForHelp, + TOOLS_PANDA_ROOT, + PANDA_SDK, + ARCH_TOOLS, + DEFAULT_DRIVER_FLAGS +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/arkts/std-lib/global.d.ts b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/arkts/std-lib/global.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ee76c1d3b065173c5779e8ce3657773f0dc1169f --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/arkts/std-lib/global.d.ts @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +declare type int32 = number +declare type int8 = number +declare type float32 = number + +// This is to allow symbols of arkts stdlib +// to be visible during ets-tsc preprocessing + +declare class StringBuilder { + constructor(value: string) + append(value: string): StringBuilder +} + +declare class Type { + static from(): Type + getName(): string +} + +declare const console: { + assert(value: any, message?: string, ...optionalParams: any[]): void; + + clear(): void; + + count(label?: string): void; + + countReset(label?: string): void; + + debug(message?: any, ...optionalParams: any[]): void; + + // dir(obj: any, options?: InspectOptions): void; + + dirxml(...data: any[]): void; + + error(message?: any, ...optionalParams: any[]): void; + + group(...label: any[]): void; + + groupCollapsed(...label: any[]): void; + + groupEnd(): void; + + info(message?: any, ...optionalParams: any[]): void; + + log(message?: any, ...optionalParams: any[]): void; + + table(tabularData: any, properties?: ReadonlyArray): void; + + time(label?: string): void; + + timeEnd(label?: string): void; + + timeLog(label?: string, ...data: any[]): void; + + trace(message?: any, ...optionalParams: any[]): void; + + warn(message?: any, ...optionalParams: any[]): void; + + profile(label?: string): void; + + profileEnd(label?: string): void; + + timeStamp(label?: string): void; + +} + +declare function setTimeout(func: () => void, delayMs: int32): int32 + +declare function setInterval(func: () => void, delayMs: int32): int32 + +declare function clearInterval(timerId: int32): void + +declare function clearTimeout(timerId: int32): void diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/arkts/ui2abc b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/arkts/ui2abc new file mode 100755 index 0000000000000000000000000000000000000000..34fc7967e3504e88d3c15b5f1714c065a685506c --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/arkts/ui2abc @@ -0,0 +1,18 @@ +#!/bin/bash + +# Copyright (c) 2022-2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +SCRIPT_DIR=`dirname "${BASH_SOURCE[0]}"` +PANDA_SDK_PATH=$SCRIPT_DIR/../node_modules/@panda/sdk node $SCRIPT_DIR/../../../../ui2abc/libarkts/lib/es2panda.js "$@" + diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/build_panda_sdk.mjs b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/build_panda_sdk.mjs new file mode 100644 index 0000000000000000000000000000000000000000..d3138640442d0594e94cc5031940534fca506888 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/build_panda_sdk.mjs @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import fs from "fs"; +import path from "path"; +import child_process from "child_process"; + +const originRuntime = "https://gitee.com/openharmony/arkcompiler_runtime_core" +const originFrontend = "https://gitee.com/openharmony/arkcompiler_ets_frontend" + +console.log("Required packages and utilities:\n" + + "Ubuntu: clang-14, lcov, libdwarf-dev, jinja2, cmake, ninja (apt install -y clang-14 lcov libdwarf-dev python3-pip cmake ninja-build && pip install jinja2-cli)") + +const argv = new Map(process.argv.slice(2).map(it => it.split("="))) +const pandaSdkDir = argv.get("--panda-sdk-dir") +const arkCompilerDir = argv.get("--arkcompiler-build-dir") +const buildType = argv.get("--build-type") ?? "Release" +const rtGitRev = argv.get("--runtime-git-rev") +const feGitRev = argv.get("--frontend-git-rev") +const feGitPatches = argv.get("--frontend-git-patches")?.split(":") ?? [] + +if (arkCompilerDir === undefined) { + console.log("--arkcompiler-build-dir argument is required") + process.exit(1) +} +if (pandaSdkDir === undefined) { + console.log("--panda-sdk-dir argument is required") + process.exit(1) +} + +const feDir = path.join(arkCompilerDir, "ets_frontend") +const rtDir = path.join(arkCompilerDir, "runtime_core") +const staticCoreDir = path.join(rtDir, "static_core") + +makeDir(arkCompilerDir) + +gitClone(originRuntime, rtDir) +if (rtGitRev !== undefined) { + gitCheckout(rtDir, rtGitRev) +} +gitClone(originFrontend, feDir) +if (feGitRev !== undefined) { + gitCheckout(feDir, feGitRev) +} +feGitPatches.forEach(it => { + child_process.spawnSync("git", ["apply", path.resolve(it)], + {stdio: "inherit", cwd: feDir}) +}) + +makeSymlink(path.join(feDir, "ets2panda"), path.join(staticCoreDir, "tools/es2panda")) + +const buildDir = path.join(staticCoreDir, "build") +makeDir(buildDir) + +child_process.spawnSync("cmake", [ + `-B${buildDir}`, + `-S${staticCoreDir}`, + "-GNinja", + `-DCMAKE_BUILD_TYPE=${buildType}`, + `-DCMAKE_TOOLCHAIN_FILE=${path.join(staticCoreDir, "cmake/toolchain/host_clang_14.cmake")}`, + "-DPANDA_ETS_INTEROP_JS=ON", + "-DPANDA_WITH_JAVA=false", + "-DPANDA_WITH_ECMASCRIPT=false", + "-DPANDA_WITH_ACCORD=false", + "-DPANDA_WITH_CANGJIE=false", + "-DPANDA_WITH_ETS=true" + ], + {stdio: "inherit"} +) + +child_process.spawnSync("ninja", [ + "-C", + buildDir, + "panda_bins"], + {stdio: "inherit"} +) + +makeDir(path.join(pandaSdkDir, "ets")) +makeSymlink(path.join(staticCoreDir, "plugins/ets/stdlib"), path.join(pandaSdkDir, "ets/stdlib")) +makeSymlink(path.join(buildDir, "plugins/ets/etsstdlib.abc"), path.join(pandaSdkDir, "ets/etsstdlib.abc")) +makeDir(path.join(pandaSdkDir, "linux_host_tools")) +makeSymlink(path.join(buildDir, "bin"), path.join(pandaSdkDir, "linux_host_tools/bin")) +makeSymlink(path.join(buildDir, "lib"), path.join(pandaSdkDir, "linux_host_tools/lib")) + +console.log("Build completed successfully") + +function makeDir(path) { + if (!fs.existsSync(path)) { + fs.mkdirSync(path, {recursive: true}) + } +} + +function makeSymlink(target, dest) { + if (fs.existsSync(dest)) { + if (fs.lstatSync(dest).isDirectory()) { + fs.rmdirSync(dest, { recursive: true, force: true }) + } else { + fs.unlinkSync(dest) + } + } + if (fs.lstatSync(target).isDirectory()) { + fs.cpSync(target, dest, { recursive: true }) + } else { + fs.symlinkSync(target, dest) + } +} + +function gitClone(repo, dir) { + child_process.spawnSync("git", ["clone", repo, dir], {stdio: "inherit"}) +} + +function gitCheckout(repo, rev) { + child_process.spawnSync("git", ["checkout", rev], {stdio: "inherit", cwd: repo}) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/fix_es2panda_1.patch b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/fix_es2panda_1.patch new file mode 100644 index 0000000000000000000000000000000000000000..79b869657069089ec3f8d180cc5df4259dc70416 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/fix_es2panda_1.patch @@ -0,0 +1,150 @@ +diff --git a/ets2panda/aot/main.cpp b/ets2panda/aot/main.cpp +index 2c916e6ac..68526dd00 100644 +--- a/ets2panda/aot/main.cpp ++++ b/ets2panda/aot/main.cpp +@@ -33,11 +33,12 @@ using mem::MemConfig; + + class MemManager { + public: +- explicit MemManager() ++ explicit MemManager(const std::size_t compilerMemSize) + { +- constexpr auto COMPILER_SIZE = 256_MB; +- +- MemConfig::Initialize(0, 0, COMPILER_SIZE, 0, 0, 0); ++ constexpr auto DEFAULT_COMPILER_SIZE = 256_MB; ++ MemConfig::Initialize(0, 0, ++ compilerMemSize > DEFAULT_COMPILER_SIZE ? compilerMemSize : DEFAULT_COMPILER_SIZE, ++ 0, 0, 0); + PoolManager::Initialize(PoolType::MMAP); + } + +@@ -98,7 +99,11 @@ static int CompileFromConfig(es2panda::Compiler &compiler, util::Options *option + es2panda::SourceFile input(src, parserInput, options->ParseModule()); + options->SetCompilerOutput(dst); + +- options->ListFiles() && std::cout << "> es2panda: compiling from '" << src << "' to '" << dst << "'" ++ const auto index = std::distance(compilationList.begin(), ++ std::find_if(compilationList.begin(), compilationList.end(), ++ [filename = src](const auto &i) { return i.first == filename; })); ++ options->ListFiles() && std::cout ++ << "> es2panda:" << " [" << index + 1 << "/" << compilationList.size() << "] " << "compiling from '" << src << "' to '" << dst << "'" + << std::endl; + auto res = CompileFromSource(compiler, input, options); + if (res != 0) { +@@ -125,14 +130,8 @@ static std::optional> InitializePlugins(std::vector &options) + { +- auto options = std::make_unique(); +- if (!options->Parse(argc, argv)) { +- std::cerr << options->ErrorMsg() << std::endl; +- return 1; +- } +- + Logger::ComponentMask mask {}; + mask.set(Logger::Component::ES2PANDA); + Logger::InitializeStdLogging(Logger::LevelFromString(options->LogLevel()), mask); +@@ -162,6 +161,11 @@ static int Run(int argc, const char **argv) + + int main(int argc, const char **argv) + { +- ark::es2panda::aot::MemManager mm; +- return ark::es2panda::aot::Run(argc, argv); ++ const auto options = std::make_unique(); ++ if (!options->Parse(argc, argv)) { ++ std::cerr << options->ErrorMsg() << std::endl; ++ return 1; ++ } ++ ark::es2panda::aot::MemManager mm(options->CompilerMemorySize()); ++ return ark::es2panda::aot::Run(options); + } +diff --git a/ets2panda/ast_verifier/everyChildHasValidParent.cpp b/ets2panda/ast_verifier/everyChildHasValidParent.cpp +index 30443fbc6..6589bc6bc 100644 +--- a/ets2panda/ast_verifier/everyChildHasValidParent.cpp ++++ b/ets2panda/ast_verifier/everyChildHasValidParent.cpp +@@ -14,7 +14,10 @@ + */ + + #include "everyChildHasValidParent.h" ++ + #include "ir/base/methodDefinition.h" ++#include "ir/base/scriptFunction.h" ++#include "ir/typeNode.h" + + namespace ark::es2panda::compiler::ast_verifier { + +@@ -52,6 +55,17 @@ CheckResult EveryChildHasValidParent::operator()(CheckContext &ctx, const ir::As + return; + } + ++ // NOTE: Temporary suppress. ++ // Fix checking of tuples in interfaces ++ if (ast->IsScriptFunction()) { ++ if (const auto *sf = ast->AsScriptFunction(); ++ sf->ReturnTypeAnnotation()->Parent() == parent && node->IsETSTuple()) { ++ return; ++ } ++ } ++ ++ return; ++ + ctx.AddCheckMessage("INCORRECT_PARENT_REF", *node, node->Start()); + result = {CheckDecision::INCORRECT, CheckAction::CONTINUE}; + } +diff --git a/ets2panda/util/options.cpp b/ets2panda/util/options.cpp +index a148246ac..3f3e2b469 100644 +--- a/ets2panda/util/options.cpp ++++ b/ets2panda/util/options.cpp +@@ -161,6 +161,7 @@ struct AllArgs { + ark::PandArg opDumpCheckedAst {"dump-dynamic-ast", false, + "Dump AST with synthetic nodes for dynamic languages"}; + ark::PandArg opListFiles {"list-files", false, "Print names of files that are part of compilation"}; ++ ark::PandArg opCompilerMemSize {"compiler-memory-size", 0, "Compiler memory size(bytes)"}; + + // compiler + ark::PandArg opDumpAssembly {"dump-assembly", false, "Dump pandasm"}; +@@ -295,6 +296,7 @@ struct AllArgs { + argparser.Add(&opThreadCount); + argparser.Add(&opSizeStat); + argparser.Add(&opListFiles); ++ argparser.Add(&opCompilerMemSize); + + argparser.Add(&inputExtension); + argparser.Add(&outputFile); +@@ -529,7 +531,7 @@ bool Options::Parse(int argc, const char **argv) + optLevel_ = allArgs.opOptLevel.GetValue(); + threadCount_ = allArgs.opThreadCount.GetValue(); + listFiles_ = allArgs.opListFiles.GetValue(); +- ++ compilerMemorySize_ = allArgs.opCompilerMemSize.GetValue(); + return true; + } + } // namespace ark::es2panda::util +diff --git a/ets2panda/util/options.h b/ets2panda/util/options.h +index b7c100436..75e6a2c74 100644 +--- a/ets2panda/util/options.h ++++ b/ets2panda/util/options.h +@@ -281,6 +281,11 @@ public: + return listFiles_; + } + ++ std::size_t CompilerMemorySize() const ++ { ++ return compilerMemorySize_; ++ } ++ + private: + es2panda::ScriptExtension extension_ {es2panda::ScriptExtension::JS}; + OptionFlags options_ {OptionFlags::DEFAULT}; +@@ -294,6 +299,7 @@ private: + int optLevel_ {0}; + int threadCount_ {0}; + bool listFiles_ {false}; ++ std::size_t compilerMemorySize_ {0}; + util::LogLevel logLevel_ {util::LogLevel::ERROR}; + }; + } // namespace ark::es2panda::util diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/fix_normalizing_source_paths.patch b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/fix_normalizing_source_paths.patch new file mode 100644 index 0000000000000000000000000000000000000000..479c1e509f53f6bc5b5f9cd946585403e9185fbb --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/fix_normalizing_source_paths.patch @@ -0,0 +1,25 @@ +diff --git a/ets2panda/util/arktsconfig.cpp b/ets2panda/util/arktsconfig.cpp +index 2c6f967f0..597a36310 100644 +--- a/ets2panda/util/arktsconfig.cpp ++++ b/ets2panda/util/arktsconfig.cpp +@@ -462,7 +462,7 @@ static std::vector GetSourceList(const std::shared_ptr &a + } + for (const auto &dirEntry : fs::recursive_directory_iterator(traverseRoot)) { + if (include.Match(dirEntry.path().string()) && !MatchExcludes(dirEntry, excludes)) { +- sourceList.emplace_back(dirEntry); ++ sourceList.emplace_back(fs::canonical(dirEntry)); + } + } + } +diff --git a/ets2panda/varbinder/ETSBinder.cpp b/ets2panda/varbinder/ETSBinder.cpp +index 988ffb856..bc1ace4d5 100644 +--- a/ets2panda/varbinder/ETSBinder.cpp ++++ b/ets2panda/varbinder/ETSBinder.cpp +@@ -611,6 +611,7 @@ ir::ETSImportDeclaration *ETSBinder::FindImportDeclInReExports(const ir::ETSImpo + { + ir::ETSImportDeclaration *implDecl = nullptr; + for (auto item : ReExportImports()) { ++ // source.Is(program) - returns false if the path in the program is not normalized + if (auto source = import->ResolvedSource()->Str(), program = item->GetProgramPath(); + !source.Is(program.Mutf8())) { + continue; diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/package.json b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/package.json new file mode 100644 index 0000000000000000000000000000000000000000..3962624acdcb31468a49fc16a27ea543c3727d4e --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/package.json @@ -0,0 +1,17 @@ +{ + "name": "panda-installer", + "private": true, + "dependencies": { + "@panda/sdk": "^1.5.0-dev.23465" + }, + "devDependencies": { + "rimraf": "^6.0.1" + }, + "scripts": { + "panda:sdk:check-install": "npm ls @panda/sdk || npm run panda:sdk:install", + "panda:sdk:install": "npm install --prefix . --no-save @panda/sdk@${PANDA_SDK_VERSION:-next}", + "panda:sdk:clean": "rimraf ./node_modules", + "panda:sdk:build": "node ./build_panda_sdk.mjs --panda-sdk-dir=./node_modules/@panda/sdk/ --arkcompiler-build-dir=$HOME/arkcompiler --runtime-git-rev=a6704b6a --frontend-git-rev=c2166bf1 --frontend-git-patches=./fix_es2panda_1.patch:./fix_normalizing_source_paths.patch", + "panda:sdk:sync": "node ./sync-panda-on-device.mjs" + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/sync-panda-on-device.mjs b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/sync-panda-on-device.mjs new file mode 100644 index 0000000000000000000000000000000000000000..7f07932fdb3e731d959c531d2c92a8a88154a49b --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/incremental/tools/panda/sync-panda-on-device.mjs @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import path from "path" +import fs from "fs" +import url from "url" + +import { execCmd } from "../../../tools/utils/system.mjs" +import { ohConf } from "../../../tools/ohos-tools/ohconf.mjs" + +const __dirname = path.dirname(url.fileURLToPath(import.meta.url)) + +const HDC = ohConf().hdcPath() + +async function execHDC(args, options = {}) { + return execCmd(HDC, [...args], { + ...options, + shell: false + }) +} + +console.log("> Connected device:") +let out = await execHDC(['list', 'targets'], { instantLogging: true }) + "" +if (out.indexOf("Empty") !== -1) { + console.log("> Error: no connection to a device") + process.exit(-1) +} + +console.log("> Mount device for write:") +await execHDC(['hdc', 'target', 'mount'], { instantLogging: true }) + +let arch = "arm64" +out = await execHDC(['shell', 'file', '/system/lib64']) + "" +if (out.indexOf("No such file") !== -1) { + out = await execHDC(['shell', 'file', '/system/lib']) + "" + if (out.indexOf("No such file") !== -1) { + console.log("> Error: cannot detect device arch") + process.exit(-1) + } + arch = "arm32" +} + +console.log("> Device arch: " + arch) + +const LIB_ARCH = arch === "arm32" ? "lib" : "lib64" + +const PANDA_LIB_ROOT = path.join(__dirname, `node_modules/@panda/sdk/ohos_${arch}/lib`) +const PANDA_ETS_ROOT = path.join(__dirname, `node_modules/@panda/sdk/ets`) + +const SEND_RULES = [ + { + root: PANDA_LIB_ROOT, + src: "libetsnative.so", + dst: `/system/${LIB_ARCH}/ndk/libetsnative.z.so` + }, + { + root: PANDA_LIB_ROOT, + src: "libets_interop_js_napi.so", + dst: `/system/${LIB_ARCH}/module/libets_interop_js_napi.z.so` + }, + { + root: PANDA_LIB_ROOT, + src: ".so", + dst: `/system/${LIB_ARCH}` + }, + { + root: PANDA_ETS_ROOT, + src: "etsstdlib.abc", + dst: "/system/etc/etsstdlib.abc" + } +] + +const RULE_APPLIED = (fileName, rule) => fileName.endsWith(rule.src) + +const SEND_FILE = async fileName => { + const rule = SEND_RULES.filter(rule => RULE_APPLIED(fileName, rule))[0] + console.log("> Send " + fileName + " to " + rule.dst) + await execHDC(['hdc', 'file', 'send', path.join(rule.root, fileName), rule.dst], { instantLogging: true }) +} + + +for (const file of fs.readdirSync(PANDA_LIB_ROOT)) { + if (file.endsWith(".so")) + await SEND_FILE(file) +} + +await SEND_FILE("etsstdlib.abc") + +console.log("> Reboot device...") +await execHDC(['hdc', 'shell', 'reboot'], { instantLogging: true }) diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/.gitignore b/frameworks/bridge/arkts_frontend/koala_mirror/interop/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..44a0964582ad20972cb3bc522a25f96c04a00484 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/.gitignore @@ -0,0 +1 @@ +*.ini \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/arktsconfig.json b/frameworks/bridge/arkts_frontend/koala_mirror/interop/arktsconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..d1f39ecaf2ec2e692fd8f281a659ca3455912ee4 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/arktsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "package": "@koalaui/interop", + "outDir": "build/abc", + "baseUrl": "./src/arkts", + "paths": { + "@koalaui/compat": ["../../../incremental/compat/src/arkts"], + "@koalaui/common": ["../../../incremental/common/src"], + "#common/wrappers/*": ["./../../src/napi/wrappers/*"] + } + }, + "include": ["src/arkts/*.ts", "src/arkts/ResourceManager.ts", "./index.ts"], + "references": [ + { "path": "../incremental/common" }, + { "path": "../incremental/compat" } + ] + +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/meson.build b/frameworks/bridge/arkts_frontend/koala_mirror/interop/meson.build new file mode 100644 index 0000000000000000000000000000000000000000..9b0e15cc40a6ead85c8b2e4c2b1e8395ec56fa1a --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/meson.build @@ -0,0 +1,309 @@ +project('InteropNativeModule', 'c', 'cpp', + version: '0.1', + default_options: ['cpp_std=c++17', 'buildtype=release'] +) + +source_dir = meson.current_source_dir() +interop_src = './src/cpp' + +oses = { 'darwin': 'macos' } # rename meson default names to convenient ones +archs = { 'x86_64': 'x64', 'aarch64': 'arm64', 'armv7-a': 'arm32', 'wasm32': 'wasm' } + +fs = import('fs') + +os = target_machine.system() +os = oses.get(os, os) +arch = target_machine.cpu() +arch = archs.get(arch, arch) + +interop_src = './src/cpp' + +sources = [ + interop_src / 'common-interop.cc', + interop_src / 'callback-resource.cc', + interop_src / 'interop-logging.cc' +] + +include_dirs = [ + interop_src, + interop_src / 'types', +] + +node_api_headers = run_command('node', '-p', 'require.resolve("node-api-headers/package.json").slice(0, -12)', check: true).stdout().strip() + +is_node = get_option('vm_kind') == 'node' +is_hzvm = get_option('vm_kind') == 'hzvm' +is_panda = get_option('vm_kind') == 'panda' +is_ani = is_panda +is_etsapi = is_panda +is_jvm = get_option('vm_kind') == 'jvm' +is_msvc = meson.get_compiler('cpp').get_id() == 'msvc' +is_napi = is_node or is_hzvm +is_jni = is_jvm +is_ohos = os == 'ohos' + +library_use_name = 'InteropNativeModule' + +if is_jni + library_use_name += '_jni' +endif + +cflags = [] +ldflags = [] +deps = [] + +if os == 'windows' + cflags += ['-DKOALA_WINDOWS'] + ldflags += [] + if is_napi + # apply node.exe symbol loading hook + sources += [ + interop_src / 'napi/win-dynamic-node.cc' + ] + cflags += ['/Gy-'] + # Strange, but true + platform_prefix = 'lib' + else + platform_prefix = '' + endif + platform_suffix = 'dll' +endif +if os == 'linux' + cflags += ['-DKOALA_LINUX', '-Wno-unused'] + platform_prefix = 'lib' + platform_suffix = 'so' +endif +if os == 'macos' + cflags += ['-DKOALA_MACOS', '-mmacosx-version-min=13.3'] + platform_prefix = 'lib' + platform_suffix = 'dylib' +endif +if is_ohos + clang_flags = [ + '-Wno-non-virtual-dtor', + '-fno-rtti', + '-Wall', + # '-Werror', TODO: turn back on once generated part compiles without warnings + '-Wno-error=attributes', + '-Wno-unused' + ] + include_dirs += [ + interop_src / 'ohos', + ] + cflags += [ + '-DKOALA_OHOS', + '-D__MUSL__', + ] + clang_flags + ldflags += [ + '-lEGL', + '-lGLESv3', + '-lhilog_ndk.z', + '-lace_ndk.z', + '-lace_napi.z', + '-luv', + '-static-libstdc++' + ] + platform_prefix = 'lib' + platform_suffix = 'so' +endif + +if is_napi + sources += [ + interop_src / 'napi/convertors-napi.cc', + ] + include_dirs += [ + interop_src / 'napi', + node_api_headers / 'include' + ] + cflags += [ + '-DKOALA_NAPI', + ] +endif +if is_etsapi + sources_ets = [ + interop_src / 'ets/convertors-ets.cc', + interop_src / 'types/signatures.cc', + ] + include_dirs_ets = [ + interop_src / 'ets', + interop_src / 'types', + ] + cflags_ets = [ + '-DKOALA_ETS_NAPI', + ] +endif +if is_ani + sources_ani = [ + interop_src / 'ani/convertors-ani.cc', + interop_src / 'types/signatures.cc', + ] + include_dirs_ani = [ + interop_src / 'ani', + interop_src / 'types', + ] + cflags_ani = [ + '-DKOALA_ANI', + ] +endif +if is_jni + sources += [ + interop_src / 'jni/convertors-jni.cc', + interop_src / 'types/signatures.cc', + ] + jni_os_dir = os + if jni_os_dir == 'windows' + jni_os_dir = 'win32' + endif + if jni_os_dir == 'macos' + jni_os_dir = 'darwin' + endif + include_dirs += [ + interop_src / 'jni', + interop_src / 'types', + get_option('jdk_dir') / 'include', + get_option('jdk_dir') / 'include' / jni_os_dir, + ] + cflags += [ + '-DKOALA_JNI', + ] +endif + +if is_node + cflags += [ + '-DKOALA_USE_NODE_VM', + ] + module_prefix = '' + module_suffix = 'node' +endif +if is_hzvm + cflags += [ + '-DKOALA_USE_HZ_VM', + ] + module_prefix = platform_prefix + module_suffix = platform_suffix +endif +if is_panda + cflags += [ + '-DKOALA_USE_PANDA_VM', + ] + if get_option('vmloader') == true + cflags += [ + '-DKOALA_FOREIGN_NAPI' + ] + endif + include_dirs += [ + interop_src / 'napi', + node_api_headers / 'include' + ] + module_prefix = platform_prefix + module_suffix = platform_suffix +endif +if is_jni + cflags += [ + '-DKOALA_USE_JAVA_VM', + ] + module_prefix = platform_prefix + module_suffix = platform_suffix +endif + +if is_msvc + cflags += [] +else + cflags += ['-Wno-parentheses-equality', '-Wno-extern-c-compat'] +endif + +if is_panda +library_use_name_ani = library_use_name +library_use_name_ets = library_use_name + '_ets' +shared_library(library_use_name_ani, + sources + sources_ani, + override_options: [ + # So that ArkJS build can refer NAPI symbols. + 'b_lundef=false', + ], + install: true, + name_prefix: module_prefix, + name_suffix: module_suffix, + include_directories: include_dirs + include_dirs_ani, + install_dir: source_dir / 'build', + cpp_args: cflags + cflags_ani, + link_args: ldflags, + dependencies: deps +) +shared_library(library_use_name_ets, + sources + sources_ets, + override_options: [ + # So that ArkJS build can refer NAPI symbols. + 'b_lundef=false', + ], + install: true, + name_prefix: module_prefix, + name_suffix: module_suffix, + include_directories: include_dirs + include_dirs_ets, + install_dir: source_dir / 'build', + cpp_args: cflags + cflags_ets, + link_args: ldflags, + dependencies: deps +) +else +shared_library(library_use_name, + sources, + override_options: [ + # So that ArkJS build can refer NAPI symbols. + 'b_lundef=false', + ], + install: true, + name_prefix: module_prefix, + name_suffix: module_suffix, + include_directories: include_dirs, + install_dir: source_dir / 'build', + cpp_args: cflags, + link_args: ldflags, + dependencies: deps +) +endif + +if get_option('vmloader') == true + + vmloader_cflags = ['-DKOALA_' + os.to_upper(), '-DKOALA_' + os.to_upper() + '_' + arch.to_upper()] + vmloader_ldflags = [] + + if is_ohos + vmloader_ldflags += ['-lhilog_ndk.z'] + endif + + if get_option('vmloader_apis').contains('jni') + jni_os_dir = os + if jni_os_dir == 'windows' + jni_os_dir = 'win32' + endif + include_dirs += [ + get_option('jdk_dir') / 'include', + get_option('jdk_dir') / 'include' / jni_os_dir, + ] + vmloader_cflags += [ + '-DKOALA_JNI', + ] + endif + + if get_option('vmloader_apis').contains('ets') + include_dirs += [ + interop_src / 'ets', + ] + vmloader_cflags += [ + '-DKOALA_ETS_NAPI', + ] + endif + + shared_library('vmloader', + interop_src / 'vmloader.cc', + override_options: [ + 'b_lundef=false', + ], + include_directories: include_dirs, + install: true, + install_dir: source_dir / 'build', + cpp_args: vmloader_cflags, + link_args: vmloader_ldflags, + ) +endif \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/meson_options.txt b/frameworks/bridge/arkts_frontend/koala_mirror/interop/meson_options.txt new file mode 100644 index 0000000000000000000000000000000000000000..1e7adce0ba6e2af3e4bd0afcfa4a81683a298e72 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/meson_options.txt @@ -0,0 +1,8 @@ +option('vm_kind', type : 'string', value : '', + description : 'VM type') +option('jdk_dir', type : 'string', value : '', + description : 'A path to JDK root') +option('vmloader', type : 'boolean', value : false, + description : 'Whether to build libvmloader.so') +option('vmloader_apis', type : 'string', value : 'ets', + description : 'APIs to use in libvmloader.so') diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/package.json b/frameworks/bridge/arkts_frontend/koala_mirror/interop/package.json new file mode 100644 index 0000000000000000000000000000000000000000..e868ba47ddfa8beaa92a6e47b118e7d657c81a6a --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/package.json @@ -0,0 +1,110 @@ +{ + "name": "@koalaui/interop", + "version": "1.5.15+devel", + "description": "", + "workspaces": [ + "../incremental/build-common", + "../incremental/compat", + "../incremental/common" + ], + "files": [ + "build/lib/src/**/*.js", + "build/lib/src/**/*.d.ts", + "src/**/*", + "index.ts", + "oh-package.json5" + ], + "main": "./build/lib/src/interop/index.js", + "exports": { + ".": "./build/lib/src/interop/index.js", + "./*.js": "./build/lib/src/interop/*.js", + "./*": "./build/lib/src/interop/*.js" + }, + "imports": { + "#common/wrappers": { + "browser": "./build/lib/src/wasm/wrappers/index.js", + "node": "./build/lib/src/napi/wrappers/index.js" + }, + "#common/wrappers/*": { + "browser": "./build/lib/src/wasm/wrappers/*.js", + "node": "./build/lib/src/napi/wrappers/*.js", + "default": "./build/lib/src/napi/wrappers/*.js" + } + }, + "types": "index.d.ts", + "typesVersions": { + "*": { + "*": [ + "./build/lib/src/interop/*" + ] + } + }, + "scripts": { + "clean": "rimraf dist build types", + "compile": "ets-tsc -b .", + "build:interop": "npm run build:interop:inc", + "build:interop:inc": "fast-arktsc --config ./arktsconfig.json --compiler ../incremental/tools/panda/arkts/arktsc --link-name ./build/interop.abc && ninja ${NINJA_OPTIONS} -f build/abc/build.ninja", + "clean:interop": "npm run clean", + "lint": "eslint src test components", + "test:wasm:coverage": "NODE_OPTIONS='--conditions browser --no-experimental-fetch' nyc mocha", + "test:wasm": "NODE_OPTIONS='--conditions browser --no-experimental-fetch' mocha", + "test:node:coverage": "nyc mocha", + "test:node": "mocha", + "test:coverage": "npm run test:node:coverage", + "test": "npm run test:node", + "watch": "ets-tsc -b . --watch", + "prepare:compiler": "test $(node -e \"console.log(process.platform)\") != \"linux\" && npm run --prefix ../arkoala-arkts/ohos-sdk download || npm run install:toolchain --prefix ../arkoala-arkts/tools/compiler", + "prepare:arm64": "npm run prepare:compiler && npm run install:sysroot:arm64 --prefix ../arkoala-arkts/tools/compiler", + "prepare:arm32": "npm run prepare:compiler && npm run install:sysroot:arm32 --prefix ../arkoala-arkts/tools/compiler", + "configure:native-node-host": "meson setup -D vm_kind=node build-node-host", + "compile:native-node-host": "npm run configure:native-node-host && meson compile -C build-node-host && meson install -C build-node-host", + "configure:native-hzvm-host": "meson setup -D vm_kind=hzvm build-hzvm-host", + "compile:native-hzvm-host": "npm run configure:native-hzvm-host && meson compile -C build-hzvm-host && meson install -C build-hzvm-host", + "configure:native-panda-host": "meson setup -D vm_kind=panda build-panda-host", + "compile:native-panda-host": "npm run configure:native-panda-host && meson compile -C build-panda-host && meson install -C build-panda-host", + "configure:native-panda-linux-x64": "node ./scripts/configure.mjs panda-linux-x64", + "compile:native-panda-linux-x64": "npm run configure:native-panda-linux-x64 && meson compile -C build-panda-linux-x64 && meson install -C build-panda-linux-x64", + "configure:native-panda-linux-arm64": "node ./scripts/configure.mjs panda-linux-arm64", + "compile:native-panda-linux-arm64": "npm run configure:native-panda-linux-arm64 && meson compile -C build-panda-linux-arm64 && meson install -C build-panda-linux-arm64", + "configure:native-panda-windows-x64": "node ./scripts/configure.mjs panda-windows-x64", + "compile:native-panda-windows-x64": "npm run configure:native-panda-windows-x64 && meson compile -C build-panda-windows-x64 && meson install -C build-panda-windows-x64", + "configure:native-panda-macos-x64": "node ./scripts/configure.mjs panda-macos-x64", + "compile:native-panda-macos-x64": "npm run configure:native-panda-macos-x64 && meson compile -C build-panda-macos-x64 && meson install -C build-panda-macos-x64", + "configure:native-panda-macos-arm64": "node ./scripts/configure.mjs panda-macos-arm64", + "compile:native-panda-macos-arm64": "npm run configure:native-panda-macos-arm64 && meson compile -C build-panda-macos-arm64 && meson install -C build-panda-macos-arm64", + "configure:native-jvm-host": "meson setup -D vm_kind=jvm build-jvm-host -D vmloader=true -D jdk_dir=$JAVA_HOME", + "compile:native-jvm-host": "npm run configure:native-jvm-host && meson compile -C build-jvm-host && meson install -C build-jvm-host", + "configure:native-hzvm-ohos-arm64": "npm run prepare:arm64 && node ./scripts/configure.mjs hzvm-ohos-arm64", + "compile:native-hzvm-ohos-arm64": "npm run configure:native-hzvm-ohos-arm64 && meson compile -C build-hzvm-ohos-arm64 && meson install -C build-hzvm-ohos-arm64", + "configure:native-hzvm-ohos-arm32": "npm run prepare:arm32 && node ./scripts/configure.mjs hzvm-ohos-arm32", + "compile:native-hzvm-ohos-arm32": "npm run configure:native-hzvm-ohos-arm32 && meson compile -C build-hzvm-ohos-arm32 && meson install -C build-hzvm-ohos-arm32", + "configure:native-hzvm-ohos": "npm run configure:native-hzvm-ohos-arm64", + "compile:native-hzvm-ohos": "npm run compile:native-hzvm-ohos-arm64", + "configure:native-panda-ohos-arm64": "npm run prepare:arm64 && node ./scripts/configure.mjs panda-ohos-arm64", + "compile:native-panda-ohos-arm64": "npm run configure:native-panda-ohos-arm64 && meson compile -C build-panda-ohos-arm64 && meson install -C build-panda-ohos-arm64", + "configure:native-panda-ohos-arm32": "npm run prepare:arm32 && node ./scripts/configure.mjs panda-ohos-arm32", + "compile:native-panda-ohos-arm32": "npm run configure:native-panda-ohos-arm32 && meson compile -C build-panda-ohos-arm32 && meson install -C build-panda-ohos-arm32", + "configure:native-panda-with-node-host": "npm run configure:native-panda-host && meson setup -D vm_kind=node -D vmloader=true build-node-host-vmloader", + "compile:native-panda-with-node-host": "npm run configure:native-panda-with-node-host && npm run compile:native-panda-host && npm run compile:native-panda-host && meson compile -C build-node-host-vmloader && meson install -C build-node-host-vmloader", + "configure:native-panda-with-hzvm-ohos-arm64": "npm run configure:native-panda-ohos-arm64 && node ./scripts/configure.mjs hzvm-ohos-arm64-vmloader", + "compile:native-panda-with-hzvm-ohos-arm64": "npm run configure:native-panda-with-hzvm-ohos-arm64 && npm run compile:native-panda-ohos-arm64 && meson compile -C build-hzvm-ohos-arm64-vmloader && meson install -C build-hzvm-ohos-arm64-vmloader", + "configure:native-panda-with-hzvm-ohos-arm32": "npm run configure:native-panda-ohos-arm32 && node ./scripts/configure.mjs hzvm-ohos-arm32-vmloader", + "compile:native-panda-with-hzvm-ohos-arm32": "npm run configure:native-panda-with-hzvm-ohos-arm32 && npm run compile:native-panda-ohos-arm32 && meson compile -C build-hzvm-ohos-arm32-vmloader && meson install -C build-hzvm-ohos-arm32-vmloader" + }, + "keywords": [], + "dependencies": { + "@types/node": "^18.0.0", + "@koalaui/common": "1.5.15+devel" + }, + "devDependencies": { + "@ohos/hypium": "1.0.6", + "@types/node": "^18.0.0", + "@typescript-eslint/eslint-plugin": "^5.20.0", + "@typescript-eslint/parser": "^5.20.0", + "eslint": "^8.13.0", + "eslint-plugin-unused-imports": "^2.0.0", + "source-map-support": "^0.5.21", + "@koalaui/ets-tsc": "4.9.5-r5", + "@koalaui/fast-arktsc": "1.5.15" + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/scripts/configure.mjs b/frameworks/bridge/arkts_frontend/koala_mirror/interop/scripts/configure.mjs new file mode 100644 index 0000000000000000000000000000000000000000..04a49aafd55f36d08bf6548fc4f9ea734af4154d --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/scripts/configure.mjs @@ -0,0 +1,502 @@ +// This is a simplified version of the original configure.mjs script, with only targers +// "hzvm-ohos-arm32" and "hzvm-ohos-arm64" +// "panda-ohos-arm32" and "panda-ohos-arm64" + +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import fs from "fs"; +import { exit, platform } from "process"; +import chalk from "chalk"; +import path from "path"; +import minimist from "minimist" + +import { findMeson, CrossFile, requireEnv, relativeToSourceRoot } from "./utils.mjs" + +import { createRequire } from 'node:module'; +import { ohConf } from "../../tools/ohos-tools/ohconf.mjs" +import { OH_SDK_COMPONENT, ohSdkInfo } from "../../tools/ohos-tools/ohos-sdk/download-ohos-sdk.mjs" +import url from "url" +const require = createRequire(import.meta.url); + +const __dirname = path.dirname(url.fileURLToPath(import.meta.url)) + +const OHCONF = ohConf(path.join(__dirname, "../../tools/ohos-tools/ohos-sdk/.ohconf.json")) + +let cliOptions = minimist(process.argv.slice(2)) + +let targets = cliOptions._; +let help = cliOptions.h || cliOptions.help; +let verbose = cliOptions.v || cliOptions.verbose; +let reconfigure = cliOptions.reconfigure; +let wipe = cliOptions.wipe; +let clean = cliOptions.clean; +let dryRun = cliOptions.n || cliOptions["dry-run"]; +let root = cliOptions.root || path.join(__dirname, "..") + +let nodeDir = cliOptions["node-dir"] || process.env.NODE_DIR || ''; +let nodeBuildType = cliOptions["node-buildtype"] || process.env.NODE_BUILDTYPE || "release"; + +let pandaBuildType = process.env.PANDA_BUILDTYPE || "Release"; +let pandaRuntimeOptions = process.env.PANDA_RUNTIME_OPTIONS || "jit:aot"; + +if (targets.length === 0 || help) { + usage(); + exit(1); +} + +const meson = findMeson(); + +if (nodeDir && !path.isAbsolute(nodeDir)) { + console.log("NODE_DIR must be an absolute path") + exit(1); +} + +nodeDir && console.log(`NODE_DIR: ${chalk.green(nodeDir)}`); +console.log(`NODE_BUILDTYPE: ${chalk.green(nodeBuildType)}`); + +targets.forEach(target => configure(target)); + +function getNdkRoot() { + if (process.env["ANDROID_NDK_ROOT"]) return process.env["ANDROID_NDK_ROOT"] + let dir = path.join(requireEnv("ANDROID_SDK_ROOT"), 'ndk') + let ndks = fs.readdirSync(dir).sort() + if (ndks.length < 1) throw new Error("Unexpected NDK dir layout") + return path.join(dir, ndks[ndks.length - 1]) +} + +function getJdkRoot() { + if (process.env["JAVA_HOME"]) return process.env["JAVA_HOME"] + throw new Error("Cannot find JAVA_HOME") +} + +export function configure(target) { + let buildDirName = `build-${target}`; + + if (fs.existsSync(buildDirName)) { + if (clean) { + !dryRun && fs.rmSync(buildDirName, { recursive: true, force: true }); + reconfigure = wipe = false; + } else if (!reconfigure && !wipe) { + console.log(chalk.yellow(`target ${target} already configured`) + + "\n restart with --clean, --wipe or --reconfigure to configure again"); + return; + } + } else { + reconfigure = false; + wipe = false; + } + + // TODO add architecture + let destDir = target; + let binDir = target == "wasm" ? destDir : void 0; // Wasm output can be an executable only + let libDir = target == "wasm" ? void 0 : destDir; + let vmKind = target.split('-')[0] + + const vsenv = process.platform === "win32" && target === "node-host" + + const doConfigure = (isJvm, ...crossFiles) => { + verbose && console.log(`Configuring target ${chalk.bold(target)}\n`); + try { + meson.configure({ + builddir: "build-" + target, + prefix: path.resolve(".runtime-prebuilt"), + wipe, + reconfigure, + verbose, + binDir, + libDir, + crossFiles, + dryRun, + vsenv, + options: { + "vm_kind": vmKind || undefined, + "jdk_dir": isJvm ? getJdkRoot() : null, + "vmloader": target.includes('vmloader'), + } + }); + verbose && console.log(); + console.log(`Target ${chalk.bold(target)}: ${chalk.green("SUCCESS")}`); + } catch (err) { + console.log(err); + console.log(`Target ${chalk.bold(target)}: ${chalk.red("FAIL")}`); + } + } + + switch (target) { + case "hzvm-ohos-arm32": + case "hzvm-ohos-arm64": + case "hzvm-ohos-arm32-vmloader": + case "hzvm-ohos-arm64-vmloader": + case "panda-ohos-arm32": + case "panda-ohos-arm64": + doConfigure(false, createOhosCrossFile(target)); + break; + case "panda-linux-x64": + case "panda-linux-arm64": + doConfigure(false, createLinuxCrossFile(target)); + break; + case "panda-windows-x64": + doConfigure(false, createWindowsClangCrossFile("x64")) + break; + case "node-macos-x64": + case "node-macos-arm64": + case "panda-macos-x64": + case "panda-macos-arm64": + doConfigure(false, createMacosCrossFile(target)); + break; + default: + console.log(chalk.yellow("unsupported target '" + target + "'")); + } +} + +function createWasmCrossFile() { + let cf = CrossFile("wasm"); + let emcc = "emcc", empp = "em++", emar = "emar"; + if (platform == "win32") { + if (process.env.EMSDK) { + let emsdk = process.env.EMSDK; + console.log("EMSDK: " + chalk.green(emsdk)); + let prefix = path.join(emsdk, "upstream", "emscripten"); + emcc = path.join(prefix, emcc + ".bat"); + empp = path.join(prefix, empp + ".bat"); + emar = path.join(prefix, emar + ".bat"); + } else { + console.log("EMSDK: " + chalk.red("not found") + "\r\n" + + chalk.gray(" set environment variable EMSDK=")); + exit(1); + } + } + cf.section("binaries", { + c: emcc, + cpp: empp, + ar: emar, + }) + .section("host_machine", { + system: 'emscripten', + cpu_family: 'wasm32', + cpu: 'wasm32', + endian: 'little', + }) + .close(); + + return cf.path; +} + +function createWindowsClangCrossFile(arch) { + let cf = CrossFile("windows-clang-" + arch); + let cpu = arch === "x64" ? "x86_64" : "x86"; // TODO check + let xwinHome = path.join(__dirname, "../prebuilt/wincrt") + if (!fs.existsSync(xwinHome)) xwinHome = requireEnv("WINCRT_HOME") + console.log(`Using CRT from ${chalk.bold(xwinHome)}`) + + let link_args = [ + `-L${xwinHome}/crt/lib/${cpu}`, + `-L${xwinHome}/sdk/lib/um/${cpu}`, + `-L${xwinHome}/sdk/lib/ucrt/${cpu}`, + ] + + let include_dirs = [ + `/I${xwinHome}/crt/include`, + `/I${xwinHome}/sdk/include/ucrt`, + `/I${xwinHome}/sdk/include/um`, + `/I${xwinHome}/sdk/include/shared`, + ] + + let llvmBin = (() => { + let llvmHome = process.env.LLVM_HOME; + if (!llvmHome) { + if (process.platform === "win32") { + llvmHome = path.join(process.env.ProgramFiles, "LLVM") + } else { + llvmHome = "/usr/lib/llvm-14" // Ubuntu + } + if (fs.existsSync(llvmHome)) { + console.log(`Using LLVM from ${chalk.bold(llvmHome)}`) + } else { + console.log(`Using LLVM from ${chalk.bold("PATH")}`) + llvmHome = null + } + } + if (llvmHome) { + return bin => path.join(llvmHome, 'bin', bin) + } else { + return bin => bin // search in PATH + } + })() + + cf.section("binaries", { + // Ninja must have /I flags for feature detection, so adding them here + c: [llvmBin("clang-cl"), ...include_dirs], + cpp: [llvmBin("clang-cl"), ...include_dirs], + ar: llvmBin("llvm-lib"), + }) + .section("built-in options", { + c_args: ['-Wno-unused-local-typedef'], + cpp_args: ['-Wno-unused-local-typedef'], + + c_link_args: [...link_args], + cpp_link_args: [...link_args], + }) + .section("host_machine", { + system: "windows", + cpu_family: cpu, + cpu: cpu, + endian: "little", + }) + .close(); + + return cf.path; +} + +function createLinuxCrossFile(target) { + let cf = CrossFile(target, root); + + let suffix = "" + if (platform == 'win32') { + suffix = ".exe"; + } + + let cpu = 'unknown' + if (target == 'panda-linux-arm64' || target == 'panda-linux-arm64-vmloader') { + cpu = 'aarch64' + } else if (target == 'panda-linux-x64' || target == 'panda-linux-x64-vmloader') { + cpu = 'x64' + } else { + throw "Unknown target " + target; + } + + cf.section("binaries", { + c: 'clang' + suffix, + cpp: 'clang++' + suffix, + }) + .section("host_machine", { + system: 'linux', + cpu_family: cpu, + cpu: cpu, + endian: 'little', + }) + .close(); + + return cf.path; +} + +function createAndroidCrossFile(target) { + let cf = CrossFile(target); + let ndkRoot = getNdkRoot() + let compilersPath = "" + let suffix = "" + if (platform == 'win32') { + compilersPath = path.join(ndkRoot, "toolchains", "llvm", "prebuilt", "windows-x86_64", "bin"); + suffix = ".cmd"; + } else + compilersPath = path.join(ndkRoot, "toolchains", "llvm", "prebuilt", platform + "-x86_64", "bin"); + compilersPath = path.resolve(compilersPath); + + let cpu = 'unknown' + if (target == 'android-arm64') + cpu = 'aarch64' + else if (target == 'android-x64') + cpu = 'x86_64' + else + throw "Unknown target " + target; + + cf.section("binaries", { + c: path.join(compilersPath, cpu + "-linux-android28-clang" + suffix), + cpp: path.join(compilersPath, cpu + "-linux-android28-clang++" + suffix), + ar: path.join(compilersPath, "llvm-ar"), + }) + .section("host_machine", { + system: 'android', + cpu_family: cpu, + cpu: cpu, + endian: 'little', + }) + .close(); + + return cf.path; +} + +function createOhosCrossFile(target) { + let cf = CrossFile(target, root); + let sdkNativePath = "" + let compilersPath = "" + let suffix = "" + if (platform == 'win32') { + suffix = ".exe"; + } + if (platform == 'linux') { + compilersPath = path.resolve('../arkoala-arkts/tools/compiler/llvm-toolchain/bin') + } else { + sdkNativePath = ohSdkInfo(OHCONF.sdkPath(), OH_SDK_COMPONENT.native).path + compilersPath = path.join(sdkNativePath, "llvm", "bin") + } + + let cflags = [ + '--sysroot=' + path.resolve(`../arkoala-arkts/tools/compiler/sysroot-${ target.includes('arm64') ? 'arm64' : 'arm' }`) + ] + let cpu = 'unknown' + if (target == 'hzvm-ohos-arm64' || target == 'hzvm-ohos-arm64-vmloader' || target == 'panda-ohos-arm64') { + cpu = 'aarch64' + cflags = [ + ...cflags, + '--target=aarch64-linux-ohos' + ] + } else if (target == 'hzvm-ohos-arm32' || target == 'hzvm-ohos-arm32-vmloader' || target == 'panda-ohos-arm32') { + cpu = 'armv7-a' + cflags = [ + ...cflags, + '--target=armv7-a-linux-ohos' + ] + } else { + throw "Unknown target " + target; + } + + cf.section("binaries", { + c: path.join(compilersPath, "clang" + suffix), + c_ld: path.join(compilersPath, "ld.lld" + suffix), + cpp: path.join(compilersPath, "clang++" + suffix), + cpp_ld: path.join(compilersPath, "ld.lld" + suffix), + ar: path.join(compilersPath, "llvm-ar" + suffix), + }) + .section("built-in options", { + c_args: cflags, + c_link_args: cflags, + cpp_args: cflags, + cpp_link_args: cflags + }) + .section("host_machine", { + system: 'ohos', + cpu_family: cpu, + cpu: cpu, + endian: 'little', + }) + .close(); + + return cf.path; +} + +function createIosCrossFile(target) { + let cf = CrossFile(target); + + let cflags = [ + ] + let cpu = 'unknown' + if (target == 'jsc-ios-arm64') { + cpu = 'aarch64' + cflags = [ + ...cflags, + '-arch', 'arm64', + "-isysroot", "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk" + ] + } else if (target == 'jsc-ios-x64') { + cpu = 'x86_64' + cflags = [ + ...cflags, + '-arch', 'x86_64', + "-isysroot", '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk' + ] + } else { + throw "Unknown target " + target; + } + + cf.section("binaries", { + c: 'clang', + cpp: 'clang++', + objcpp: 'clang++', + ar: 'ar', + strip: 'strip' + }) + .section("built-in options", { + c_args: cflags, + c_link_args: cflags, + cpp_args: cflags, + cpp_link_args: cflags, + objcpp_args: cflags, + objcpp_link_args: cflags, + }) + .section("host_machine", { + system: 'ios', + cpu_family: cpu, + cpu: cpu, + endian: 'little', + }) + .close(); + + return cf.path; +} + +function createMacosCrossFile(target) { + let cf = CrossFile(target); + + let cflags = [ + ] + let cpu = 'unknown' + if (target == 'panda-macos-arm64' || target == 'node-macos-arm64') { + cpu = 'aarch64' + cflags = [ + ...cflags, + '-arch', 'arm64', + ] + } else if (target == 'panda-macos-x64' || target == 'node-macos-x64') { + cpu = 'x86_64' + cflags = [ + ...cflags, + '-arch', 'x86_64', + ] + } else { + throw "Unknown target " + target; + } + + cf.section("binaries", { + c: 'clang', + cpp: 'clang++', + objcpp: 'clang++', + ar: 'ar', + strip: 'strip', + }) + .section("built-in options", { + c_args: cflags, + c_link_args: cflags, + cpp_args: cflags, + cpp_link_args: cflags, + objcpp_args: cflags, + objcpp_link_args: cflags, + }) + .section("host_machine", { + system: 'darwin', + cpu_family: cpu, + cpu: cpu, + endian: 'little', + }) + .close(); + + return cf.path; +} + +function usage() { + console.log(`USAGE: node configure.mjs [OPTION]... TARGET [TARGET]... + +TARGET = wasm | node-android-x64 | node-android-arm64 | jni-host | node-host | hzvm-ohos-arm64 | hzvm-ohos-arm32 | jsc-ios-arm64 | jsc-ios-x64 | node-macos-x64 | node-macos-arm64 compilation target + +OPTIONS: + -h, --help show this help and exit + -v, --verbose show Meson output + -n, --dry-run do not emit files and do not perform meson configuring + --wipe wipe build directory and reconfigure + --reconfigure reconfigure build directory (use if options were changed) + --clean remove build directory before configuring +`) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/scripts/get_napi.mjs b/frameworks/bridge/arkts_frontend/koala_mirror/interop/scripts/get_napi.mjs new file mode 100644 index 0000000000000000000000000000000000000000..e663e3a24bd3176eb535c577545b67f3974f2879 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/scripts/get_napi.mjs @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { GitLab } from "../../tools/storage/gitlab/gitlab.mjs"; +import minimist from "minimist"; +import path from "path" + +let args = minimist(process.argv.slice(2)) + +const version = args.version +const apiVersion = version.split('-')[0] +const outDir = path.join('prebuilt', 'node-addon-api-'+ version) + +const gitlab = new GitLab() +gitlab.downloadRawArchive( + 'node-addon-api', + apiVersion, + 'v' + version + '.tar.gz', + outDir +) diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/scripts/get_prebuilt.mjs b/frameworks/bridge/arkts_frontend/koala_mirror/interop/scripts/get_prebuilt.mjs new file mode 100644 index 0000000000000000000000000000000000000000..d76ac6aec21aa2e4727661fb3a4dcddb2eb4441f --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/scripts/get_prebuilt.mjs @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { GitLab } from "../../tools/storage/gitlab/gitlab.mjs"; +import minimist from "minimist"; +import path from "path" + +const gitlab = new GitLab() + +let args = minimist(process.argv.slice(2)) + +const version = args.version +const buildType = args['build-type'] +const machine = args.machine +const target = args.target + +const nodeVersion = version.split('-')[0] +const buildName = buildType + '-' + target + '-' + machine +const outDir = path.join('prebuilt', version, buildName) + +if (target === 'android') { + gitlab.downloadRawArchive( + 'node-bin', + nodeVersion, + `node-${target}-${buildType}-${machine}-${version}.zip`, + outDir + ) +} else { + gitlab.downloadRawArchive( + 'node-bin', + nodeVersion, + `node-v${nodeVersion}-headers.tar.gz`, + outDir, + `node-v${nodeVersion}/`, + ) + if (target === 'windows') { + gitlab.downloadRawFile( + 'node-bin', + nodeVersion, + `win-${machine}.node.lib`, + path.join(outDir, 'lib'), + 'node.lib' + ) + } +} + diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/scripts/utils.mjs b/frameworks/bridge/arkts_frontend/koala_mirror/interop/scripts/utils.mjs new file mode 100644 index 0000000000000000000000000000000000000000..c2e50d669fb607a30b386d9d53f82619d9e775bf --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/scripts/utils.mjs @@ -0,0 +1,248 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import fs from "fs" +import { exit } from "process" +import { spawnSync } from "child_process" +import chalk from "chalk" +import path from "path" +import url from "url" + +const __dirname = path.dirname(url.fileURLToPath(import.meta.url)); + +class Version { + constructor(version) { + let [major, minor, patch] = version.split(/\./).map(x => +x); + this.major = major; + this.minor = minor; + this.patch = patch; + } + + toString() { + return `${this.major}.${this.minor}.${this.patch}`; + } +} + +export function toIniValue(value) { + if (typeof value == "string") { + value = value.replace("'", "\\'"); + return `'${value}'`; + } else if (Array.isArray(value)) { + let res = '' + for (let i in value) { + res += toIniValue(value[i]) + (i < value.length - 1 ? ', ' : '') + } + return '[' + res + ']'; + } else { + return value.toString(); + } +} + + +export function CrossFile(target, root = path.join(__dirname, '..')) { + let filename = target + '.ini'; + let filepath = path.join(root, filename); + + let lines = [] + return { + section(name, values) { + lines.push(`\n[${name}]\n`); + if (values) { + for (let prop in values) { + if (values.hasOwnProperty(prop)) { + this.property(prop, values[prop]); + } + } + } + return this; + }, + property(name, value) { + value = toIniValue(value); + lines.push(`${name} = ${value}\n`); + return this; + }, + close() { + fs.writeFileSync(filepath, lines.join('')); + }, + get path() { + return filepath; + } + } +} + +class Meson { + #version; + + constructor(version) { + this.#version = new Version(version); + } + + get version() { + return this.#version; + } + + configure(options) { + let builddir = options.builddir; + let crossFiles = options.crossFiles || []; + let defs = options.options || {}; + let dryRun = options.dryRun || false; + + let args = ["setup", builddir]; + if (options.prefix) { + args.push("--prefix", options.prefix); + } + if (options.binDir) { + args.push("--bindir", options.binDir); + } + if (options.libDir) { + args.push("--libdir", options.libDir); + } + for (const file of crossFiles) { + args.push("--cross-file", file); + } + for (const def in defs) { + let value = defs[def]; + if (defs.hasOwnProperty(def) && value != null) { + args.push(`-D${def}=${value}`); + } + } + if (options.wipe) { + args.push("--wipe"); + } + if (options.reconfigure) { + args.push("--reconfigure"); + } + if (options.vsenv) { + // Force MSVC instead of clang + args.push("--vsenv"); + } + if (options.vm_kind) { + args.push(`-Dvm_kind=${options.vm_kind}`); + } + console.log(`> meson ${args.join(' ')}`); + if (!dryRun) { + let stdio = options.verbose ? ['inherit', 'inherit', 'inherit'] : void 0; + let env = process.env + let meson = spawnSync("meson", args, { encoding: "utf8", stdio, env }); + if (meson.status != 0) { + throw new Error("failed to configure"); + } + } + } +} + +export function findMeson() { + try { + let version = spawnSync("meson", ["-v"], { encoding: "utf8" }).output.join('').trim(); + console.log("Meson: " + chalk.green(version)); + return new Meson(version); + } catch (err) { + console.log("Meson: " + chalk.red("NOT FOUND")); + exit(1); + } +} + +export function findNinja() { + try { + let version = spawnSync("ninja", ["--version"], { encoding: "utf8" }).output.join('').trim(); + console.log("Ninja: " + chalk.green(version)); + return { version: new Version(version) }; + } catch (err) { + console.log("Ninja: " + chalk.red("NOT FOUND")); + exit(1); + } +} + +export function findPython() { + try { + let version = spawnSync("python3", ["--version"], { encoding: "utf8" }).output.join('').trim(); + version = version.replace(/^Python\s*/i, ""); + console.log("Python: " + chalk.green(version)); + return { version: new Version(version) }; + } catch (err) { + console.log("Python: " + chalk.red("NOT FOUND")); + exit(1); + } +} + +export function requireEnv(name, description) { + let value = process.env[name]; + if (value) { + console.log(`${name}: ${chalk.green(value)}`); + return value; + } else { + console.log(name + ": " + chalk.red("not found") + "\r\n" + + chalk.gray(` set environment variable ${name}=<${description}>`)); + exit(1); + } +} + +export function relativeToSourceRoot(abspath) { + let sourceRoot = path.resolve(__dirname, ".."); + return path.relative(sourceRoot, abspath); +} + +export function sourceRoot() { + return path.resolve(__dirname, ".."); +} + +class CMake { + #version; + + constructor(version) { + this.#version = new Version(version); + } + + get version() { + return this.#version; + } + + configure(options) { + let builddir = options.builddir; + let srcdir = options.srcdir + let defs = options.defs; + let dryRun = options.dryRun || false; + + let args = ['-GNinja', `-S${srcdir}`, `-B${builddir}`]; + for (const def in defs) { + let value = defs[def]; + if (defs.hasOwnProperty(def) && value != null) { + args.push(`-D${def}=${value}`); + } + } + console.log(`> cmake ${args.join(' ')}`); + if (!dryRun) { + let stdio = options.verbose ? ['inherit', 'inherit', 'inherit'] : void 0; + let cmake = spawnSync("cmake", args, { + encoding: "utf8", + stdio + }); + if (cmake.status != 0) { + throw new Error("failed to configure"); + } + } + } +} + +export function findCmake() { + try { + let version = spawnSync("cmake", ["--version"], { encoding: "utf8" }).output.join('').trim(); + console.log("CMake: " + chalk.green(version)); + return new CMake(version); + } catch (err) { + console.log("CMake: " + chalk.red("NOT FOUND")); + exit(1); + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/arkts/DeserializerBase.ts b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/arkts/DeserializerBase.ts new file mode 100644 index 0000000000000000000000000000000000000000..cd9b41419d20b213bca4dc180aabe293563d1533 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/arkts/DeserializerBase.ts @@ -0,0 +1,246 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { float32, int32, int64, float32FromBits, uint8 } from "@koalaui/common" +import { pointer, KUint8ArrayPtr, KSerializerBuffer, nullptr } from "./InteropTypes" +import { NativeBuffer } from "./NativeBuffer" +import { InteropNativeModule } from "./InteropNativeModule" +import { Tags, CallbackResource } from "./SerializerBase"; +import { ResourceHolder, Disposable } from "./ResourceManager" +import { StubFastIntrinsics } from "./StubFastIntrinsics" + +export class DeserializerBase implements Disposable { + private position = 0 + private _buffer: KSerializerBuffer + private readonly _isOwnBuffer: boolean; + private readonly _length: int32 + private static customDeserializers: CustomDeserializer | undefined = new DateDeserializer() + + static registerCustomDeserializer(deserializer: CustomDeserializer) { + let current = DeserializerBase.customDeserializers + if (current == undefined) { + DeserializerBase.customDeserializers = deserializer + } else { + while (current!.next != undefined) { + current = current!.next + } + current!.next = deserializer + } + } + + constructor(buffer: KUint8ArrayPtr|KSerializerBuffer, length: int32) { + if (buffer instanceof KUint8ArrayPtr) { + this._buffer = InteropNativeModule._Malloc(length) + this._isOwnBuffer = true + for (let i = 0; i < length; i++) { + StubFastIntrinsics.writeInt8(this._buffer + i, buffer[i] as byte) + } + } else { + this._buffer = buffer + } + this._length = length + } + + public dispose() { + if (this._isOwnBuffer) { + InteropNativeModule._Free(this._buffer) + this._buffer = nullptr + } + } + + // TODO: get rid of length. + private static writeu8(buffer: KSerializerBuffer, offset: int32, length: int32, value: int32): void { + InteropNativeModule._WriteByte(buffer, offset as int64, length as int64, value as uint8) + } + // TODO: get rid of length. + private static readu8(buffer: KSerializerBuffer, offset: int32, length: int32): int32 { + return (InteropNativeModule._ReadByte(buffer, offset as int64, length as int64) as byte) & 0xff + } + + final asBuffer(): KSerializerBuffer { + return this._buffer + } + + final currentPosition(): int32 { + return this.position + } + + final resetCurrentPosition(): void { + this.position = 0 + } + + private checkCapacity(value: int32) { + if (value > this._length) { + throw new Error(`${value} is less than remaining buffer length`) + } + } + + final readInt8(): int32 { + this.checkCapacity(1) + const value = StubFastIntrinsics.readInt8(this._buffer + this.position) + this.position += 1 + return value + } + + final readInt32(): int32 { + this.checkCapacity(4) + let result = StubFastIntrinsics.readInt32(this._buffer + this.position) + this.position += 4 + return result + } + + final readPointer(): pointer { + this.checkCapacity(8) + let result = StubFastIntrinsics.readInt64(this._buffer + this.position) + this.position += 8 + return result + } + + final readInt64(): int64 { + this.checkCapacity(8) + let result = StubFastIntrinsics.readInt64(this._buffer + this.position) + this.position += 8 + return result + } + + final readFloat32(): float32 { + this.checkCapacity(4) + let result = StubFastIntrinsics.readFloat32(this._buffer + this.position) + this.position += 4 + return result + } + + final readBoolean(): boolean { + this.checkCapacity(1) + let value = StubFastIntrinsics.readBoolean(this._buffer + this.position); + this.position += 1 + if (value == undefined) + return false; + + return value + } + + readFunction(): int32 { + // TODO: not exactly correct. + const id = this.readInt32() + return id + } + + // readMaterialized(): object { + // const ptr = this.readPointer() + // return { ptr: ptr } + // } + + final readCallbackResource(): CallbackResource { + return ({ + resourceId: this.readInt32(), + hold: this.readPointer(), + release: this.readPointer(), + } as CallbackResource) + } + + final readString(): string { + // read without null-terminated byte + let encodedLength = this.readInt32(); + const value = StubFastIntrinsics.readString(this._buffer + this.position, encodedLength) + this.position += encodedLength + return value + } + + final readCustomObject(kind: string): object { + let current = DeserializerBase.customDeserializers + while (current) { + if (current!.supports(kind)) { + return current!.deserialize(this, kind) + } + current = current!.next + } + // consume tag + const tag = this.readInt8() + throw Error(`${kind} is not supported`) + } + + final readNumber(): number | undefined { + const tag = this.readInt8() + if (tag == Tags.UNDEFINED) { + return undefined + } else if (tag == Tags.INT32) { + return this.readInt32() + } else if (tag == Tags.FLOAT32) { + return this.readFloat32() + } else { + throw new Error(`Unknown number tag: ${tag}`) + } + } + + readObject():object { + const resource = this.readCallbackResource() + return ResourceHolder.instance().get(resource.resourceId) + } + + static lengthUnitFromInt(unit: int32): string { + let suffix: string + switch (unit) { + case 0: + suffix = "px" + break + case 1: + suffix = "vp" + break + case 3: + suffix = "%" + break + case 4: + suffix = "lpx" + break + default: + suffix = "" + } + return suffix + } + + final readBuffer(): NativeBuffer { + /* not implemented */ + const resource = this.readCallbackResource() + const data = this.readPointer() + const length = this.readInt64() + return NativeBuffer.wrap(data, length, resource.resourceId, resource.hold, resource.release) + } +} + +export abstract class CustomDeserializer { + protected supported: string + protected constructor(supported_: string) { + this.supported = supported_ + } + + supports(kind: string): boolean { + return this.supported.includes(kind) + } + + abstract deserialize(serializer: DeserializerBase, kind: string): object + + next: CustomDeserializer | undefined = undefined +} + +class DateDeserializer extends CustomDeserializer { + constructor() { + super("Date") + } + + deserialize(serializer: DeserializerBase, kind: string): Date { + return new Date(serializer.readString()) + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/arkts/Finalizable.ts b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/arkts/Finalizable.ts new file mode 100644 index 0000000000000000000000000000000000000000..6ae3ac2d8b4f612072e37bee9b64eae3d91a2b01 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/arkts/Finalizable.ts @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { finalizerRegister, finalizerUnregister, Thunk } from "@koalaui/common" +import { InteropNativeModule } from "./InteropNativeModule" +import { pointer, nullptr } from "./InteropTypes" + +class NativeThunk implements Thunk { + finalizer: pointer + obj: pointer + name: string|undefined + + constructor(obj: pointer, finalizer: pointer, name?: string) { + this.finalizer = finalizer + this.obj = obj + this.name = name + } + + clean() { + if (this.obj != nullptr) { + this.destroyNative(this.obj, this.finalizer) + } + this.obj = nullptr + } + + destroyNative(ptr: pointer, finalizer: pointer): void { + InteropNativeModule._InvokeFinalizer(ptr, finalizer) + } +} + +/** + * Class with the custom finalizer, usually used to release a native peer. + * Do not use directly, only via subclasses. + */ +export class Finalizable { + ptr: pointer + finalizer: pointer + cleaner: NativeThunk|undefined = undefined + managed: boolean + constructor(ptr: pointer, finalizer: pointer, managed: boolean = true) { + this.ptr = ptr + this.finalizer = finalizer + this.managed = managed + const handle = undefined + + if (this.managed) { + if (this.ptr == nullptr) throw new Error("Can't have nullptr ptr ${}") + if (this.finalizer == nullptr) throw new Error("Managed finalizer is 0") + + const thunk = new NativeThunk(ptr, finalizer, handle) + finalizerRegister(this, thunk) + this.cleaner = thunk + } + } + + close() { + if (this.ptr == nullptr) { + throw new Error(`Closing a closed object: ` + this.toString()) + } else if (this.cleaner == undefined) { + throw new Error(`No thunk assigned to ` + this.toString()) + } else { + finalizerUnregister(this) + this.cleaner!.clean() + this.cleaner = undefined + this.ptr = nullptr + } + } + + release(): pointer { + finalizerUnregister(this) + if (this.cleaner) + this.cleaner!.obj = nullptr + let result = this.ptr + this.ptr = nullptr + return result + } + + resetPeer(pointer: pointer) { + if (this.managed) throw new Error("Can only reset peer for an unmanaged object") + this.ptr = pointer + } + + use(body: (value: Finalizable) => R): R { + let result = body(this) + this.close() + return result + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/arkts/InteropNativeModule.ts b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/arkts/InteropNativeModule.ts new file mode 100644 index 0000000000000000000000000000000000000000..4e8b046772b16be85f85f42bf729999870450cfc --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/arkts/InteropNativeModule.ts @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { int32, int64 } from "@koalaui/common"; +import { KPointer, KUint8ArrayPtr, KInt, KSerializerBuffer } from "./InteropTypes"; +import { callCallback } from "./callback" +import { loadNativeModuleLibrary } from "./loadLibraries" + +export class InteropNativeModule { + static { + loadNativeModuleLibrary("InteropNativeModule") + } + static callCallbackFromNative(id: KInt, args: KSerializerBuffer, length: KInt): KInt { + return callCallback(id, args, length) + } + native static _GetGroupedLog(index: int32): KPointer + native static _StartGroupedLog(index: int32): void + native static _StopGroupedLog(index: int32): void + native static _AppendGroupedLog(index: int32, message: string): void + native static _PrintGroupedLog(index: int32): void + native static _GetStringFinalizer(): KPointer + native static _InvokeFinalizer(ptr1: KPointer, ptr2: KPointer): void + native static _IncrementNumber(value: number): number + native static _GetPtrVectorElement(ptr1: KPointer, arg: int32): KPointer + native static _StringLength(ptr1: KPointer): int32 + native static _StringData(ptr1: KPointer, arr: KUint8ArrayPtr, i: int32): void + native static _StringMake(str1: string): KPointer + native static _GetPtrVectorSize(ptr1: KPointer): int32 + @ani.unsafe.Quick + native static _ManagedStringWrite(str1: string, arr: KPointer, arg: int32): int32 + native static _NativeLog(str1: string): void + @ani.unsafe.Quick + native static _Utf8ToString(data: KPointer, offset: int32, length: int32): string + native static _StdStringToString(cstring: KPointer): string + @ani.unsafe.Direct + native static _CheckCallbackEvent(buffer: KSerializerBuffer, bufferLength: int32): int32 + native static _HoldCallbackResource(resourceId: int32): void + native static _ReleaseCallbackResource(resourceId: int32): void + native static _CallCallback(callbackKind: int32, args: KSerializerBuffer, argsSize: int32): void + native static _CallCallbackSync(callbackKind: int32, args: KSerializerBuffer, argsSize: int32): void + native static _CallCallbackResourceHolder(holder: KPointer, resourceId: int32): void + native static _CallCallbackResourceReleaser(releaser: KPointer, resourceId: int32): void + native static _LoadVirtualMachine(arg0: int32, arg1: string, arg2: string): int32 + native static _RunApplication(arg0: int32, arg1: int32): boolean + native static _StartApplication(appUrl: string, appParams: string): KPointer + native static _EmitEvent(eventType: int32, target: int32, arg0: int32, arg1: int32): void + native static _CallForeignVM(context:KPointer, callback: int32, data: KSerializerBuffer, dataLength: int32): int32 + native static _SetForeignVMContext(context: KPointer): void + native static _RestartWith(page: string): void + @ani.unsafe.Direct + native static _ReadByte(data: KPointer, index: int64, length: int64): int32 + @ani.unsafe.Direct + native static _WriteByte(data: KPointer, index: int64, length: int64, value: int32): void + @ani.unsafe.Direct + native static _Malloc(length: int64): KPointer + @ani.unsafe.Direct + native static _Free(data: KPointer): void + @ani.unsafe.Quick + native static _CopyArray(data: KPointer, length: int64, args: KUint8ArrayPtr): void + native static _ReportMemLeaks(): void +} + diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/arkts/InteropTypes.ts b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/arkts/InteropTypes.ts new file mode 100644 index 0000000000000000000000000000000000000000..656b34f458d02a3aeef7b3d89ab42861fec2ffb9 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/arkts/InteropTypes.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export type NodePointer = pointer // todo: move to NativeModule + +export type KStringPtr = string +export type KStringPtrArray = FixedArray +export type KUint8ArrayPtr = FixedArray +export type KInt32ArrayPtr = FixedArray +export type KFloat32ArrayPtr = FixedArray +export type KInt = int +export type KLong = long +export type KUInt = KInt +export type KBoolean = int +export type KFloat = float +export type KPointer = long // look once again +export type pointer = KPointer +export type KNativePointer = KPointer +export type KInteropReturnBuffer = FixedArray +export type KSerializerBuffer = pointer + +export const nullptr: pointer = 0 + diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/arkts/MaterializedBase.ts b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/arkts/MaterializedBase.ts new file mode 100644 index 0000000000000000000000000000000000000000..3f26a861ef8f7094a80963a25d1c9da020752c38 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/arkts/MaterializedBase.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Finalizable } from "./Finalizable" + +export interface MaterializedBase { + getPeer(): Finalizable | undefined +} + diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/arkts/NativeBuffer.ts b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/arkts/NativeBuffer.ts new file mode 100644 index 0000000000000000000000000000000000000000..655cff48a21b5ba6f83844a6c2b0b5905ee2c218 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/arkts/NativeBuffer.ts @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { pointer, KSerializerBuffer, nullptr } from './InteropTypes' +import { int32, int64 } from '@koalaui/common' +import { InteropNativeModule } from "./InteropNativeModule" +import { Disposable } from "./ResourceManager" +import { StubFastIntrinsics } from "./StubFastIntrinsics" + +// stub wrapper for KInteropBuffer +export final class NativeBuffer { + public data:pointer = 0 + public length: int64 = 0 + public resourceId: int32 = 0 + public hold:pointer = 0 + public release: pointer = 0 + + constructor(data:pointer, length: int64, resourceId: int32, hold:pointer, release: pointer) { + this.data = data + this.length = length + this.resourceId = resourceId + this.hold = hold + this.release = release + } + + public readByte(index:int64): int32 { + return StubFastIntrinsics.readInt8(this.data + index) + } + + public writeByte(index:int64, value: int32): void { + StubFastIntrinsics.writeInt8(this.data + index, value as byte) + } + + static wrap(data:pointer, length: int64, resourceId: int32, hold:pointer, release: pointer): NativeBuffer { + return new NativeBuffer(data, length, resourceId, hold, release) + } +} + +export class KBuffer implements Disposable { + private _buffer: KSerializerBuffer + private readonly _length: int64 + private readonly _owned: boolean + constructor(length: int64) { + this._buffer = InteropNativeModule._Malloc(length) + this._length = length + this._owned = true + } + constructor(buffer: KSerializerBuffer, length: int64) { + this._buffer = buffer + this._length = length + this._owned = false + } + + dispose(): void { + if (this._owned && this._buffer != nullptr) { + InteropNativeModule._Free(this._buffer) + this._buffer = nullptr + } + } + + public get buffer(): KSerializerBuffer { + return this._buffer + } + + public get length(): int64 { + return this._length + } + + public get(index: int64): byte { + return StubFastIntrinsics.readInt8(this._buffer + index) + } + public set(index: int64, value: byte): void { + StubFastIntrinsics.writeInt8(this._buffer + index, value) + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/arkts/ResourceManager.ts b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/arkts/ResourceManager.ts new file mode 100644 index 0000000000000000000000000000000000000000..85d990bd1c2972ee205ae492dc47d4c82de26330 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/arkts/ResourceManager.ts @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { int32 } from "@koalaui/common" + +export type ResourceId = int32 + +interface ResourceInfo { + resource: object + holdersCount: int32 +} + +export interface Disposable { + dispose(): void; +} + +export class ResourceHolder { + private static nextResourceId: ResourceId = 100 + private resources: Map = new Map() + private static _instance: ResourceHolder|undefined = undefined + private static disposables = new Array(); + private static disposablesSize = 0 + + static instance(): ResourceHolder { + if (ResourceHolder._instance == undefined) { + ResourceHolder._instance = new ResourceHolder() + } + return ResourceHolder._instance! + } + + public hold(resourceId: ResourceId) { + if (!this.resources.has(resourceId)) + throw new Error(`Resource ${resourceId} does not exists, can not hold`) + this.resources.get(resourceId)!.holdersCount++ + } + + public release(resourceId: ResourceId) { + if (!this.resources.has(resourceId)) + throw new Error(`Resource ${resourceId} does not exists, can not release`) + const resource = this.resources.get(resourceId)! + resource.holdersCount-- + if (resource.holdersCount <= 0) + this.resources.delete(resourceId) + } + + public registerAndHold(resource: object): ResourceId { + const resourceId = ResourceHolder.nextResourceId++ + this.resources.set(resourceId, { + resource: resource, + holdersCount: 1, + }) + return resourceId + } + + public get(resourceId: ResourceId): object { + if (!this.resources.has(resourceId)) + throw new Error(`Resource ${resourceId} does not exists`) + return this.resources.get(resourceId)!.resource + } + + public has(resourceId: ResourceId): boolean { + return this.resources.has(resourceId) + } + + static register(resource: Disposable) { + if (ResourceHolder.disposablesSize < ResourceHolder.disposables.length) { + ResourceHolder.disposables[ResourceHolder.disposablesSize] = resource + } else { + ResourceHolder.disposables.push(resource) + } + ResourceHolder.disposablesSize++ + } + + static unregister(resource: Disposable) { + const index = ResourceHolder.disposables.indexOf(resource); + if (index !== -1 && index < ResourceHolder.disposablesSize) { + if (index !== ResourceHolder.disposablesSize - 1) { + ResourceHolder.disposables[index] = ResourceHolder.disposables[ResourceHolder.disposablesSize - 1]; + } + ResourceHolder.disposablesSize--; + } + } + + static disposeAll() { + for (let i = 0; i < ResourceHolder.disposablesSize; ++i) { + ResourceHolder.disposables[i].dispose() + } + ResourceHolder.disposablesSize = 0 + } + + static compactDisposables() { + ResourceHolder.disposables = ResourceHolder.disposables.slice(0, ResourceHolder.disposablesSize); + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/arkts/SerializerBase.ts b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/arkts/SerializerBase.ts new file mode 100644 index 0000000000000000000000000000000000000000..d54bd27d2c8b52600916ce06015b9220416b68da --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/arkts/SerializerBase.ts @@ -0,0 +1,333 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { float32, float64, int8, int32, int64, uint8, int32BitsFromFloat } from "@koalaui/common" +import { pointer, nullptr, KSerializerBuffer } from "./InteropTypes" +import { ResourceId, ResourceHolder, Disposable } from "./ResourceManager" +import { NativeBuffer } from "./NativeBuffer" +import { InteropNativeModule } from "./InteropNativeModule" +import { MaterializedBase } from "./MaterializedBase" +import { StubFastIntrinsics } from "./StubFastIntrinsics" + +/** + * Value representing possible JS runtime object type. + * Must be synced with "enum RuntimeType" in C++. + */ +export class RuntimeType { + static UNEXPECTED = -1 + static NUMBER = 1 + static STRING = 2 + static OBJECT = 3 + static BOOLEAN = 4 + static UNDEFINED = 5 + static BIGINT = 6 + static FUNCTION = 7 + static SYMBOL = 8 + static MATERIALIZED = 9 +} + +/** + * Value representing object type in serialized data. + * Must be synced with "enum Tags" in C++. + */ +export class Tags { + static UNDEFINED = 101 + static INT32 = 102 + static FLOAT32 = 103 + static STRING = 104 + static LENGTH = 105 + static RESOURCE = 106 + static OBJECT = 107 +} + +export function runtimeType(value: Object|String|number|undefined|null): int32 { + let type = typeof value + if (type == "number") return RuntimeType.NUMBER + if (type == "string") return RuntimeType.STRING + if (type == "undefined") return RuntimeType.UNDEFINED + if (type == "object") return RuntimeType.OBJECT + if (type == "boolean") return RuntimeType.BOOLEAN + if (type == "bigint") return RuntimeType.BIGINT + if (type == "function") return RuntimeType.FUNCTION + if (type == "symbol") return RuntimeType.SYMBOL + + throw new Error(`bug: ${value} is ${type}`) +} + +export function registerCallback(value: object): int32 { + // TODO: fix me! + return 42 +} + +export function toPeerPtr(value: object): pointer { + if (value instanceof MaterializedBase) { + const peer = (value as MaterializedBase).getPeer() + return peer ? peer.ptr : nullptr + } else { + throw new Error("Value is not a MaterializedBase instance") + } +} + +export interface CallbackResource { + resourceId: int32 + hold: pointer + release: pointer +} + +/* Serialization extension point */ +export abstract class CustomSerializer { + protected supported: Array + constructor(supported: Array) { + this.supported = supported + } + supports(kind: string): boolean { return this.supported.includes(kind) } + abstract serialize(serializer: SerializerBase, value: object, kind: string): void + next: CustomSerializer | undefined = undefined +} + +class DateSerializer extends CustomSerializer { + constructor() { + super(Array.of("Date" as string)) + } + + serialize(serializer: SerializerBase, value: object, kind: string): void { + serializer.writeString((value as Date).toISOString()) + } +} +SerializerBase.registerCustomSerializer(new DateSerializer()) + +export class SerializerBase implements Disposable { + private position: int32 = 0 + private _buffer: KSerializerBuffer + private _length: int32 + + private static customSerializers: CustomSerializer | undefined = new DateSerializer() + static registerCustomSerializer(serializer: CustomSerializer) { + if (SerializerBase.customSerializers == undefined) { + SerializerBase.customSerializers = serializer + } else { + let current = SerializerBase.customSerializers + while (current!.next != undefined) { + current = current!.next + } + current!.next = serializer + } + } + + constructor() { + let length = 96 + this._buffer = InteropNativeModule._Malloc(length as int64) + this._length = length + } + public release() { + this.releaseResources() + this.position = 0 + } + public dispose() { + InteropNativeModule._Free(this._buffer) + this._buffer = nullptr + } + + final asBuffer(): KSerializerBuffer { + return this._buffer + } + final length(): int32 { + return this.position + } + final currentPosition(): int32 { + return this.position + } + + final getByte(offset: int32): byte { + return StubFastIntrinsics.readInt8(this._buffer + offset) + } + final toArray(): byte[] { + let result = new byte[this.currentPosition()] + for (let i = 0; i < this.currentPosition(); i++) { + result[i] = this.getByte(i) as byte + } + return result + } + private checkCapacity(value: int32) { + if (value < 1) { + throw new Error(`${value} is less than 1`) + } + let buffSize = this._length + if (this.position > buffSize - value) { + const minSize = this.position + value + const resizedSize = Math.max(minSize, Math.round(3 * buffSize / 2)) as int32 + let resizedBuffer = InteropNativeModule._Malloc(resizedSize) + let oldBuffer = this._buffer + for (let i = 0; i < this.position; i++) { + let val = StubFastIntrinsics.readInt8(oldBuffer + i); + StubFastIntrinsics.writeInt8(resizedBuffer + i, val) + } + this._buffer = resizedBuffer + this._length = resizedSize + InteropNativeModule._Free(oldBuffer) + } + } + private heldResources: Array = new Array() + private heldResourcesCount: int32 = 0 + private addHeldResource(resourceId: ResourceId) { + if (this.heldResourcesCount == this.heldResources.length) + this.heldResources.push(resourceId) + else + this.heldResources[this.heldResourcesCount] = resourceId + this.heldResourcesCount++ + } + holdAndWriteCallback(callback: object, hold: pointer = 0, release: pointer = 0, call: pointer = 0, callSync: pointer = 0): ResourceId { + const resourceId = ResourceHolder.instance().registerAndHold(callback) + this.addHeldResource(resourceId) + this.writeInt32(resourceId) + this.writePointer(hold) + this.writePointer(release) + this.writePointer(call) + this.writePointer(callSync) + return resourceId + } + holdAndWriteCallbackForPromiseVoid(hold: pointer = 0, release: pointer = 0, call: pointer = 0): [Promise, ResourceId] { + let resourceId: ResourceId = 0 + const promise = new Promise((resolve: (value: PromiseLike) => void, reject: (err: Object|null|undefined) => void) => { + const callback = (err: string[]|undefined) => { + if (err !== undefined) + reject(err!) + else + resolve(Promise.resolve()) + } + resourceId = this.holdAndWriteCallback(callback, hold, release, call) + }) + return [promise, resourceId] + } + holdAndWriteCallbackForPromise(hold: pointer = 0, release: pointer = 0, call: pointer = 0): [Promise, ResourceId] { + let resourceId: ResourceId = 0 + const promise = new Promise((resolve: (value: T|PromiseLike) => void, reject: (err: Object|null|undefined) => void) => { + const callback = (value?: T|undefined, err?: string[]|undefined) => { + if (err !== undefined) + reject(err!) + else + resolve(value!) + } + resourceId = this.holdAndWriteCallback(callback, hold, release, call) + }) + return [promise, resourceId] + } + holdAndWriteObject(obj:object, hold: pointer = 0, release: pointer = 0): ResourceId { + const resourceId = ResourceHolder.instance().registerAndHold(obj) + this.addHeldResource(resourceId) + this.writeInt32(resourceId) + this.writePointer(hold) + this.writePointer(release) + return resourceId + } + final writeCallbackResource(resource: CallbackResource) { + this.writeInt32(resource.resourceId) + this.writePointer(resource.hold) + this.writePointer(resource.release) + } + final writeResource(resource: object) { + const resourceId = ResourceHolder.instance().registerAndHold(resource) + this.addHeldResource(resourceId) + this.writeInt32(resourceId) + } + private releaseResources() { + if (this.heldResourcesCount == 0) return + for (let i = 0; i < this.heldResourcesCount; i++) { + InteropNativeModule._ReleaseCallbackResource(this.heldResources[i]) + } + this.heldResourcesCount = 0 + } + final writeCustomObject(kind: string, value: object) { + let current = SerializerBase.customSerializers + while (current) { + if (current!.supports(kind)) { + current!.serialize(this, value, kind) + return + } + current = current!.next + } + // console.log(`Unsupported custom serialization for ${kind}, write undefined`) + this.writeInt8(Tags.UNDEFINED as int32) + } + writeFunction(value: Object) { + this.writeInt32(registerCallback(value)) + } + final writeTag(tag: int32): void { + StubFastIntrinsics.writeInt8(this._buffer + this.position, tag as byte) + this.position++ + } + final writeNumber(value: number|undefined) { + this.checkCapacity(5) + if (value == undefined) { + this.writeTag(Tags.UNDEFINED) + this.position++ + return + } + if ((value as float64) == Math.round(value)) { + this.writeTag(Tags.INT32) + this.writeInt32(value as int32) + return + } else { + this.writeTag(Tags.FLOAT32) + this.writeFloat32(value as float32) + } + } + final writeInt8(value: int32) { + this.checkCapacity(1) + StubFastIntrinsics.writeInt8(this._buffer + this.position, value as byte) + this.position += 1 + } + + final writeInt32(value: int32) { + this.checkCapacity(4) + StubFastIntrinsics.writeInt32(this._buffer + this.position, value) + this.position += 4 + } + final writeInt64(value: int64) { + this.checkCapacity(8) + StubFastIntrinsics.writeInt64(this._buffer + this.position, value) + this.position += 8 + } + final writeFloat32(value: float32) { + this.checkCapacity(4) + StubFastIntrinsics.writeFloat32(this._buffer + this.position, value) + this.position += 4 + } + final writePointer(value: pointer) { + this.writeInt64(value) + } + final writeBoolean(value: boolean|undefined) { + this.checkCapacity(1) + StubFastIntrinsics.writeBoolean(this._buffer + this.position, value); + this.position++ + } + final writeString(value: string) { + let encodedCapacity = StubFastIntrinsics.getByteCapacityOfString(value); + this.checkCapacity(encodedCapacity) // length, data + let encodedLength = StubFastIntrinsics.writeString(this._buffer + this.position + 4, value) + this.writeInt32(encodedLength) + this.position += encodedLength + } + //TODO: Needs to be implemented + final writeBuffer(value: NativeBuffer) { + this.writeCallbackResource({ + resourceId: value.resourceId, + hold: value.hold, + release: value.release + }) + this.writePointer(value.data) + this.writeInt64(value.length as int64) + } +} + diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/arkts/StubFastIntrinsics.ts b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/arkts/StubFastIntrinsics.ts new file mode 100644 index 0000000000000000000000000000000000000000..f05d6badf2792e7e320991f8c55d0037304c6f43 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/arkts/StubFastIntrinsics.ts @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { int8, int32, int64, uint8, int32BitsFromFloat, float32FromBits } from "@koalaui/common" +import { KSerializerBuffer } from "./InteropTypes" +import { InteropNativeModule } from "./InteropNativeModule" + +export class StubFastIntrinsics { + + public static writeBoolean(address: long, value: boolean|undefined): void { + if (value == undefined) { + StubFastIntrinsics.writeu8(address, 0, 1, 5) // RuntimeType.UNDEFINED is 5 + } else { + StubFastIntrinsics.writeu8(address, 0, 1, (value ? 1 : 0) as int8) + } + } + + public static writeInt8(address: long, value: byte): void { + StubFastIntrinsics.writeu8(address, 0, 1 , value as int8) + } + + public static writeInt32(address: long, value: int): void { + StubFastIntrinsics.writeu32(address, 0, 4, value) + } + + public static writeInt64(address: long, value: long): void { + StubFastIntrinsics.writeu64(address, 0, 8, value) + } + + public static writeFloat32(address: long, value: float): void { + let bits = int32BitsFromFloat(value) + StubFastIntrinsics.writeu32(address, 0, 4, bits) + } + + public static getByteCapacityOfString(value: string): int32 { + return value.length as int32 * 4 + 1 + 4 + } + + public static writeString(address: long, value: string): int { + return StubFastIntrinsics.writeString(address, 0, value); + } + + public static readBoolean(address: long): boolean|undefined { + const value = StubFastIntrinsics.readu8(address, 0, 1) + return value === 1 + } + + public static readInt8(address: long): byte { + return StubFastIntrinsics.readu8(address, 0, 1) as byte; + } + + public static readInt32(address: long): int { + return StubFastIntrinsics.readu32(address, 0, 4) + } + + public static readInt64(address: long): long { + return StubFastIntrinsics.readu64(address, 0, 8) + } + + public static readFloat32(address: long): float { + let result = StubFastIntrinsics.readu32(address, 0, 4) + return float32FromBits(result) + } + + public static readString(address: long, byteSize: int): String { + return StubFastIntrinsics.readString(address, 0, byteSize) + } + + // TODO: get rid of length. + private static writeu8(buffer: KSerializerBuffer, offset: int32, length: int32, value: int32) { + InteropNativeModule._WriteByte(buffer, offset as int64, length as int64, value as uint8) + } + + private static writeu32(buffer: KSerializerBuffer, offset: int32, length: int32, value: int32) { + InteropNativeModule._WriteByte(buffer, offset, length as int64, (value & 0xff) as uint8) + InteropNativeModule._WriteByte(buffer, offset + 1, length as int64, ((value >> 8) & 0xff) as uint8) + InteropNativeModule._WriteByte(buffer, offset + 2, length as int64, ((value >> 16) & 0xff) as uint8) + InteropNativeModule._WriteByte(buffer, offset + 3, length as int64, ((value >> 24) & 0xff) as uint8) + } + + private static writeu64(buffer: KSerializerBuffer, offset: int32, length: int32, value: int64) { + StubFastIntrinsics.writeu8(buffer, offset + 0, length, ((value ) & 0xff) as int8) + StubFastIntrinsics.writeu8(buffer, offset + 1, length, ((value >> 8) & 0xff) as int8) + StubFastIntrinsics.writeu8(buffer, offset + 2, length, ((value >> 16) & 0xff) as int8) + StubFastIntrinsics.writeu8(buffer, offset + 3, length, ((value >> 24) & 0xff) as int8) + StubFastIntrinsics.writeu8(buffer, offset + 4, length, ((value >> 32) & 0xff) as int8) + StubFastIntrinsics.writeu8(buffer, offset + 5, length, ((value >> 40) & 0xff) as int8) + StubFastIntrinsics.writeu8(buffer, offset + 6, length, ((value >> 48) & 0xff) as int8) + StubFastIntrinsics.writeu8(buffer, offset + 7, length, ((value >> 56) & 0xff) as int8) + } + + private static writeString(buffer: KSerializerBuffer, offset: int32, value: string) { + let encodedLength = InteropNativeModule._ManagedStringWrite(value, buffer, offset) + return encodedLength; + } + + // TODO: get rid of length. + private static readu8(buffer: KSerializerBuffer, offset: int32, length: int32): int32 { + let byteValue: byte = InteropNativeModule._ReadByte(buffer, offset as int64, length as int64) as byte + byteValue &= 0xff + return byteValue + } + + private static readu32(buffer: KSerializerBuffer, offset: int32, length: int32): int32 { + let result: int32 = 0; + for (let i = 0; i < 4; i++) { + let byteValue = StubFastIntrinsics.readu8(buffer, offset + i, length) as int32 + byteValue &= 0xff + result = (result | byteValue << (8 * i)) as int32 + } + + return result; + } + + private static readu64(buffer: KSerializerBuffer, offset: int32, length: int32): int64 { + let result: int64 = 0; + for (let i = 0; i < 8; i++) { + let byteValue = StubFastIntrinsics.readu8(buffer, offset + i, length) as int64; + byteValue &= 0xff + result = (result | byteValue << (8 * i)) as int64; + } + return result; + } + + private static readString(buffer: KSerializerBuffer, offset: int32, length: int32):string { + return InteropNativeModule._Utf8ToString(buffer, offset, length) + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/arkts/callback.ts b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/arkts/callback.ts new file mode 100644 index 0000000000000000000000000000000000000000..ea7eac29623f62bb59f08f4694c42c226e8d0aec --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/arkts/callback.ts @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { KUint8ArrayPtr, KSerializerBuffer } from "./InteropTypes" +import { int32 } from "@koalaui/common" + +export type CallbackType = (args: KSerializerBuffer, length: int32) => int32 + +class CallbackRecord { + public readonly callback: CallbackType + public readonly autoDisposable: boolean + + constructor( + callback: CallbackType, + autoDisposable: boolean + ) { + this.callback = callback + this.autoDisposable = autoDisposable + } +} + +class CallbackRegistry { + + static INSTANCE = new CallbackRegistry() + + private callbacks = new Map() + private id = 1024 + + constructor() { + this.callbacks.set(0, new CallbackRecord( + (args: KSerializerBuffer, length: int32): int32 => { + console.log(`Callback 0 called with args = ${args} and length = ${length}`) + throw new Error(`Null callback called`) + }, false) + ) + } + + wrap(callback: CallbackType, autoDisposable: boolean): int32 { + const id = this.id++ + this.callbacks.set(id, new CallbackRecord(callback, autoDisposable)) + return id + } + + wrapSystem(id: int32, callback: CallbackType, autoDisposable: boolean): int32 { + this.callbacks.set(id, new CallbackRecord(callback, autoDisposable)) + return id + } + + call(id: int32, args: KSerializerBuffer, length: int32): int32 { + const record = this.callbacks.get(id) + if (!record) { + console.log(`Callback ${id} is not known`) + throw new Error(`Disposed or unwrapped callback called (id = ${id})`) + } + if (record.autoDisposable) { + this.dispose(id) + } + return record.callback(args, length) + } + + dispose(id: int32) { + this.callbacks.delete(id) + } +} + +export function wrapCallback(callback: CallbackType, autoDisposable: boolean = true): int32 { + return CallbackRegistry.INSTANCE.wrap(callback, autoDisposable) +} + +export function wrapSystemCallback(id:int32, callback: CallbackType): int32 { + return CallbackRegistry.INSTANCE.wrapSystem(id, callback, false) +} + +export function disposeCallback(id: int32) { + CallbackRegistry.INSTANCE.dispose(id) +} + +export function callCallback(id: int32, args: KSerializerBuffer, length: int32): int32 { + return CallbackRegistry.INSTANCE.call(id, args, length) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/arkts/index.ts b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/arkts/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..b31a7b7ac6a24043d89765db0c0d9e756607b931 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/arkts/index.ts @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export * from "./InteropTypes" +export * from "./callback" +export * from "./ResourceManager" +export * from "./NativeBuffer" +export * from "./InteropNativeModule" +export * from "./SerializerBase" +export * from "./DeserializerBase" +export * from "./Finalizable" +export * from "./loadLibraries" +export * from "./MaterializedBase" diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/arkts/loadLibraries.ts b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/arkts/loadLibraries.ts new file mode 100644 index 0000000000000000000000000000000000000000..33238bc6081563e109dff188d7704e120267f393 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/arkts/loadLibraries.ts @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const nativeModuleLibraries: Map = new Map() + +export function loadNativeLibrary(library: string) { + loadLibrary(library) +} + +export function registerNativeModuleLibraryName(nativeModule: string, libraryName: string) { + nativeModuleLibraries.set(nativeModule, libraryName) +} + +export function loadNativeModuleLibrary(nativeModule: string) { + loadLibrary(nativeModuleLibraries.get(nativeModule) ?? nativeModule) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cangjie/DeserializerBase.cj b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cangjie/DeserializerBase.cj new file mode 100644 index 0000000000000000000000000000000000000000..0f609f2cd61560f91b338cdbd2be0a8638fb3d48 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cangjie/DeserializerBase.cj @@ -0,0 +1,154 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package Interop + +import std.binary.* +import std.collection.* + +public class CallbackResource { + public var resourceId: Int32 + public var hold: pointer + public var release: pointer + init(resourceId: Int32, hold: pointer, release: pointer) { + this.resourceId = resourceId + this.hold = hold + this.release = release + } +} + +public open class DeserializerBase { + private var position: Int32 = 0 + public var length: Int32 = 96 // make private + public var buffer: pointer // make private + + public init(buffer: UInt64, length: Int32) { + this.buffer = buffer + this.length = length + } + public init(buffer: Array, length: Int32) { + this.buffer = InteropNativeModule._Malloc(length) + for (i in 0..length) { + DeserializerBase.writeu8(this.buffer, i, length, buffer[Int64(i)]) + } + this.length = length + } + + private static func writeu8(buffer: pointer, offset: Int32, length: Int32, value: UInt8): Unit { + InteropNativeModule._WriteByte(buffer, Int64(offset), Int64(length), Int32(value)) + } + private static func readu8(buffer: pointer, offset: Int32, length: Int32): Int32 { + return InteropNativeModule._ReadByte(buffer, Int64(offset), Int64(length)) + } + + public func asBuffer(): pointer { + return this.buffer + } + + public func currentPosition(): Int32 { + return this.position + } + + public func resetCurrentPosition(): Unit { + this.position = 0 + } + + private func checkCapacity(value: Int32) { + if (value > this.length) { + throw Exception("${value} is less than remaining buffer length") + } + } + + public func readInt8(): Int8 { + this.checkCapacity(1) + var res = DeserializerBase.readu8(this.buffer, this.position, this.length) + this.position += 1 + return Int8(res) + } + + public func readInt32(): Int32 { + this.checkCapacity(4) + let arr = Array(4, {i => UInt8(DeserializerBase.readu8(this.buffer, this.position + Int32(i), this.length))}) + this.position += 4 + return Int32.readLittleEndian(arr) + } + + public func readInt64(): Int64 { + this.checkCapacity(8) + let arr = Array(8, {i => UInt8(DeserializerBase.readu8(this.buffer, this.position + Int32(i), this.length))}) + this.position += 8 + return Int64.readLittleEndian(arr) + } + + public func readPointer(): KPointer { + this.checkCapacity(8) + let arr = Array(8, {i => UInt8(DeserializerBase.readu8(this.buffer, this.position + Int32(i), this.length))}) + this.position += 8 + return UInt64.readLittleEndian(arr) + } + + public func readFloat32(): Float32 { + this.checkCapacity(4) + let arr = Array(4, {i => UInt8(DeserializerBase.readu8(this.buffer, this.position + Int32(i), this.length))}) + this.position += 4 + return Float32.readLittleEndian(arr) + } + public func readFloat64(): Float64 { + this.checkCapacity(8) + let arr = Array(8, {i => UInt8(DeserializerBase.readu8(this.buffer, this.position + Int32(i), this.length))}) + this.position += 8 + return Float64.readLittleEndian(arr) + } + + public func readBoolean(): Bool { + var byteVal = DeserializerBase.readu8(this.buffer, this.position, this.length) + this.position += 1 + return byteVal == 1 + } + + public func readString(): String { + let length = this.readInt32() + this.checkCapacity(length) + // read without null-terminated byte + let value = InteropNativeModule._Utf8ToString(this.buffer, Int32(this.position), Int32(length)) + this.position += length + return value + } + + public func readCustomObject(kind: String): Object { + throw Exception("readCustomObject") + } + + public func readObject(): Any { + let resource = this.readCallbackResource() + return ResourceHolder.instance().get(resource.resourceId) + } + + public func readNumber(): Float64 { + let tag = this.readInt8() + if (tag == Tag.UNDEFINED.value) { + throw Exception("Read number can't return undefined.") + } else if (tag == Tag.INT32.value) { + return Float64(this.readInt32()) + } else if (tag == Tag.FLOAT32.value) { + return Float64(this.readFloat32()) + } else { + throw Exception("Unknown number tag: ${tag}") + } + } + + public func readCallbackResource(): CallbackResource { + return CallbackResource(this.readInt32(), this.readPointer(), this.readPointer()) + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cangjie/InteropNativeModule.cj b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cangjie/InteropNativeModule.cj new file mode 100644 index 0000000000000000000000000000000000000000..bc7fce8156a0e4f0737e53619b7548500c0fdb3d --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cangjie/InteropNativeModule.cj @@ -0,0 +1,260 @@ +/* + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package Interop + +import std.collection.* + +foreign { + func Malloc(length: Int32): UInt64 + func Free(data: KPointer): Unit + func ReadByte(data: KPointer, index: Int64, length: Int64): Int32 + func WriteByte(data: KPointer, index: Int64, length: Int64, value: Int32): Unit + func ReleaseCallbackResource(resourceId: Int32): Unit + + func GetGroupedLog(index: Int32): UInt64 + func StartGroupedLog(index: Int32): Unit + func StopGroupedLog(index: Int32): Unit + func AppendGroupedLog(index: Int32, message: CString): Unit + func PrintGroupedLog(index: Int32): Unit + func GetStringFinalizer(): UInt64 + func InvokeFinalizer(ptr1: UInt64, ptr2: UInt64): Unit + func GetPtrVectorElement(ptr1: UInt64, arg: Int32): UInt64 + func StringLength(ptr1: UInt64): Int32 + func StringData(ptr1: UInt64, arr: CPointer, i: Int32): Unit + func StringMake(str1: CString): UInt64 + func GetPtrVectorSize(ptr1: UInt64): Int32 + func ManagedStringWrite(str1: CString, arr: pointer, arg: Int32): Int32 + func NativeLog(str1: CString): Unit + func Utf8ToString(data: pointer, offset: Int32, length: Int32): CString + func CheckCallbackEvent(buffer: KSerializerBuffer, bufferLength: Int32): Int32 + func StdStringToString(cstring: UInt64): CString + func IncrementNumber(input: Float64): Float64 + func CallCallback(callbackKind: Int32, args: KSerializerBuffer, argsSize: Int32): Unit + func CallCallbackSync(callbackKind: Int32, args: KSerializerBuffer, argsSize: Int32): Unit + func CallCallbackResourceHolder(holder: UInt64, resourceId: Int32): Unit + func CallCallbackResourceReleaser(releaser: UInt64, resourceId: Int32): Unit + func CallForeignVM(foreignContext: UInt64, kind: Int32, data: CPointer, length: Int32): Int32 + func LoadVirtualMachine(arg0: Int32, arg1: CString, arg2: CString): Int32 + func RunApplication(arg0: Int32, arg1: Int32): Bool + func StartApplication(appUrl: CString, appParams: CString): UInt64 + func EmitEvent(eventType: Int32, target: Int32, arg0: Int32, arg1: Int32): CString + func RestartWith(page: CString): Unit +} + +public open class InteropNativeModule { + public static func _Malloc(length: Int32) { + unsafe { + return Malloc(length) + } + } + public static func _Free(data: KPointer): Unit { + unsafe { + Free(data) + } + } + public static func _ReadByte(data: KPointer, index: Int64, length: Int64): Int32 { + unsafe { + return ReadByte(data, index, length) + } + } + public static func _WriteByte(data: KPointer, index: Int64, length: Int64, value: Int32) { + unsafe { + WriteByte(data, index, length, value) + } + } + public static func _ReleaseCallbackResource(resourceId: Int32): Unit { + unsafe { + ReleaseCallbackResource(resourceId) + } + } + public static func _GetGroupedLog(index: Int32): UInt64 { + unsafe { + let result = GetGroupedLog(index) + return result + } + } + public static func _StartGroupedLog(index: Int32): Unit { + unsafe { + StartGroupedLog(index) + } + } + public static func _StopGroupedLog(index: Int32): Unit { + unsafe { + StopGroupedLog(index) + } + } + public static func _AppendGroupedLog(index: Int32, message: String): Unit { + unsafe { + let message = LibC.mallocCString(message) + AppendGroupedLog(index, message) + LibC.free(message) + } + } + public static func _PrintGroupedLog(index: Int32): Unit { + unsafe { + PrintGroupedLog(index) + } + } + public static func _GetStringFinalizer(): UInt64 { + unsafe { + let result = GetStringFinalizer() + return result + } + } + public static func _InvokeFinalizer(ptr1: UInt64, ptr2: UInt64): Unit { + unsafe { + InvokeFinalizer(ptr1, ptr2) + } + } + public static func _GetPtrVectorElement(ptr1: UInt64, arg: Int32): UInt64 { + unsafe { + let result = GetPtrVectorElement(ptr1, arg) + return result + } + } + public static func _StringLength(ptr1: UInt64): Int32 { + unsafe { + let result = StringLength(ptr1) + return result + } + } + public static func _StringData(ptr1: UInt64, arr: Array, i: Int32): Unit { + unsafe { + let handle_1 = acquireArrayRawData(arr) + StringData(ptr1, handle_1.pointer, i) + releaseArrayRawData(handle_1) + } + } + public static func _StringMake(str1: String): UInt64 { + unsafe { + let str1 = LibC.mallocCString(str1) + let result = StringMake(str1) + LibC.free(str1) + return result + } + } + public static func _GetPtrVectorSize(ptr1: UInt64): Int32 { + unsafe { + let result = GetPtrVectorSize(ptr1) + return result + } + } + public static func _ManagedStringWrite(str1: String, arr: pointer, arg: Int32): Int32 { + unsafe { + let str1 = LibC.mallocCString(str1) + let result = ManagedStringWrite(str1, arr, arg) + LibC.free(str1) + return result + } + } + public static func _NativeLog(str1: String): Unit { + unsafe { + let str1 = LibC.mallocCString(str1) + NativeLog(str1) + LibC.free(str1) + } + } + public static func _Utf8ToString(data: pointer, offset: Int32, length: Int32): String { + unsafe { + let result = Utf8ToString(data, offset, length) + return result.toString() + } + } + public static func _CheckCallbackEvent(buffer: KSerializerBuffer, bufferLength: Int32): Int32 { + unsafe { + return CheckCallbackEvent(buffer, bufferLength) + } + } + public static func _StdStringToString(cstring: UInt64): String { + unsafe { + let result = StdStringToString(cstring) + return result.toString() + } + } + public static func _IncrementNumber(input: Float64): Float64 { + unsafe { + let result = IncrementNumber(input) + return result + } + } + public static func _CallCallback(callbackKind: Int32, args: KSerializerBuffer, argsSize: Int32): Unit { + unsafe { + CallCallback(callbackKind, args, argsSize) + } + } + public static func _CallCallbackSync(callbackKind: Int32, args: KSerializerBuffer, argsSize: Int32): Unit { + unsafe { + CallCallbackSync(callbackKind, args, argsSize) + } + } + public static func _CallCallbackResourceHolder(holder: UInt64, resourceId: Int32): Unit { + unsafe { + CallCallbackResourceHolder(holder, resourceId) + } + } + public static func _CallCallbackResourceReleaser(releaser: UInt64, resourceId: Int32): Unit { + unsafe { + CallCallbackResourceReleaser(releaser, resourceId) + } + } + public static func _CallForeignVM(foreignContext: UInt64, kind: Int32, data: ArrayList, length: Int32): Int32 { + unsafe { + let handle_2 = acquireArrayRawData(data.toArray()) + let result = CallForeignVM(foreignContext, kind, handle_2.pointer, length) + releaseArrayRawData(handle_2) + return result + } + } + public static func _LoadVirtualMachine(arg0: Int32, arg1: String, arg2: String): Int32 { + unsafe { + let arg1 = LibC.mallocCString(arg1) + let arg2 = LibC.mallocCString(arg2) + let result = LoadVirtualMachine(arg0, arg1, arg2) + LibC.free(arg1) + LibC.free(arg2) + return result + } + } + public static func _RunApplication(arg0: Int32, arg1: Int32): Bool { + unsafe { + let result = RunApplication(arg0, arg1) + return result + } + } + public static func _StartApplication(appUrl: String, appParams: String): UInt64 { + unsafe { + let appUrl = LibC.mallocCString(appUrl) + let appParams = LibC.mallocCString(appParams) + let result = StartApplication(appUrl, appParams) + LibC.free(appUrl) + LibC.free(appParams) + return result + } + } + public static func _EmitEvent(eventType: Int32, target: Int32, arg0: Int32, arg1: Int32): String { + unsafe { + let result = EmitEvent(eventType, target, arg0, arg1) + return result.toString() + } + } + public static func _RestartWith(page: String): Unit { + unsafe { + let page = LibC.mallocCString(page) + RestartWith(page) + LibC.free(page) + } + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cangjie/InteropTypes.cj b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cangjie/InteropTypes.cj new file mode 100644 index 0000000000000000000000000000000000000000..ddda5415ddc68fa8788fa05360058f0c1de15207 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cangjie/InteropTypes.cj @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package Interop + +import std.collection.* + +public type KPointer = UInt64 +public type KFloat = Float32 +public type pointer = KPointer +public type KInt = Int32 +public type KLong = Int64 +public type KStringPtr = String +public type ArrayBuffer = ArrayList +public type KSerializerBuffer = pointer +public const nullptr: UInt64 = 0 +@C +public struct KInteropReturnBuffer { + public var length: Int32 + public var data: CPointer + public var dispose: CPointer, Int32) -> Unit>> + init (length: Int32, data: CPointer, dispose: CPointer, Int32) -> Unit>>) { + this.length = length + this.data = data + this.dispose = dispose + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cangjie/MaterializedBase.cj b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cangjie/MaterializedBase.cj new file mode 100644 index 0000000000000000000000000000000000000000..362de947c7ac506d35fc45ec7348be4991bcf927 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cangjie/MaterializedBase.cj @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package Interop + +public open class Finalizable { + public var ptr: KPointer + public var finalizer: KPointer + + public Finalizable(ptr: KPointer, finalizer: KPointer) { + this.ptr = ptr + this.finalizer = finalizer + } +} + +public interface MaterializedBase { + public func getPeer(): ?Finalizable + + public static func toPeerPtr(value: Any): KPointer + { + let base: MaterializedBase = match (value as MaterializedBase) { + case Some(x) => x + case None => throw Exception("Value is not a MaterializedBase instance!") + } + return match (base.getPeer()) { + case Some(peer) => peer.ptr + case None => nullptr + } + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cangjie/ResourceManager.cj b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cangjie/ResourceManager.cj new file mode 100644 index 0000000000000000000000000000000000000000..d2e589d5f6058a8dd469da300134321754f4aba0 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cangjie/ResourceManager.cj @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package Interop + +import std.binary.* +import std.math.* +import std.collection.* + +public type ResourceId = Int32 + +class ResourceInfo { + public var resource: Any + public var holdersCount: Int32 + init(resource: Any, holdersCount: Int32 ) { + this.resource = resource + this.holdersCount = holdersCount + } +} + +public class ResourceHolder { + private static var nextResourceId: ResourceId = 100 + private var resources: HashMap = HashMap() + private static var _instance: ?ResourceHolder = Option.None + public static func instance(): ResourceHolder { + ResourceHolder._instance = match (ResourceHolder._instance) { + case Some(resourceHolder) => resourceHolder + case _ => ResourceHolder() + } + if (let Some(rh) <- ResourceHolder._instance) { + return rh + } else { + throw Exception() + } + } + public func hold(resourceId: ResourceId) { + match(this.resources.get(resourceId)) { + case Some(resource) => resource.holdersCount++ + case _ => throw Exception("Resource ${resourceId} does not exists, can not hold") + } + } + + public func release(resourceId: ResourceId) { + let resource = match (this.resources.get(resourceId)) { + case Some(resource) => resource + case _ => throw Exception("Resource ${resourceId} does not exists, can not hold") + } + resource.holdersCount-- + if (resource.holdersCount <= 0) { + this.resources.remove(resourceId) + } + } + + public func registerAndHold(resource: Any): ResourceId { + ResourceHolder.nextResourceId += 1 + let resourceId = ResourceHolder.nextResourceId + this.resources.add(resourceId, ResourceInfo(resource, resourceId)) + return resourceId + } + + public func get(resourceId: ResourceId): Any { + match(this.resources.get(resourceId)) { + case Some(resource) => return resource.resource + case _ => throw Exception("Resource ${resourceId} does not exists") + } + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cangjie/SerializerBase.cj b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cangjie/SerializerBase.cj new file mode 100644 index 0000000000000000000000000000000000000000..0081f7986ca6c9d2a82462c0035103804cfccd8f --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cangjie/SerializerBase.cj @@ -0,0 +1,355 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package Interop + +import std.binary.* +import std.math.* +import std.collection.* + +public enum RuntimeType { + |UNEXPECTED + |NUMBER + |STRING + |OBJECT + |BOOLEAN + |UNDEFINED + |BIGINT + |FUNCTION + |SYMBOL + |MATERIALIZED + public prop ordinal: Int32 { + get() { + match (this) { + case UNEXPECTED => -1 + case NUMBER => 1 + case STRING => 2 + case OBJECT => 3 + case BOOLEAN => 4 + case UNDEFINED => 5 + case BIGINT => 6 + case FUNCTION => 7 + case SYMBOL => 8 + case MATERIALIZED => 9 + } + } + } +} + +public class PromiseAndResourceId { + public var promise: Any + public var resourceId: ResourceId + init (promise: Any, resourceId: ResourceId) { + this.promise = promise + this.resourceId = resourceId + } +} + + +/* Serialization extension point */ +public abstract class CustomSerializer { + public var supported: Array + init(supported: Array) { + this.supported = supported + } + public func supports(kind: String): Bool { return this.supported.contains(kind) } + public func serialize(serializer: SerializerBase, value: Object, kind: String): Unit {} + var next: ?CustomSerializer = Option.None +} + +public open class SerializerBase { + private var position: Int32 = 0 + private var _buffer: pointer + private var _length: Int32 + + private static var customSerializers: ?CustomSerializer = Option.None + static func registerCustomSerializer(serializer: CustomSerializer) { + //TODO + } + + public init() { + let length: Int32 = 96 + this._buffer = InteropNativeModule._Malloc(length) + this._length = length + } + + private static func writeu8(_buffer: pointer, offset: Int32, length: Int32, value: Int32): Unit { + InteropNativeModule._WriteByte(_buffer, Int64(offset), Int64(length), value) + } + private static func readu8(_buffer: pointer, offset: Int32, length: Int32): Int32 { + return InteropNativeModule._ReadByte(_buffer, Int64(offset), Int64(length)) + } + + public open func release() { + this.releaseResources() + this.position = 0 + } + private func releaseResources() { + if (this.heldResourcesCount == 0) { + return + } + for (i in 0..this.heldResourcesCount) { + InteropNativeModule._ReleaseCallbackResource(this.heldResources[i]) + } + this.heldResourcesCount = 0 + } + public func asBuffer(): KSerializerBuffer { + this._buffer + } + public func length(): Int32 { + return Int32(this.position) + } + public func currentPosition(): Int32 { return this.position } + private func checkCapacity(value: Int32) { + if (value < 1) { + throw Exception("${value} is less than 1") + } + var buffSize = this._length + if (this.position > buffSize - value) { + let minSize: Int32 = this.position + value + let resizedSize: Int32 = max(minSize, Int32(round(1.5 * Float64(buffSize)))) + let resizedBuffer = InteropNativeModule._Malloc(resizedSize) + let oldBuffer = this._buffer + for (i in 0..this.position) { + SerializerBase.writeu8(resizedBuffer, Int32(i), resizedSize, SerializerBase.readu8(oldBuffer, i, this.position)) + } + this._buffer = resizedBuffer + this._length = resizedSize + InteropNativeModule._Free(oldBuffer) + } + } + public func writeCustomObject(kind: String, value: Any): Unit { + var current = SerializerBase.customSerializers + // TODO + println("Unsupported custom serialization for ${kind}, write undefined") + this.writeInt8(Tag.UNDEFINED.value) + } + + private var heldResources: ArrayList = ArrayList() + private var heldResourcesCount: Int64 = 0 + private func addHeldResource(resourceId: ResourceId) { + if (this.heldResourcesCount == this.heldResources.size) { + this.heldResources.add(resourceId) + } + else { + this.heldResources[this.heldResourcesCount] = resourceId + } + this.heldResourcesCount += 1 + } + + public func holdAndWriteCallback(callback: Any): ResourceId { + let resourceId = ResourceHolder.instance().registerAndHold(callback) + this.heldResources.add(resourceId) + this.writeInt32(resourceId) + this.writePointer(0) + this.writePointer(0) + this.writePointer(0) + this.writePointer(0) + return resourceId + } + public func holdAndWriteCallback(callback: Any, hold: KPointer, release: KPointer, call: KPointer, callSync: KPointer): ResourceId { + let resourceId = ResourceHolder.instance().registerAndHold(callback) + this.heldResources.add(resourceId) + this.writeInt32(resourceId) + this.writePointer(hold) + this.writePointer(release) + this.writePointer(call) + this.writePointer(callSync) + return resourceId + } + public func holdAndWriteCallbackForPromiseVoid(): PromiseAndResourceId { + return holdAndWriteCallbackForPromiseVoid(0, 0, 0, 0) + } + public func holdAndWriteCallbackForPromiseVoid(hold: KPointer, release: KPointer, call: KPointer, callSync: KPointer): PromiseAndResourceId { + var resourceId: ResourceId = 0 + let promise = { => } + return PromiseAndResourceId(promise, resourceId) + } + public func holdAndWriteCallbackForPromise(): PromiseAndResourceId { + return holdAndWriteCallbackForPromise(0, 0, 0) + } + public func holdAndWriteCallbackForPromise(hold: KPointer, release: KPointer, call: KPointer): PromiseAndResourceId { + var resourceId: ResourceId = 0 + let promise = { => } + return PromiseAndResourceId(promise, resourceId) + } + public func writeFunction(value: Any): Unit { + // TODO + } + public func writeTag(tag: Int32): Unit { + this.checkCapacity(1) + SerializerBase.writeu8(this._buffer, this.position, this._length, tag) + this.position++ + } + public func writeTag(tag: Int8): Unit { + this.checkCapacity(1) + SerializerBase.writeu8(this._buffer, this.position, this._length, Int32(tag)) + this.position++ + } + public func writeNumber(value: ?Float32): Unit { + if (let Some(value) <- value) { + if(value == Float32(Int32(value))) { + this.writeNumber(Int32(value)) + } else { + this.writeTag(Tag.FLOAT32.value) + this.writeInt32(Int64(value.toBits())) + } + } + else { + this.writeTag(Tag.UNDEFINED.value) + } + } + public func writeNumber(value: ?Float64): Unit { + if (let Some(value) <- value) { + if(value == Float64(Int32(value))) { + this.writeNumber(Int32(value)) + } else { + this.writeTag(Tag.FLOAT32.value) + this.writeInt32(Int64(Float32(value).toBits())) + } + } + else { + this.writeTag(Tag.UNDEFINED.value) + } + } + public func writeNumber(value: ?Int32): Unit { + if (let Some(value) <- value) { + this.writeTag(Tag.INT32.value) + this.writeInt32(Int32(value)) + } + else { + this.writeTag(Tag.UNDEFINED.value) + } + } + public func writeNumber(value: ?Int64): Unit { + this.checkCapacity(5) + if (let Some(value) <- value) { + this.writeTag(Tag.INT32.value) + this.writeInt32(Int32(value)) + } + else { + this.writeTag(Tag.UNDEFINED.value) + } + } + public func writeInt8(value: Int8): Unit { + this.checkCapacity(1) + SerializerBase.writeu8(this._buffer, this.position, this._length, Int32(value)) + this.position += 1 + } + public func writeInt8(value: Int32): Unit { + this.checkCapacity(1) + SerializerBase.writeu8(this._buffer, this.position, this._length, Int32(value)) + this.position += 1 + } + public func writeInt32(value: Int32): Unit { + this.checkCapacity(4) + let arr = Array(4, repeat: 0) + value.writeLittleEndian(arr) + for (idx in 0..4) { + SerializerBase.writeu8(this._buffer, this.position + Int32(idx), this._length, Int32(arr[idx])) + } + this.position += 4 + } + public func writeInt32(value: Int64): Unit { + this.checkCapacity(4) + let arr = Array(4, repeat: 0) + Int32(value).writeLittleEndian(arr) + for (idx in 0..4) { + SerializerBase.writeu8(this._buffer, this.position + Int32(idx), this._length, Int32(arr[idx])) + } + this.position += 4 + } + public func writeInt64(value: Int64): Unit { + this.checkCapacity(8) + let arr = Array(8, repeat: 0) + value.writeLittleEndian(arr) + for (idx in 0..8) { + SerializerBase.writeu8(this._buffer, this.position + Int32(idx), this._length, Int32(arr[idx])) + } + this.position += 8 + } + public func writeFloat32(value: Float32): Unit { + this.checkCapacity(4) + this.position += 4 + } + public func writePointer(ptr: UInt64): Unit { + this.checkCapacity(8) + let arr = Array(8, repeat: 0) + ptr.writeLittleEndian(arr) + for (idx in 0..8) { + SerializerBase.writeu8(this._buffer, this.position + Int32(idx), this._length, Int32(arr[idx])) + } + this.position += 8 + } + public func writeBoolean(value: ?Bool): Unit { + this.checkCapacity(1) + if(let Some(value) <- value) { + SerializerBase.writeu8(this._buffer, this.position, this._length, if (value) {1} else {0}) + } + else { + SerializerBase.writeu8(this._buffer, this.position, this._length, RuntimeType.UNDEFINED.ordinal) + } + this.position++ + } + public func writeMaterialized(value: Object): Unit { + // TODO + } + public func writeCallbackResource(resource: CallbackResource) { + this.writeInt32(resource.resourceId) + this.writePointer(resource.hold) + this.writePointer(resource.release) + } + public func writeString(value: String): Unit { + this.checkCapacity(Int32(4 + value.size * 4 + 1)) // length, data + let encodedLength = InteropNativeModule._ManagedStringWrite(value, this.asBuffer(), this.position + 4) + this.writeInt32(encodedLength) + this.position += encodedLength + } + public func writeBuffer(_buffer: Array) { + // let resourceId = ResourceHolder.instance().registerAndHold(_buffer) + // this.writeCallbackResource(CallbackResource(resourceId, 0, 0)) + // unsafe { + // let ptr = acquireArrayRawData(_buffer).pointer + // this.writePointer(UInt64(ptr.toUIntNative())) + // this.writeInt64(_buffer.size) + // } + } + public func holdAndWriteObject(obj: Any): ResourceId { + return this.holdAndWriteObject(obj, 0, 0) + } + public func holdAndWriteObject(obj: Any, hold: pointer, release: pointer): ResourceId { + let resourceId = ResourceHolder.instance().registerAndHold(obj) + this.addHeldResource(resourceId) + this.writeInt32(resourceId) + this.writePointer(hold) + this.writePointer(release) + return resourceId + } +} + +public open class DateCustomSerializer <: CustomSerializer { + public DateCustomSerializer() { + super(["Date"]) + } + public func serialize(serializer: SerializerBase, value: Ark_CustomObject, kind: String): Unit { + serializer.writeString("{}") + } +} + +public open class Ark_CustomObject { + init() { + SerializerBase.registerCustomSerializer(DateCustomSerializer()) + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cangjie/Tag.cj b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cangjie/Tag.cj new file mode 100644 index 0000000000000000000000000000000000000000..8c5cc317f9721d5cad36b5cae262e759eb1eac4c --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cangjie/Tag.cj @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package Interop + +public open class Tag { + public static var UNDEFINED: Tag = Tag(101) + public static var INT32: Tag = Tag(102) + public static var FLOAT32: Tag = Tag(103) + public static var STRING: Tag = Tag(104) + public static var LENGTH: Tag = Tag(105) + public static var RESOURCE: Tag = Tag(106) + public static var OBJECT: Tag = Tag(107) + public var value: Int8 + Tag (arg0: Int8) { + value = arg0 + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cangjie/cjpm.toml b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cangjie/cjpm.toml new file mode 100644 index 0000000000000000000000000000000000000000..e909dcd4044f51bf4ace340c7d5c559679d12d31 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cangjie/cjpm.toml @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +[dependencies] +[package] + cjc-version = "0.56.4" + compile-option = "" + description = "config file for cj build" + link-option = "" + name = "Interop" + output-type = "static" + src-dir = "." + target-dir = "./build/cj" + version = "1.0.0" + package-configuration = {} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/DeserializerBase.h b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/DeserializerBase.h new file mode 100644 index 0000000000000000000000000000000000000000..68965f3fc6880ec0b9add554478e6a7759fa98e6 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/DeserializerBase.h @@ -0,0 +1,678 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef _DESERIALIZER_BASE_H_ +#define _DESERIALIZER_BASE_H_ + +#include +#include +#include +#include +#include +#include + +#include "interop-types.h" +#include "interop-logging.h" +#include "koala-types.h" + +void holdManagedCallbackResource(InteropInt32); +void releaseManagedCallbackResource(InteropInt32); + +#ifdef __arm__ +#define KOALA_NO_UNALIGNED_ACCESS 1 +#endif + +inline const char *tagName(InteropTag tag) +{ + switch (tag) + { + case InteropTag::INTEROP_TAG_UNDEFINED: + return "UNDEFINED"; + case InteropTag::INTEROP_TAG_INT32: + return "INT32"; + case InteropTag::INTEROP_TAG_FLOAT32: + return "FLOAT32"; + case InteropTag::INTEROP_TAG_LENGTH: + return "LENGTH"; + case InteropTag::INTEROP_TAG_RESOURCE: + return "RESOURCE"; + case InteropTag::INTEROP_TAG_STRING: + return "STRING"; + case InteropTag::INTEROP_TAG_OBJECT: + return "OBJECT"; + } + INTEROP_FATAL("Fatal error"); +} + +inline const char *tagNameExact(InteropTag tag) +{ + switch (tag) + { + case InteropTag::INTEROP_TAG_UNDEFINED: + return "INTEROP_TAG_UNDEFINED"; + case InteropTag::INTEROP_TAG_INT32: + return "INTEROP_TAG_INT32"; + case InteropTag::INTEROP_TAG_FLOAT32: + return "INTEROP_TAG_FLOAT32"; + case InteropTag::INTEROP_TAG_LENGTH: + return "INTEROP_TAG_LENGTH"; + case InteropTag::INTEROP_TAG_RESOURCE: + return "INTEROP_TAG_RESOURCE"; + case InteropTag::INTEROP_TAG_STRING: + return "INTEROP_TAG_STRING"; + case InteropTag::INTEROP_TAG_OBJECT: + return "INTEROP_TAG_OBJECT"; + } + INTEROP_FATAL("Fatal error"); +} + +inline InteropFunction makeArkFunctionFromId(InteropInt32 id) { + InteropFunction result; + result.id = id; + return result; +} + +inline const char *getUnitName(int value) +{ + switch (value) + { + case 0: + return "px"; + case 1: + return "vp"; + case 2: + return "fp"; + case 3: + return "%"; + case 4: + return "lpx"; + default: + return ""; + } +} + +inline void parseDimension(const InteropString &string, InteropLength *result) +{ + char *suffixPtr = nullptr; + float value = std::strtof(string.chars, &suffixPtr); + + if (!suffixPtr || suffixPtr == string.chars) + { + // not a numeric value + result->unit = -1; + return; + } + result->value = value; + if (suffixPtr[0] == '\0' || (suffixPtr[0] == 'v' && suffixPtr[1] == 'p')) + { + result->unit = 1; + } + else if (suffixPtr[0] == '%') + { + result->unit = 3; + } + else if (suffixPtr[0] == 'p' && suffixPtr[1] == 'x') + { + result->unit = 0; + } + else if (suffixPtr[0] == 'l' && suffixPtr[1] == 'p' && suffixPtr[2] == 'x') + { + result->unit = 4; + } + else if (suffixPtr[0] == 'f' && suffixPtr[1] == 'p') + { + result->unit = 2; + } + else + { + result->unit = -1; + } +} + +template +inline void convertor(T value) = delete; + +// TODO: restore full printing! +template +inline void WriteToString(std::string *result, T value) = delete; + +template <> +inline void WriteToString(std::string *result, const InteropEmpty &value) +{ + result->append("{"); + result->append(".dummy=" + std::to_string(value.dummy)); + result->append("}"); +} + +struct Error +{ + std::string message; + Error(const std::string &message) : message(message) {} +}; + +template <> +inline void WriteToString(std::string *result, InteropTag value) +{ + result->append(".tag="); + result->append(tagName(value)); +} + +template <> +inline void WriteToString(std::string *result, InteropNativePointer value) +{ + result->append("0x" + std::to_string((uint64_t)value)); +} + +template <> +inline void WriteToString(std::string *result, InteropNodeHandle value) +{ + result->append("0x" + std::to_string((uint64_t)value)); +} + +template <> +inline void WriteToString(std::string *result, InteropFunction value) +{ + result->append("{"); + result->append(".id=" + std::to_string(value.id)); + result->append("}"); +} + +template <> +inline void WriteToString(std::string *result, const InteropFunction* value) +{ + result->append("{"); + result->append(".id=" + std::to_string(value->id)); + result->append("}"); +} + +template <> +inline void WriteToString(std::string *result, const InteropMaterialized *value) +{ + char hex[20]; + std::snprintf(hex, sizeof(hex), "0x%llx", (long long)value->ptr); + result->append("\""); + result->append("Materialized "); + result->append(hex); + result->append("\""); +} + +// TODO: generate! +template<> +inline void WriteToString(std::string *result, const InteropCallbackResource *value) +{ + result->append("{"); + result->append(".resourceId=" + std::to_string(value->resourceId)); + result->append(", .hold=0"); + result->append(", .release=0"); + result->append("}"); +} + +class DeserializerBase; + +template <> +inline void WriteToString(std::string *result, InteropUndefined value) +{ + result->append("{}"); +} +template <> +inline void WriteToString(std::string *result, const InteropUndefined *value) +{ + result->append("{}"); +} +template <> +inline void WriteToString(std::string *result, InteropVoid value) +{ + result->append("{}"); +} +template <> +inline void WriteToString(std::string *result, const InteropVoid *value) +{ + result->append("{}"); +} +template <> +inline void WriteToString(std::string *result, const InteropCustomObject *value) +{ + if (strcmp(value->kind, "NativeErrorFunction") == 0) + { + result->append("() => {} /* TBD: Function*/"); + return; + } + result->append("{"); + result->append(".kind=\""); + result->append(value->kind); + result->append("\"}"); +} +template <> +inline void WriteToString(std::string *result, const InteropObject *value) +{ + result->append("{"); + result->append(".resource="); + WriteToString(result, &(value->resource)); + result->append("}"); +} +template <> +inline void WriteToString(std::string *result, const InteropObject value) +{ + WriteToString(result, &value); +} + +struct CustomDeserializer +{ + virtual ~CustomDeserializer() {} + virtual bool supports(const std::string &kind) { return false; } + virtual InteropCustomObject deserialize(DeserializerBase *deserializer, const std::string &kind) + { + InteropCustomObject result; + strcpy(result.kind, "error"); + return result; + } + CustomDeserializer *next = nullptr; +}; + +class DeserializerBase +{ +protected: + uint8_t *data; + int32_t length; + int32_t position; + std::vector toClean; + + static CustomDeserializer *customDeserializers; + +public: + DeserializerBase(KSerializerBuffer data, int32_t length) + : data(reinterpret_cast(data)), length(length), position(0) {} + + DeserializerBase(uint8_t* data, int32_t length) + : data(data), length(length), position(0) {} + + ~DeserializerBase() + { + for (auto data : toClean) + { + free(data); + } + } + + static void registerCustomDeserializer(CustomDeserializer *deserializer) + { + if (DeserializerBase::customDeserializers == nullptr) + { + DeserializerBase::customDeserializers = deserializer; + } + else + { + auto *current = DeserializerBase::customDeserializers; + while (current->next != nullptr) + current = current->next; + current->next = deserializer; + } + } + + template + void resizeArray(T *array, int32_t length) + { + void *value = nullptr; + if (length > 0) + { + value = malloc(length * sizeof(E)); + memset(value, 0, length * sizeof(E)); + toClean.push_back(value); + } + array->length = length; + array->array = reinterpret_cast(value); + } + + template + void resizeMap(T *map, int32_t length) + { + void *keys = nullptr; + void *values = nullptr; + if (length > 0) + { + keys = malloc(length * sizeof(K)); + memset(keys, 0, length * sizeof(K)); + toClean.push_back(keys); + + values = malloc(length * sizeof(V)); + memset(values, 0, length * sizeof(V)); + toClean.push_back(values); + } + map->size = length; + map->keys = reinterpret_cast(keys); + map->values = reinterpret_cast(values); + } + + int32_t currentPosition() const { return this->position; } + + void check(int32_t count) + { + if (position + count > length) { + fprintf(stderr, "Incorrect serialized data, check for %d, buffer %d position %d\n", count, length, position); + assert(false); + abort(); + } + } + + InteropCustomObject readCustomObject(std::string kind) + { + auto *current = DeserializerBase::customDeserializers; + while (current) + { + if (current->supports(kind)) + return current->deserialize(this, kind); + current = current->next; + } + LOGE("Unsupported custom deserialization for %s\n", kind.c_str()); + auto tag = readTag(); + if (tag == INTEROP_TAG_UNDEFINED) LOGE("Undefined interop tag"); + // Skip undefined tag!. + InteropCustomObject result; + strcpy(result.kind, "Error"); + strcat(result.kind, kind.c_str()); + return result; + } + + InteropCallbackResource readCallbackResource() { + InteropCallbackResource result = {}; + result.resourceId = readInt32(); + result.hold = reinterpret_cast(readPointerOrDefault(reinterpret_cast(holdManagedCallbackResource))); + result.release = reinterpret_cast(readPointerOrDefault(reinterpret_cast(releaseManagedCallbackResource))); + return result; + } + + InteropObject readObject() { + InteropObject obj; + obj.resource = readCallbackResource(); + return obj; + } + + int8_t readInt8() + { + check(1); + int8_t value = *(data + position); + position += 1; + return value; + } + InteropTag readTag() + { + return (InteropTag)readInt8(); + } + InteropBoolean readBoolean() + { + check(1); + int8_t value = *(data + position); + position += 1; + return value; + } + InteropInt32 readInt32() + { + check(4); +#ifdef KOALA_NO_UNALIGNED_ACCESS + InteropInt32 value; + memcpy(&value, data + position, 4); +#else + auto value = *(InteropInt32 *)(data + position); +#endif + position += 4; + return value; + } + InteropInt64 readInt64() + { + check(8); +#ifdef KOALA_NO_UNALIGNED_ACCESS + InteropInt64 value; + memcpy(&value, data + position, 4); +#else + auto value = *(InteropInt64 *)(data + position); +#endif + position += 8; + return value; + } + InteropUInt64 readUInt64() + { + check(8); +#ifdef KOALA_NO_UNALIGNED_ACCESS + InteropInt64 value; + memcpy(&value, data + position, 4); +#else + auto value = *(InteropUInt64 *)(data + position); +#endif + position += 8; + return value; + } + InteropFloat32 readFloat32() + { + check(4); +#ifdef KOALA_NO_UNALIGNED_ACCESS + InteropFloat32 value; + memcpy(&value, data + position, 4); +#else + auto value = *(InteropFloat32 *)(data + position); +#endif + position += 4; + return value; + } + InteropNativePointer readPointer() + { + check(8); +#ifdef KOALA_NO_UNALIGNED_ACCESS + int64_t value = 0; + memcpy(&value, data + position, 8); +#else + int64_t value = *(int64_t *)(data + position); +#endif + position += 8; + return reinterpret_cast(static_cast(value)); + } + InteropNativePointer readPointerOrDefault(InteropNativePointer defaultValue) + { + const InteropNativePointer value = this->readPointer(); + return value ? value : defaultValue; + } + InteropNumber readNumber() + { + check(5); + InteropNumber result; + result.tag = readTag(); + if (result.tag == InteropTag::INTEROP_TAG_INT32) + { + result.i32 = readInt32(); + } + else if (result.tag == InteropTag::INTEROP_TAG_FLOAT32) + { + result.f32 = readFloat32(); + } + else + { + INTEROP_FATAL("Fatal error"); + } + return result; + } + InteropBuffer readBuffer() + { + InteropCallbackResource resource = readCallbackResource(); + InteropNativePointer data = readPointer(); + InteropInt64 length = readInt64(); + return InteropBuffer { resource, (void*)data, length }; + } + + // TODO: produce them with prefix in generator. + InteropLength readLength() + { + InteropLength result = {}; + result.unit = 1; + result.type = readInt8(); + switch (result.type) + { + case INTEROP_RUNTIME_OBJECT: + { + result.resource = readInt32(); + break; + } + case INTEROP_RUNTIME_STRING: + { + InteropString string = readString(); + parseDimension(string, &result); + break; + } + case INTEROP_RUNTIME_NUMBER: + { + result.value = readFloat32(); + break; + } + default: + { + INTEROP_FATAL("Fatal error"); + } + } + return result; + } + + InteropString readString() + { + InteropString result; + InteropInt32 length = readInt32(); + check(length); + // We refer to string data in-place. + result.chars = (const char *)(data + position); + result.length = length - 1; + this->position += length; + return result; + } + + InteropFunction readFunction() + { + InteropFunction result; + result.id = readInt32(); + return result; + } + + InteropMaterialized readMaterialized() + { + InteropMaterialized result; + result.ptr = readPointer(); + return result; + } + + InteropUndefined readUndefined() + { + return InteropUndefined(); + } +}; +template <> +inline void WriteToString(std::string *result, InteropBoolean value) +{ + result->append(value ? "true" : "false"); +} +template <> +inline void WriteToString(std::string *result, InteropInt32 value) +{ + result->append(std::to_string(value)); +} +template <> +inline void WriteToString(std::string *result, const InteropInt32* value) +{ + result->append(std::to_string(*value)); +} +template <> +inline void WriteToString(std::string *result, InteropUInt64 value) +{ + result->append(std::to_string(value)); +} +template <> +inline void WriteToString(std::string *result, InteropInt64 value) +{ + result->append(std::to_string(value)); +} +template <> +inline void WriteToString(std::string *result, InteropUInt32 value) +{ + result->append(std::to_string(value)); +} +template <> +inline void WriteToString(std::string *result, InteropFloat32 value) +{ +#if (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && (__MAC_OS_X_VERSION_MAX_ALLOWED < 130300L)) + // to_chars() is not available on older macOS. + char buf[20]; + snprintf(buf, sizeof buf, "%f", value); + result->append(buf); +#else + std::string storage; + storage.resize(20); + // We use to_chars() to avoid locale issues. + auto rc = std::to_chars(storage.data(), storage.data() + storage.size(), value); + storage.resize(rc.ptr - storage.data()); + result->append(storage); +#endif +} +template <> +inline void WriteToString(std::string* result, const InteropBuffer* value) { + result->append("{.data=nullptr, .length="); + result->append(std::to_string(value->length)); + result->append("}"); +} +template <> +inline void WriteToString(std::string* result, InteropBuffer value) { + result->append("{.data=nullptr, .length="); + result->append(std::to_string(value.length)); + result->append("}"); +} +template <> +inline void WriteToString(std::string *result, const InteropString *value) +{ + result->append("{"); + if (value->chars) { + result->append(".chars=\""); + result->append(value->chars); + result->append("\""); + } else { + result->append(".chars=\"\""); + } + result->append(", .length="); + WriteToString(result, value->length); + result->append("}"); +} + +template <> +inline void WriteToString(std::string *result, const InteropNumber *value) +{ + result->append("{.tag=" + std::to_string(value->tag) + ", "); + + if (value->tag == INTEROP_TAG_FLOAT32) + { + std::string valueString; + result->append(".f32="); + WriteToString(result, value->f32); + } else { + result->append(".i32=" + std::to_string(value->i32)); + } + + result->append("}"); +} + +template <> +inline void WriteToString(std::string *result, const InteropLength *value) +{ + result->append("{"); + result->append(".type=" + std::to_string(value->type)); + result->append(", .value="); + WriteToString(result, value->value); + result->append(", .unit=" + std::to_string(value->unit)); + result->append(", .resource=" + std::to_string(value->resource)); + result->append("}"); +} + +#endif // _DESERIALIZER_BASE_H_ diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/SerializerBase.h b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/SerializerBase.h new file mode 100644 index 0000000000000000000000000000000000000000..dbf2b51bd0a7ee18ab9a2533d130f085bede59c9 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/SerializerBase.h @@ -0,0 +1,272 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _SERIALIZER_BASE_H +#define _SERIALIZER_BASE_H + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "callback-resource.h" +#include "interop-types.h" +#include "koala-types.h" + +#ifdef __arm__ +#define KOALA_NO_UNALIGNED_ACCESS 1 +#endif + +template +inline InteropRuntimeType runtimeType(const T& value) = delete; + +template <> +inline InteropRuntimeType runtimeType(const InteropCustomObject& value) { + return INTEROP_RUNTIME_OBJECT; +} + +template <> +inline InteropRuntimeType runtimeType(const InteropMaterialized& value) { + return INTEROP_RUNTIME_OBJECT; +} + +static const std::size_t buffer_size = 1024 * 1024; // 1 MB +static std::size_t offset = 0; +alignas(std::max_align_t) static char buffer[buffer_size]; + +template +T* allocArray(const std::array& ref) { + std::size_t space = sizeof(buffer) - offset; + void* ptr = buffer + offset; + void* aligned_ptr = std::align(alignof(T), sizeof(T) * size, ptr, space); + assert(aligned_ptr != nullptr && "Insufficient space or alignment failed!"); + offset = (char*)aligned_ptr + sizeof(T) * size - buffer; + T* array = reinterpret_cast(aligned_ptr); + for (size_t i = 0; i < size; ++i) { + new (&array[i]) T(ref[i]); + } + return array; +} + +class SerializerBase { +private: + uint8_t* data; + uint32_t dataLength; + uint32_t position; + bool ownData; + CallbackResourceHolder* resourceHolder; + void resize(uint32_t newLength) { + assert(ownData); + assert(newLength > dataLength); + auto* newData = reinterpret_cast(malloc(newLength)); + memcpy(newData, data, position); + free(data); + data = newData; + } +public: + SerializerBase(CallbackResourceHolder* resourceHolder = nullptr): + position(0), ownData(true), resourceHolder(resourceHolder) { + this->dataLength = 256; + this->data = reinterpret_cast(malloc(this->dataLength)); + } + + SerializerBase(uint8_t* data, uint32_t dataLength, CallbackResourceHolder* resourceHolder = nullptr): + data(data), dataLength(dataLength), position(0), ownData(false), resourceHolder(resourceHolder) { + } + + SerializerBase(KSerializerBuffer data, uint32_t dataLength, CallbackResourceHolder* resourceHolder = nullptr): + data(reinterpret_cast(data)), dataLength(dataLength), position(0), ownData(false), resourceHolder(resourceHolder) { + } + + virtual ~SerializerBase() { + if (ownData) { + free(data); + } + } + + SerializerBase(const SerializerBase&) = delete; + SerializerBase& operator=(const SerializerBase&) = delete; + + void* release() { + ownData = false; + return data; + } + int length() { + return position; + } + + inline void check(int more) { + if (position + more > dataLength) { + if (ownData) { + resize((position + more) * 3 / 2 + 2); + } else { + INTEROP_FATAL("Buffer overrun: %d > %d\n", position + more, dataLength); + } + } + } + + void writeInt8(InteropInt8 value) { + check(1); + *((InteropInt8*)(data + position)) = value; + position += 1; + } + + void writeInt32(InteropInt32 value) { + check(4); +#ifdef KOALA_NO_UNALIGNED_ACCESS + memcpy(data + position, &value, 4); +#else + *((InteropInt32*)(data + position)) = value; +#endif + position += 4; + } + + void writeInt64(InteropInt64 value) { + check(8); +#ifdef KOALA_NO_UNALIGNED_ACCESS + memcpy(data + position, &value, 8); +#else + *((InteropInt64*)(data + position)) = value; +#endif + position += 8; + } + + void writeUInt64(InteropUInt64 value) { + check(8); +#ifdef KOALA_NO_UNALIGNED_ACCESS + memcpy(data + position, &value, 8); +#else + *((InteropUInt64*)(data + position)) = value; +#endif + position += 8; + } + + void writeFloat32(InteropFloat32 value) { + check(4); +#ifdef KOALA_NO_UNALIGNED_ACCESS + memcpy(data + position, &value, 4); +#else + *((InteropFloat32*)(data + position)) = value; +#endif + position += 4; + } + + void writePointer(InteropNativePointer value) { + check(8); + int64_t value64 = static_cast(reinterpret_cast(value)); +#ifdef KOALA_NO_UNALIGNED_ACCESS + memcpy(data + position, &value64, 8); +#else + *((int64_t*)(data + position)) = value64; +#endif + position += 8; + } + + void writeFunction(InteropFunction value) { + // TODO: ignored, remove! + writeInt32(0x666); + } + + void writeNumber(InteropNumber value) { + writeInt8(value.tag); + if (value.tag == InteropTag::INTEROP_TAG_INT32) { + writeInt32(value.i32); + } else if (value.tag == InteropTag::INTEROP_TAG_FLOAT32) { + writeFloat32(value.f32); + } else { + INTEROP_FATAL("Unknown tag number"); + } + } + + void writeString(InteropString value) { + writeInt32(value.length + 1); + check(value.length + 1); + strcpy((char*)(data + position), value.chars); + position += value.length + 1; + } + + void writeBoolean(InteropBoolean value) { + writeInt8(value); + } + + void writeLength(InteropLength value) { + InteropRuntimeType tag = (InteropRuntimeType) value.type; + writeInt8(tag); + switch (tag) { + case INTEROP_RUNTIME_NUMBER: + writeFloat32(value.value); + break; + case INTEROP_RUNTIME_OBJECT: + writeInt32(value.resource); + break; + case INTEROP_RUNTIME_STRING: { + char buf[64]; + std::string suffix; + switch (value.unit) { + case 0: suffix = "px"; break; + case 1: suffix = "vp"; break; + case 2: suffix = "fp"; break; + case 3: suffix = "%"; break; + case 4: suffix = "lpx"; break; + } + snprintf(buf, 64, "%.8f%s", value.value, suffix.c_str()); + InteropString str = { buf, (InteropInt32) strlen(buf) }; + writeString(str); + break; + } + default: + break; + } + } + + void writeCallbackResource(const InteropCallbackResource resource) { + writeInt32(resource.resourceId); + writePointer(reinterpret_cast(resource.hold)); + writePointer(reinterpret_cast(resource.release)); + if (this->resourceHolder != nullptr) { + this->resourceHolder->holdCallbackResource(&resource); + } + } + + void writeObject(InteropObject any) { + writeCallbackResource(any.resource); + } + + void writeCustomObject(std::string type, InteropCustomObject value) { + // TODO implement + } + + void writeBuffer(InteropBuffer buffer) { + writeCallbackResource(buffer.resource); + writePointer((void*)buffer.data); + writeInt64(buffer.length); + } + + KInteropReturnBuffer toReturnBuffer() { + if (this->ownData) { + KInteropReturnBuffer buffer {this->length(), this->release(), [](KNativePointer data, KInt length) { free(data); }}; + // TODO fix memory issues + return buffer; + } else { + return {this->length(), this->data, nullptr}; + } + } +}; + +#endif // _SERIALIZER_BASE_H \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/ani/ani.h b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/ani/ani.h new file mode 100644 index 0000000000000000000000000000000000000000..d31a8de28d1b4975f39400aab89483b79f8b7781 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/ani/ani.h @@ -0,0 +1,7701 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __ANI_H__ +#define __ANI_H__ +// NOLINTBEGIN + +#ifdef __cplusplus +#include +#include +#include +#else +#include +#include +#include +#endif + +#define ANI_VERSION_1 1 + +#define ANI_FALSE 0 +#define ANI_TRUE 1 + +// Logger interface: +// typedef void (*ani_logger)(FILE *stream, int log_level, const char *component, const char *message); +// ani_option: +// 'option': "--logger" +// 'extra': ani_logger +// where 'log_level' can have the following values: +#define ANI_LOGLEVEL_FATAL 0 +#define ANI_LOGLEVEL_ERROR 1 +#define ANI_LOGLEVEL_WARNING 2 +#define ANI_LOGLEVEL_INFO 3 +#define ANI_LOGLEVEL_DEBUG 4 + +typedef size_t ani_size; + +// Primitive types: +typedef uint8_t ani_boolean; +typedef uint16_t ani_char; +typedef int8_t ani_byte; +typedef int16_t ani_short; +typedef int32_t ani_int; +typedef int64_t ani_long; +typedef float ani_float; +typedef double ani_double; + +// Reference types: +#ifdef __cplusplus +class __ani_ref +{ +}; +class __ani_module : public __ani_ref +{ +}; +class __ani_namespace : public __ani_ref +{ +}; +class __ani_object : public __ani_ref +{ +}; +class __ani_fn_object : public __ani_object +{ +}; +class __ani_enum_item : public __ani_object +{ +}; +class __ani_error : public __ani_object +{ +}; +class __ani_tuple_value : public __ani_object +{ +}; +class __ani_type : public __ani_object +{ +}; +class __ani_arraybuffer : public __ani_object +{ +}; +class __ani_string : public __ani_object +{ +}; +class __ani_class : public __ani_type +{ +}; +class __ani_enum : public __ani_type +{ +}; +class __ani_union : public __ani_type +{ +}; +class __ani_array : public __ani_object +{ +}; +class __ani_array_boolean : public __ani_array +{ +}; +class __ani_array_char : public __ani_array +{ +}; +class __ani_array_byte : public __ani_array +{ +}; +class __ani_array_short : public __ani_array +{ +}; +class __ani_array_int : public __ani_array +{ +}; +class __ani_array_long : public __ani_array +{ +}; +class __ani_array_float : public __ani_array +{ +}; +class __ani_array_double : public __ani_array +{ +}; +class __ani_array_ref : public __ani_array +{ +}; +typedef __ani_ref *ani_ref; +typedef __ani_module *ani_module; +typedef __ani_namespace *ani_namespace; +typedef __ani_object *ani_object; +typedef __ani_fn_object *ani_fn_object; +typedef __ani_enum_item *ani_enum_item; +typedef __ani_error *ani_error; +typedef __ani_tuple_value *ani_tuple_value; +typedef __ani_type *ani_type; +typedef __ani_arraybuffer *ani_arraybuffer; +typedef __ani_string *ani_string; +typedef __ani_class *ani_class; +typedef __ani_enum *ani_enum; +typedef __ani_union *ani_union; +typedef __ani_array *ani_array; +typedef __ani_array_boolean *ani_array_boolean; +typedef __ani_array_char *ani_array_char; +typedef __ani_array_byte *ani_array_byte; +typedef __ani_array_short *ani_array_short; +typedef __ani_array_int *ani_array_int; +typedef __ani_array_long *ani_array_long; +typedef __ani_array_float *ani_array_float; +typedef __ani_array_double *ani_array_double; +typedef __ani_array_ref *ani_array_ref; +#else // __cplusplus +struct __ani_ref; +typedef struct __ani_ref *ani_ref; +typedef ani_ref ani_module; +typedef ani_ref ani_namespace; +typedef ani_ref ani_object; +typedef ani_object ani_fn_object; +typedef ani_object ani_enum_item; +typedef ani_object ani_error; +typedef ani_object ani_tuple_value; +typedef ani_object ani_type; +typedef ani_object ani_arraybuffer; +typedef ani_object ani_string; +typedef ani_type ani_class; +typedef ani_type ani_enum; +typedef ani_type ani_union; +typedef ani_object ani_array; +typedef ani_array ani_array_boolean; +typedef ani_array ani_array_char; +typedef ani_array ani_array_byte; +typedef ani_array ani_array_short; +typedef ani_array ani_array_int; +typedef ani_array ani_array_long; +typedef ani_array ani_array_float; +typedef ani_array ani_array_double; +typedef ani_array ani_array_ref; +#endif // __cplusplus + +struct __ani_wref; +typedef struct __ani_wref *ani_wref; + +struct __ani_variable; +typedef struct __ani_variable *ani_variable; + +struct __ani_function; +typedef struct __ani_function *ani_function; + +struct __ani_field; +typedef struct __ani_field *ani_field; + +struct __ani_static_field; +typedef struct __ani_satic_field *ani_static_field; + +struct __ani_method; +typedef struct __ani_method *ani_method; + +struct __ani_static_method; +typedef struct __ani_static_method *ani_static_method; + +struct __ani_resolver; +typedef struct __ani_resolver *ani_resolver; + +typedef void (*ani_finalizer)(void *data, void *hint); + +typedef union { + ani_boolean z; + ani_char c; + ani_byte b; + ani_short s; + ani_int i; + ani_long l; + ani_float f; + ani_double d; + ani_ref r; +} ani_value; + +typedef struct { + const char *name; + const char *signature; + const void *pointer; +} ani_native_function; + +#ifdef __cplusplus +typedef struct __ani_vm ani_vm; +typedef struct __ani_env ani_env; +#else +typedef const struct __ani_vm_api *ani_vm; +typedef const struct __ani_interaction_api *ani_env; +#endif + +typedef enum { + ANI_OK, + ANI_ERROR, + ANI_INVALID_ARGS, + ANI_INVALID_TYPE, + ANI_INVALID_DESCRIPTOR, + ANI_INCORRECT_REF, + ANI_PENDING_ERROR, + ANI_NOT_FOUND, + ANI_ALREADY_BINDED, + ANI_OUT_OF_REF, + ANI_OUT_OF_MEMORY, + ANI_OUT_OF_RANGE, + ANI_BUFFER_TO_SMALL, + ANI_INVALID_VERSION, + ANI_AMBIGUOUS, + // NOTE: Add necessary status codes +} ani_status; + +typedef struct { + const char *option; + void *extra; +} ani_option; + +typedef struct { + size_t nr_options; + const ani_option *options; +} ani_options; + +struct __ani_vm_api { + void *reserved0; + void *reserved1; + void *reserved2; + void *reserved3; + + ani_status (*DestroyVM)(ani_vm *vm); + ani_status (*GetEnv)(ani_vm *vm, uint32_t version, ani_env **result); + ani_status (*AttachCurrentThread)(ani_vm *vm, const ani_options *options, uint32_t version, ani_env **result); + ani_status (*DetachCurrentThread)(ani_vm *vm); +}; + +#define ANI_EXPORT __attribute__((visibility("default"))) + +#ifdef __cplusplus +extern "C" { +#endif + + ANI_EXPORT ani_status ANI_CreateVM(const ani_options *options, uint32_t version, ani_vm **result); + ANI_EXPORT ani_status ANI_GetCreatedVMs(ani_vm **vms_buffer, ani_size vms_buffer_length, ani_size *result); + + // Prototypes of exported functions for a shared library. + ANI_EXPORT ani_status ANI_Constructor(ani_vm *vm, uint32_t *result); + ANI_EXPORT ani_status ANI_Destructor(ani_vm *vm); + +#ifdef __cplusplus +} +#endif + +struct __ani_interaction_api { + void *reserved0; + void *reserved1; + void *reserved2; + void *reserved3; + + /** + * @brief Retrieves the version information. + * + * This function retrieves the version information and stores it in the result parameter. + * + * @param[in] env A pointer to the environment structure. + * @param[out] result A pointer to a variable where the version information will be stored. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*GetVersion)(ani_env *env, uint32_t *result); + + /** + * @brief Retrieves the Virtual Machine (VM) instance. + * + * This function retrieves the VM instance and stores it in the result parameter. + * + * @param[in] env A pointer to the environment structure. + * @param[out] result A pointer to the VM instance to be populated. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*GetVM)(ani_env *env, ani_vm **result); + + /** + * @brief Creates a new object of a specified class using a constructor method. + * + * This function creates a new object of the given class and calls the specified constructor method with variadic + * arguments. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class of the object to create. + * @param[in] method The constructor method to invoke. + * @param[in] ... Variadic arguments to pass to the constructor method. + * @param[out] result A pointer to store the object return value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_New)(ani_env *env, ani_class cls, ani_method method, ani_object *result, ...); + + /** + * @brief Creates a new object of a specified class using a constructor method (array-based). + * + * This function creates a new object of the given class and calls the specified constructor method with arguments + * provided in an array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class of the object to create. + * @param[in] method The constructor method to invoke. + * @param[in] args An array of arguments to pass to the constructor method. + * @param[out] result A pointer to store the object return value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_New_A)(ani_env *env, ani_class cls, ani_method method, ani_object *result, + const ani_value *args); + + /** + * @brief Creates a new object of a specified class using a constructor method (variadic arguments). + * + * This function creates a new object of the given class and calls the specified constructor method with a `va_list` + * of arguments. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class of the object to create. + * @param[in] method The constructor method to invoke. + * @param[in] args A `va_list` of arguments to pass to the constructor method. + * @param[out] result A pointer to store the object return value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_New_V)(ani_env *env, ani_class cls, ani_method method, ani_object *result, va_list args); + + /** + * @brief Retrieves the type of a given object. + * + * This function retrieves the type of the specified object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object whose type is to be retrieved. + * @param[out] result A pointer to store the retrieved type. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetType)(ani_env *env, ani_object object, ani_type *result); + + /** + * @brief Checks if an object is an instance of a specified type. + * + * This function checks whether the given object is an instance of the specified type. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object to check. + * @param[in] type The type to compare against. + * @param[out] result A pointer to store the boolean result (true if the object is an instance of the type, false + * otherwise). + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_InstanceOf)(ani_env *env, ani_object object, ani_type type, ani_boolean *result); + + /** + * @brief Retrieves the superclass of a specified type. + * + * This function retrieves the superclass of a given type and stores it in the result parameter. + * + * @param[in] env A pointer to the environment structure. + * @param[in] type The type for which to retrieve the superclass. + * @param[out] result A pointer to the superclass to be populated. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Type_GetSuperClass)(ani_env *env, ani_type type, ani_class *result); + + /** + * @brief Determines if one type is assignable from another. + * + * This function checks if a type is assignable from another and stores the result in the output parameter. + * + * @param[in] env A pointer to the environment structure. + * @param[in] from_type The source type. + * @param[in] to_type The target type. + * @param[out] result A pointer to a boolean indicating assignability. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Type_IsAssignableFrom)(ani_env *env, ani_type from_type, ani_type to_type, ani_boolean *result); + + /** + * @brief Finds a module by its descriptor. + * + * This function locates a module based on its descriptor and stores it in the result parameter. + * + * @param[in] env A pointer to the environment structure. + * @param[in] module_descriptor The descriptor of the module to find. + * @param[out] result A pointer to the module to be populated. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FindModule)(ani_env *env, const char *module_descriptor, ani_module *result); + + /** + * @brief Finds a namespace by its descriptor. + * + * This function locates a namespace based on its descriptor and stores it in the result parameter. + * + * @param[in] env A pointer to the environment structure. + * @param[in] namespace_descriptor The descriptor of the namespace to find. + * @param[out] result A pointer to the namespace to be populated. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FindNamespace)(ani_env *env, const char *namespace_descriptor, ani_namespace *result); + + /** + * @brief Finds a class by its descriptor. + * + * This function locates a class based on its descriptor and stores it in the result parameter. + * + * @param[in] env A pointer to the environment structure. + * @param[in] class_descriptor The descriptor of the class to find. + * @param[out] result A pointer to the class to be populated. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FindClass)(ani_env *env, const char *class_descriptor, ani_class *result); + + /** + * @brief Finds an enum by its descriptor. + * + * This function locates an enum based on its descriptor and stores it in the result parameter. + * + * @param[in] env A pointer to the environment structure. + * @param[in] enum_descriptor The descriptor of the enum to find. + * @param[out] result A pointer to the enum to be populated. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FindEnum)(ani_env *env, const char *enum_descriptor, ani_enum *result); + + /** + * @brief Finds a namespace within a module by its descriptor. + * + * This function locates a namespace within the specified module based on its descriptor. + * + * @param[in] env A pointer to the environment structure. + * @param[in] module The module to search within. + * @param[in] namespace_descriptor The descriptor of the namespace to find. + * @param[out] result A pointer to the namespace object. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Module_FindNamespace)(ani_env *env, ani_module module, const char *namespace_descriptor, + ani_namespace *result); + + /** + * @brief Finds a class within a module by its descriptor. + * + * This function locates a class within the specified module based on its descriptor. + * + * @param[in] env A pointer to the environment structure. + * @param[in] module The module to search within. + * @param[in] class_descriptor The descriptor of the class to find. + * @param[out] result A pointer to the class object. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Module_FindClass)(ani_env *env, ani_module module, const char *class_descriptor, ani_class *result); + + /** + * @brief Finds an enum within a module by its descriptor. + * + * This function locates an enum within the specified module based on its descriptor. + * + * @param[in] env A pointer to the environment structure. + * @param[in] module The module to search within. + * @param[in] enum_descriptor The descriptor of the enum to find. + * @param[out] result A pointer to the enum object. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Module_FindEnum)(ani_env *env, ani_module module, const char *enum_descriptor, ani_enum *result); + + /** + * @brief Finds a function within a module by its name and signature. + * + * This function locates a function within the specified module based on its name and signature. + * + * @param[in] env A pointer to the environment structure. + * @param[in] module The module to search within. + * @param[in] name The name of the function to find. + * @param[in] signature The signature of the function to find. + * @param[out] result A pointer to the function object. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Module_FindFunction)(ani_env *env, ani_module module, const char *name, const char *signature, + ani_function *result); + + /** + * @brief Finds a variable within a module by its name. + * + * This function locates a variable within the specified module based on its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] module The module to search within. + * @param[in] name The name of the variable to find. + * @param[out] result A pointer to the variable object. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Module_FindVariable)(ani_env *env, ani_module module, const char *name, ani_variable *result); + + /** + * @brief Finds a namespace within another namespace by its descriptor. + * + * This function locates a namespace within the specified parent namespace based on its descriptor. + * + * @param[in] env A pointer to the environment structure. + * @param[in] ns The parent namespace to search within. + * @param[in] namespace_descriptor The descriptor of the namespace to find. + * @param[out] result A pointer to the namespace object. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Namespace_FindNamespace)(ani_env *env, ani_namespace ns, const char *namespace_descriptor, + ani_namespace *result); + + /** + * @brief Finds a class within a namespace by its descriptor. + * + * This function locates a class within the specified namespace based on its descriptor. + * + * @param[in] env A pointer to the environment structure. + * @param[in] ns The namespace to search within. + * @param[in] class_descriptor The descriptor of the class to find. + * @param[out] result A pointer to the class object. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Namespace_FindClass)(ani_env *env, ani_namespace ns, const char *class_descriptor, ani_class *result); + + /** + * @brief Finds an enum within a namespace by its descriptor. + * + * This function locates an enum within the specified namespace based on its descriptor. + * + * @param[in] env A pointer to the environment structure. + * @param[in] ns The namespace to search within. + * @param[in] enum_descriptor The descriptor of the enum to find. + * @param[out] result A pointer to the enum object. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Namespace_FindEnum)(ani_env *env, ani_namespace ns, const char *enum_descriptor, ani_enum *result); + + /** + * @brief Finds a function within a namespace by its name and signature. + * + * This function locates a function within the specified namespace based on its name and signature. + * + * @param[in] env A pointer to the environment structure. + * @param[in] ns The namespace to search within. + * @param[in] name The name of the function to find. + * @param[in] signature The signature of the function to find. + * @param[out] result A pointer to the function object. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Namespace_FindFunction)(ani_env *env, ani_namespace ns, const char *name, const char *signature, + ani_function *result); + + /** + * @brief Finds a variable within a namespace by its name. + * + * This function locates a variable within the specified namespace based on its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] ns The namespace to search within. + * @param[in] name The name of the variable to find. + * @param[out] result A pointer to the variable object. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Namespace_FindVariable)(ani_env *env, ani_namespace ns, const char *name, ani_variable *result); + + /** + * @brief Binds native functions to a module. + * + * This function binds an array of native functions to the specified module. + * + * @param[in] env A pointer to the environment structure. + * @param[in] module The module to which the native functions will be bound. + * @param[in] functions A pointer to an array of native functions to bind. + * @param[in] nr_functions The number of native functions in the array. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Module_BindNativeFunctions)(ani_env *env, ani_module module, const ani_native_function *functions, + ani_size nr_functions); + + /** + * @brief Binds native functions to a namespace. + * + * This function binds an array of native functions to the specified namespace. + * + * @param[in] env A pointer to the environment structure. + * @param[in] ns The namespace to which the native functions will be bound. + * @param[in] functions A pointer to an array of native functions to bind. + * @param[in] nr_functions The number of native functions in the array. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Namespace_BindNativeFunctions)(ani_env *env, ani_namespace ns, const ani_native_function *functions, + ani_size nr_functions); + + /** + * @brief Binds native methods to a class. + * + * This function binds an array of native methods to the specified class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class to which the native methods will be bound. + * @param[in] methods A pointer to an array of native methods to bind. + * @param[in] nr_methods The number of native methods in the array. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_BindNativeMethods)(ani_env *env, ani_class cls, const ani_native_function *methods, + ani_size nr_methods); + + /** + * @brief Deletes a local reference. + * + * This function deletes a specified local reference to free up resources. + * + * @param[in] env A pointer to the environment structure. + * @param[in] ref The reference to be deleted. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Reference_Delete)(ani_env *env, ani_ref ref); + + /** + * @brief Ensures enough local references are available. + * + * This function checks and ensures that the specified number of local references can be created. + * + * @param[in] env A pointer to the environment structure. + * @param[in] nr_refs The number of local references to ensure availability for. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*EnsureEnoughReferences)(ani_env *env, ani_size nr_refs); + + /** + * @brief Creates a new local scope for references. + * + * This function creates a local scope for references with a specified capacity. + * + * @param[in] env A pointer to the environment structure. + * @param[in] nr_refs The maximum number of references that can be created in this scope. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*CreateLocalScope)(ani_env *env, ani_size nr_refs); + + /** + * @brief Destroys the current local scope. + * + * This function destroys the current local scope and frees all references within it. + * + * @param[in] env A pointer to the environment structure. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*DestroyLocalScope)(ani_env *env); + + /** + * @brief Creates a new escape local scope. + * + * This function creates a local scope for references with escape functionality, allowing objects to escape this + * scope. + * + * @param[in] env A pointer to the environment structure. + * @param[in] nr_refs The maximum number of references that can be created in this scope. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*CreateEscapeLocalScope)(ani_env *env, ani_size nr_refs); + + /** + * @brief Destroys the current escape local scope. + * + * This function destroys the current escape local scope and allows escaping references to be retrieved. + * + * @param[in] env A pointer to the environment structure. + * @param[in] ref The reference to be escaped from the current scope. + * @param[out] result A pointer to the resulting reference that has escaped the scope. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*DestroyEscapeLocalScope)(ani_env *env, ani_ref ref, ani_ref *result); + + /** + * @brief Throws an error. + * + * This function throws the specified error in the current environment. + * + * @param[in] env A pointer to the environment structure. + * @param[in] err The error to throw. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*ThrowError)(ani_env *env, ani_error err); + + /** + * @brief Checks if there are unhandled errors. + * + * This function determines if there are unhandled errors in the current environment. + * + * @param[in] env A pointer to the environment structure. + * @param[out] result A pointer to a boolean indicating if unhandled errors exist. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*ExistUnhandledError)(ani_env *env, ani_boolean *result); + + /** + * @brief Retrieves the current unhandled error. + * + * This function fetches the unhandled error in the environment. + * + * @param[in] env A pointer to the environment structure. + * @param[out] result A pointer to store the unhandled error. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*GetUnhandledError)(ani_env *env, ani_error *result); + + /** + * @brief Resets the current error state. + * + * This function clears the error state in the current environment. + * + * @param[in] env A pointer to the environment structure. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*ResetError)(ani_env *env); + + /** + * @brief Provides a description of the current error. + * + * This function prints the stack trace or other debug information for the current error. + * + * @param[in] env A pointer to the environment structure. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*DescribeError)(ani_env *env); // NOTE: Print stacktrace for debugging? + + /** + * @brief Aborts execution with a message. + * + * This function terminates execution with the specified error message. + * + * @param[in] env A pointer to the environment structure. + * @param[in] message The error message to display on termination. + * @return Does not return; the process terminates. + */ + ani_status (*Abort)(ani_env *env, const char *message); + + /** + * @brief Retrieves a null reference. + * + * This function provides a null reference in the specified result. + * + * @param[in] env A pointer to the environment structure. + * @param[out] result A pointer to store the null reference. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*GetNull)(ani_env *env, ani_ref *result); + + /** + * @brief Retrieves an undefined reference. + * + * This function provides an undefined reference in the specified result. + * + * @param[in] env A pointer to the environment structure. + * @param[out] result A pointer to store the undefined reference. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*GetUndefined)(ani_env *env, ani_ref *result); + + /** + * @brief Checks if a reference is null. + * + * This function determines if the specified reference is null. + * + * @param[in] env A pointer to the environment structure. + * @param[in] ref The reference to check. + * @param[out] result A pointer to a boolean indicating if the reference is null. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Reference_IsNull)(ani_env *env, ani_ref ref, ani_boolean *result); + + /** + * @brief Checks if a reference is undefined. + * + * This function determines if the specified reference is undefined. + * + * @param[in] env A pointer to the environment structure. + * @param[in] ref The reference to check. + * @param[out] result A pointer to a boolean indicating if the reference is undefined. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Reference_IsUndefined)(ani_env *env, ani_ref ref, ani_boolean *result); + + /** + * @brief Checks if a reference is nullish value (null or undefined). + * + * This function determines if the specified reference is either null or undefined. + * + * @param[in] env A pointer to the environment structure. + * @param[in] ref The reference to check. + * @param[out] result A pointer to a boolean indicating if the reference is nullish value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Reference_IsNullishValue)(ani_env *env, ani_ref ref, ani_boolean *result); + + /** + * @brief Compares two references for equality. + * + * This function checks if two references are equal. + * + * @param[in] env A pointer to the environment structure. + * @param[in] ref0 The first reference to compare. + * @param[in] ref1 The second reference to compare. + * @param[out] result A pointer to a boolean indicating if the references are equal. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Reference_Equals)(ani_env *env, ani_ref ref0, ani_ref ref1, ani_boolean *result); + + /** + * @brief Compares two references for strict equality. + * + * This function checks if two references are strictly equal. + * + * @param[in] env A pointer to the environment structure. + * @param[in] ref0 The first reference to compare. + * @param[in] ref1 The second reference to compare. + * @param[out] result A pointer to a boolean indicating if the references are strictly equal. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Reference_StrictEquals)(ani_env *env, ani_ref ref0, ani_ref ref1, ani_boolean *result); + + /** + * @brief Creates a new UTF-16 string. + * + * This function creates a new string from the provided UTF-16 encoded data. + * + * @param[in] env A pointer to the environment structure. + * @param[in] utf16_string A pointer to the UTF-16 encoded string data. + * @param[in] utf16_size The size of the UTF-16 string in code units. + * @param[out] result A pointer to store the created string. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*String_NewUTF16)(ani_env *env, const uint16_t *utf16_string, ani_size utf16_size, ani_string *result); + + /** + * @brief Retrieves the size of a UTF-16 string. + * + * This function retrieves the size (in code units) of the specified UTF-16 string. + * + * @param[in] env A pointer to the environment structure. + * @param[in] string The UTF-16 string to measure. + * @param[out] result A pointer to store the size of the string. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*String_GetUTF16Size)(ani_env *env, ani_string string, ani_size *result); + + /** + * @brief Retrieves the UTF-16 encoded data of a string. + * + * This function copies the UTF-16 encoded data of the string into the provided buffer. + * + * @param[in] env A pointer to the environment structure. + * @param[in] string The string to retrieve data from. + * @param[out] utf16_buffer A buffer to store the UTF-16 encoded data. + * @param[in] utf16_buffer_size The size of the buffer in code units. + * @param[out] result A pointer to store the number of code units written. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*String_GetUTF16)(ani_env *env, ani_string string, uint16_t *utf16_buffer, ani_size utf16_buffer_size, + ani_size *result); + + /** + * @brief Retrieves a substring of a UTF-16 string. + * + * This function copies a portion of the UTF-16 string into the provided buffer. + * + * @param[in] env A pointer to the environment structure. + * @param[in] string The string to retrieve data from. + * @param[in] substr_offset The starting offset of the substring. + * @param[in] substr_size The size of the substring in code units. + * @param[out] utf16_buffer A buffer to store the substring. + * @param[in] utf16_buffer_size The size of the buffer in code units. + * @param[out] result A pointer to store the number of code units written. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*String_GetUTF16SubString)(ani_env *env, ani_string string, ani_size substr_offset, + ani_size substr_size, uint16_t *utf16_buffer, ani_size utf16_buffer_size, + ani_size *result); + + /** + * @brief Creates a new UTF-8 string. + * + * This function creates a new string from the provided UTF-8 encoded data. + * + * @param[in] env A pointer to the environment structure. + * @param[in] utf8_string A pointer to the UTF-8 encoded string data. + * @param[in] utf8_size The size of the UTF-8 string in bytes. + * @param[out] result A pointer to store the created string. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*String_NewUTF8)(ani_env *env, const char *utf8_string, ani_size utf8_size, ani_string *result); + + /** + * @brief Retrieves the size of a UTF-8 string. + * + * This function retrieves the size (in bytes) of the specified UTF-8 string. + * + * @param[in] env A pointer to the environment structure. + * @param[in] string The UTF-8 string to measure. + * @param[out] result A pointer to store the size of the string. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*String_GetUTF8Size)(ani_env *env, ani_string string, ani_size *result); + + /** + * @brief Retrieves the UTF-8 encoded data of a string. + * + * This function copies the UTF-8 encoded data of the string into the provided buffer. + * + * @param[in] env A pointer to the environment structure. + * @param[in] string The string to retrieve data from. + * @param[out] utf8_buffer A buffer to store the UTF-8 encoded data. + * @param[in] utf8_buffer_size The size of the buffer in bytes. + * @param[out] result A pointer to store the number of bytes written. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*String_GetUTF8)(ani_env *env, ani_string string, char *utf8_buffer, ani_size utf8_buffer_size, + ani_size *result); + + /** + * @brief Retrieves a substring of a UTF-8 string. + * + * This function copies a portion of the UTF-8 string into the provided buffer. + * + * @param[in] env A pointer to the environment structure. + * @param[in] string The string to retrieve data from. + * @param[in] substr_offset The starting offset of the substring. + * @param[in] substr_size The size of the substring in bytes. + * @param[out] utf8_buffer A buffer to store the substring. + * @param[in] utf8_buffer_size The size of the buffer in bytes. + * @param[out] result A pointer to store the number of bytes written. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*String_GetUTF8SubString)(ani_env *env, ani_string string, ani_size substr_offset, ani_size substr_size, + char *utf8_buffer, ani_size utf8_buffer_size, ani_size *result); + + /** + * @brief Retrieves the length of an array. + * + * This function retrieves the length of the specified array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] array The array whose length is to be retrieved. + * @param[out] result A pointer to store the length of the array. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Array_GetLength)(ani_env *env, ani_array array, ani_size *result); + + /** + * @brief Creates a new array of booleans. + * + * This function creates a new array of the specified length for boolean values. + * + * @param[in] env A pointer to the environment structure. + * @param[in] length The length of the array to be created. + * @param[out] result A pointer to store the created array. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Array_New_Boolean)(ani_env *env, ani_size length, ani_array_boolean *result); + + /** + * @brief Creates a new array of characters. + * + * This function creates a new array of the specified length for character values. + * + * @param[in] env A pointer to the environment structure. + * @param[in] length The length of the array to be created. + * @param[out] result A pointer to store the created array. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Array_New_Char)(ani_env *env, ani_size length, ani_array_char *result); + + /** + * @brief Creates a new array of bytes. + * + * This function creates a new array of the specified length for byte values. + * + * @param[in] env A pointer to the environment structure. + * @param[in] length The length of the array to be created. + * @param[out] result A pointer to store the created array. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Array_New_Byte)(ani_env *env, ani_size length, ani_array_byte *result); + + /** + * @brief Creates a new array of shorts. + * + * This function creates a new array of the specified length for short integer values. + * + * @param[in] env A pointer to the environment structure. + * @param[in] length The length of the array to be created. + * @param[out] result A pointer to store the created array. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Array_New_Short)(ani_env *env, ani_size length, ani_array_short *result); + + /** + * @brief Creates a new array of integers. + * + * This function creates a new array of the specified length for integer values. + * + * @param[in] env A pointer to the environment structure. + * @param[in] length The length of the array to be created. + * @param[out] result A pointer to store the created array. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Array_New_Int)(ani_env *env, ani_size length, ani_array_int *result); + + /** + * @brief Creates a new array of long integers. + * + * This function creates a new array of the specified length for long integer values. + * + * @param[in] env A pointer to the environment structure. + * @param[in] length The length of the array to be created. + * @param[out] result A pointer to store the created array. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Array_New_Long)(ani_env *env, ani_size length, ani_array_long *result); + + /** + * @brief Creates a new array of floats. + * + * This function creates a new array of the specified length for float values. + * + * @param[in] env A pointer to the environment structure. + * @param[in] length The length of the array to be created. + * @param[out] result A pointer to store the created array. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Array_New_Float)(ani_env *env, ani_size length, ani_array_float *result); + + /** + * @brief Creates a new array of doubles. + * + * This function creates a new array of the specified length for double values. + * + * @param[in] env A pointer to the environment structure. + * @param[in] length The length of the array to be created. + * @param[out] result A pointer to store the created array. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Array_New_Double)(ani_env *env, ani_size length, ani_array_double *result); + + /** + * @brief Retrieves a region of boolean values from an array. + * + * This function retrieves a portion of the specified boolean array into a native buffer. + * + * @param[in] env A pointer to the environment structure. + * @param[in] array The array to retrieve values from. + * @param[in] offset The starting offset of the region. + * @param[in] length The number of elements to retrieve. + * @param[out] native_buffer A buffer to store the retrieved boolean values. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Array_GetRegion_Boolean)(ani_env *env, ani_array_boolean array, ani_size offset, ani_size length, + ani_boolean *native_buffer); + + /** + * @brief Retrieves a region of character values from an array. + * + * This function retrieves a portion of the specified character array into a native buffer. + * + * @param[in] env A pointer to the environment structure. + * @param[in] array The array to retrieve values from. + * @param[in] offset The starting offset of the region. + * @param[in] length The number of elements to retrieve. + * @param[out] native_buffer A buffer to store the retrieved character values. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Array_GetRegion_Char)(ani_env *env, ani_array_char array, ani_size offset, ani_size length, + ani_char *native_buffer); + + /** + * @brief Retrieves a region of byte values from an array. + * + * This function retrieves a portion of the specified byte array into a native buffer. + * + * @param[in] env A pointer to the environment structure. + * @param[in] array The array to retrieve values from. + * @param[in] offset The starting offset of the region. + * @param[in] length The number of elements to retrieve. + * @param[out] native_buffer A buffer to store the retrieved byte values. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Array_GetRegion_Byte)(ani_env *env, ani_array_byte array, ani_size offset, ani_size length, + ani_byte *native_buffer); + + /** + * @brief Retrieves a region of short values from an array. + * + * This function retrieves a portion of the specified short array into a native buffer. + * + * @param[in] env A pointer to the environment structure. + * @param[in] array The array to retrieve values from. + * @param[in] offset The starting offset of the region. + * @param[in] length The number of elements to retrieve. + * @param[out] native_buffer A buffer to store the retrieved short values. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Array_GetRegion_Short)(ani_env *env, ani_array_short array, ani_size offset, ani_size length, + ani_short *native_buffer); + + /** + * @brief Retrieves a region of integer values from an array. + * + * This function retrieves a portion of the specified integer array into a native buffer. + * + * @param[in] env A pointer to the environment structure. + * @param[in] array The array to retrieve values from. + * @param[in] offset The starting offset of the region. + * @param[in] length The number of elements to retrieve. + * @param[out] native_buffer A buffer to store the retrieved integer values. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Array_GetRegion_Int)(ani_env *env, ani_array_int array, ani_size offset, ani_size length, + ani_int *native_buffer); + + /** + * @brief Retrieves a region of long integer values from an array. + * + * This function retrieves a portion of the specified long integer array into a native buffer. + * + * @param[in] env A pointer to the environment structure. + * @param[in] array The array to retrieve values from. + * @param[in] offset The starting offset of the region. + * @param[in] length The number of elements to retrieve. + * @param[out] native_buffer A buffer to store the retrieved long integer values. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Array_GetRegion_Long)(ani_env *env, ani_array_long array, ani_size offset, ani_size length, + ani_long *native_buffer); + + /** + * @brief Retrieves a region of float values from an array. + * + * This function retrieves a portion of the specified float array into a native buffer. + * + * @param[in] env A pointer to the environment structure. + * @param[in] array The array to retrieve values from. + * @param[in] offset The starting offset of the region. + * @param[in] length The number of elements to retrieve. + * @param[out] native_buffer A buffer to store the retrieved float values. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Array_GetRegion_Float)(ani_env *env, ani_array_float array, ani_size offset, ani_size length, + ani_float *native_buffer); + + /** + * @brief Retrieves a region of double values from an array. + * + * This function retrieves a portion of the specified double array into a native buffer. + * + * @param[in] env A pointer to the environment structure. + * @param[in] array The array to retrieve values from. + * @param[in] offset The starting offset of the region. + * @param[in] length The number of elements to retrieve. + * @param[out] native_buffer A buffer to store the retrieved double values. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Array_GetRegion_Double)(ani_env *env, ani_array_double array, ani_size offset, ani_size length, + ani_double *native_buffer); + + /** + * @brief Sets a region of boolean values in an array. + * + * This function sets a portion of the specified boolean array using a native buffer. + * + * @param[in] env A pointer to the environment structure. + * @param[in] array The array to set values in. + * @param[in] offset The starting offset of the region. + * @param[in] length The number of elements to set. + * @param[in] native_buffer A buffer containing the boolean values to set. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Array_SetRegion_Boolean)(ani_env *env, ani_array_boolean array, ani_size offset, ani_size length, + const ani_boolean *native_buffer); + + /** + * @brief Sets a region of character values in an array. + * + * This function sets a portion of the specified character array using a native buffer. + * + * @param[in] env A pointer to the environment structure. + * @param[in] array The array to set values in. + * @param[in] offset The starting offset of the region. + * @param[in] length The number of elements to set. + * @param[in] native_buffer A buffer containing the character values to set. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Array_SetRegion_Char)(ani_env *env, ani_array_char array, ani_size offset, ani_size length, + const ani_char *native_buffer); + + /** + * @brief Sets a region of byte values in an array. + * + * This function sets a portion of the specified byte array using a native buffer. + * + * @param[in] env A pointer to the environment structure. + * @param[in] array The array to set values in. + * @param[in] offset The starting offset of the region. + * @param[in] length The number of elements to set. + * @param[in] native_buffer A buffer containing the byte values to set. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Array_SetRegion_Byte)(ani_env *env, ani_array_byte array, ani_size offset, ani_size length, + const ani_byte *native_buffer); + + /** + * @brief Sets a region of short values in an array. + * + * This function sets a portion of the specified short array using a native buffer. + * + * @param[in] env A pointer to the environment structure. + * @param[in] array The array to set values in. + * @param[in] offset The starting offset of the region. + * @param[in] length The number of elements to set. + * @param[in] native_buffer A buffer containing the short values to set. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Array_SetRegion_Short)(ani_env *env, ani_array_short array, ani_size offset, ani_size length, + const ani_short *native_buffer); + + /** + * @brief Sets a region of integer values in an array. + * + * This function sets a portion of the specified integer array using a native buffer. + * + * @param[in] env A pointer to the environment structure. + * @param[in] array The array to set values in. + * @param[in] offset The starting offset of the region. + * @param[in] length The number of elements to set. + * @param[in] native_buffer A buffer containing the integer values to set. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Array_SetRegion_Int)(ani_env *env, ani_array_int array, ani_size offset, ani_size length, + const ani_int *native_buffer); + + /** + * @brief Sets a region of long integer values in an array. + * + * This function sets a portion of the specified long integer array using a native buffer. + * + * @param[in] env A pointer to the environment structure. + * @param[in] array The array to set values in. + * @param[in] offset The starting offset of the region. + * @param[in] length The number of elements to set. + * @param[in] native_buffer A buffer containing the long integer values to set. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Array_SetRegion_Long)(ani_env *env, ani_array_long array, ani_size offset, ani_size length, + const ani_long *native_buffer); + + /** + * @brief Sets a region of float values in an array. + * + * This function sets a portion of the specified float array using a native buffer. + * + * @param[in] env A pointer to the environment structure. + * @param[in] array The array to set values in. + * @param[in] offset The starting offset of the region. + * @param[in] length The number of elements to set. + * @param[in] native_buffer A buffer containing the float values to set. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Array_SetRegion_Float)(ani_env *env, ani_array_float array, ani_size offset, ani_size length, + const ani_float *native_buffer); + + /** + * @brief Sets a region of double values in an array. + * + * This function sets a portion of the specified double array using a native buffer. + * + * @param[in] env A pointer to the environment structure. + * @param[in] array The array to set values in. + * @param[in] offset The starting offset of the region. + * @param[in] length The number of elements to set. + * @param[in] native_buffer A buffer containing the double values to set. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Array_SetRegion_Double)(ani_env *env, ani_array_double array, ani_size offset, ani_size length, + const ani_double *native_buffer); + + /** + * @brief Creates a new array of references. + * + * This function creates a new array of references, optionally initializing it with an array of references. + * + * @param[in] env A pointer to the environment structure. + * @param[in] type The type of the elements of the array. + * @param[in] length The length of the array to be created. + * @param[in] initial_element An optional reference to initialize the array. Can be null. + * @param[out] result A pointer to store the created array of references. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Array_New_Ref)(ani_env *env, ani_type type, ani_size length, ani_ref initial_element, + ani_array_ref *result); + + /** + * @brief Sets a reference at a specific index in an array. + * + * This function sets the value of a reference at the specified index in the array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] array The array of references to modify. + * @param[in] index The index at which to set the reference. + * @param[in] ref The reference to set at the specified index. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Array_Set_Ref)(ani_env *env, ani_array_ref array, ani_size index, ani_ref ref); + + /** + * @brief Retrieves a reference from a specific index in an array. + * + * This function retrieves the value of a reference at the specified index in the array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] array The array of references to query. + * @param[in] index The index from which to retrieve the reference. + * @param[out] result A pointer to store the retrieved reference. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Array_Get_Ref)(ani_env *env, ani_array_ref array, ani_size index, ani_ref *result); + + /** + * @brief Retrieves an enum item by its name. + * + * This function retrieves an enum item associated with the specified name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] enm The enum to search within. + * @param[in] name The name of the enum item to retrieve. + * @param[out] result A pointer to store the retrieved enum item. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Enum_GetEnumItemByName)(ani_env *env, ani_enum enm, const char *name, ani_enum_item *result); + + /** + * @brief Retrieves an enum item by its index. + * + * This function retrieves an enum item located at the specified index. + * + * @param[in] env A pointer to the environment structure. + * @param[in] enm The enum to search within. + * @param[in] index The index of the enum item to retrieve. + * @param[out] result A pointer to store the retrieved enum item. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Enum_GetEnumItemByIndex)(ani_env *env, ani_enum enm, ani_size index, ani_enum_item *result); + + /** + * @brief Retrieves the enum associated with an enum item. + * + * This function retrieves the enum to which the specified enum item belongs. + * + * @param[in] env A pointer to the environment structure. + * @param[in] enum_item The enum item whose associated enum is to be retrieved. + * @param[out] result A pointer to store the retrieved enum. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*EnumItem_GetEnum)(ani_env *env, ani_enum_item enum_item, ani_enum *result); + + /** + * @brief Retrieves the integer value of an enum item. + * + * This function retrieves the integer representing the value of the specified enum item. + * + * @param[in] env A pointer to the environment structure. + * @param[in] enum_item The enum item whose underlying value is to be retrieved. + * @param[out] result A pointer to store the retrieved integer. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*EnumItem_GetValue_Int)(ani_env *env, ani_enum_item enum_item, ani_int *result); + + /** + * @brief Retrieves the string value of an enum item. + * + * This function retrieves the string representing the value of the specified enum item. + * + * @param[in] env A pointer to the environment structure. + * @param[in] enum_item The enum item whose underlying value is to be retrieved. + * @param[out] result A pointer to store the retrieved string. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*EnumItem_GetValue_String)(ani_env *env, ani_enum_item enum_item, ani_string *result); + + /** + * @brief Retrieves the name of an enum item. + * + * This function retrieves the name associated with the specified enum item. + * + * @param[in] env A pointer to the environment structure. + * @param[in] enum_item The enum item whose name is to be retrieved. + * @param[out] result A pointer to store the retrieved name. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*EnumItem_GetName)(ani_env *env, ani_enum_item enum_item, ani_string *result); + + /** + * @brief Retrieves the index of an enum item. + * + * This function retrieves the index of the specified enum item within its enum. + * + * @param[in] env A pointer to the environment structure. + * @param[in] enum_item The enum item whose index is to be retrieved. + * @param[out] result A pointer to store the retrieved index. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*EnumItem_GetIndex)(ani_env *env, ani_enum_item enum_item, ani_size *result); + + /** + * @brief Invokes a functional object. + * + * This function invokes a functional object (e.g., a function or callable object) with the specified arguments. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The functional object to invoke. + * @param[in] argc The number of arguments being passed to the functional object. + * @param[in] argv A pointer to an array of references representing the arguments. Can be null if `argc` is 0. + * @param[out] result A pointer to store the result of the invocation. Must be non null. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FunctionalObject_Call)(ani_env *env, ani_fn_object fn, ani_size argc, ani_ref *argv, ani_ref *result); + + /** + * @brief Sets a boolean value to a variable. + * + * This function assigns a boolean value to the specified variable. + * + * @param[in] env A pointer to the environment structure. + * @param[in] variable The variable to modify. + * @param[in] value The boolean value to assign to the variable. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Variable_SetValue_Boolean)(ani_env *env, ani_variable variable, ani_boolean value); + + /** + * @brief Sets a character value to a variable. + * + * This function assigns a character value to the specified variable. + * + * @param[in] env A pointer to the environment structure. + * @param[in] variable The variable to modify. + * @param[in] value The character value to assign to the variable. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Variable_SetValue_Char)(ani_env *env, ani_variable variable, ani_char value); + + /** + * @brief Sets a byte value to a variable. + * + * This function assigns a byte value to the specified variable. + * + * @param[in] env A pointer to the environment structure. + * @param[in] variable The variable to modify. + * @param[in] value The byte value to assign to the variable. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Variable_SetValue_Byte)(ani_env *env, ani_variable variable, ani_byte value); + + /** + * @brief Sets a short value to a variable. + * + * This function assigns a short integer value to the specified variable. + * + * @param[in] env A pointer to the environment structure. + * @param[in] variable The variable to modify. + * @param[in] value The short integer value to assign to the variable. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Variable_SetValue_Short)(ani_env *env, ani_variable variable, ani_short value); + + /** + * @brief Sets an integer value to a variable. + * + * This function assigns an integer value to the specified variable. + * + * @param[in] env A pointer to the environment structure. + * @param[in] variable The variable to modify. + * @param[in] value The integer value to assign to the variable. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Variable_SetValue_Int)(ani_env *env, ani_variable variable, ani_int value); + + /** + * @brief Sets a long value to a variable. + * + * This function assigns a long integer value to the specified variable. + * + * @param[in] env A pointer to the environment structure. + * @param[in] variable The variable to modify. + * @param[in] value The long integer value to assign to the variable. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Variable_SetValue_Long)(ani_env *env, ani_variable variable, ani_long value); + + /** + * @brief Sets a float value to a variable. + * + * This function assigns a float value to the specified variable. + * + * @param[in] env A pointer to the environment structure. + * @param[in] variable The variable to modify. + * @param[in] value The float value to assign to the variable. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Variable_SetValue_Float)(ani_env *env, ani_variable variable, ani_float value); + + /** + * @brief Sets a double value to a variable. + * + * This function assigns a double value to the specified variable. + * + * @param[in] env A pointer to the environment structure. + * @param[in] variable The variable to modify. + * @param[in] value The double value to assign to the variable. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Variable_SetValue_Double)(ani_env *env, ani_variable variable, ani_double value); + + /** + * @brief Sets a reference value to a variable. + * + * This function assigns a reference value to the specified variable. + * + * @param[in] env A pointer to the environment structure. + * @param[in] variable The variable to modify. + * @param[in] value The reference value to assign to the variable. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Variable_SetValue_Ref)(ani_env *env, ani_variable variable, ani_ref value); + + /** + * @brief Retrieves a boolean value from a variable. + * + * This function fetches a boolean value from the specified variable. + * + * @param[in] env A pointer to the environment structure. + * @param[in] variable The variable to query. + * @param[out] result A pointer to store the retrieved boolean value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Variable_GetValue_Boolean)(ani_env *env, ani_variable variable, ani_boolean *result); + + /** + * @brief Retrieves a character value from a variable. + * + * This function fetches a character value from the specified variable. + * + * @param[in] env A pointer to the environment structure. + * @param[in] variable The variable to query. + * @param[out] result A pointer to store the retrieved character value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Variable_GetValue_Char)(ani_env *env, ani_variable variable, ani_char *result); + + /** + * @brief Retrieves a byte value from a variable. + * + * This function fetches a byte value from the specified variable. + * + * @param[in] env A pointer to the environment structure. + * @param[in] variable The variable to query. + * @param[out] result A pointer to store the retrieved byte value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Variable_GetValue_Byte)(ani_env *env, ani_variable variable, ani_byte *result); + + /** + * @brief Retrieves a short value from a variable. + * + * This function fetches a short integer value from the specified variable. + * + * @param[in] env A pointer to the environment structure. + * @param[in] variable The variable to query. + * @param[out] result A pointer to store the retrieved short integer value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Variable_GetValue_Short)(ani_env *env, ani_variable variable, ani_short *result); + + /** + * @brief Retrieves an integer value from a variable. + * + * This function fetches an integer value from the specified variable. + * + * @param[in] env A pointer to the environment structure. + * @param[in] variable The variable to query. + * @param[out] result A pointer to store the retrieved integer value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Variable_GetValue_Int)(ani_env *env, ani_variable variable, ani_int *result); + + /** + * @brief Retrieves a long value from a variable. + * + * This function fetches a long integer value from the specified variable. + * + * @param[in] env A pointer to the environment structure. + * @param[in] variable The variable to query. + * @param[out] result A pointer to store the retrieved long integer value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Variable_GetValue_Long)(ani_env *env, ani_variable variable, ani_long *result); + + /** + * @brief Retrieves a float value from a variable. + * + * This function fetches a float value from the specified variable. + * + * @param[in] env A pointer to the environment structure. + * @param[in] variable The variable to query. + * @param[out] result A pointer to store the retrieved float value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Variable_GetValue_Float)(ani_env *env, ani_variable variable, ani_float *result); + + /** + * @brief Retrieves a double value from a variable. + * + * This function fetches a double value from the specified variable. + * + * @param[in] env A pointer to the environment structure. + * @param[in] variable The variable to query. + * @param[out] result A pointer to store the retrieved double value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Variable_GetValue_Double)(ani_env *env, ani_variable variable, ani_double *result); + + /** + * @brief Retrieves a reference value from a variable. + * + * This function fetches a reference value from the specified variable. + * + * @param[in] env A pointer to the environment structure. + * @param[in] variable The variable to query. + * @param[out] result A pointer to store the retrieved reference value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Variable_GetValue_Ref)(ani_env *env, ani_variable variable, ani_ref *result); + + /** + * @brief Calls a function and retrieves a boolean result. + * + * This function calls the specified function with variadic arguments and retrieves a boolean result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the boolean result. + * @param[in] ... Variadic arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Boolean)(ani_env *env, ani_function fn, ani_boolean *result, ...); + + /** + * @brief Calls a function and retrieves a boolean result (array-based). + * + * This function calls the specified function with arguments provided in an array and retrieves a boolean result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the boolean result. + * @param[in] args A pointer to an array of arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Boolean_A)(ani_env *env, ani_function fn, ani_boolean *result, const ani_value *args); + + /** + * @brief Calls a function and retrieves a boolean result (variadic arguments). + * + * This function calls the specified function with arguments provided in a `va_list` and retrieves a boolean result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the boolean result. + * @param[in] args A `va_list` containing the arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Boolean_V)(ani_env *env, ani_function fn, ani_boolean *result, va_list args); + + /** + * @brief Calls a function and retrieves a character result. + * + * This function calls the specified function with variadic arguments and retrieves a character result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the character result. + * @param[in] ... Variadic arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Char)(ani_env *env, ani_function fn, ani_char *result, ...); + + /** + * @brief Calls a function and retrieves a character result (array-based). + * + * This function calls the specified function with arguments provided in an array and retrieves a character result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the character result. + * @param[in] args A pointer to an array of arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Char_A)(ani_env *env, ani_function fn, ani_char *result, const ani_value *args); + + /** + * @brief Calls a function and retrieves a character result (variadic arguments). + * + * This function calls the specified function with arguments provided in a `va_list` and retrieves a character + * result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the character result. + * @param[in] args A `va_list` containing the arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Char_V)(ani_env *env, ani_function fn, ani_char *result, va_list args); + + /** + * @brief Calls a function and retrieves a byte result. + * + * This function calls the specified function with variadic arguments and retrieves a byte result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the byte result. + * @param[in] ... Variadic arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Byte)(ani_env *env, ani_function fn, ani_byte *result, ...); + + /** + * @brief Calls a function and retrieves a byte result (array-based). + * + * This function calls the specified function with arguments provided in an array and retrieves a byte result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the byte result. + * @param[in] args A pointer to an array of arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Byte_A)(ani_env *env, ani_function fn, ani_byte *result, const ani_value *args); + + /** + * @brief Calls a function and retrieves a byte result (variadic arguments). + * + * This function calls the specified function with arguments provided in a `va_list` and retrieves a byte result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the byte result. + * @param[in] args A `va_list` containing the arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Byte_V)(ani_env *env, ani_function fn, ani_byte *result, va_list args); + + /** + * @brief Calls a function and retrieves a short result. + * + * This function calls the specified function with variadic arguments and retrieves a short result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the short result. + * @param[in] ... Variadic arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Short)(ani_env *env, ani_function fn, ani_short *result, ...); + + /** + * @brief Calls a function and retrieves a short result (array-based). + * + * This function calls the specified function with arguments provided in an array and retrieves a short result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the short result. + * @param[in] args A pointer to an array of arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Short_A)(ani_env *env, ani_function fn, ani_short *result, const ani_value *args); + + /** + * @brief Calls a function and retrieves a short result (variadic arguments). + * + * This function calls the specified function with arguments provided in a `va_list` and retrieves a short result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the short result. + * @param[in] args A `va_list` containing the arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Short_V)(ani_env *env, ani_function fn, ani_short *result, va_list args); + + /** + * @brief Calls a function and retrieves an integer result. + * + * This function calls the specified function with variadic arguments and retrieves an integer result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the integer result. + * @param[in] ... Variadic arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Int)(ani_env *env, ani_function fn, ani_int *result, ...); + + /** + * @brief Calls a function and retrieves an integer result (array-based). + * + * This function calls the specified function with arguments provided in an array and retrieves an integer result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the integer result. + * @param[in] args A pointer to an array of arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Int_A)(ani_env *env, ani_function fn, ani_int *result, const ani_value *args); + + /** + * @brief Calls a function and retrieves an integer result (variadic arguments). + * + * This function calls the specified function with arguments provided in a `va_list` and retrieves an integer + * result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the integer result. + * @param[in] args A `va_list` containing the arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Int_V)(ani_env *env, ani_function fn, ani_int *result, va_list args); + + /** + * @brief Calls a function and retrieves a long result. + * + * This function calls the specified function with variadic arguments and retrieves a long result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the long result. + * @param[in] ... Variadic arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Long)(ani_env *env, ani_function fn, ani_long *result, ...); + + /** + * @brief Calls a function and retrieves a long result (array-based). + * + * This function calls the specified function with arguments provided in an array and retrieves a long result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the long result. + * @param[in] args A pointer to an array of arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Long_A)(ani_env *env, ani_function fn, ani_long *result, const ani_value *args); + + /** + * @brief Calls a function and retrieves a long result (variadic arguments). + * + * This function calls the specified function with arguments provided in a `va_list` and retrieves a long result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the long result. + * @param[in] args A `va_list` containing the arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Long_V)(ani_env *env, ani_function fn, ani_long *result, va_list args); + + /** + * @brief Calls a function and retrieves a float result. + * + * This function calls the specified function with variadic arguments and retrieves a float result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the float result. + * @param[in] ... Variadic arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Float)(ani_env *env, ani_function fn, ani_float *result, ...); + + /** + * @brief Calls a function and retrieves a float result (array-based). + * + * This function calls the specified function with arguments provided in an array and retrieves a float result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the float result. + * @param[in] args A pointer to an array of arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Float_A)(ani_env *env, ani_function fn, ani_float *result, const ani_value *args); + + /** + * @brief Calls a function and retrieves a float result (variadic arguments). + * + * This function calls the specified function with arguments provided in a `va_list` and retrieves a float result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the float result. + * @param[in] args A `va_list` containing the arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Float_V)(ani_env *env, ani_function fn, ani_float *result, va_list args); + + /** + * @brief Calls a function and retrieves a double result. + * + * This function calls the specified function with variadic arguments and retrieves a double result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the double result. + * @param[in] ... Variadic arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Double)(ani_env *env, ani_function fn, ani_double *result, ...); + + /** + * @brief Calls a function and retrieves a double result (array-based). + * + * This function calls the specified function with arguments provided in an array and retrieves a double result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the double result. + * @param[in] args A pointer to an array of arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Double_A)(ani_env *env, ani_function fn, ani_double *result, const ani_value *args); + + /** + * @brief Calls a function and retrieves a double result (variadic arguments). + * + * This function calls the specified function with arguments provided in a `va_list` and retrieves a double result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the double result. + * @param[in] args A `va_list` containing the arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Double_V)(ani_env *env, ani_function fn, ani_double *result, va_list args); + + /** + * @brief Calls a function and retrieves a reference result. + * + * This function calls the specified function with variadic arguments and retrieves a reference result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the reference result. + * @param[in] ... Variadic arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Ref)(ani_env *env, ani_function fn, ani_ref *result, ...); + + /** + * @brief Calls a function and retrieves a reference result (array-based). + * + * This function calls the specified function with arguments provided in an array and retrieves a reference result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the reference result. + * @param[in] args A pointer to an array of arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Ref_A)(ani_env *env, ani_function fn, ani_ref *result, const ani_value *args); + + /** + * @brief Calls a function and retrieves a reference result (variadic arguments). + * + * This function calls the specified function with arguments provided in a `va_list` and retrieves a reference + * result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the reference result. + * @param[in] args A `va_list` containing the arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Ref_V)(ani_env *env, ani_function fn, ani_ref *result, va_list args); + + /** + * @brief Calls a function without returning a result. + * + * This function calls the specified function with variadic arguments and does not return a result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[in] ... Variadic arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Void)(ani_env *env, ani_function fn, ...); + + /** + * @brief Calls a function without returning a result (array-based). + * + * This function calls the specified function with arguments provided in an array and does not return a result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[in] args A pointer to an array of arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Void_A)(ani_env *env, ani_function fn, const ani_value *args); + + /** + * @brief Calls a function without returning a result (variadic arguments). + * + * This function calls the specified function with arguments provided in a `va_list` and does not return a result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[in] args A `va_list` containing the arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Void_V)(ani_env *env, ani_function fn, va_list args); + + /** + * @brief Finds a field from by its name. + * + * This function locates a field based on its name and stores it in the result parameter. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class to query. + * @param[in] name The name of the field to find. + * @param[out] result A pointer to the field to be populated. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_FindField)(ani_env *env, ani_class cls, const char *name, ani_field *result); + + /** + * @brief Finds a static field by its name. + * + * This function locates a static field based on its name and stores it in the result parameter. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class to query. + * @param[in] name The name of the static field to find. + * @param[out] result A pointer to the static field to be populated. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_FindStaticField)(ani_env *env, ani_class cls, const char *name, ani_static_field *result); + + /** + * @brief Finds a method from by its name and signature. + * + * This function locates a method based on its name and signature and stores it in the result parameter. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class to query. + * @param[in] name The name of the method to find. + * @param[in] signature The signature of the method to find. + * @param[out] result A pointer to the method to be populated. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_FindMethod)(ani_env *env, ani_class cls, const char *name, const char *signature, + ani_method *result); + + /** + * @brief Finds a static method from by its name and signature. + * + * This function locates a static method based on its name and signature and stores it in the result parameter. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class to query. + * @param[in] name The name of the static method to find. + * @param[in] signature The signature of the static method to find. + * @param[out] result A pointer to the static method to be populated. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_FindStaticMethod)(ani_env *env, ani_class cls, const char *name, const char *signature, + ani_static_method *result); + + /** + * @brief Finds a setter method from by its name. + * + * This function locates a setter method based on its name and stores it in the result parameter. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class to query. + * @param[in] name The name of the property whose setter is to be found. + * @param[out] result A pointer to the method to be populated. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_FindSetter)(ani_env *env, ani_class cls, const char *name, ani_method *result); + + /** + * @brief Finds a getter method from by its name. + * + * This function locates a getter method based on its name and stores it in the result parameter. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class to query. + * @param[in] name The name of the property whose getter is to be found. + * @param[out] result A pointer to the method to be populated. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_FindGetter)(ani_env *env, ani_class cls, const char *name, ani_method *result); + + /** + * @brief Finds an indexable getter method from by its signature. + * + * This function locates an indexable getter method based on its signature and stores it in the result parameter. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class to query. + * @param[in] signature The signature of the indexable getter to find. + * @param[out] result A pointer to the method to be populated. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_FindIndexableGetter)(ani_env *env, ani_class cls, const char *signature, ani_method *result); + + /** + * @brief Finds an indexable setter method from by its signature. + * + * This function locates an indexable setter method based on its signature and stores it in the result parameter. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class to query. + * @param[in] signature The signature of the indexable setter to find. + * @param[out] result A pointer to the method to be populated. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_FindIndexableSetter)(ani_env *env, ani_class cls, const char *signature, ani_method *result); + + /** + * @brief Finds an iterator method. + * + * This function locates an iterator method + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class to query. + * @param[out] result A pointer to the method to be populated. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_FindIterator)(ani_env *env, ani_class cls, ani_method *result); + + /** + * @brief Retrieves a boolean value from a static field of a class. + * + * This function retrieves the boolean value of the specified static field from the given class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] field The static field to retrieve. + * @param[out] result A pointer to store the retrieved boolean value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetStaticField_Boolean)(ani_env *env, ani_class cls, ani_static_field field, + ani_boolean *result); + + /** + * @brief Retrieves a character value from a static field of a class. + * + * This function retrieves the character value of the specified static field from the given class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] field The static field to retrieve. + * @param[out] result A pointer to store the retrieved character value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetStaticField_Char)(ani_env *env, ani_class cls, ani_static_field field, ani_char *result); + + /** + * @brief Retrieves a byte value from a static field of a class. + * + * This function retrieves the byte value of the specified static field from the given class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] field The static field to retrieve. + * @param[out] result A pointer to store the retrieved byte value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetStaticField_Byte)(ani_env *env, ani_class cls, ani_static_field field, ani_byte *result); + + /** + * @brief Retrieves a short value from a static field of a class. + * + * This function retrieves the short value of the specified static field from the given class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] field The static field to retrieve. + * @param[out] result A pointer to store the retrieved short value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetStaticField_Short)(ani_env *env, ani_class cls, ani_static_field field, ani_short *result); + + /** + * @brief Retrieves an integer value from a static field of a class. + * + * This function retrieves the integer value of the specified static field from the given class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] field The static field to retrieve. + * @param[out] result A pointer to store the retrieved integer value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetStaticField_Int)(ani_env *env, ani_class cls, ani_static_field field, ani_int *result); + + /** + * @brief Retrieves a long value from a static field of a class. + * + * This function retrieves the long value of the specified static field from the given class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] field The static field to retrieve. + * @param[out] result A pointer to store the retrieved long value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetStaticField_Long)(ani_env *env, ani_class cls, ani_static_field field, ani_long *result); + + /** + * @brief Retrieves a float value from a static field of a class. + * + * This function retrieves the float value of the specified static field from the given class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] field The static field to retrieve. + * @param[out] result A pointer to store the retrieved float value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetStaticField_Float)(ani_env *env, ani_class cls, ani_static_field field, ani_float *result); + + /** + * @brief Retrieves a double value from a static field of a class. + * + * This function retrieves the double value of the specified static field from the given class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] field The static field to retrieve. + * @param[out] result A pointer to store the retrieved double value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetStaticField_Double)(ani_env *env, ani_class cls, ani_static_field field, ani_double *result); + + /** + * @brief Retrieves a reference value from a static field of a class. + * + * This function retrieves the reference value of the specified static field from the given class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] field The static field to retrieve. + * @param[out] result A pointer to store the retrieved reference value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetStaticField_Ref)(ani_env *env, ani_class cls, ani_static_field field, ani_ref *result); + + /** + * @brief Sets a boolean value to a static field of a class. + * + * This function assigns a boolean value to the specified static field of the given class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] field The static field to modify. + * @param[in] value The boolean value to assign. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_SetStaticField_Boolean)(ani_env *env, ani_class cls, ani_static_field field, ani_boolean value); + + /** + * @brief Sets a character value to a static field of a class. + * + * This function assigns a character value to the specified static field of the given class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] field The static field to modify. + * @param[in] value The character value to assign. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_SetStaticField_Char)(ani_env *env, ani_class cls, ani_static_field field, ani_char value); + + /** + * @brief Sets a byte value to a static field of a class. + * + * This function assigns a byte value to the specified static field of the given class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] field The static field to modify. + * @param[in] value The byte value to assign. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_SetStaticField_Byte)(ani_env *env, ani_class cls, ani_static_field field, ani_byte value); + + /** + * @brief Sets a short value to a static field of a class. + * + * This function assigns a short value to the specified static field of the given class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] field The static field to modify. + * @param[in] value The short value to assign. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_SetStaticField_Short)(ani_env *env, ani_class cls, ani_static_field field, ani_short value); + + /** + * @brief Sets an integer value to a static field of a class. + * + * This function assigns an integer value to the specified static field of the given class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] field The static field to modify. + * @param[in] value The integer value to assign. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_SetStaticField_Int)(ani_env *env, ani_class cls, ani_static_field field, ani_int value); + + /** + * @brief Sets a long value to a static field of a class. + * + * This function assigns a long value to the specified static field of the given class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] field The static field to modify. + * @param[in] value The long value to assign. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_SetStaticField_Long)(ani_env *env, ani_class cls, ani_static_field field, ani_long value); + + /** + * @brief Sets a float value to a static field of a class. + * + * This function assigns a float value to the specified static field of the given class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] field The static field to modify. + * @param[in] value The float value to assign. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_SetStaticField_Float)(ani_env *env, ani_class cls, ani_static_field field, ani_float value); + + /** + * @brief Sets a double value to a static field of a class. + * + * This function assigns a double value to the specified static field of the given class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] field The static field to modify. + * @param[in] value The double value to assign. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_SetStaticField_Double)(ani_env *env, ani_class cls, ani_static_field field, ani_double value); + + /** + * @brief Sets a reference value to a static field of a class. + * + * This function assigns a reference value to the specified static field of the given class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] field The static field to modify. + * @param[in] value The reference value to assign. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_SetStaticField_Ref)(ani_env *env, ani_class cls, ani_static_field field, ani_ref value); + + /** + * @brief Retrieves a boolean value from a static field of a class by its name. + * + * This function retrieves the boolean value of the specified static field from the given class by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] name The name of the static field to retrieve. + * @param[out] result A pointer to store the retrieved boolean value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetStaticFieldByName_Boolean)(ani_env *env, ani_class cls, const char *name, + ani_boolean *result); + + /** + * @brief Retrieves a character value from a static field of a class by its name. + * + * This function retrieves the character value of the specified static field from the given class by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] name The name of the static field to retrieve. + * @param[out] result A pointer to store the retrieved character value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetStaticFieldByName_Char)(ani_env *env, ani_class cls, const char *name, ani_char *result); + + /** + * @brief Retrieves a byte value from a static field of a class by its name. + * + * This function retrieves the byte value of the specified static field from the given class by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] name The name of the static field to retrieve. + * @param[out] result A pointer to store the retrieved byte value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetStaticFieldByName_Byte)(ani_env *env, ani_class cls, const char *name, ani_byte *result); + + /** + * @brief Retrieves a short value from a static field of a class by its name. + * + * This function retrieves the short value of the specified static field from the given class by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] name The name of the static field to retrieve. + * @param[out] result A pointer to store the retrieved short value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetStaticFieldByName_Short)(ani_env *env, ani_class cls, const char *name, ani_short *result); + + /** + * @brief Retrieves an integer value from a static field of a class by its name. + * + * This function retrieves the integer value of the specified static field from the given class by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] name The name of the static field to retrieve. + * @param[out] result A pointer to store the retrieved integer value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetStaticFieldByName_Int)(ani_env *env, ani_class cls, const char *name, ani_int *result); + + /** + * @brief Retrieves a long value from a static field of a class by its name. + * + * This function retrieves the long value of the specified static field from the given class by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] name The name of the static field to retrieve. + * @param[out] result A pointer to store the retrieved long value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetStaticFieldByName_Long)(ani_env *env, ani_class cls, const char *name, ani_long *result); + + /** + * @brief Retrieves a float value from a static field of a class by its name. + * + * This function retrieves the float value of the specified static field from the given class by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] name The name of the static field to retrieve. + * @param[out] result A pointer to store the retrieved float value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetStaticFieldByName_Float)(ani_env *env, ani_class cls, const char *name, ani_float *result); + + /** + * @brief Retrieves a double value from a static field of a class by its name. + * + * This function retrieves the double value of the specified static field from the given class by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] name The name of the static field to retrieve. + * @param[out] result A pointer to store the retrieved double value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetStaticFieldByName_Double)(ani_env *env, ani_class cls, const char *name, ani_double *result); + + /** + * @brief Retrieves a reference value from a static field of a class by its name. + * + * This function retrieves the reference value of the specified static field from the given class by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] name The name of the static field to retrieve. + * @param[out] result A pointer to store the retrieved reference value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetStaticFieldByName_Ref)(ani_env *env, ani_class cls, const char *name, ani_ref *result); + + /** + * @brief Sets a boolean value to a static field of a class by its name. + * + * This function assigns a boolean value to the specified static field of the given class by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] name The name of the static field to modify. + * @param[in] value The boolean value to assign. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_SetStaticFieldByName_Boolean)(ani_env *env, ani_class cls, const char *name, ani_boolean value); + + /** + * @brief Sets a character value to a static field of a class by its name. + * + * This function assigns a character value to the specified static field of the given class by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] name The name of the static field to modify. + * @param[in] value The character value to assign. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_SetStaticFieldByName_Char)(ani_env *env, ani_class cls, const char *name, ani_char value); + + /** + * @brief Sets a byte value to a static field of a class by its name. + * + * This function assigns a byte value to the specified static field of the given class by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] name The name of the static field to modify. + * @param[in] value The byte value to assign. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_SetStaticFieldByName_Byte)(ani_env *env, ani_class cls, const char *name, ani_byte value); + + /** + * @brief Sets a short value to a static field of a class by its name. + * + * This function assigns a short value to the specified static field of the given class by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] name The name of the static field to modify. + * @param[in] value The short value to assign. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_SetStaticFieldByName_Short)(ani_env *env, ani_class cls, const char *name, ani_short value); + + /** + * @brief Sets an integer value to a static field of a class by its name. + * + * This function assigns an integer value to the specified static field of the given class by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] name The name of the static field to modify. + * @param[in] value The integer value to assign. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_SetStaticFieldByName_Int)(ani_env *env, ani_class cls, const char *name, ani_int value); + + /** + * @brief Sets a long value to a static field of a class by its name. + * + * This function assigns a long value to the specified static field of the given class by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] name The name of the static field to modify. + * @param[in] value The long value to assign. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_SetStaticFieldByName_Long)(ani_env *env, ani_class cls, const char *name, ani_long value); + + /** + * @brief Sets a float value to a static field of a class by its name. + * + * This function assigns a float value to the specified static field of the given class by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] name The name of the static field to modify. + * @param[in] value The float value to assign. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_SetStaticFieldByName_Float)(ani_env *env, ani_class cls, const char *name, ani_float value); + + /** + * @brief Sets a double value to a static field of a class by its name. + * + * This function assigns a double value to the specified static field of the given class by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] name The name of the static field to modify. + * @param[in] value The double value to assign. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_SetStaticFieldByName_Double)(ani_env *env, ani_class cls, const char *name, ani_double value); + + /** + * @brief Sets a reference value to a static field of a class by its name. + * + * This function assigns a reference value to the specified static field of the given class by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] name The name of the static field to modify. + * @param[in] value The reference value to assign. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_SetStaticFieldByName_Ref)(ani_env *env, ani_class cls, const char *name, ani_ref value); + + /** + * @brief Calls a static method with a boolean return type. + * + * This function calls the specified static method of a class and retrieves a boolean result using variadic + * arguments. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the boolean result. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Boolean)(ani_env *env, ani_class cls, ani_static_method method, + ani_boolean *result, ...); + + /** + * @brief Calls a static method with a boolean return type (array-based). + * + * This function calls the specified static method of a class and retrieves a boolean result using arguments from an + * array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the boolean result. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Boolean_A)(ani_env *env, ani_class cls, ani_static_method method, + ani_boolean *result, const ani_value *args); + + /** + * @brief Calls a static method with a boolean return type (variadic arguments). + * + * This function calls the specified static method of a class and retrieves a boolean result using a `va_list`. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the boolean result. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Boolean_V)(ani_env *env, ani_class cls, ani_static_method method, + ani_boolean *result, va_list args); + + /** + * @brief Calls a static method with a character return type. + * + * This function calls the specified static method of a class and retrieves a character result using variadic + * arguments. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the character result. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Char)(ani_env *env, ani_class cls, ani_static_method method, ani_char *result, + ...); + + /** + * @brief Calls a static method with a character return type (array-based). + * + * This function calls the specified static method of a class and retrieves a character result using arguments from + * an array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the character result. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Char_A)(ani_env *env, ani_class cls, ani_static_method method, ani_char *result, + const ani_value *args); + + /** + * @brief Calls a static method with a character return type (variadic arguments). + * + * This function calls the specified static method of a class and retrieves a character result using a `va_list`. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the character result. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Char_V)(ani_env *env, ani_class cls, ani_static_method method, ani_char *result, + va_list args); + + /** + * @brief Calls a static method with a byte return type. + * + * This function calls the specified static method of a class and retrieves a byte result using variadic arguments. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the byte result. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Byte)(ani_env *env, ani_class cls, ani_static_method method, ani_byte *result, + ...); + + /** + * @brief Calls a static method with a byte return type (array-based). + * + * This function calls the specified static method of a class and retrieves a byte result using arguments from an + * array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the byte result. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Byte_A)(ani_env *env, ani_class cls, ani_static_method method, ani_byte *result, + const ani_value *args); + + /** + * @brief Calls a static method with a byte return type (variadic arguments). + * + * This function calls the specified static method of a class and retrieves a byte result using a `va_list`. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the byte result. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Byte_V)(ani_env *env, ani_class cls, ani_static_method method, ani_byte *result, + va_list args); + + /** + * @brief Calls a static method with a short return type. + * + * This function calls the specified static method of a class and retrieves a short result using variadic arguments. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the short result. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Short)(ani_env *env, ani_class cls, ani_static_method method, ani_short *result, + ...); + + /** + * @brief Calls a static method with a short return type (array-based). + * + * This function calls the specified static method of a class and retrieves a short result using arguments from an + * array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the short result. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Short_A)(ani_env *env, ani_class cls, ani_static_method method, + ani_short *result, const ani_value *args); + + /** + * @brief Calls a static method with a short return type (variadic arguments). + * + * This function calls the specified static method of a class and retrieves a short result using a `va_list`. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the short result. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Short_V)(ani_env *env, ani_class cls, ani_static_method method, + ani_short *result, va_list args); + + /** + * @brief Calls a static method with an integer return type. + * + * This function calls the specified static method of a class and retrieves an integer result using variadic + * arguments. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the integer result. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Int)(ani_env *env, ani_class cls, ani_static_method method, ani_int *result, + ...); + + /** + * @brief Calls a static method with an integer return type (array-based). + * + * This function calls the specified static method of a class and retrieves an integer result using arguments from + * an array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the integer result. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Int_A)(ani_env *env, ani_class cls, ani_static_method method, ani_int *result, + const ani_value *args); + + /** + * @brief Calls a static method with an integer return type (variadic arguments). + * + * This function calls the specified static method of a class and retrieves an integer result using a `va_list`. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the integer result. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Int_V)(ani_env *env, ani_class cls, ani_static_method method, ani_int *result, + va_list args); + + /** + * @brief Calls a static method with a long return type. + * + * This function calls the specified static method of a class and retrieves a long result using variadic arguments. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the long result. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Long)(ani_env *env, ani_class cls, ani_static_method method, ani_long *result, + ...); + + /** + * @brief Calls a static method with a long return type (array-based). + * + * This function calls the specified static method of a class and retrieves a long result using arguments from an + * array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the long result. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Long_A)(ani_env *env, ani_class cls, ani_static_method method, ani_long *result, + const ani_value *args); + + /** + * @brief Calls a static method with a long return type (variadic arguments). + * + * This function calls the specified static method of a class and retrieves a long result using a `va_list`. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the long result. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Long_V)(ani_env *env, ani_class cls, ani_static_method method, ani_long *result, + va_list args); + + /** + * @brief Calls a static method with a float return type. + * + * This function calls the specified static method of a class and retrieves a float result using variadic arguments. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the float result. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Float)(ani_env *env, ani_class cls, ani_static_method method, ani_float *result, + ...); + + /** + * @brief Calls a static method with a float return type (array-based). + * + * This function calls the specified static method of a class and retrieves a float result using arguments from an + * array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the float result. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Float_A)(ani_env *env, ani_class cls, ani_static_method method, + ani_float *result, const ani_value *args); + + /** + * @brief Calls a static method with a float return type (variadic arguments). + * + * This function calls the specified static method of a class and retrieves a float result using a `va_list`. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the float result. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Float_V)(ani_env *env, ani_class cls, ani_static_method method, + ani_float *result, va_list args); + + /** + * @brief Calls a static method with a double return type. + * + * This function calls the specified static method of a class and retrieves a double result using variadic + * arguments. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the double result. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Double)(ani_env *env, ani_class cls, ani_static_method method, + ani_double *result, ...); + + /** + * @brief Calls a static method with a double return type (array-based). + * + * This function calls the specified static method of a class and retrieves a double result using arguments from an + * array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the double result. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Double_A)(ani_env *env, ani_class cls, ani_static_method method, + ani_double *result, const ani_value *args); + + /** + * @brief Calls a static method with a double return type (variadic arguments). + * + * This function calls the specified static method of a class and retrieves a double result using a `va_list`. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the double result. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Double_V)(ani_env *env, ani_class cls, ani_static_method method, + ani_double *result, va_list args); + + /** + * @brief Calls a static method with a reference return type. + * + * This function calls the specified static method of a class and retrieves a reference result using variadic + * arguments. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the reference result. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Ref)(ani_env *env, ani_class cls, ani_static_method method, ani_ref *result, + ...); + + /** + * @brief Calls a static method with a reference return type (array-based). + * + * This function calls the specified static method of a class and retrieves a reference result using arguments from + * an array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the reference result. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Ref_A)(ani_env *env, ani_class cls, ani_static_method method, ani_ref *result, + const ani_value *args); + + /** + * @brief Calls a static method with a reference return type (variadic arguments). + * + * This function calls the specified static method of a class and retrieves a reference result using a `va_list`. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the reference result. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Ref_V)(ani_env *env, ani_class cls, ani_static_method method, ani_ref *result, + va_list args); + + /** + * @brief Calls a static method with no return value. + * + * This function calls the specified static method of a class using variadic arguments. The method does not return a + * value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Void)(ani_env *env, ani_class cls, ani_static_method method, ...); + + /** + * @brief Calls a static method with no return value (array-based). + * + * This function calls the specified static method of a class using arguments from an array. The method does not + * return a value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Void_A)(ani_env *env, ani_class cls, ani_static_method method, + const ani_value *args); + + /** + * @brief Calls a static method with no return value (variadic arguments). + * + * This function calls the specified static method of a class using a `va_list`. The method does not return a value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Void_V)(ani_env *env, ani_class cls, ani_static_method method, va_list args); + + /** + * @brief Calls a static method by name with a boolean return type. + * + * This function calls the specified static method of a class by its name and retrieves a boolean result using + * variadic arguments. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[in] signature The signature of the static method to call. + * @param[out] result A pointer to store the boolean result. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Boolean)(ani_env *env, ani_class cls, const char *name, + const char *signature, ani_boolean *result, ...); + + /** + * @brief Calls a static method by name with a boolean return type (array-based). + * + * This function calls the specified static method of a class by its name and retrieves a boolean result using + * arguments from an array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[in] signature The signature of the static method to call. + * @param[out] result A pointer to store the boolean result. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Boolean_A)(ani_env *env, ani_class cls, const char *name, + const char *signature, ani_boolean *result, + const ani_value *args); + + /** + * @brief Calls a static method by name with a boolean return type (variadic arguments). + * + * This function calls the specified static method of a class by its name and retrieves a boolean result using a + * `va_list`. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[in] signature The signature of the static method to call. + * @param[out] result A pointer to store the boolean result. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Boolean_V)(ani_env *env, ani_class cls, const char *name, + const char *signature, ani_boolean *result, va_list args); + + /** + * @brief Calls a static method by name with a char return type. + * + * This function calls the specified static method of a class by its name and retrieves a char result using variadic + * arguments. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[in] signature The signature of the static method to call. + * @param[out] result A pointer to store the char result. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Char)(ani_env *env, ani_class cls, const char *name, + const char *signature, ani_char *result, ...); + + /** + * @brief Calls a static method by name with a char return type (array-based). + * + * This function calls the specified static method of a class by its name and retrieves a char result using + * arguments from an array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[in] signature The signature of the static method to call. + * @param[out] result A pointer to store the char result. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Char_A)(ani_env *env, ani_class cls, const char *name, + const char *signature, ani_char *result, const ani_value *args); + + /** + * @brief Calls a static method by name with a char return type (variadic arguments). + * + * This function calls the specified static method of a class by its name and retrieves a char result using a + * `va_list`. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[in] signature The signature of the static method to call. + * @param[out] result A pointer to store the char result. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Char_V)(ani_env *env, ani_class cls, const char *name, + const char *signature, ani_char *result, va_list args); + + /** + * @brief Calls a static method by name with a byte return type. + * + * This function calls the specified static method of a class by its name and retrieves a byte result using variadic + * arguments. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[in] signature The signature of the static method to call. + * @param[out] result A pointer to store the byte result. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Byte)(ani_env *env, ani_class cls, const char *name, + const char *signature, ani_byte *result, ...); + + /** + * @brief Calls a static method by name with a byte return type (array-based). + * + * This function calls the specified static method of a class by its name and retrieves a byte result using + * arguments from an array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[in] signature The signature of the static method to call. + * @param[out] result A pointer to store the byte result. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Byte_A)(ani_env *env, ani_class cls, const char *name, + const char *signature, ani_byte *result, const ani_value *args); + + /** + * @brief Calls a static method by name with a byte return type (variadic arguments). + * + * This function calls the specified static method of a class by its name and retrieves a byte result using a + * `va_list`. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[in] signature The signature of the static method to call. + * @param[out] result A pointer to store the byte result. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Byte_V)(ani_env *env, ani_class cls, const char *name, + const char *signature, ani_byte *result, va_list args); + + /** + * @brief Calls a static method by name with a short return type. + * + * This function calls the specified static method of a class by its name and retrieves a short result using + * variadic arguments. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[in] signature The signature of the static method to call. + * @param[out] result A pointer to store the short result. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Short)(ani_env *env, ani_class cls, const char *name, + const char *signature, ani_short *result, ...); + + /** + * @brief Calls a static method by name with a short return type (array-based). + * + * This function calls the specified static method of a class by its name and retrieves a short result using + * arguments from an array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[in] signature The signature of the static method to call. + * @param[out] result A pointer to store the short result. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Short_A)(ani_env *env, ani_class cls, const char *name, + const char *signature, ani_short *result, const ani_value *args); + + /** + * @brief Calls a static method by name with a short return type (variadic arguments). + * + * This function calls the specified static method of a class by its name and retrieves a short result using a + * `va_list`. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[in] signature The signature of the static method to call. + * @param[out] result A pointer to store the short result. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Short_V)(ani_env *env, ani_class cls, const char *name, + const char *signature, ani_short *result, va_list args); + + /** + * @brief Calls a static method by name with a integer return type. + * + * This function calls the specified static method of a class by its name and retrieves a integer result using + * variadic arguments. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[in] signature The signature of the static method to call. + * @param[out] result A pointer to store the integer result. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Int)(ani_env *env, ani_class cls, const char *name, const char *signature, + ani_int *result, ...); + + /** + * @brief Calls a static method by name with a integer return type (array-based). + * + * This function calls the specified static method of a class by its name and retrieves a integer result using + * arguments from an array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[in] signature The signature of the static method to call. + * @param[out] result A pointer to store the integer result. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Int_A)(ani_env *env, ani_class cls, const char *name, + const char *signature, ani_int *result, const ani_value *args); + + /** + * @brief Calls a static method by name with a integer return type (variadic arguments). + * + * This function calls the specified static method of a class by its name and retrieves a integer result using a + * `va_list`. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[in] signature The signature of the static method to call. + * @param[out] result A pointer to store the integer result. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Int_V)(ani_env *env, ani_class cls, const char *name, + const char *signature, ani_int *result, va_list args); + + /** + * @brief Calls a static method by name with a long return type. + * + * This function calls the specified static method of a class by its name and retrieves a long result using variadic + * arguments. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[in] signature The signature of the static method to call. + * @param[out] result A pointer to store the long result. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Long)(ani_env *env, ani_class cls, const char *name, + const char *signature, ani_long *result, ...); + + /** + * @brief Calls a static method by name with a long return type (array-based). + * + * This function calls the specified static method of a class by its name and retrieves a long result using + * arguments from an array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[in] signature The signature of the static method to call. + * @param[out] result A pointer to store the long result. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Long_A)(ani_env *env, ani_class cls, const char *name, + const char *signature, ani_long *result, const ani_value *args); + + /** + * @brief Calls a static method by name with a long return type (variadic arguments). + * + * This function calls the specified static method of a class by its name and retrieves a long result using a + * `va_list`. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[in] signature The signature of the static method to call. + * @param[out] result A pointer to store the long result. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Long_V)(ani_env *env, ani_class cls, const char *name, + const char *signature, ani_long *result, va_list args); + + /** + * @brief Calls a static method by name with a float return type. + * + * This function calls the specified static method of a class by its name and retrieves a float result using + * variadic arguments. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[in] signature The signature of the static method to call. + * @param[out] result A pointer to store the float result. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Float)(ani_env *env, ani_class cls, const char *name, + const char *signature, ani_float *result, ...); + + /** + * @brief Calls a static method by name with a float return type (array-based). + * + * This function calls the specified static method of a class by its name and retrieves a float result using + * arguments from an array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[in] signature The signature of the static method to call. + * @param[out] result A pointer to store the float result. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Float_A)(ani_env *env, ani_class cls, const char *name, + const char *signature, ani_float *result, const ani_value *args); + + /** + * @brief Calls a static method by name with a float return type (variadic arguments). + * + * This function calls the specified static method of a class by its name and retrieves a float result using a + * `va_list`. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[in] signature The signature of the static method to call. + * @param[out] result A pointer to store the float result. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Float_V)(ani_env *env, ani_class cls, const char *name, + const char *signature, ani_float *result, va_list args); + + /** + * @brief Calls a static method by name with a double return type. + * + * This function calls the specified static method of a class by its name and retrieves a double result using + * variadic arguments. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[in] signature The signature of the static method to call. + * @param[out] result A pointer to store the double result. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Double)(ani_env *env, ani_class cls, const char *name, + const char *signature, ani_double *result, ...); + + /** + * @brief Calls a static method by name with a double return type (array-based). + * + * This function calls the specified static method of a class by its name and retrieves a double result using + * arguments from an array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[in] signature The signature of the static method to call. + * @param[out] result A pointer to store the double result. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Double_A)(ani_env *env, ani_class cls, const char *name, + const char *signature, ani_double *result, + const ani_value *args); + + /** + * @brief Calls a static method by name with a double return type (variadic arguments). + * + * This function calls the specified static method of a class by its name and retrieves a double result using a + * `va_list`. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[in] signature The signature of the static method to call. + * @param[out] result A pointer to store the double result. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Double_V)(ani_env *env, ani_class cls, const char *name, + const char *signature, ani_double *result, va_list args); + + /** + * @brief Calls a static method by name with a reference return type. + * + * This function calls the specified static method of a class by its name and retrieves a reference result using + * variadic arguments. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[in] signature The signature of the static method to call. + * @param[out] result A pointer to store the reference result. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Ref)(ani_env *env, ani_class cls, const char *name, const char *signature, + ani_ref *result, ...); + + /** + * @brief Calls a static method by name with a reference return type (array-based). + * + * This function calls the specified static method of a class by its name and retrieves a reference result using + * arguments from an array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[in] signature The signature of the static method to call. + * @param[out] result A pointer to store the reference result. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Ref_A)(ani_env *env, ani_class cls, const char *name, + const char *signature, ani_ref *result, const ani_value *args); + + /** + * @brief Calls a static method by name with a reference return type (variadic arguments). + * + * This function calls the specified static method of a class by its name and retrieves a reference result using a + * `va_list`. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[in] signature The signature of the static method to call. + * @param[out] result A pointer to store the reference result. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Ref_V)(ani_env *env, ani_class cls, const char *name, + const char *signature, ani_ref *result, va_list args); + + /** + * @brief Calls a static method by name with no return value. + * + * This function calls the specified static method of a class by its name using variadic arguments. The method does + * not return a value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[in] signature The signature of the static method to call. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Void)(ani_env *env, ani_class cls, const char *name, + const char *signature, ...); + + /** + * @brief Calls a static method by name with no return value (array-based). + * + * This function calls the specified static method of a class by its name using arguments from an array. The method + * does not return a value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[in] signature The signature of the static method to call. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Void_A)(ani_env *env, ani_class cls, const char *name, + const char *signature, const ani_value *args); + + /** + * @brief Calls a static method by name with no return value (variadic arguments). + * + * This function calls the specified static method of a class by its name using a `va_list`. The method does not + * return a value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[in] signature The signature of the static method to call. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Void_V)(ani_env *env, ani_class cls, const char *name, + const char *signature, va_list args); + + /** + * @brief Retrieves a boolean value from a field of an object. + * + * This function retrieves the boolean value of the specified field from the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] field The field to retrieve the boolean value from. + * @param[out] result A pointer to store the retrieved boolean value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetField_Boolean)(ani_env *env, ani_object object, ani_field field, ani_boolean *result); + + /** + * @brief Retrieves a char value from a field of an object. + * + * This function retrieves the char value of the specified field from the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] field The field to retrieve the char value from. + * @param[out] result A pointer to store the retrieved char value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetField_Char)(ani_env *env, ani_object object, ani_field field, ani_char *result); + + /** + * @brief Retrieves a byte value from a field of an object. + * + * This function retrieves the byte value of the specified field from the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] field The field to retrieve the byte value from. + * @param[out] result A pointer to store the retrieved byte value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetField_Byte)(ani_env *env, ani_object object, ani_field field, ani_byte *result); + + /** + * @brief Retrieves a short value from a field of an object. + * + * This function retrieves the short value of the specified field from the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] field The field to retrieve the short value from. + * @param[out] result A pointer to store the retrieved short value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetField_Short)(ani_env *env, ani_object object, ani_field field, ani_short *result); + + /** + * @brief Retrieves a integer value from a field of an object. + * + * This function retrieves the integer value of the specified field from the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] field The field to retrieve the integer value from. + * @param[out] result A pointer to store the retrieved integer value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetField_Int)(ani_env *env, ani_object object, ani_field field, ani_int *result); + + /** + * @brief Retrieves a long value from a field of an object. + * + * This function retrieves the long value of the specified field from the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] field The field to retrieve the long value from. + * @param[out] result A pointer to store the retrieved long value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetField_Long)(ani_env *env, ani_object object, ani_field field, ani_long *result); + + /** + * @brief Retrieves a float value from a field of an object. + * + * This function retrieves the float value of the specified field from the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] field The field to retrieve the float value from. + * @param[out] result A pointer to store the retrieved float value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetField_Float)(ani_env *env, ani_object object, ani_field field, ani_float *result); + + /** + * @brief Retrieves a double value from a field of an object. + * + * This function retrieves the double value of the specified field from the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] field The field to retrieve the double value from. + * @param[out] result A pointer to store the retrieved double value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetField_Double)(ani_env *env, ani_object object, ani_field field, ani_double *result); + + /** + * @brief Retrieves a reference value from a field of an object. + * + * This function retrieves the reference value of the specified field from the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] field The field to retrieve the reference value from. + * @param[out] result A pointer to store the retrieved reference value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetField_Ref)(ani_env *env, ani_object object, ani_field field, ani_ref *result); + + /** + * @brief Sets a boolean value to a field of an object. + * + * This function assigns a boolean value to the specified field of the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] field The field to set the boolean value to. + * @param[in] value The boolean value to assign to the field. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetField_Boolean)(ani_env *env, ani_object object, ani_field field, ani_boolean value); + + /** + * @brief Sets a char value to a field of an object. + * + * This function assigns a char value to the specified field of the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] field The field to set the char value to. + * @param[in] value The char value to assign to the field. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetField_Char)(ani_env *env, ani_object object, ani_field field, ani_char value); + + /** + * @brief Sets a byte value to a field of an object. + * + * This function assigns a byte value to the specified field of the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] field The field to set the byte value to. + * @param[in] value The byte value to assign to the field. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetField_Byte)(ani_env *env, ani_object object, ani_field field, ani_byte value); + + /** + * @brief Sets a short value to a field of an object. + * + * This function assigns a short value to the specified field of the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] field The field to set the short value to. + * @param[in] value The short value to assign to the field. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetField_Short)(ani_env *env, ani_object object, ani_field field, ani_short value); + + /** + * @brief Sets a integer value to a field of an object. + * + * This function assigns a integer value to the specified field of the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] field The field to set the integer value to. + * @param[in] value The integer value to assign to the field. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetField_Int)(ani_env *env, ani_object object, ani_field field, ani_int value); + + /** + * @brief Sets a long value to a field of an object. + * + * This function assigns a long value to the specified field of the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] field The field to set the long value to. + * @param[in] value The long value to assign to the field. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetField_Long)(ani_env *env, ani_object object, ani_field field, ani_long value); + + /** + * @brief Sets a float value to a field of an object. + * + * This function assigns a float value to the specified field of the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] field The field to set the float value to. + * @param[in] value The float value to assign to the field. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetField_Float)(ani_env *env, ani_object object, ani_field field, ani_float value); + + /** + * @brief Sets a double value to a field of an object. + * + * This function assigns a double value to the specified field of the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] field The field to set the double value to. + * @param[in] value The double value to assign to the field. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetField_Double)(ani_env *env, ani_object object, ani_field field, ani_double value); + + /** + * @brief Sets a reference value to a field of an object. + * + * This function assigns a reference value to the specified field of the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] field The field to set the reference value to. + * @param[in] value The reference value to assign to the field. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetField_Ref)(ani_env *env, ani_object object, ani_field field, ani_ref value); + + /** + * @brief Retrieves a boolean value from a field of an object by its name. + * + * This function retrieves the boolean value of the specified field from the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] name The name of the field to retrieve the boolean value from. + * @param[out] result A pointer to store the retrieved boolean value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetFieldByName_Boolean)(ani_env *env, ani_object object, const char *name, ani_boolean *result); + + /** + * @brief Retrieves a char value from a field of an object by its name. + * + * This function retrieves the char value of the specified field from the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] name The name of the field to retrieve the char value from. + * @param[out] result A pointer to store the retrieved char value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetFieldByName_Char)(ani_env *env, ani_object object, const char *name, ani_char *result); + + /** + * @brief Retrieves a byte value from a field of an object by its name. + * + * This function retrieves the byte value of the specified field from the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] name The name of the field to retrieve the byte value from. + * @param[out] result A pointer to store the retrieved byte value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetFieldByName_Byte)(ani_env *env, ani_object object, const char *name, ani_byte *result); + + /** + * @brief Retrieves a short value from a field of an object by its name. + * + * This function retrieves the short value of the specified field from the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] name The name of the field to retrieve the short value from. + * @param[out] result A pointer to store the retrieved short value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetFieldByName_Short)(ani_env *env, ani_object object, const char *name, ani_short *result); + + /** + * @brief Retrieves a integer value from a field of an object by its name. + * + * This function retrieves the integer value of the specified field from the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] name The name of the field to retrieve the integer value from. + * @param[out] result A pointer to store the retrieved integer value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetFieldByName_Int)(ani_env *env, ani_object object, const char *name, ani_int *result); + + /** + * @brief Retrieves a long value from a field of an object by its name. + * + * This function retrieves the long value of the specified field from the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] name The name of the field to retrieve the long value from. + * @param[out] result A pointer to store the retrieved long value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetFieldByName_Long)(ani_env *env, ani_object object, const char *name, ani_long *result); + + /** + * @brief Retrieves a float value from a field of an object by its name. + * + * This function retrieves the float value of the specified field from the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] name The name of the field to retrieve the float value from. + * @param[out] result A pointer to store the retrieved float value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetFieldByName_Float)(ani_env *env, ani_object object, const char *name, ani_float *result); + + /** + * @brief Retrieves a double value from a field of an object by its name. + * + * This function retrieves the double value of the specified field from the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] name The name of the field to retrieve the double value from. + * @param[out] result A pointer to store the retrieved double value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetFieldByName_Double)(ani_env *env, ani_object object, const char *name, ani_double *result); + + /** + * @brief Retrieves a reference value from a field of an object by its name. + * + * This function retrieves the reference value of the specified field from the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] name The name of the field to retrieve the reference value from. + * @param[out] result A pointer to store the retrieved reference value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetFieldByName_Ref)(ani_env *env, ani_object object, const char *name, ani_ref *result); + + /** + * @brief Sets a boolean value to a field of an object by its name. + * + * This function assigns a boolean value to the specified field of the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] name The name of the field to set the boolean value to. + * @param[in] value The boolean value to assign to the field. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetFieldByName_Boolean)(ani_env *env, ani_object object, const char *name, ani_boolean value); + + /** + * @brief Sets a char value to a field of an object by its name. + * + * This function assigns a char value to the specified field of the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] name The name of the field to set the char value to. + * @param[in] value The char value to assign to the field. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetFieldByName_Char)(ani_env *env, ani_object object, const char *name, ani_char value); + + /** + * @brief Sets a byte value to a field of an object by its name. + * + * This function assigns a byte value to the specified field of the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] name The name of the field to set the byte value to. + * @param[in] value The byte value to assign to the field. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetFieldByName_Byte)(ani_env *env, ani_object object, const char *name, ani_byte value); + + /** + * @brief Sets a short value to a field of an object by its name. + * + * This function assigns a short value to the specified field of the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] name The name of the field to set the short value to. + * @param[in] value The short value to assign to the field. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetFieldByName_Short)(ani_env *env, ani_object object, const char *name, ani_short value); + + /** + * @brief Sets a integer value to a field of an object by its name. + * + * This function assigns a integer value to the specified field of the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] name The name of the field to set the integer value to. + * @param[in] value The integer value to assign to the field. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetFieldByName_Int)(ani_env *env, ani_object object, const char *name, ani_int value); + + /** + * @brief Sets a long value to a field of an object by its name. + * + * This function assigns a long value to the specified field of the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] name The name of the field to set the long value to. + * @param[in] value The long value to assign to the field. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetFieldByName_Long)(ani_env *env, ani_object object, const char *name, ani_long value); + + /** + * @brief Sets a float value to a field of an object by its name. + * + * This function assigns a float value to the specified field of the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] name The name of the field to set the float value to. + * @param[in] value The float value to assign to the field. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetFieldByName_Float)(ani_env *env, ani_object object, const char *name, ani_float value); + + /** + * @brief Sets a double value to a field of an object by its name. + * + * This function assigns a double value to the specified field of the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] name The name of the field to set the double value to. + * @param[in] value The double value to assign to the field. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetFieldByName_Double)(ani_env *env, ani_object object, const char *name, ani_double value); + + /** + * @brief Sets a reference value to a field of an object by its name. + * + * This function assigns a reference value to the specified field of the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] name The name of the field to set the reference value to. + * @param[in] value The reference value to assign to the field. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetFieldByName_Ref)(ani_env *env, ani_object object, const char *name, ani_ref value); + + /** + * @brief Retrieves a boolean value from a property of an object by its name. + * + * This function retrieves the boolean value of the specified property from the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] name The name of the property to retrieve the boolean value from. + * @param[out] result A pointer to store the retrieved boolean value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetPropertyByName_Boolean)(ani_env *env, ani_object object, const char *name, + ani_boolean *result); + + /** + * @brief Retrieves a char value from a property of an object by its name. + * + * This function retrieves the char value of the specified property from the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] name The name of the property to retrieve the char value from. + * @param[out] result A pointer to store the retrieved char value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetPropertyByName_Char)(ani_env *env, ani_object object, const char *name, ani_char *result); + + /** + * @brief Retrieves a byte value from a property of an object by its name. + * + * This function retrieves the byte value of the specified property from the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] name The name of the property to retrieve the byte value from. + * @param[out] result A pointer to store the retrieved byte value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetPropertyByName_Byte)(ani_env *env, ani_object object, const char *name, ani_byte *result); + + /** + * @brief Retrieves a short value from a property of an object by its name. + * + * This function retrieves the short value of the specified property from the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] name The name of the property to retrieve the short value from. + * @param[out] result A pointer to store the retrieved short value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetPropertyByName_Short)(ani_env *env, ani_object object, const char *name, ani_short *result); + + /** + * @brief Retrieves a integer value from a property of an object by its name. + * + * This function retrieves the integer value of the specified property from the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] name The name of the property to retrieve the integer value from. + * @param[out] result A pointer to store the retrieved integer value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetPropertyByName_Int)(ani_env *env, ani_object object, const char *name, ani_int *result); + + /** + * @brief Retrieves a long value from a property of an object by its name. + * + * This function retrieves the long value of the specified property from the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] name The name of the property to retrieve the long value from. + * @param[out] result A pointer to store the retrieved long value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetPropertyByName_Long)(ani_env *env, ani_object object, const char *name, ani_long *result); + + /** + * @brief Retrieves a float value from a property of an object by its name. + * + * This function retrieves the float value of the specified property from the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] name The name of the property to retrieve the float value from. + * @param[out] result A pointer to store the retrieved float value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetPropertyByName_Float)(ani_env *env, ani_object object, const char *name, ani_float *result); + + /** + * @brief Retrieves a double value from a property of an object by its name. + * + * This function retrieves the double value of the specified property from the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] name The name of the property to retrieve the double value from. + * @param[out] result A pointer to store the retrieved double value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetPropertyByName_Double)(ani_env *env, ani_object object, const char *name, + ani_double *result); + + /** + * @brief Retrieves a reference value from a property of an object by its name. + * + * This function retrieves the reference value of the specified property from the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] name The name of the property to retrieve the reference value from. + * @param[out] result A pointer to store the retrieved reference value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetPropertyByName_Ref)(ani_env *env, ani_object object, const char *name, ani_ref *result); + + /** + * @brief Sets a boolean value to a property of an object by its name. + * + * This function assigns a boolean value to the specified property of the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] name The name of the property to set the boolean value to. + * @param[in] value The boolean value to assign to the property. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetPropertyByName_Boolean)(ani_env *env, ani_object object, const char *name, + ani_boolean value); + + /** + * @brief Sets a char value to a property of an object by its name. + * + * This function assigns a char value to the specified property of the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] name The name of the property to set the char value to. + * @param[in] value The char value to assign to the property. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetPropertyByName_Char)(ani_env *env, ani_object object, const char *name, ani_char value); + + /** + * @brief Sets a byte value to a property of an object by its name. + * + * This function assigns a byte value to the specified property of the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] name The name of the property to set the byte value to. + * @param[in] value The byte value to assign to the property. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetPropertyByName_Byte)(ani_env *env, ani_object object, const char *name, ani_byte value); + + /** + * @brief Sets a short value to a property of an object by its name. + * + * This function assigns a short value to the specified property of the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] name The name of the property to set the short value to. + * @param[in] value The short value to assign to the property. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetPropertyByName_Short)(ani_env *env, ani_object object, const char *name, ani_short value); + + /** + * @brief Sets a integer value to a property of an object by its name. + * + * This function assigns a integer value to the specified property of the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] name The name of the property to set the integer value to. + * @param[in] value The integer value to assign to the property. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetPropertyByName_Int)(ani_env *env, ani_object object, const char *name, ani_int value); + + /** + * @brief Sets a long value to a property of an object by its name. + * + * This function assigns a long value to the specified property of the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] name The name of the property to set the long value to. + * @param[in] value The long value to assign to the property. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetPropertyByName_Long)(ani_env *env, ani_object object, const char *name, ani_long value); + + /** + * @brief Sets a float value to a property of an object by its name. + * + * This function assigns a float value to the specified property of the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] name The name of the property to set the float value to. + * @param[in] value The float value to assign to the property. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetPropertyByName_Float)(ani_env *env, ani_object object, const char *name, ani_float value); + + /** + * @brief Sets a double value to a property of an object by its name. + * + * This function assigns a double value to the specified property of the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] name The name of the property to set the double value to. + * @param[in] value The double value to assign to the property. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetPropertyByName_Double)(ani_env *env, ani_object object, const char *name, ani_double value); + + /** + * @brief Sets a reference value to a property of an object by its name. + * + * This function assigns a reference value to the specified property of the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] name The name of the property to set the reference value to. + * @param[in] value The reference value to assign to the property. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetPropertyByName_Ref)(ani_env *env, ani_object object, const char *name, ani_ref value); + + /** + * @brief Calls a method on an object and retrieves a boolean return value. + * + * This function calls the specified method of an object using variadic arguments and retrieves a boolean result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the boolean return value. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Boolean)(ani_env *env, ani_object object, ani_method method, ani_boolean *result, + ...); + + /** + * @brief Calls a method on an object and retrieves a boolean return value (array-based). + * + * This function calls the specified method of an object using arguments provided in an array and retrieves a + * boolean result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the boolean return value. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Boolean_A)(ani_env *env, ani_object object, ani_method method, ani_boolean *result, + const ani_value *args); + + /** + * @brief Calls a method on an object and retrieves a boolean return value (variadic arguments). + * + * This function calls the specified method of an object using a `va_list` and retrieves a boolean result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the boolean return value. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Boolean_V)(ani_env *env, ani_object object, ani_method method, ani_boolean *result, + va_list args); + + /** + * @brief Calls a method on an object and retrieves a char return value. + * + * This function calls the specified method of an object using variadic arguments and retrieves a char result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the char return value. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Char)(ani_env *env, ani_object object, ani_method method, ani_char *result, ...); + + /** + * @brief Calls a method on an object and retrieves a char return value (array-based). + * + * This function calls the specified method of an object using arguments provided in an array and retrieves a char + * result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the char return value. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Char_A)(ani_env *env, ani_object object, ani_method method, ani_char *result, + const ani_value *args); + + /** + * @brief Calls a method on an object and retrieves a char return value (variadic arguments). + * + * This function calls the specified method of an object using a `va_list` and retrieves a char result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the char return value. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Char_V)(ani_env *env, ani_object object, ani_method method, ani_char *result, + va_list args); + + /** + * @brief Calls a method on an object and retrieves a byte return value. + * + * This function calls the specified method of an object using variadic arguments and retrieves a byte result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the byte return value. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Byte)(ani_env *env, ani_object object, ani_method method, ani_byte *result, ...); + + /** + * @brief Calls a method on an object and retrieves a byte return value (array-based). + * + * This function calls the specified method of an object using arguments provided in an array and retrieves a byte + * result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the byte return value. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Byte_A)(ani_env *env, ani_object object, ani_method method, ani_byte *result, + const ani_value *args); + + /** + * @brief Calls a method on an object and retrieves a byte return value (variadic arguments). + * + * This function calls the specified method of an object using a `va_list` and retrieves a byte result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the byte return value. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Byte_V)(ani_env *env, ani_object object, ani_method method, ani_byte *result, + va_list args); + + /** + * @brief Calls a method on an object and retrieves a short return value. + * + * This function calls the specified method of an object using variadic arguments and retrieves a short result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the short return value. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Short)(ani_env *env, ani_object object, ani_method method, ani_short *result, ...); + + /** + * @brief Calls a method on an object and retrieves a short return value (array-based). + * + * This function calls the specified method of an object using arguments provided in an array and retrieves a short + * result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the short return value. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Short_A)(ani_env *env, ani_object object, ani_method method, ani_short *result, + const ani_value *args); + + /** + * @brief Calls a method on an object and retrieves a short return value (variadic arguments). + * + * This function calls the specified method of an object using a `va_list` and retrieves a short result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the short return value. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Short_V)(ani_env *env, ani_object object, ani_method method, ani_short *result, + va_list args); + + /** + * @brief Calls a method on an object and retrieves a integer return value. + * + * This function calls the specified method of an object using variadic arguments and retrieves a integer result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the integer return value. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Int)(ani_env *env, ani_object object, ani_method method, ani_int *result, ...); + + /** + * @brief Calls a method on an object and retrieves a integer return value (array-based). + * + * This function calls the specified method of an object using arguments provided in an array and retrieves a + * integer result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the integer return value. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Int_A)(ani_env *env, ani_object object, ani_method method, ani_int *result, + const ani_value *args); + + /** + * @brief Calls a method on an object and retrieves a integer return value (variadic arguments). + * + * This function calls the specified method of an object using a `va_list` and retrieves a integer result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the integer return value. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Int_V)(ani_env *env, ani_object object, ani_method method, ani_int *result, + va_list args); + + /** + * @brief Calls a method on an object and retrieves a long return value. + * + * This function calls the specified method of an object using variadic arguments and retrieves a long result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the long return value. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Long)(ani_env *env, ani_object object, ani_method method, ani_long *result, ...); + + /** + * @brief Calls a method on an object and retrieves a long return value (array-based). + * + * This function calls the specified method of an object using arguments provided in an array and retrieves a long + * result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the long return value. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Long_A)(ani_env *env, ani_object object, ani_method method, ani_long *result, + const ani_value *args); + + /** + * @brief Calls a method on an object and retrieves a long return value (variadic arguments). + * + * This function calls the specified method of an object using a `va_list` and retrieves a long result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the long return value. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Long_V)(ani_env *env, ani_object object, ani_method method, ani_long *result, + va_list args); + + /** + * @brief Calls a method on an object and retrieves a float return value. + * + * This function calls the specified method of an object using variadic arguments and retrieves a float result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the float return value. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Float)(ani_env *env, ani_object object, ani_method method, ani_float *result, ...); + + /** + * @brief Calls a method on an object and retrieves a float return value (array-based). + * + * This function calls the specified method of an object using arguments provided in an array and retrieves a float + * result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the float return value. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Float_A)(ani_env *env, ani_object object, ani_method method, ani_float *result, + const ani_value *args); + + /** + * @brief Calls a method on an object and retrieves a float return value (variadic arguments). + * + * This function calls the specified method of an object using a `va_list` and retrieves a float result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the float return value. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Float_V)(ani_env *env, ani_object object, ani_method method, ani_float *result, + va_list args); + + /** + * @brief Calls a method on an object and retrieves a double return value. + * + * This function calls the specified method of an object using variadic arguments and retrieves a double result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the double return value. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Double)(ani_env *env, ani_object object, ani_method method, ani_double *result, ...); + + /** + * @brief Calls a method on an object and retrieves a double return value (array-based). + * + * This function calls the specified method of an object using arguments provided in an array and retrieves a double + * result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the double return value. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Double_A)(ani_env *env, ani_object object, ani_method method, ani_double *result, + const ani_value *args); + + /** + * @brief Calls a method on an object and retrieves a double return value (variadic arguments). + * + * This function calls the specified method of an object using a `va_list` and retrieves a double result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the double return value. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Double_V)(ani_env *env, ani_object object, ani_method method, ani_double *result, + va_list args); + + /** + * @brief Calls a method on an object and retrieves a reference return value. + * + * This function calls the specified method of an object using variadic arguments and retrieves a reference result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the reference return value. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Ref)(ani_env *env, ani_object object, ani_method method, ani_ref *result, ...); + + /** + * @brief Calls a method on an object and retrieves a reference return value (array-based). + * + * This function calls the specified method of an object using arguments provided in an array and retrieves a + * reference result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the reference return value. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Ref_A)(ani_env *env, ani_object object, ani_method method, ani_ref *result, + const ani_value *args); + + /** + * @brief Calls a method on an object and retrieves a reference return value (variadic arguments). + * + * This function calls the specified method of an object using a `va_list` and retrieves a reference result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the reference return value. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Ref_V)(ani_env *env, ani_object object, ani_method method, ani_ref *result, + va_list args); + + /** + * @brief Calls a method on an object with no return value. + * + * This function calls the specified method of an object using variadic arguments. The method does not return a + * value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Void)(ani_env *env, ani_object object, ani_method method, ...); + + /** + * @brief Calls a method on an object with no return value (array-based). + * + * This function calls the specified method of an object using arguments provided in an array. The method does not + * return a value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Void_A)(ani_env *env, ani_object object, ani_method method, const ani_value *args); + + /** + * @brief Calls a method on an object with no return value (variadic arguments). + * + * This function calls the specified method of an object using a `va_list`. The method does not return a value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Void_V)(ani_env *env, ani_object object, ani_method method, va_list args); + + /** + * @brief Calls a method by name on an object and retrieves a boolean return value. + * + * This function calls the specified method by its name and signature on an object using variadic arguments and + * retrieves a boolean result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the boolean return value. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Boolean)(ani_env *env, ani_object object, const char *name, + const char *signature, ani_boolean *result, ...); + + /** + * @brief Calls a method by name on an object and retrieves a boolean return value (array-based). + * + * This function calls the specified method by its name and signature on an object using arguments provided in an + * array and retrieves a boolean result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the boolean return value. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Boolean_A)(ani_env *env, ani_object object, const char *name, + const char *signature, ani_boolean *result, const ani_value *args); + + /** + * @brief Calls a method by name on an object and retrieves a boolean return value (variadic arguments). + * + * This function calls the specified method by its name and signature on an object using a `va_list` and retrieves a + * boolean result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the boolean return value. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Boolean_V)(ani_env *env, ani_object object, const char *name, + const char *signature, ani_boolean *result, va_list args); + + /** + * @brief Calls a method by name on an object and retrieves a char return value. + * + * This function calls the specified method by its name and signature on an object using variadic arguments and + * retrieves a char result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the char return value. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Char)(ani_env *env, ani_object object, const char *name, const char *signature, + ani_char *result, ...); + + /** + * @brief Calls a method by name on an object and retrieves a char return value (array-based). + * + * This function calls the specified method by its name and signature on an object using arguments provided in an + * array and retrieves a char result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the char return value. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Char_A)(ani_env *env, ani_object object, const char *name, + const char *signature, ani_char *result, const ani_value *args); + + /** + * @brief Calls a method by name on an object and retrieves a char return value (variadic arguments). + * + * This function calls the specified method by its name and signature on an object using a `va_list` and retrieves a + * char result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the char return value. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Char_V)(ani_env *env, ani_object object, const char *name, + const char *signature, ani_char *result, va_list args); + + /** + * @brief Calls a method by name on an object and retrieves a byte return value. + * + * This function calls the specified method by its name and signature on an object using variadic arguments and + * retrieves a byte result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the byte return value. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Byte)(ani_env *env, ani_object object, const char *name, const char *signature, + ani_byte *result, ...); + + /** + * @brief Calls a method by name on an object and retrieves a byte return value (array-based). + * + * This function calls the specified method by its name and signature on an object using arguments provided in an + * array and retrieves a byte result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the byte return value. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Byte_A)(ani_env *env, ani_object object, const char *name, + const char *signature, ani_byte *result, const ani_value *args); + + /** + * @brief Calls a method by name on an object and retrieves a byte return value (variadic arguments). + * + * This function calls the specified method by its name and signature on an object using a `va_list` and retrieves a + * byte result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the byte return value. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Byte_V)(ani_env *env, ani_object object, const char *name, + const char *signature, ani_byte *result, va_list args); + + /** + * @brief Calls a method by name on an object and retrieves a short return value. + * + * This function calls the specified method by its name and signature on an object using variadic arguments and + * retrieves a short result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the short return value. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Short)(ani_env *env, ani_object object, const char *name, + const char *signature, ani_short *result, ...); + + /** + * @brief Calls a method by name on an object and retrieves a short return value (array-based). + * + * This function calls the specified method by its name and signature on an object using arguments provided in an + * array and retrieves a short result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the short return value. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Short_A)(ani_env *env, ani_object object, const char *name, + const char *signature, ani_short *result, const ani_value *args); + + /** + * @brief Calls a method by name on an object and retrieves a short return value (variadic arguments). + * + * This function calls the specified method by its name and signature on an object using a `va_list` and retrieves a + * short result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the short return value. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Short_V)(ani_env *env, ani_object object, const char *name, + const char *signature, ani_short *result, va_list args); + + /** + * @brief Calls a method by name on an object and retrieves a integer return value. + * + * This function calls the specified method by its name and signature on an object using variadic arguments and + * retrieves a integer result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the integer return value. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Int)(ani_env *env, ani_object object, const char *name, const char *signature, + ani_int *result, ...); + + /** + * @brief Calls a method by name on an object and retrieves a integer return value (array-based). + * + * This function calls the specified method by its name and signature on an object using arguments provided in an + * array and retrieves a integer result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the integer return value. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Int_A)(ani_env *env, ani_object object, const char *name, + const char *signature, ani_int *result, const ani_value *args); + + /** + * @brief Calls a method by name on an object and retrieves a integer return value (variadic arguments). + * + * This function calls the specified method by its name and signature on an object using a `va_list` and retrieves a + * integer result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the integer return value. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Int_V)(ani_env *env, ani_object object, const char *name, + const char *signature, ani_int *result, va_list args); + + /** + * @brief Calls a method by name on an object and retrieves a long return value. + * + * This function calls the specified method by its name and signature on an object using variadic arguments and + * retrieves a long result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the long return value. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Long)(ani_env *env, ani_object object, const char *name, const char *signature, + ani_long *result, ...); + + /** + * @brief Calls a method by name on an object and retrieves a long return value (array-based). + * + * This function calls the specified method by its name and signature on an object using arguments provided in an + * array and retrieves a long result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the long return value. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Long_A)(ani_env *env, ani_object object, const char *name, + const char *signature, ani_long *result, const ani_value *args); + + /** + * @brief Calls a method by name on an object and retrieves a long return value (variadic arguments). + * + * This function calls the specified method by its name and signature on an object using a `va_list` and retrieves a + * long result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the long return value. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Long_V)(ani_env *env, ani_object object, const char *name, + const char *signature, ani_long *result, va_list args); + + /** + * @brief Calls a method by name on an object and retrieves a float return value. + * + * This function calls the specified method by its name and signature on an object using variadic arguments and + * retrieves a float result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the float return value. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Float)(ani_env *env, ani_object object, const char *name, + const char *signature, ani_float *result, ...); + + /** + * @brief Calls a method by name on an object and retrieves a float return value (array-based). + * + * This function calls the specified method by its name and signature on an object using arguments provided in an + * array and retrieves a float result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the float return value. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Float_A)(ani_env *env, ani_object object, const char *name, + const char *signature, ani_float *result, const ani_value *args); + + /** + * @brief Calls a method by name on an object and retrieves a float return value (variadic arguments). + * + * This function calls the specified method by its name and signature on an object using a `va_list` and retrieves a + * float result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the float return value. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Float_V)(ani_env *env, ani_object object, const char *name, + const char *signature, ani_float *result, va_list args); + + /** + * @brief Calls a method by name on an object and retrieves a double return value. + * + * This function calls the specified method by its name and signature on an object using variadic arguments and + * retrieves a double result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the double return value. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Double)(ani_env *env, ani_object object, const char *name, + const char *signature, ani_double *result, ...); + + /** + * @brief Calls a method by name on an object and retrieves a double return value (array-based). + * + * This function calls the specified method by its name and signature on an object using arguments provided in an + * array and retrieves a double result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the double return value. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Double_A)(ani_env *env, ani_object object, const char *name, + const char *signature, ani_double *result, const ani_value *args); + + /** + * @brief Calls a method by name on an object and retrieves a double return value (variadic arguments). + * + * This function calls the specified method by its name and signature on an object using a `va_list` and retrieves a + * double result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the double return value. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Double_V)(ani_env *env, ani_object object, const char *name, + const char *signature, ani_double *result, va_list args); + + /** + * @brief Calls a method by name on an object and retrieves a reference return value. + * + * This function calls the specified method by its name and signature on an object using variadic arguments and + * retrieves a reference result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the reference return value. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Ref)(ani_env *env, ani_object object, const char *name, const char *signature, + ani_ref *result, ...); + + /** + * @brief Calls a method by name on an object and retrieves a reference return value (array-based). + * + * This function calls the specified method by its name and signature on an object using arguments provided in an + * array and retrieves a reference result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the reference return value. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Ref_A)(ani_env *env, ani_object object, const char *name, + const char *signature, ani_ref *result, const ani_value *args); + + /** + * @brief Calls a method by name on an object and retrieves a reference return value (variadic arguments). + * + * This function calls the specified method by its name and signature on an object using a `va_list` and retrieves a + * reference result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the reference return value. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Ref_V)(ani_env *env, ani_object object, const char *name, + const char *signature, ani_ref *result, va_list args); + + /** + * @brief Calls a method by name on an object with no return value. + * + * This function calls the specified method by its name and signature on an object using variadic arguments. The + * method does not return a value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Void)(ani_env *env, ani_object object, const char *name, const char *signature, + ...); + + /** + * @brief Calls a method by name on an object with no return value (array-based). + * + * This function calls the specified method by its name and signature on an object using arguments provided in an + * array. The method does not return a value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Void_A)(ani_env *env, ani_object object, const char *name, + const char *signature, const ani_value *args); + + /** + * @brief Calls a method by name on an object with no return value (variadic arguments). + * + * This function calls the specified method by its name and signature on an object using a `va_list`. The method + * does not return a value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Void_V)(ani_env *env, ani_object object, const char *name, + const char *signature, va_list args); + + /** + * @brief Retrieves the number of items in a tuple value. + * + * This function retrieves the total number of items in the specified tuple value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] tuple_value The tuple value whose number of items is to be retrieved. + * @param[out] result A pointer to store the number of items. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*TupleValue_GetNumberOfItems)(ani_env *env, ani_tuple_value tuple_value, ani_size *result); + + /** + * @brief Retrieves a boolean item from a tuple value. + * + * This function retrieves the boolean value of the item at the specified index in the tuple value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] tuple_value The tuple value containing the item. + * @param[in] index The index of the item. + * @param[out] result A pointer to store the boolean value of the item. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*TupleValue_GetItem_Boolean)(ani_env *env, ani_tuple_value tuple_value, ani_size index, + ani_boolean *result); + + /** + * @brief Retrieves a char item from a tuple value. + * + * This function retrieves the char value of the item at the specified index in the tuple value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] tuple_value The tuple value containing the item. + * @param[in] index The index of the item. + * @param[out] result A pointer to store the char value of the item. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*TupleValue_GetItem_Char)(ani_env *env, ani_tuple_value tuple_value, ani_size index, ani_char *result); + + /** + * @brief Retrieves a byte item from a tuple value. + * + * This function retrieves the byte value of the item at the specified index in the tuple value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] tuple_value The tuple value containing the item. + * @param[in] index The index of the item. + * @param[out] result A pointer to store the byte value of the item. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*TupleValue_GetItem_Byte)(ani_env *env, ani_tuple_value tuple_value, ani_size index, ani_byte *result); + + /** + * @brief Retrieves a short item from a tuple value. + * + * This function retrieves the short value of the item at the specified index in the tuple value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] tuple_value The tuple value containing the item. + * @param[in] index The index of the item. + * @param[out] result A pointer to store the short value of the item. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*TupleValue_GetItem_Short)(ani_env *env, ani_tuple_value tuple_value, ani_size index, + ani_short *result); + + /** + * @brief Retrieves a integer item from a tuple value. + * + * This function retrieves the integer value of the item at the specified index in the tuple value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] tuple_value The tuple value containing the item. + * @param[in] index The index of the item. + * @param[out] result A pointer to store the integer value of the item. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*TupleValue_GetItem_Int)(ani_env *env, ani_tuple_value tuple_value, ani_size index, ani_int *result); + + /** + * @brief Retrieves a long item from a tuple value. + * + * This function retrieves the long value of the item at the specified index in the tuple value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] tuple_value The tuple value containing the item. + * @param[in] index The index of the item. + * @param[out] result A pointer to store the long value of the item. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*TupleValue_GetItem_Long)(ani_env *env, ani_tuple_value tuple_value, ani_size index, ani_long *result); + + /** + * @brief Retrieves a float item from a tuple value. + * + * This function retrieves the float value of the item at the specified index in the tuple value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] tuple_value The tuple value containing the item. + * @param[in] index The index of the item. + * @param[out] result A pointer to store the float value of the item. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*TupleValue_GetItem_Float)(ani_env *env, ani_tuple_value tuple_value, ani_size index, + ani_float *result); + + /** + * @brief Retrieves a double item from a tuple value. + * + * This function retrieves the double value of the item at the specified index in the tuple value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] tuple_value The tuple value containing the item. + * @param[in] index The index of the item. + * @param[out] result A pointer to store the double value of the item. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*TupleValue_GetItem_Double)(ani_env *env, ani_tuple_value tuple_value, ani_size index, + ani_double *result); + + /** + * @brief Retrieves a reference item from a tuple value. + * + * This function retrieves the reference value of the item at the specified index in the tuple value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] tuple_value The tuple value containing the item. + * @param[in] index The index of the item. + * @param[out] result A pointer to store the reference value of the item. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*TupleValue_GetItem_Ref)(ani_env *env, ani_tuple_value tuple_value, ani_size index, ani_ref *result); + + /** + * @brief Sets a boolean value to an item in a tuple value. + * + * This function assigns a boolean value to the item at the specified index in the tuple value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] tuple_value The tuple value containing the item. + * @param[in] index The index of the item. + * @param[in] value The boolean value to assign to the item. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*TupleValue_SetItem_Boolean)(ani_env *env, ani_tuple_value tuple_value, ani_size index, + ani_boolean value); + + /** + * @brief Sets a char value to an item in a tuple value. + * + * This function assigns a char value to the item at the specified index in the tuple value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] tuple_value The tuple value containing the item. + * @param[in] index The index of the item. + * @param[in] value The char value to assign to the item. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*TupleValue_SetItem_Char)(ani_env *env, ani_tuple_value tuple_value, ani_size index, ani_char value); + + /** + * @brief Sets a byte value to an item in a tuple value. + * + * This function assigns a byte value to the item at the specified index in the tuple value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] tuple_value The tuple value containing the item. + * @param[in] index The index of the item. + * @param[in] value The byte value to assign to the item. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*TupleValue_SetItem_Byte)(ani_env *env, ani_tuple_value tuple_value, ani_size index, ani_byte value); + + /** + * @brief Sets a short value to an item in a tuple value. + * + * This function assigns a short value to the item at the specified index in the tuple value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] tuple_value The tuple value containing the item. + * @param[in] index The index of the item. + * @param[in] value The short value to assign to the item. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*TupleValue_SetItem_Short)(ani_env *env, ani_tuple_value tuple_value, ani_size index, ani_short value); + + /** + * @brief Sets a integer value to an item in a tuple value. + * + * This function assigns a integer value to the item at the specified index in the tuple value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] tuple_value The tuple value containing the item. + * @param[in] index The index of the item. + * @param[in] value The integer value to assign to the item. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*TupleValue_SetItem_Int)(ani_env *env, ani_tuple_value tuple_value, ani_size index, ani_int value); + + /** + * @brief Sets a long value to an item in a tuple value. + * + * This function assigns a long value to the item at the specified index in the tuple value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] tuple_value The tuple value containing the item. + * @param[in] index The index of the item. + * @param[in] value The long value to assign to the item. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*TupleValue_SetItem_Long)(ani_env *env, ani_tuple_value tuple_value, ani_size index, ani_long value); + + /** + * @brief Sets a float value to an item in a tuple value. + * + * This function assigns a float value to the item at the specified index in the tuple value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] tuple_value The tuple value containing the item. + * @param[in] index The index of the item. + * @param[in] value The float value to assign to the item. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*TupleValue_SetItem_Float)(ani_env *env, ani_tuple_value tuple_value, ani_size index, ani_float value); + + /** + * @brief Sets a double value to an item in a tuple value. + * + * This function assigns a double value to the item at the specified index in the tuple value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] tuple_value The tuple value containing the item. + * @param[in] index The index of the item. + * @param[in] value The double value to assign to the item. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*TupleValue_SetItem_Double)(ani_env *env, ani_tuple_value tuple_value, ani_size index, + ani_double value); + + /** + * @brief Sets a reference value to an item in a tuple value. + * + * This function assigns a reference value to the item at the specified index in the tuple value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] tuple_value The tuple value containing the item. + * @param[in] index The index of the item. + * @param[in] value The reference value to assign to the item. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*TupleValue_SetItem_Ref)(ani_env *env, ani_tuple_value tuple_value, ani_size index, ani_ref value); + + /** + * @brief Creates a global reference. + * + * This function creates a global reference from a local reference. + * + * @param[in] env A pointer to the environment structure. + * @param[in] ref The local reference to convert to a global reference. + * @param[out] result A pointer to store the created global reference. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*GlobalReference_Create)(ani_env *env, ani_ref ref, ani_ref *result); + + /** + * @brief Deletes a global reference. + * + * This function deletes the specified global reference, releasing all associated resources. + * + * @param[in] env A pointer to the environment structure. + * @param[in] gref The global reference to delete. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*GlobalReference_Delete)(ani_env *env, ani_ref gref); + + /** + * @brief Creates a weak reference. + * + * This function creates a weak reference from a local reference. + * + * @param[in] env A pointer to the environment structure. + * @param[in] ref The local reference to convert to a weak reference. + * @param[out] result A pointer to store the created weak reference. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*WeakReference_Create)(ani_env *env, ani_ref ref, ani_wref *result); + + /** + * @brief Deletes a weak reference. + * + * This function deletes the specified weak reference, releasing all associated resources. + * + * @param[in] env A pointer to the environment structure. + * @param[in] wref The weak reference to delete. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*WeakReference_Delete)(ani_env *env, ani_wref wref); + + /** + * @brief Retrieves the local reference associated with a weak reference. + * + * This function retrieves the local reference that corresponds to the specified weak reference. + * + * @param[in] env A pointer to the environment structure. + * @param[in] wref The weak reference to query. + * @param[out] was_released_result A pointer to boolean flag which indicates that wref is GC collected. + * @param[out] ref_result A pointer to store the retrieved local reference. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*WeakReference_GetReference)(ani_env *env, ani_wref wref, ani_boolean *was_released_result, + ani_ref *ref_result); + + /** + * @brief Creates a new array buffer. + * + * This function creates a new array buffer with the specified length and returns a pointer to the allocated data. + * + * @param[in] env A pointer to the environment structure. + * @param[in] length The length of the array buffer in bytes. + * @param[out] data_result A pointer to store the allocated data of the array buffer. + * @param[out] arraybuffer_result A pointer to store the created array buffer object. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*CreateArrayBuffer)(ani_env *env, size_t length, void **data_result, + ani_arraybuffer *arraybuffer_result); + + /** + * @brief Creates a new array buffer using external data. + * + * This function creates an array buffer that uses external data. The provided finalizer will be called when the + * array buffer is no longer needed. + * + * @param[in] env A pointer to the environment structure. + * @param[in] external_data A pointer to the external data to be used by the array buffer. + * @param[in] length The length of the external data in bytes. + * @param[in] finalizer A callback function to be called when the array buffer is finalized. Can be nullptr. + * @param[in] hint A user-defined hint to be passed to the finalizer. Can be nullptr. + * @param[out] result A pointer to store the created array buffer object. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*CreateArrayBufferExternal)(ani_env *env, void *external_data, size_t length, ani_finalizer finalizer, + void *hint, ani_arraybuffer *result); + + /** + * @brief Retrieves information about an array buffer. + * + * This function retrieves the data pointer and length of the specified array buffer. + * + * @param[in] env A pointer to the environment structure. + * @param[in] arraybuffer The array buffer to query. + * @param[out] data_result A pointer to store the data of the array buffer. + * @param[out] length_result A pointer to store the length of the array buffer in bytes. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*ArrayBuffer_GetInfo)(ani_env *env, ani_arraybuffer arraybuffer, void **data_result, + size_t *length_result); + + /** + * @brief Creates a new Promise. + * + * This function creates a new promise and a resolver to manage it. + * + * @param[in] env A pointer to the environment structure. + * @param[out] result_resolver A pointer to store the created resolver. + * @param[out] result_promise A pointer to store the created promise. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Promise_New)(ani_env *env, ani_resolver *result_resolver, ani_object *result_promise); + + /** + * @brief Resolves a promise. + * + * This function resolves a promise by way of the resolver with which it is associated + * and queues promise `then` callbacks. + * + * @param[in] env A pointer to the environment structure. + * @param[in] resolver A resolver whose associated promise to resolve. + * @param[in] resolution A reference with which to resolve the promise. + * @return Returns a status code of type `ani_status` indicating success or failure. + * The `resolver` is freed upon successful completion. + */ + ani_status (*PromiseResolver_Resolve)(ani_env *env, ani_resolver resolver, ani_ref resolution); + + /** + * @brief Rejects a promise. + * + * This function rejects a promise by way of the resolver with which it is associated + * and queues promise `catch` callbacks. + * + * @param[in] env A pointer to the environment structure. + * @param[in] resolver A resolver whose associated promise to resolve. + * @param[in] rejection An error with which to reject the promise. + * @return Returns a status code of type `ani_status` indicating success or failure. + * The `resolver` is freed upon successful completion. + */ + ani_status (*PromiseResolver_Reject)(ani_env *env, ani_resolver resolver, ani_error rejection); + + /** + * @brief Creates a new fixedarray of booleans. + * + * This function creates a new array of the specified length for boolean values. + * + * @param[in] env A pointer to the environment structure. + * @param[in] length The length of the fixedarray to be created. + * @param[out] result A pointer to store the created FixedArray. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FixedArray_New_Boolean)(ani_env *env, ani_size length, ani_array_boolean *result); + + /** + * @brief Creates a new FixedArray of characters. + * + * This function creates a new FixedArray of the specified length for character values. + * + * @param[in] env A pointer to the environment structure. + * @param[in] length The length of the FixedArray to be created. + * @param[out] result A pointer to store the created FixedArray. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FixedArray_New_Char)(ani_env *env, ani_size length, ani_array_char *result); + + /** + * @brief Creates a new FixedArray of bytes. + * + * This function creates a new FixedArray of the specified length for byte values. + * + * @param[in] env A pointer to the environment structure. + * @param[in] length The length of the FixedArray to be created. + * @param[out] result A pointer to store the created FixedArray. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FixedArray_New_Byte)(ani_env *env, ani_size length, ani_array_byte *result); + + /** + * @brief Creates a new FixedArray of shorts. + * + * This function creates a new FixedArray of the specified length for short integer values. + * + * @param[in] env A pointer to the environment structure. + * @param[in] length The length of the FixedArray to be created. + * @param[out] result A pointer to store the created FixedArray. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FixedArray_New_Short)(ani_env *env, ani_size length, ani_array_short *result); + + /** + * @brief Creates a new FixedArray of integers. + * + * This function creates a new FixedArray of the specified length for integer values. + * + * @param[in] env A pointer to the environment structure. + * @param[in] length The length of the FixedArray to be created. + * @param[out] result A pointer to store the created FixedArray. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FixedArray_New_Int)(ani_env *env, ani_size length, ani_array_int *result); + + /** + * @brief Creates a new FixedArray of long integers. + * + * This function creates a new FixedArray of the specified length for long integer values. + * + * @param[in] env A pointer to the environment structure. + * @param[in] length The length of the FixedArray to be created. + * @param[out] result A pointer to store the created FixedArray. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FixedArray_New_Long)(ani_env *env, ani_size length, ani_array_long *result); + + /** + * @brief Creates a new FixedArray of floats. + * + * This function creates a new FixedArray of the specified length for float values. + * + * @param[in] env A pointer to the environment structure. + * @param[in] length The length of the FixedArray to be created. + * @param[out] result A pointer to store the created FixedArray. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FixedArray_New_Float)(ani_env *env, ani_size length, ani_array_float *result); + + /** + * @brief Creates a new FixedArray of doubles. + * + * This function creates a new FixedArray of the specified length for double values. + * + * @param[in] env A pointer to the environment structure. + * @param[in] length The length of the FixedArray to be created. + * @param[out] result A pointer to store the created FixedArray. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FixedArray_New_Double)(ani_env *env, ani_size length, ani_array_double *result); + + /** + * @brief Creates a new FixedArray of references. + * + * This function creates a new FixedArray of references, optionally initializing it with an FixedArray of + * references. + * + * @param[in] env A pointer to the environment structure. + * @param[in] type The type of the elements of the FixedArray. + * @param[in] length The length of the FixedArray to be created. + * @param[in] initial_element An optional reference to initialize the FixedArray. Can be null. + * @param[out] result A pointer to store the created FixedArray of references. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FixedArray_New_Ref)(ani_env *env, ani_type type, ani_size length, ani_ref initial_element, + ani_array_ref *result); +}; + +// C++ API +struct __ani_vm { + const struct __ani_vm_api *c_api; + +#ifdef __cplusplus + ani_status DestroyVM() + { + return c_api->DestroyVM(this); + } + ani_status GetEnv(uint32_t version, ani_env **result) + { + return c_api->GetEnv(this, version, result); + } + ani_status AttachCurrentThread(const ani_options *options, uint32_t version, ani_env **result) + { + return c_api->AttachCurrentThread(this, options, version, result); + } + ani_status DetachCurrentThread() + { + return c_api->DetachCurrentThread(this); + } +#endif // __cplusplus +}; + +struct __ani_env { + const struct __ani_interaction_api *c_api; + +#ifdef __cplusplus + ani_status GetVersion(uint32_t *result) + { + return c_api->GetVersion(this, result); + } + ani_status GetVM(ani_vm **result) + { + return c_api->GetVM(this, result); + } + ani_status Object_New(ani_class cls, ani_method method, ani_object *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Object_New_V(this, cls, method, result, args); + va_end(args); + return status; + } + ani_status Object_New_A(ani_class cls, ani_method method, ani_object *result, const ani_value *args) + { + return c_api->Object_New_A(this, cls, method, result, args); + } + ani_status Object_New_V(ani_class cls, ani_method method, ani_object *result, va_list args) + { + return c_api->Object_New_V(this, cls, method, result, args); + } + ani_status Object_GetType(ani_object object, ani_type *result) + { + return c_api->Object_GetType(this, object, result); + } + ani_status Object_InstanceOf(ani_object object, ani_type type, ani_boolean *result) + { + return c_api->Object_InstanceOf(this, object, type, result); + } + ani_status Type_GetSuperClass(ani_type type, ani_class *result) + { + return c_api->Type_GetSuperClass(this, type, result); + } + ani_status Type_IsAssignableFrom(ani_type from_type, ani_type to_type, ani_boolean *result) + { + return c_api->Type_IsAssignableFrom(this, from_type, to_type, result); + } + ani_status FindModule(const char *module_descriptor, ani_module *result) + { + return c_api->FindModule(this, module_descriptor, result); + } + ani_status FindNamespace(const char *namespace_descriptor, ani_namespace *result) + { + return c_api->FindNamespace(this, namespace_descriptor, result); + } + ani_status FindClass(const char *class_descriptor, ani_class *result) + { + return c_api->FindClass(this, class_descriptor, result); + } + ani_status FindEnum(const char *enum_descriptor, ani_enum *result) + { + return c_api->FindEnum(this, enum_descriptor, result); + } + ani_status Module_FindNamespace(ani_module module, const char *namespace_descriptor, ani_namespace *result) + { + return c_api->Module_FindNamespace(this, module, namespace_descriptor, result); + } + ani_status Module_FindClass(ani_module module, const char *class_descriptor, ani_class *result) + { + return c_api->Module_FindClass(this, module, class_descriptor, result); + } + ani_status Module_FindEnum(ani_module module, const char *enum_descriptor, ani_enum *result) + { + return c_api->Module_FindEnum(this, module, enum_descriptor, result); + } + ani_status Module_FindFunction(ani_module module, const char *name, const char *signature, ani_function *result) + { + return c_api->Module_FindFunction(this, module, name, signature, result); + } + ani_status Module_FindVariable(ani_module module, const char *name, ani_variable *result) + { + return c_api->Module_FindVariable(this, module, name, result); + } + ani_status Namespace_FindNamespace(ani_namespace ns, const char *namespace_descriptor, ani_namespace *result) + { + return c_api->Namespace_FindNamespace(this, ns, namespace_descriptor, result); + } + ani_status Namespace_FindClass(ani_namespace ns, const char *class_descriptor, ani_class *result) + { + return c_api->Namespace_FindClass(this, ns, class_descriptor, result); + } + ani_status Namespace_FindEnum(ani_namespace ns, const char *enum_descriptor, ani_enum *result) + { + return c_api->Namespace_FindEnum(this, ns, enum_descriptor, result); + } + ani_status Namespace_FindFunction(ani_namespace ns, const char *name, const char *signature, ani_function *result) + { + return c_api->Namespace_FindFunction(this, ns, name, signature, result); + } + ani_status Namespace_FindVariable(ani_namespace ns, const char *name, ani_variable *result) + { + return c_api->Namespace_FindVariable(this, ns, name, result); + } + ani_status Module_BindNativeFunctions(ani_module module, const ani_native_function *functions, + ani_size nr_functions) + { + return c_api->Module_BindNativeFunctions(this, module, functions, nr_functions); + } + ani_status Namespace_BindNativeFunctions(ani_namespace ns, const ani_native_function *functions, + ani_size nr_functions) + { + return c_api->Namespace_BindNativeFunctions(this, ns, functions, nr_functions); + } + ani_status Class_BindNativeMethods(ani_class cls, const ani_native_function *methods, ani_size nr_methods) + { + return c_api->Class_BindNativeMethods(this, cls, methods, nr_methods); + } + ani_status Reference_Delete(ani_ref ref) + { + return c_api->Reference_Delete(this, ref); + } + ani_status EnsureEnoughReferences(ani_size nr_refs) + { + return c_api->EnsureEnoughReferences(this, nr_refs); + } + ani_status CreateLocalScope(ani_size nr_refs) + { + return c_api->CreateLocalScope(this, nr_refs); + } + ani_status DestroyLocalScope() + { + return c_api->DestroyLocalScope(this); + } + ani_status CreateEscapeLocalScope(ani_size nr_refs) + { + return c_api->CreateEscapeLocalScope(this, nr_refs); + } + ani_status DestroyEscapeLocalScope(ani_ref ref, ani_ref *result) + { + return c_api->DestroyEscapeLocalScope(this, ref, result); + } + ani_status ThrowError(ani_error err) + { + return c_api->ThrowError(this, err); + } + ani_status ExistUnhandledError(ani_boolean *result) + { + return c_api->ExistUnhandledError(this, result); + } + ani_status GetUnhandledError(ani_error *result) + { + return c_api->GetUnhandledError(this, result); + } + ani_status ResetError() + { + return c_api->ResetError(this); + } + ani_status DescribeError() + { + return c_api->DescribeError(this); + } + ani_status Abort(const char *message) + { + return c_api->Abort(this, message); + } + ani_status GetNull(ani_ref *result) + { + return c_api->GetNull(this, result); + } + ani_status GetUndefined(ani_ref *result) + { + return c_api->GetUndefined(this, result); + } + ani_status Reference_IsNull(ani_ref ref, ani_boolean *result) + { + return c_api->Reference_IsNull(this, ref, result); + } + ani_status Reference_IsUndefined(ani_ref ref, ani_boolean *result) + { + return c_api->Reference_IsUndefined(this, ref, result); + } + ani_status Reference_IsNullishValue(ani_ref ref, ani_boolean *result) + { + return c_api->Reference_IsNullishValue(this, ref, result); + } + ani_status Reference_Equals(ani_ref ref0, ani_ref ref1, ani_boolean *result) + { + return c_api->Reference_Equals(this, ref0, ref1, result); + } + ani_status Reference_StrictEquals(ani_ref ref0, ani_ref ref1, ani_boolean *result) + { + return c_api->Reference_StrictEquals(this, ref0, ref1, result); + } + ani_status String_NewUTF16(const uint16_t *utf16_string, ani_size utf16_size, ani_string *result) + { + return c_api->String_NewUTF16(this, utf16_string, utf16_size, result); + } + ani_status String_GetUTF16Size(ani_string string, ani_size *result) + { + return c_api->String_GetUTF16Size(this, string, result); + } + ani_status String_GetUTF16(ani_string string, uint16_t *utf16_buffer, ani_size utf16_buffer_size, ani_size *result) + { + return c_api->String_GetUTF16(this, string, utf16_buffer, utf16_buffer_size, result); + } + ani_status String_GetUTF16SubString(ani_string string, ani_size substr_offset, ani_size substr_size, + uint16_t *utf16_buffer, ani_size utf16_buffer_size, ani_size *result) + { + return c_api->String_GetUTF16SubString(this, string, substr_offset, substr_size, utf16_buffer, + utf16_buffer_size, result); + } + ani_status String_NewUTF8(const char *utf8_string, ani_size utf8_size, ani_string *result) + { + return c_api->String_NewUTF8(this, utf8_string, utf8_size, result); + } + ani_status String_GetUTF8Size(ani_string string, ani_size *result) + { + return c_api->String_GetUTF8Size(this, string, result); + } + ani_status String_GetUTF8(ani_string string, char *utf8_buffer, ani_size utf8_buffer_size, ani_size *result) + { + return c_api->String_GetUTF8(this, string, utf8_buffer, utf8_buffer_size, result); + } + ani_status String_GetUTF8SubString(ani_string string, ani_size substr_offset, ani_size substr_size, + char *utf8_buffer, ani_size utf8_buffer_size, ani_size *result) + { + return c_api->String_GetUTF8SubString(this, string, substr_offset, substr_size, utf8_buffer, utf8_buffer_size, + result); + } + ani_status Array_GetLength(ani_array array, ani_size *result) + { + return c_api->Array_GetLength(this, array, result); + } + ani_status Array_New_Boolean(ani_size length, ani_array_boolean *result) + { + return c_api->Array_New_Boolean(this, length, result); + } + ani_status Array_New_Char(ani_size length, ani_array_char *result) + { + return c_api->Array_New_Char(this, length, result); + } + ani_status Array_New_Byte(ani_size length, ani_array_byte *result) + { + return c_api->Array_New_Byte(this, length, result); + } + ani_status Array_New_Short(ani_size length, ani_array_short *result) + { + return c_api->Array_New_Short(this, length, result); + } + ani_status Array_New_Int(ani_size length, ani_array_int *result) + { + return c_api->Array_New_Int(this, length, result); + } + ani_status Array_New_Long(ani_size length, ani_array_long *result) + { + return c_api->Array_New_Long(this, length, result); + } + ani_status Array_New_Float(ani_size length, ani_array_float *result) + { + return c_api->Array_New_Float(this, length, result); + } + ani_status Array_New_Double(ani_size length, ani_array_double *result) + { + return c_api->Array_New_Double(this, length, result); + } + ani_status Array_GetRegion_Boolean(ani_array_boolean array, ani_size offset, ani_size length, + ani_boolean *native_buffer) + { + return c_api->Array_GetRegion_Boolean(this, array, offset, length, native_buffer); + } + ani_status Array_GetRegion_Char(ani_array_char array, ani_size offset, ani_size length, ani_char *native_buffer) + { + return c_api->Array_GetRegion_Char(this, array, offset, length, native_buffer); + } + ani_status Array_GetRegion_Byte(ani_array_byte array, ani_size offset, ani_size length, ani_byte *native_buffer) + { + return c_api->Array_GetRegion_Byte(this, array, offset, length, native_buffer); + } + ani_status Array_GetRegion_Short(ani_array_short array, ani_size offset, ani_size length, ani_short *native_buffer) + { + return c_api->Array_GetRegion_Short(this, array, offset, length, native_buffer); + } + ani_status Array_GetRegion_Int(ani_array_int array, ani_size offset, ani_size length, ani_int *native_buffer) + { + return c_api->Array_GetRegion_Int(this, array, offset, length, native_buffer); + } + ani_status Array_GetRegion_Long(ani_array_long array, ani_size offset, ani_size length, ani_long *native_buffer) + { + return c_api->Array_GetRegion_Long(this, array, offset, length, native_buffer); + } + ani_status Array_GetRegion_Float(ani_array_float array, ani_size offset, ani_size length, ani_float *native_buffer) + { + return c_api->Array_GetRegion_Float(this, array, offset, length, native_buffer); + } + ani_status Array_GetRegion_Double(ani_array_double array, ani_size offset, ani_size length, + ani_double *native_buffer) + { + return c_api->Array_GetRegion_Double(this, array, offset, length, native_buffer); + } + ani_status Array_SetRegion_Boolean(ani_array_boolean array, ani_size offset, ani_size length, + const ani_boolean *native_buffer) + { + return c_api->Array_SetRegion_Boolean(this, array, offset, length, native_buffer); + } + ani_status Array_SetRegion_Char(ani_array_char array, ani_size offset, ani_size length, + const ani_char *native_buffer) + { + return c_api->Array_SetRegion_Char(this, array, offset, length, native_buffer); + } + ani_status Array_SetRegion_Byte(ani_array_byte array, ani_size offset, ani_size length, + const ani_byte *native_buffer) + { + return c_api->Array_SetRegion_Byte(this, array, offset, length, native_buffer); + } + ani_status Array_SetRegion_Short(ani_array_short array, ani_size offset, ani_size length, + const ani_short *native_buffer) + { + return c_api->Array_SetRegion_Short(this, array, offset, length, native_buffer); + } + ani_status Array_SetRegion_Int(ani_array_int array, ani_size offset, ani_size length, const ani_int *native_buffer) + { + return c_api->Array_SetRegion_Int(this, array, offset, length, native_buffer); + } + ani_status Array_SetRegion_Long(ani_array_long array, ani_size offset, ani_size length, + const ani_long *native_buffer) + { + return c_api->Array_SetRegion_Long(this, array, offset, length, native_buffer); + } + ani_status Array_SetRegion_Float(ani_array_float array, ani_size offset, ani_size length, + const ani_float *native_buffer) + { + return c_api->Array_SetRegion_Float(this, array, offset, length, native_buffer); + } + ani_status Array_SetRegion_Double(ani_array_double array, ani_size offset, ani_size length, + const ani_double *native_buffer) + { + return c_api->Array_SetRegion_Double(this, array, offset, length, native_buffer); + } + ani_status Array_New_Ref(ani_type type, ani_size length, ani_ref initial_element, ani_array_ref *result) + { + return c_api->Array_New_Ref(this, type, length, initial_element, result); + } + ani_status Array_Set_Ref(ani_array_ref array, ani_size index, ani_ref ref) + { + return c_api->Array_Set_Ref(this, array, index, ref); + } + ani_status Array_Get_Ref(ani_array_ref array, ani_size index, ani_ref *result) + { + return c_api->Array_Get_Ref(this, array, index, result); + } + ani_status Enum_GetEnumItemByName(ani_enum enm, const char *name, ani_enum_item *result) + { + return c_api->Enum_GetEnumItemByName(this, enm, name, result); + } + ani_status Enum_GetEnumItemByIndex(ani_enum enm, ani_size index, ani_enum_item *result) + { + return c_api->Enum_GetEnumItemByIndex(this, enm, index, result); + } + ani_status EnumItem_GetEnum(ani_enum_item enum_item, ani_enum *result) + { + return c_api->EnumItem_GetEnum(this, enum_item, result); + } + ani_status EnumItem_GetValue_Int(ani_enum_item enum_item, ani_int *result) + { + return c_api->EnumItem_GetValue_Int(this, enum_item, result); + } + ani_status EnumItem_GetValue_String(ani_enum_item enum_item, ani_string *result) + { + return c_api->EnumItem_GetValue_String(this, enum_item, result); + } + ani_status EnumItem_GetName(ani_enum_item enum_item, ani_string *result) + { + return c_api->EnumItem_GetName(this, enum_item, result); + } + ani_status EnumItem_GetIndex(ani_enum_item enum_item, ani_size *result) + { + return c_api->EnumItem_GetIndex(this, enum_item, result); + } + ani_status FunctionalObject_Call(ani_fn_object fn, ani_size argc, ani_ref *argv, ani_ref *result) + { + return c_api->FunctionalObject_Call(this, fn, argc, argv, result); + } + ani_status Variable_SetValue_Boolean(ani_variable variable, ani_boolean value) + { + return c_api->Variable_SetValue_Boolean(this, variable, value); + } + ani_status Variable_SetValue_Char(ani_variable variable, ani_char value) + { + return c_api->Variable_SetValue_Char(this, variable, value); + } + ani_status Variable_SetValue_Byte(ani_variable variable, ani_byte value) + { + return c_api->Variable_SetValue_Byte(this, variable, value); + } + ani_status Variable_SetValue_Short(ani_variable variable, ani_short value) + { + return c_api->Variable_SetValue_Short(this, variable, value); + } + ani_status Variable_SetValue_Int(ani_variable variable, ani_int value) + { + return c_api->Variable_SetValue_Int(this, variable, value); + } + ani_status Variable_SetValue_Long(ani_variable variable, ani_long value) + { + return c_api->Variable_SetValue_Long(this, variable, value); + } + ani_status Variable_SetValue_Float(ani_variable variable, ani_float value) + { + return c_api->Variable_SetValue_Float(this, variable, value); + } + ani_status Variable_SetValue_Double(ani_variable variable, ani_double value) + { + return c_api->Variable_SetValue_Double(this, variable, value); + } + ani_status Variable_SetValue_Ref(ani_variable variable, ani_ref value) + { + return c_api->Variable_SetValue_Ref(this, variable, value); + } + ani_status Variable_GetValue_Boolean(ani_variable variable, ani_boolean *result) + { + return c_api->Variable_GetValue_Boolean(this, variable, result); + } + ani_status Variable_GetValue_Char(ani_variable variable, ani_char *result) + { + return c_api->Variable_GetValue_Char(this, variable, result); + } + ani_status Variable_GetValue_Byte(ani_variable variable, ani_byte *result) + { + return c_api->Variable_GetValue_Byte(this, variable, result); + } + ani_status Variable_GetValue_Short(ani_variable variable, ani_short *result) + { + return c_api->Variable_GetValue_Short(this, variable, result); + } + ani_status Variable_GetValue_Int(ani_variable variable, ani_int *result) + { + return c_api->Variable_GetValue_Int(this, variable, result); + } + ani_status Variable_GetValue_Long(ani_variable variable, ani_long *result) + { + return c_api->Variable_GetValue_Long(this, variable, result); + } + ani_status Variable_GetValue_Float(ani_variable variable, ani_float *result) + { + return c_api->Variable_GetValue_Float(this, variable, result); + } + ani_status Variable_GetValue_Double(ani_variable variable, ani_double *result) + { + return c_api->Variable_GetValue_Double(this, variable, result); + } + ani_status Variable_GetValue_Ref(ani_variable variable, ani_ref *result) + { + return c_api->Variable_GetValue_Ref(this, variable, result); + } + ani_status Function_Call_Boolean(ani_function fn, ani_boolean *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Function_Call_Boolean_V(this, fn, result, args); + va_end(args); + return status; + } + ani_status Function_Call_Boolean_A(ani_function fn, ani_boolean *result, const ani_value *args) + { + return c_api->Function_Call_Boolean_A(this, fn, result, args); + } + ani_status Function_Call_Boolean_V(ani_function fn, ani_boolean *result, va_list args) + { + return c_api->Function_Call_Boolean_V(this, fn, result, args); + } + ani_status Function_Call_Char(ani_function fn, ani_char *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Function_Call_Char_V(this, fn, result, args); + va_end(args); + return status; + } + ani_status Function_Call_Char_A(ani_function fn, ani_char *result, const ani_value *args) + { + return c_api->Function_Call_Char_A(this, fn, result, args); + } + ani_status Function_Call_Char_V(ani_function fn, ani_char *result, va_list args) + { + return c_api->Function_Call_Char_V(this, fn, result, args); + } + ani_status Function_Call_Byte(ani_function fn, ani_byte *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Function_Call_Byte_V(this, fn, result, args); + va_end(args); + return status; + } + ani_status Function_Call_Byte_A(ani_function fn, ani_byte *result, const ani_value *args) + { + return c_api->Function_Call_Byte_A(this, fn, result, args); + } + ani_status Function_Call_Byte_V(ani_function fn, ani_byte *result, va_list args) + { + return c_api->Function_Call_Byte_V(this, fn, result, args); + } + ani_status Function_Call_Short(ani_function fn, ani_short *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Function_Call_Short_V(this, fn, result, args); + va_end(args); + return status; + } + ani_status Function_Call_Short_A(ani_function fn, ani_short *result, const ani_value *args) + { + return c_api->Function_Call_Short_A(this, fn, result, args); + } + ani_status Function_Call_Short_V(ani_function fn, ani_short *result, va_list args) + { + return c_api->Function_Call_Short_V(this, fn, result, args); + } + ani_status Function_Call_Int(ani_function fn, ani_int *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Function_Call_Int_V(this, fn, result, args); + va_end(args); + return status; + } + ani_status Function_Call_Int_A(ani_function fn, ani_int *result, const ani_value *args) + { + return c_api->Function_Call_Int_A(this, fn, result, args); + } + ani_status Function_Call_Int_V(ani_function fn, ani_int *result, va_list args) + { + return c_api->Function_Call_Int_V(this, fn, result, args); + } + ani_status Function_Call_Long(ani_function fn, ani_long *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Function_Call_Long_V(this, fn, result, args); + va_end(args); + return status; + } + ani_status Function_Call_Long_A(ani_function fn, ani_long *result, const ani_value *args) + { + return c_api->Function_Call_Long_A(this, fn, result, args); + } + ani_status Function_Call_Long_V(ani_function fn, ani_long *result, va_list args) + { + return c_api->Function_Call_Long_V(this, fn, result, args); + } + ani_status Function_Call_Float(ani_function fn, ani_float *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Function_Call_Float_V(this, fn, result, args); + va_end(args); + return status; + } + ani_status Function_Call_Float_A(ani_function fn, ani_float *result, const ani_value *args) + { + return c_api->Function_Call_Float_A(this, fn, result, args); + } + ani_status Function_Call_Float_V(ani_function fn, ani_float *result, va_list args) + { + return c_api->Function_Call_Float_V(this, fn, result, args); + } + ani_status Function_Call_Double(ani_function fn, ani_double *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Function_Call_Double_V(this, fn, result, args); + va_end(args); + return status; + } + ani_status Function_Call_Double_A(ani_function fn, ani_double *result, const ani_value *args) + { + return c_api->Function_Call_Double_A(this, fn, result, args); + } + ani_status Function_Call_Double_V(ani_function fn, ani_double *result, va_list args) + { + return c_api->Function_Call_Double_V(this, fn, result, args); + } + ani_status Function_Call_Ref(ani_function fn, ani_ref *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Function_Call_Ref_V(this, fn, result, args); + va_end(args); + return status; + } + ani_status Function_Call_Ref_A(ani_function fn, ani_ref *result, const ani_value *args) + { + return c_api->Function_Call_Ref_A(this, fn, result, args); + } + ani_status Function_Call_Ref_V(ani_function fn, ani_ref *result, va_list args) + { + return c_api->Function_Call_Ref_V(this, fn, result, args); + } + ani_status Function_Call_Void(ani_function fn, ...) + { + va_list args; + va_start(args, fn); + ani_status status = c_api->Function_Call_Void_V(this, fn, args); + va_end(args); + return status; + } + ani_status Function_Call_Void_A(ani_function fn, const ani_value *args) + { + return c_api->Function_Call_Void_A(this, fn, args); + } + ani_status Function_Call_Void_V(ani_function fn, va_list args) + { + return c_api->Function_Call_Void_V(this, fn, args); + } + ani_status Class_FindField(ani_class cls, const char *name, ani_field *result) + { + return c_api->Class_FindField(this, cls, name, result); + } + ani_status Class_FindStaticField(ani_class cls, const char *name, ani_static_field *result) + { + return c_api->Class_FindStaticField(this, cls, name, result); + } + ani_status Class_FindMethod(ani_class cls, const char *name, const char *signature, ani_method *result) + { + return c_api->Class_FindMethod(this, cls, name, signature, result); + } + ani_status Class_FindStaticMethod(ani_class cls, const char *name, const char *signature, ani_static_method *result) + { + return c_api->Class_FindStaticMethod(this, cls, name, signature, result); + } + ani_status Class_FindSetter(ani_class cls, const char *name, ani_method *result) + { + return c_api->Class_FindSetter(this, cls, name, result); + } + ani_status Class_FindGetter(ani_class cls, const char *name, ani_method *result) + { + return c_api->Class_FindGetter(this, cls, name, result); + } + ani_status Class_FindIndexableGetter(ani_class cls, const char *signature, ani_method *result) + { + return c_api->Class_FindIndexableGetter(this, cls, signature, result); + } + ani_status Class_FindIndexableSetter(ani_class cls, const char *signature, ani_method *result) + { + return c_api->Class_FindIndexableSetter(this, cls, signature, result); + } + ani_status Class_FindIterator(ani_class cls, ani_method *result) + { + return c_api->Class_FindIterator(this, cls, result); + } + ani_status Class_GetStaticField_Boolean(ani_class cls, ani_static_field field, ani_boolean *result) + { + return c_api->Class_GetStaticField_Boolean(this, cls, field, result); + } + ani_status Class_GetStaticField_Char(ani_class cls, ani_static_field field, ani_char *result) + { + return c_api->Class_GetStaticField_Char(this, cls, field, result); + } + ani_status Class_GetStaticField_Byte(ani_class cls, ani_static_field field, ani_byte *result) + { + return c_api->Class_GetStaticField_Byte(this, cls, field, result); + } + ani_status Class_GetStaticField_Short(ani_class cls, ani_static_field field, ani_short *result) + { + return c_api->Class_GetStaticField_Short(this, cls, field, result); + } + ani_status Class_GetStaticField_Int(ani_class cls, ani_static_field field, ani_int *result) + { + return c_api->Class_GetStaticField_Int(this, cls, field, result); + } + ani_status Class_GetStaticField_Long(ani_class cls, ani_static_field field, ani_long *result) + { + return c_api->Class_GetStaticField_Long(this, cls, field, result); + } + ani_status Class_GetStaticField_Float(ani_class cls, ani_static_field field, ani_float *result) + { + return c_api->Class_GetStaticField_Float(this, cls, field, result); + } + ani_status Class_GetStaticField_Double(ani_class cls, ani_static_field field, ani_double *result) + { + return c_api->Class_GetStaticField_Double(this, cls, field, result); + } + ani_status Class_GetStaticField_Ref(ani_class cls, ani_static_field field, ani_ref *result) + { + return c_api->Class_GetStaticField_Ref(this, cls, field, result); + } + ani_status Class_SetStaticField_Boolean(ani_class cls, ani_static_field field, ani_boolean value) + { + return c_api->Class_SetStaticField_Boolean(this, cls, field, value); + } + ani_status Class_SetStaticField_Char(ani_class cls, ani_static_field field, ani_char value) + { + return c_api->Class_SetStaticField_Char(this, cls, field, value); + } + ani_status Class_SetStaticField_Byte(ani_class cls, ani_static_field field, ani_byte value) + { + return c_api->Class_SetStaticField_Byte(this, cls, field, value); + } + ani_status Class_SetStaticField_Short(ani_class cls, ani_static_field field, ani_short value) + { + return c_api->Class_SetStaticField_Short(this, cls, field, value); + } + ani_status Class_SetStaticField_Int(ani_class cls, ani_static_field field, ani_int value) + { + return c_api->Class_SetStaticField_Int(this, cls, field, value); + } + ani_status Class_SetStaticField_Long(ani_class cls, ani_static_field field, ani_long value) + { + return c_api->Class_SetStaticField_Long(this, cls, field, value); + } + ani_status Class_SetStaticField_Float(ani_class cls, ani_static_field field, ani_float value) + { + return c_api->Class_SetStaticField_Float(this, cls, field, value); + } + ani_status Class_SetStaticField_Double(ani_class cls, ani_static_field field, ani_double value) + { + return c_api->Class_SetStaticField_Double(this, cls, field, value); + } + ani_status Class_SetStaticField_Ref(ani_class cls, ani_static_field field, ani_ref value) + { + return c_api->Class_SetStaticField_Ref(this, cls, field, value); + } + ani_status Class_GetStaticFieldByName_Boolean(ani_class cls, const char *name, ani_boolean *result) + { + return c_api->Class_GetStaticFieldByName_Boolean(this, cls, name, result); + } + ani_status Class_GetStaticFieldByName_Char(ani_class cls, const char *name, ani_char *result) + { + return c_api->Class_GetStaticFieldByName_Char(this, cls, name, result); + } + ani_status Class_GetStaticFieldByName_Byte(ani_class cls, const char *name, ani_byte *result) + { + return c_api->Class_GetStaticFieldByName_Byte(this, cls, name, result); + } + ani_status Class_GetStaticFieldByName_Short(ani_class cls, const char *name, ani_short *result) + { + return c_api->Class_GetStaticFieldByName_Short(this, cls, name, result); + } + ani_status Class_GetStaticFieldByName_Int(ani_class cls, const char *name, ani_int *result) + { + return c_api->Class_GetStaticFieldByName_Int(this, cls, name, result); + } + ani_status Class_GetStaticFieldByName_Long(ani_class cls, const char *name, ani_long *result) + { + return c_api->Class_GetStaticFieldByName_Long(this, cls, name, result); + } + ani_status Class_GetStaticFieldByName_Float(ani_class cls, const char *name, ani_float *result) + { + return c_api->Class_GetStaticFieldByName_Float(this, cls, name, result); + } + ani_status Class_GetStaticFieldByName_Double(ani_class cls, const char *name, ani_double *result) + { + return c_api->Class_GetStaticFieldByName_Double(this, cls, name, result); + } + ani_status Class_GetStaticFieldByName_Ref(ani_class cls, const char *name, ani_ref *result) + { + return c_api->Class_GetStaticFieldByName_Ref(this, cls, name, result); + } + ani_status Class_SetStaticFieldByName_Boolean(ani_class cls, const char *name, ani_boolean value) + { + return c_api->Class_SetStaticFieldByName_Boolean(this, cls, name, value); + } + ani_status Class_SetStaticFieldByName_Char(ani_class cls, const char *name, ani_char value) + { + return c_api->Class_SetStaticFieldByName_Char(this, cls, name, value); + } + ani_status Class_SetStaticFieldByName_Byte(ani_class cls, const char *name, ani_byte value) + { + return c_api->Class_SetStaticFieldByName_Byte(this, cls, name, value); + } + ani_status Class_SetStaticFieldByName_Short(ani_class cls, const char *name, ani_short value) + { + return c_api->Class_SetStaticFieldByName_Short(this, cls, name, value); + } + ani_status Class_SetStaticFieldByName_Int(ani_class cls, const char *name, ani_int value) + { + return c_api->Class_SetStaticFieldByName_Int(this, cls, name, value); + } + ani_status Class_SetStaticFieldByName_Long(ani_class cls, const char *name, ani_long value) + { + return c_api->Class_SetStaticFieldByName_Long(this, cls, name, value); + } + ani_status Class_SetStaticFieldByName_Float(ani_class cls, const char *name, ani_float value) + { + return c_api->Class_SetStaticFieldByName_Float(this, cls, name, value); + } + ani_status Class_SetStaticFieldByName_Double(ani_class cls, const char *name, ani_double value) + { + return c_api->Class_SetStaticFieldByName_Double(this, cls, name, value); + } + ani_status Class_SetStaticFieldByName_Ref(ani_class cls, const char *name, ani_ref value) + { + return c_api->Class_SetStaticFieldByName_Ref(this, cls, name, value); + } + ani_status Class_CallStaticMethod_Boolean(ani_class cls, ani_static_method method, ani_boolean *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Class_CallStaticMethod_Boolean_V(this, cls, method, result, args); + va_end(args); + return status; + } + ani_status Class_CallStaticMethod_Boolean_A(ani_class cls, ani_static_method method, ani_boolean *result, + const ani_value *args) + { + return c_api->Class_CallStaticMethod_Boolean_A(this, cls, method, result, args); + } + ani_status Class_CallStaticMethod_Boolean_V(ani_class cls, ani_static_method method, ani_boolean *result, + va_list args) + { + return c_api->Class_CallStaticMethod_Boolean_V(this, cls, method, result, args); + } + ani_status Class_CallStaticMethod_Char(ani_class cls, ani_static_method method, ani_char *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Class_CallStaticMethod_Char_V(this, cls, method, result, args); + va_end(args); + return status; + } + ani_status Class_CallStaticMethod_Char_A(ani_class cls, ani_static_method method, ani_char *result, + const ani_value *args) + { + return c_api->Class_CallStaticMethod_Char_A(this, cls, method, result, args); + } + ani_status Class_CallStaticMethod_Char_V(ani_class cls, ani_static_method method, ani_char *result, va_list args) + { + return c_api->Class_CallStaticMethod_Char_V(this, cls, method, result, args); + } + ani_status Class_CallStaticMethod_Byte(ani_class cls, ani_static_method method, ani_byte *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Class_CallStaticMethod_Byte_V(this, cls, method, result, args); + va_end(args); + return status; + } + ani_status Class_CallStaticMethod_Byte_A(ani_class cls, ani_static_method method, ani_byte *result, + const ani_value *args) + { + return c_api->Class_CallStaticMethod_Byte_A(this, cls, method, result, args); + } + ani_status Class_CallStaticMethod_Byte_V(ani_class cls, ani_static_method method, ani_byte *result, va_list args) + { + return c_api->Class_CallStaticMethod_Byte_V(this, cls, method, result, args); + } + ani_status Class_CallStaticMethod_Short(ani_class cls, ani_static_method method, ani_short *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Class_CallStaticMethod_Short_V(this, cls, method, result, args); + va_end(args); + return status; + } + ani_status Class_CallStaticMethod_Short_A(ani_class cls, ani_static_method method, ani_short *result, + const ani_value *args) + { + return c_api->Class_CallStaticMethod_Short_A(this, cls, method, result, args); + } + ani_status Class_CallStaticMethod_Short_V(ani_class cls, ani_static_method method, ani_short *result, va_list args) + { + return c_api->Class_CallStaticMethod_Short_V(this, cls, method, result, args); + } + ani_status Class_CallStaticMethod_Int(ani_class cls, ani_static_method method, ani_int *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Class_CallStaticMethod_Int_V(this, cls, method, result, args); + va_end(args); + return status; + } + ani_status Class_CallStaticMethod_Int_A(ani_class cls, ani_static_method method, ani_int *result, + const ani_value *args) + { + return c_api->Class_CallStaticMethod_Int_A(this, cls, method, result, args); + } + ani_status Class_CallStaticMethod_Int_V(ani_class cls, ani_static_method method, ani_int *result, va_list args) + { + return c_api->Class_CallStaticMethod_Int_V(this, cls, method, result, args); + } + ani_status Class_CallStaticMethod_Long(ani_class cls, ani_static_method method, ani_long *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Class_CallStaticMethod_Long_V(this, cls, method, result, args); + va_end(args); + return status; + } + ani_status Class_CallStaticMethod_Long_A(ani_class cls, ani_static_method method, ani_long *result, + const ani_value *args) + { + return c_api->Class_CallStaticMethod_Long_A(this, cls, method, result, args); + } + ani_status Class_CallStaticMethod_Long_V(ani_class cls, ani_static_method method, ani_long *result, va_list args) + { + return c_api->Class_CallStaticMethod_Long_V(this, cls, method, result, args); + } + ani_status Class_CallStaticMethod_Float(ani_class cls, ani_static_method method, ani_float *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Class_CallStaticMethod_Float_V(this, cls, method, result, args); + va_end(args); + return status; + } + ani_status Class_CallStaticMethod_Float_A(ani_class cls, ani_static_method method, ani_float *result, + const ani_value *args) + { + return c_api->Class_CallStaticMethod_Float_A(this, cls, method, result, args); + } + ani_status Class_CallStaticMethod_Float_V(ani_class cls, ani_static_method method, ani_float *result, va_list args) + { + return c_api->Class_CallStaticMethod_Float_V(this, cls, method, result, args); + } + ani_status Class_CallStaticMethod_Double(ani_class cls, ani_static_method method, ani_double *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Class_CallStaticMethod_Double_V(this, cls, method, result, args); + va_end(args); + return status; + } + ani_status Class_CallStaticMethod_Double_A(ani_class cls, ani_static_method method, ani_double *result, + const ani_value *args) + { + return c_api->Class_CallStaticMethod_Double_A(this, cls, method, result, args); + } + ani_status Class_CallStaticMethod_Double_V(ani_class cls, ani_static_method method, ani_double *result, + va_list args) + { + return c_api->Class_CallStaticMethod_Double_V(this, cls, method, result, args); + } + ani_status Class_CallStaticMethod_Ref(ani_class cls, ani_static_method method, ani_ref *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Class_CallStaticMethod_Ref_V(this, cls, method, result, args); + va_end(args); + return status; + } + ani_status Class_CallStaticMethod_Ref_A(ani_class cls, ani_static_method method, ani_ref *result, + const ani_value *args) + { + return c_api->Class_CallStaticMethod_Ref_A(this, cls, method, result, args); + } + ani_status Class_CallStaticMethod_Ref_V(ani_class cls, ani_static_method method, ani_ref *result, va_list args) + { + return c_api->Class_CallStaticMethod_Ref_V(this, cls, method, result, args); + } + ani_status Class_CallStaticMethod_Void(ani_class cls, ani_static_method method, ...) + { + va_list args; + va_start(args, method); + ani_status status = c_api->Class_CallStaticMethod_Void_V(this, cls, method, args); + va_end(args); + return status; + } + ani_status Class_CallStaticMethod_Void_A(ani_class cls, ani_static_method method, const ani_value *args) + { + return c_api->Class_CallStaticMethod_Void_A(this, cls, method, args); + } + ani_status Class_CallStaticMethod_Void_V(ani_class cls, ani_static_method method, va_list args) + { + return c_api->Class_CallStaticMethod_Void_V(this, cls, method, args); + } + ani_status Class_CallStaticMethodByName_Boolean(ani_class cls, const char *name, const char *signature, + ani_boolean *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Class_CallStaticMethodByName_Boolean_V(this, cls, name, signature, result, args); + va_end(args); + return status; + } + ani_status Class_CallStaticMethodByName_Boolean_A(ani_class cls, const char *name, const char *signature, + ani_boolean *result, const ani_value *args) + { + return c_api->Class_CallStaticMethodByName_Boolean_A(this, cls, name, signature, result, args); + } + ani_status Class_CallStaticMethodByName_Boolean_V(ani_class cls, const char *name, const char *signature, + ani_boolean *result, va_list args) + { + return c_api->Class_CallStaticMethodByName_Boolean_V(this, cls, name, signature, result, args); + } + ani_status Class_CallStaticMethodByName_Char(ani_class cls, const char *name, const char *signature, + ani_char *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Class_CallStaticMethodByName_Char_V(this, cls, name, signature, result, args); + va_end(args); + return status; + } + ani_status Class_CallStaticMethodByName_Char_A(ani_class cls, const char *name, const char *signature, + ani_char *result, const ani_value *args) + { + return c_api->Class_CallStaticMethodByName_Char_A(this, cls, name, signature, result, args); + } + ani_status Class_CallStaticMethodByName_Char_V(ani_class cls, const char *name, const char *signature, + ani_char *result, va_list args) + { + return c_api->Class_CallStaticMethodByName_Char_V(this, cls, name, signature, result, args); + } + ani_status Class_CallStaticMethodByName_Byte(ani_class cls, const char *name, const char *signature, + ani_byte *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Class_CallStaticMethodByName_Byte_V(this, cls, name, signature, result, args); + va_end(args); + return status; + } + ani_status Class_CallStaticMethodByName_Byte_A(ani_class cls, const char *name, const char *signature, + ani_byte *result, const ani_value *args) + { + return c_api->Class_CallStaticMethodByName_Byte_A(this, cls, name, signature, result, args); + } + ani_status Class_CallStaticMethodByName_Byte_V(ani_class cls, const char *name, const char *signature, + ani_byte *result, va_list args) + { + return c_api->Class_CallStaticMethodByName_Byte_V(this, cls, name, signature, result, args); + } + ani_status Class_CallStaticMethodByName_Short(ani_class cls, const char *name, const char *signature, + ani_short *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Class_CallStaticMethodByName_Short_V(this, cls, name, signature, result, args); + va_end(args); + return status; + } + ani_status Class_CallStaticMethodByName_Short_A(ani_class cls, const char *name, const char *signature, + ani_short *result, const ani_value *args) + { + return c_api->Class_CallStaticMethodByName_Short_A(this, cls, name, signature, result, args); + } + ani_status Class_CallStaticMethodByName_Short_V(ani_class cls, const char *name, const char *signature, + ani_short *result, va_list args) + { + return c_api->Class_CallStaticMethodByName_Short_V(this, cls, name, signature, result, args); + } + ani_status Class_CallStaticMethodByName_Int(ani_class cls, const char *name, const char *signature, ani_int *result, + ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Class_CallStaticMethodByName_Int_V(this, cls, name, signature, result, args); + va_end(args); + return status; + } + ani_status Class_CallStaticMethodByName_Int_A(ani_class cls, const char *name, const char *signature, + ani_int *result, const ani_value *args) + { + return c_api->Class_CallStaticMethodByName_Int_A(this, cls, name, signature, result, args); + } + ani_status Class_CallStaticMethodByName_Int_V(ani_class cls, const char *name, const char *signature, + ani_int *result, va_list args) + { + return c_api->Class_CallStaticMethodByName_Int_V(this, cls, name, signature, result, args); + } + ani_status Class_CallStaticMethodByName_Long(ani_class cls, const char *name, const char *signature, + ani_long *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Class_CallStaticMethodByName_Long_V(this, cls, name, signature, result, args); + va_end(args); + return status; + } + ani_status Class_CallStaticMethodByName_Long_A(ani_class cls, const char *name, const char *signature, + ani_long *result, const ani_value *args) + { + return c_api->Class_CallStaticMethodByName_Long_A(this, cls, name, signature, result, args); + } + ani_status Class_CallStaticMethodByName_Long_V(ani_class cls, const char *name, const char *signature, + ani_long *result, va_list args) + { + return c_api->Class_CallStaticMethodByName_Long_V(this, cls, name, signature, result, args); + } + ani_status Class_CallStaticMethodByName_Float(ani_class cls, const char *name, const char *signature, + ani_float *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Class_CallStaticMethodByName_Float_V(this, cls, name, signature, result, args); + va_end(args); + return status; + } + ani_status Class_CallStaticMethodByName_Float_A(ani_class cls, const char *name, const char *signature, + ani_float *result, const ani_value *args) + { + return c_api->Class_CallStaticMethodByName_Float_A(this, cls, name, signature, result, args); + } + ani_status Class_CallStaticMethodByName_Float_V(ani_class cls, const char *name, const char *signature, + ani_float *result, va_list args) + { + return c_api->Class_CallStaticMethodByName_Float_V(this, cls, name, signature, result, args); + } + ani_status Class_CallStaticMethodByName_Double(ani_class cls, const char *name, const char *signature, + ani_double *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Class_CallStaticMethodByName_Double_V(this, cls, name, signature, result, args); + va_end(args); + return status; + } + ani_status Class_CallStaticMethodByName_Double_A(ani_class cls, const char *name, const char *signature, + ani_double *result, const ani_value *args) + { + return c_api->Class_CallStaticMethodByName_Double_A(this, cls, name, signature, result, args); + } + ani_status Class_CallStaticMethodByName_Double_V(ani_class cls, const char *name, const char *signature, + ani_double *result, va_list args) + { + return c_api->Class_CallStaticMethodByName_Double_V(this, cls, name, signature, result, args); + } + ani_status Class_CallStaticMethodByName_Ref(ani_class cls, const char *name, const char *signature, ani_ref *result, + ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Class_CallStaticMethodByName_Ref_V(this, cls, name, signature, result, args); + va_end(args); + return status; + } + ani_status Class_CallStaticMethodByName_Ref_A(ani_class cls, const char *name, const char *signature, + ani_ref *result, const ani_value *args) + { + return c_api->Class_CallStaticMethodByName_Ref_A(this, cls, name, signature, result, args); + } + ani_status Class_CallStaticMethodByName_Ref_V(ani_class cls, const char *name, const char *signature, + ani_ref *result, va_list args) + { + return c_api->Class_CallStaticMethodByName_Ref_V(this, cls, name, signature, result, args); + } + ani_status Class_CallStaticMethodByName_Void(ani_class cls, const char *name, const char *signature, ...) + { + va_list args; + va_start(args, signature); + ani_status status = c_api->Class_CallStaticMethodByName_Void_V(this, cls, name, signature, args); + va_end(args); + return status; + } + ani_status Class_CallStaticMethodByName_Void_A(ani_class cls, const char *name, const char *signature, + const ani_value *args) + { + return c_api->Class_CallStaticMethodByName_Void_A(this, cls, name, signature, args); + } + ani_status Class_CallStaticMethodByName_Void_V(ani_class cls, const char *name, const char *signature, va_list args) + { + return c_api->Class_CallStaticMethodByName_Void_V(this, cls, name, signature, args); + } + ani_status Object_GetField_Boolean(ani_object object, ani_field field, ani_boolean *result) + { + return c_api->Object_GetField_Boolean(this, object, field, result); + } + ani_status Object_GetField_Char(ani_object object, ani_field field, ani_char *result) + { + return c_api->Object_GetField_Char(this, object, field, result); + } + ani_status Object_GetField_Byte(ani_object object, ani_field field, ani_byte *result) + { + return c_api->Object_GetField_Byte(this, object, field, result); + } + ani_status Object_GetField_Short(ani_object object, ani_field field, ani_short *result) + { + return c_api->Object_GetField_Short(this, object, field, result); + } + ani_status Object_GetField_Int(ani_object object, ani_field field, ani_int *result) + { + return c_api->Object_GetField_Int(this, object, field, result); + } + ani_status Object_GetField_Long(ani_object object, ani_field field, ani_long *result) + { + return c_api->Object_GetField_Long(this, object, field, result); + } + ani_status Object_GetField_Float(ani_object object, ani_field field, ani_float *result) + { + return c_api->Object_GetField_Float(this, object, field, result); + } + ani_status Object_GetField_Double(ani_object object, ani_field field, ani_double *result) + { + return c_api->Object_GetField_Double(this, object, field, result); + } + ani_status Object_GetField_Ref(ani_object object, ani_field field, ani_ref *result) + { + return c_api->Object_GetField_Ref(this, object, field, result); + } + ani_status Object_SetField_Boolean(ani_object object, ani_field field, ani_boolean value) + { + return c_api->Object_SetField_Boolean(this, object, field, value); + } + ani_status Object_SetField_Char(ani_object object, ani_field field, ani_char value) + { + return c_api->Object_SetField_Char(this, object, field, value); + } + ani_status Object_SetField_Byte(ani_object object, ani_field field, ani_byte value) + { + return c_api->Object_SetField_Byte(this, object, field, value); + } + ani_status Object_SetField_Short(ani_object object, ani_field field, ani_short value) + { + return c_api->Object_SetField_Short(this, object, field, value); + } + ani_status Object_SetField_Int(ani_object object, ani_field field, ani_int value) + { + return c_api->Object_SetField_Int(this, object, field, value); + } + ani_status Object_SetField_Long(ani_object object, ani_field field, ani_long value) + { + return c_api->Object_SetField_Long(this, object, field, value); + } + ani_status Object_SetField_Float(ani_object object, ani_field field, ani_float value) + { + return c_api->Object_SetField_Float(this, object, field, value); + } + ani_status Object_SetField_Double(ani_object object, ani_field field, ani_double value) + { + return c_api->Object_SetField_Double(this, object, field, value); + } + ani_status Object_SetField_Ref(ani_object object, ani_field field, ani_ref value) + { + return c_api->Object_SetField_Ref(this, object, field, value); + } + ani_status Object_GetFieldByName_Boolean(ani_object object, const char *name, ani_boolean *result) + { + return c_api->Object_GetFieldByName_Boolean(this, object, name, result); + } + ani_status Object_GetFieldByName_Char(ani_object object, const char *name, ani_char *result) + { + return c_api->Object_GetFieldByName_Char(this, object, name, result); + } + ani_status Object_GetFieldByName_Byte(ani_object object, const char *name, ani_byte *result) + { + return c_api->Object_GetFieldByName_Byte(this, object, name, result); + } + ani_status Object_GetFieldByName_Short(ani_object object, const char *name, ani_short *result) + { + return c_api->Object_GetFieldByName_Short(this, object, name, result); + } + ani_status Object_GetFieldByName_Int(ani_object object, const char *name, ani_int *result) + { + return c_api->Object_GetFieldByName_Int(this, object, name, result); + } + ani_status Object_GetFieldByName_Long(ani_object object, const char *name, ani_long *result) + { + return c_api->Object_GetFieldByName_Long(this, object, name, result); + } + ani_status Object_GetFieldByName_Float(ani_object object, const char *name, ani_float *result) + { + return c_api->Object_GetFieldByName_Float(this, object, name, result); + } + ani_status Object_GetFieldByName_Double(ani_object object, const char *name, ani_double *result) + { + return c_api->Object_GetFieldByName_Double(this, object, name, result); + } + ani_status Object_GetFieldByName_Ref(ani_object object, const char *name, ani_ref *result) + { + return c_api->Object_GetFieldByName_Ref(this, object, name, result); + } + ani_status Object_SetFieldByName_Boolean(ani_object object, const char *name, ani_boolean value) + { + return c_api->Object_SetFieldByName_Boolean(this, object, name, value); + } + ani_status Object_SetFieldByName_Char(ani_object object, const char *name, ani_char value) + { + return c_api->Object_SetFieldByName_Char(this, object, name, value); + } + ani_status Object_SetFieldByName_Byte(ani_object object, const char *name, ani_byte value) + { + return c_api->Object_SetFieldByName_Byte(this, object, name, value); + } + ani_status Object_SetFieldByName_Short(ani_object object, const char *name, ani_short value) + { + return c_api->Object_SetFieldByName_Short(this, object, name, value); + } + ani_status Object_SetFieldByName_Int(ani_object object, const char *name, ani_int value) + { + return c_api->Object_SetFieldByName_Int(this, object, name, value); + } + ani_status Object_SetFieldByName_Long(ani_object object, const char *name, ani_long value) + { + return c_api->Object_SetFieldByName_Long(this, object, name, value); + } + ani_status Object_SetFieldByName_Float(ani_object object, const char *name, ani_float value) + { + return c_api->Object_SetFieldByName_Float(this, object, name, value); + } + ani_status Object_SetFieldByName_Double(ani_object object, const char *name, ani_double value) + { + return c_api->Object_SetFieldByName_Double(this, object, name, value); + } + ani_status Object_SetFieldByName_Ref(ani_object object, const char *name, ani_ref value) + { + return c_api->Object_SetFieldByName_Ref(this, object, name, value); + } + ani_status Object_GetPropertyByName_Boolean(ani_object object, const char *name, ani_boolean *result) + { + return c_api->Object_GetPropertyByName_Boolean(this, object, name, result); + } + ani_status Object_GetPropertyByName_Char(ani_object object, const char *name, ani_char *result) + { + return c_api->Object_GetPropertyByName_Char(this, object, name, result); + } + ani_status Object_GetPropertyByName_Byte(ani_object object, const char *name, ani_byte *result) + { + return c_api->Object_GetPropertyByName_Byte(this, object, name, result); + } + ani_status Object_GetPropertyByName_Short(ani_object object, const char *name, ani_short *result) + { + return c_api->Object_GetPropertyByName_Short(this, object, name, result); + } + ani_status Object_GetPropertyByName_Int(ani_object object, const char *name, ani_int *result) + { + return c_api->Object_GetPropertyByName_Int(this, object, name, result); + } + ani_status Object_GetPropertyByName_Long(ani_object object, const char *name, ani_long *result) + { + return c_api->Object_GetPropertyByName_Long(this, object, name, result); + } + ani_status Object_GetPropertyByName_Float(ani_object object, const char *name, ani_float *result) + { + return c_api->Object_GetPropertyByName_Float(this, object, name, result); + } + ani_status Object_GetPropertyByName_Double(ani_object object, const char *name, ani_double *result) + { + return c_api->Object_GetPropertyByName_Double(this, object, name, result); + } + ani_status Object_GetPropertyByName_Ref(ani_object object, const char *name, ani_ref *result) + { + return c_api->Object_GetPropertyByName_Ref(this, object, name, result); + } + ani_status Object_SetPropertyByName_Boolean(ani_object object, const char *name, ani_boolean value) + { + return c_api->Object_SetPropertyByName_Boolean(this, object, name, value); + } + ani_status Object_SetPropertyByName_Char(ani_object object, const char *name, ani_char value) + { + return c_api->Object_SetPropertyByName_Char(this, object, name, value); + } + ani_status Object_SetPropertyByName_Byte(ani_object object, const char *name, ani_byte value) + { + return c_api->Object_SetPropertyByName_Byte(this, object, name, value); + } + ani_status Object_SetPropertyByName_Short(ani_object object, const char *name, ani_short value) + { + return c_api->Object_SetPropertyByName_Short(this, object, name, value); + } + ani_status Object_SetPropertyByName_Int(ani_object object, const char *name, ani_int value) + { + return c_api->Object_SetPropertyByName_Int(this, object, name, value); + } + ani_status Object_SetPropertyByName_Long(ani_object object, const char *name, ani_long value) + { + return c_api->Object_SetPropertyByName_Long(this, object, name, value); + } + ani_status Object_SetPropertyByName_Float(ani_object object, const char *name, ani_float value) + { + return c_api->Object_SetPropertyByName_Float(this, object, name, value); + } + ani_status Object_SetPropertyByName_Double(ani_object object, const char *name, ani_double value) + { + return c_api->Object_SetPropertyByName_Double(this, object, name, value); + } + ani_status Object_SetPropertyByName_Ref(ani_object object, const char *name, ani_ref value) + { + return c_api->Object_SetPropertyByName_Ref(this, object, name, value); + } + ani_status Object_CallMethod_Boolean(ani_object object, ani_method method, ani_boolean *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Object_CallMethod_Boolean_V(this, object, method, result, args); + va_end(args); + return status; + } + ani_status Object_CallMethod_Boolean_A(ani_object object, ani_method method, ani_boolean *result, + const ani_value *args) + { + return c_api->Object_CallMethod_Boolean_A(this, object, method, result, args); + } + ani_status Object_CallMethod_Boolean_V(ani_object object, ani_method method, ani_boolean *result, va_list args) + { + return c_api->Object_CallMethod_Boolean_V(this, object, method, result, args); + } + ani_status Object_CallMethod_Char(ani_object object, ani_method method, ani_char *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Object_CallMethod_Char_V(this, object, method, result, args); + va_end(args); + return status; + } + ani_status Object_CallMethod_Char_A(ani_object object, ani_method method, ani_char *result, const ani_value *args) + { + return c_api->Object_CallMethod_Char_A(this, object, method, result, args); + } + ani_status Object_CallMethod_Char_V(ani_object object, ani_method method, ani_char *result, va_list args) + { + return c_api->Object_CallMethod_Char_V(this, object, method, result, args); + } + ani_status Object_CallMethod_Byte(ani_object object, ani_method method, ani_byte *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Object_CallMethod_Byte_V(this, object, method, result, args); + va_end(args); + return status; + } + ani_status Object_CallMethod_Byte_A(ani_object object, ani_method method, ani_byte *result, const ani_value *args) + { + return c_api->Object_CallMethod_Byte_A(this, object, method, result, args); + } + ani_status Object_CallMethod_Byte_V(ani_object object, ani_method method, ani_byte *result, va_list args) + { + return c_api->Object_CallMethod_Byte_V(this, object, method, result, args); + } + ani_status Object_CallMethod_Short(ani_object object, ani_method method, ani_short *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Object_CallMethod_Short_V(this, object, method, result, args); + va_end(args); + return status; + } + ani_status Object_CallMethod_Short_A(ani_object object, ani_method method, ani_short *result, const ani_value *args) + { + return c_api->Object_CallMethod_Short_A(this, object, method, result, args); + } + ani_status Object_CallMethod_Short_V(ani_object object, ani_method method, ani_short *result, va_list args) + { + return c_api->Object_CallMethod_Short_V(this, object, method, result, args); + } + ani_status Object_CallMethod_Int(ani_object object, ani_method method, ani_int *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Object_CallMethod_Int_V(this, object, method, result, args); + va_end(args); + return status; + } + ani_status Object_CallMethod_Int_A(ani_object object, ani_method method, ani_int *result, const ani_value *args) + { + return c_api->Object_CallMethod_Int_A(this, object, method, result, args); + } + ani_status Object_CallMethod_Int_V(ani_object object, ani_method method, ani_int *result, va_list args) + { + return c_api->Object_CallMethod_Int_V(this, object, method, result, args); + } + ani_status Object_CallMethod_Long(ani_object object, ani_method method, ani_long *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Object_CallMethod_Long_V(this, object, method, result, args); + va_end(args); + return status; + } + ani_status Object_CallMethod_Long_A(ani_object object, ani_method method, ani_long *result, const ani_value *args) + { + return c_api->Object_CallMethod_Long_A(this, object, method, result, args); + } + ani_status Object_CallMethod_Long_V(ani_object object, ani_method method, ani_long *result, va_list args) + { + return c_api->Object_CallMethod_Long_V(this, object, method, result, args); + } + ani_status Object_CallMethod_Float(ani_object object, ani_method method, ani_float *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Object_CallMethod_Float_V(this, object, method, result, args); + va_end(args); + return status; + } + ani_status Object_CallMethod_Float_A(ani_object object, ani_method method, ani_float *result, const ani_value *args) + { + return c_api->Object_CallMethod_Float_A(this, object, method, result, args); + } + ani_status Object_CallMethod_Float_V(ani_object object, ani_method method, ani_float *result, va_list args) + { + return c_api->Object_CallMethod_Float_V(this, object, method, result, args); + } + ani_status Object_CallMethod_Double(ani_object object, ani_method method, ani_double *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Object_CallMethod_Double_V(this, object, method, result, args); + va_end(args); + return status; + } + ani_status Object_CallMethod_Double_A(ani_object object, ani_method method, ani_double *result, + const ani_value *args) + { + return c_api->Object_CallMethod_Double_A(this, object, method, result, args); + } + ani_status Object_CallMethod_Double_V(ani_object object, ani_method method, ani_double *result, va_list args) + { + return c_api->Object_CallMethod_Double_V(this, object, method, result, args); + } + ani_status Object_CallMethod_Ref(ani_object object, ani_method method, ani_ref *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Object_CallMethod_Ref_V(this, object, method, result, args); + va_end(args); + return status; + } + ani_status Object_CallMethod_Ref_A(ani_object object, ani_method method, ani_ref *result, const ani_value *args) + { + return c_api->Object_CallMethod_Ref_A(this, object, method, result, args); + } + ani_status Object_CallMethod_Ref_V(ani_object object, ani_method method, ani_ref *result, va_list args) + { + return c_api->Object_CallMethod_Ref_V(this, object, method, result, args); + } + ani_status Object_CallMethod_Void(ani_object object, ani_method method, ...) + { + va_list args; + va_start(args, method); + ani_status status = c_api->Object_CallMethod_Void_V(this, object, method, args); + va_end(args); + return status; + } + ani_status Object_CallMethod_Void_A(ani_object object, ani_method method, const ani_value *args) + { + return c_api->Object_CallMethod_Void_A(this, object, method, args); + } + ani_status Object_CallMethod_Void_V(ani_object object, ani_method method, va_list args) + { + return c_api->Object_CallMethod_Void_V(this, object, method, args); + } + ani_status Object_CallMethodByName_Boolean(ani_object object, const char *name, const char *signature, + ani_boolean *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Object_CallMethodByName_Boolean_V(this, object, name, signature, result, args); + va_end(args); + return status; + } + ani_status Object_CallMethodByName_Boolean_A(ani_object object, const char *name, const char *signature, + ani_boolean *result, const ani_value *args) + { + return c_api->Object_CallMethodByName_Boolean_A(this, object, name, signature, result, args); + } + ani_status Object_CallMethodByName_Boolean_V(ani_object object, const char *name, const char *signature, + ani_boolean *result, va_list args) + { + return c_api->Object_CallMethodByName_Boolean_V(this, object, name, signature, result, args); + } + ani_status Object_CallMethodByName_Char(ani_object object, const char *name, const char *signature, + ani_char *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Object_CallMethodByName_Char_V(this, object, name, signature, result, args); + va_end(args); + return status; + } + ani_status Object_CallMethodByName_Char_A(ani_object object, const char *name, const char *signature, + ani_char *result, const ani_value *args) + { + return c_api->Object_CallMethodByName_Char_A(this, object, name, signature, result, args); + } + ani_status Object_CallMethodByName_Char_V(ani_object object, const char *name, const char *signature, + ani_char *result, va_list args) + { + return c_api->Object_CallMethodByName_Char_V(this, object, name, signature, result, args); + } + ani_status Object_CallMethodByName_Byte(ani_object object, const char *name, const char *signature, + ani_byte *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Object_CallMethodByName_Byte_V(this, object, name, signature, result, args); + va_end(args); + return status; + } + ani_status Object_CallMethodByName_Byte_A(ani_object object, const char *name, const char *signature, + ani_byte *result, const ani_value *args) + { + return c_api->Object_CallMethodByName_Byte_A(this, object, name, signature, result, args); + } + ani_status Object_CallMethodByName_Byte_V(ani_object object, const char *name, const char *signature, + ani_byte *result, va_list args) + { + return c_api->Object_CallMethodByName_Byte_V(this, object, name, signature, result, args); + } + ani_status Object_CallMethodByName_Short(ani_object object, const char *name, const char *signature, + ani_short *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Object_CallMethodByName_Short_V(this, object, name, signature, result, args); + va_end(args); + return status; + } + ani_status Object_CallMethodByName_Short_A(ani_object object, const char *name, const char *signature, + ani_short *result, const ani_value *args) + { + return c_api->Object_CallMethodByName_Short_A(this, object, name, signature, result, args); + } + ani_status Object_CallMethodByName_Short_V(ani_object object, const char *name, const char *signature, + ani_short *result, va_list args) + { + return c_api->Object_CallMethodByName_Short_V(this, object, name, signature, result, args); + } + ani_status Object_CallMethodByName_Int(ani_object object, const char *name, const char *signature, ani_int *result, + ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Object_CallMethodByName_Int_V(this, object, name, signature, result, args); + va_end(args); + return status; + } + ani_status Object_CallMethodByName_Int_A(ani_object object, const char *name, const char *signature, + ani_int *result, const ani_value *args) + { + return c_api->Object_CallMethodByName_Int_A(this, object, name, signature, result, args); + } + ani_status Object_CallMethodByName_Int_V(ani_object object, const char *name, const char *signature, + ani_int *result, va_list args) + { + return c_api->Object_CallMethodByName_Int_V(this, object, name, signature, result, args); + } + ani_status Object_CallMethodByName_Long(ani_object object, const char *name, const char *signature, + ani_long *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Object_CallMethodByName_Long_V(this, object, name, signature, result, args); + va_end(args); + return status; + } + ani_status Object_CallMethodByName_Long_A(ani_object object, const char *name, const char *signature, + ani_long *result, const ani_value *args) + { + return c_api->Object_CallMethodByName_Long_A(this, object, name, signature, result, args); + } + ani_status Object_CallMethodByName_Long_V(ani_object object, const char *name, const char *signature, + ani_long *result, va_list args) + { + return c_api->Object_CallMethodByName_Long_V(this, object, name, signature, result, args); + } + ani_status Object_CallMethodByName_Float(ani_object object, const char *name, const char *signature, + ani_float *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Object_CallMethodByName_Float_V(this, object, name, signature, result, args); + va_end(args); + return status; + } + ani_status Object_CallMethodByName_Float_A(ani_object object, const char *name, const char *signature, + ani_float *result, const ani_value *args) + { + return c_api->Object_CallMethodByName_Float_A(this, object, name, signature, result, args); + } + ani_status Object_CallMethodByName_Float_V(ani_object object, const char *name, const char *signature, + ani_float *result, va_list args) + { + return c_api->Object_CallMethodByName_Float_V(this, object, name, signature, result, args); + } + ani_status Object_CallMethodByName_Double(ani_object object, const char *name, const char *signature, + ani_double *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Object_CallMethodByName_Double_V(this, object, name, signature, result, args); + va_end(args); + return status; + } + ani_status Object_CallMethodByName_Double_A(ani_object object, const char *name, const char *signature, + ani_double *result, const ani_value *args) + { + return c_api->Object_CallMethodByName_Double_A(this, object, name, signature, result, args); + } + ani_status Object_CallMethodByName_Double_V(ani_object object, const char *name, const char *signature, + ani_double *result, va_list args) + { + return c_api->Object_CallMethodByName_Double_V(this, object, name, signature, result, args); + } + ani_status Object_CallMethodByName_Ref(ani_object object, const char *name, const char *signature, ani_ref *result, + ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Object_CallMethodByName_Ref_V(this, object, name, signature, result, args); + va_end(args); + return status; + } + ani_status Object_CallMethodByName_Ref_A(ani_object object, const char *name, const char *signature, + ani_ref *result, const ani_value *args) + { + return c_api->Object_CallMethodByName_Ref_A(this, object, name, signature, result, args); + } + ani_status Object_CallMethodByName_Ref_V(ani_object object, const char *name, const char *signature, + ani_ref *result, va_list args) + { + return c_api->Object_CallMethodByName_Ref_V(this, object, name, signature, result, args); + } + ani_status Object_CallMethodByName_Void(ani_object object, const char *name, const char *signature, ...) + { + va_list args; + va_start(args, signature); + ani_status status = c_api->Object_CallMethodByName_Void_V(this, object, name, signature, args); + va_end(args); + return status; + } + ani_status Object_CallMethodByName_Void_A(ani_object object, const char *name, const char *signature, + const ani_value *args) + { + return c_api->Object_CallMethodByName_Void_A(this, object, name, signature, args); + } + ani_status Object_CallMethodByName_Void_V(ani_object object, const char *name, const char *signature, va_list args) + { + return c_api->Object_CallMethodByName_Void_V(this, object, name, signature, args); + } + ani_status TupleValue_GetNumberOfItems(ani_tuple_value tuple_value, ani_size *result) + { + return c_api->TupleValue_GetNumberOfItems(this, tuple_value, result); + } + ani_status TupleValue_GetItem_Boolean(ani_tuple_value tuple_value, ani_size index, ani_boolean *result) + { + return c_api->TupleValue_GetItem_Boolean(this, tuple_value, index, result); + } + ani_status TupleValue_GetItem_Char(ani_tuple_value tuple_value, ani_size index, ani_char *result) + { + return c_api->TupleValue_GetItem_Char(this, tuple_value, index, result); + } + ani_status TupleValue_GetItem_Byte(ani_tuple_value tuple_value, ani_size index, ani_byte *result) + { + return c_api->TupleValue_GetItem_Byte(this, tuple_value, index, result); + } + ani_status TupleValue_GetItem_Short(ani_tuple_value tuple_value, ani_size index, ani_short *result) + { + return c_api->TupleValue_GetItem_Short(this, tuple_value, index, result); + } + ani_status TupleValue_GetItem_Int(ani_tuple_value tuple_value, ani_size index, ani_int *result) + { + return c_api->TupleValue_GetItem_Int(this, tuple_value, index, result); + } + ani_status TupleValue_GetItem_Long(ani_tuple_value tuple_value, ani_size index, ani_long *result) + { + return c_api->TupleValue_GetItem_Long(this, tuple_value, index, result); + } + ani_status TupleValue_GetItem_Float(ani_tuple_value tuple_value, ani_size index, ani_float *result) + { + return c_api->TupleValue_GetItem_Float(this, tuple_value, index, result); + } + ani_status TupleValue_GetItem_Double(ani_tuple_value tuple_value, ani_size index, ani_double *result) + { + return c_api->TupleValue_GetItem_Double(this, tuple_value, index, result); + } + ani_status TupleValue_GetItem_Ref(ani_tuple_value tuple_value, ani_size index, ani_ref *result) + { + return c_api->TupleValue_GetItem_Ref(this, tuple_value, index, result); + } + ani_status TupleValue_SetItem_Boolean(ani_tuple_value tuple_value, ani_size index, ani_boolean value) + { + return c_api->TupleValue_SetItem_Boolean(this, tuple_value, index, value); + } + ani_status TupleValue_SetItem_Char(ani_tuple_value tuple_value, ani_size index, ani_char value) + { + return c_api->TupleValue_SetItem_Char(this, tuple_value, index, value); + } + ani_status TupleValue_SetItem_Byte(ani_tuple_value tuple_value, ani_size index, ani_byte value) + { + return c_api->TupleValue_SetItem_Byte(this, tuple_value, index, value); + } + ani_status TupleValue_SetItem_Short(ani_tuple_value tuple_value, ani_size index, ani_short value) + { + return c_api->TupleValue_SetItem_Short(this, tuple_value, index, value); + } + ani_status TupleValue_SetItem_Int(ani_tuple_value tuple_value, ani_size index, ani_int value) + { + return c_api->TupleValue_SetItem_Int(this, tuple_value, index, value); + } + ani_status TupleValue_SetItem_Long(ani_tuple_value tuple_value, ani_size index, ani_long value) + { + return c_api->TupleValue_SetItem_Long(this, tuple_value, index, value); + } + ani_status TupleValue_SetItem_Float(ani_tuple_value tuple_value, ani_size index, ani_float value) + { + return c_api->TupleValue_SetItem_Float(this, tuple_value, index, value); + } + ani_status TupleValue_SetItem_Double(ani_tuple_value tuple_value, ani_size index, ani_double value) + { + return c_api->TupleValue_SetItem_Double(this, tuple_value, index, value); + } + ani_status TupleValue_SetItem_Ref(ani_tuple_value tuple_value, ani_size index, ani_ref value) + { + return c_api->TupleValue_SetItem_Ref(this, tuple_value, index, value); + } + ani_status GlobalReference_Create(ani_ref ref, ani_ref *result) + { + return c_api->GlobalReference_Create(this, ref, result); + } + ani_status GlobalReference_Delete(ani_ref ref) + { + return c_api->GlobalReference_Delete(this, ref); + } + ani_status WeakReference_Create(ani_ref ref, ani_wref *result) + { + return c_api->WeakReference_Create(this, ref, result); + } + ani_status WeakReference_Delete(ani_wref wref) + { + return c_api->WeakReference_Delete(this, wref); + } + ani_status WeakReference_GetReference(ani_wref wref, ani_boolean *was_released_result, ani_ref *ref_result) + { + return c_api->WeakReference_GetReference(this, wref, was_released_result, ref_result); + } + ani_status CreateArrayBuffer(size_t length, void **data_result, ani_arraybuffer *arraybuffer_result) + { + return c_api->CreateArrayBuffer(this, length, data_result, arraybuffer_result); + } + ani_status CreateArrayBufferExternal(void *external_data, size_t length, ani_finalizer finalizer, void *hint, + ani_arraybuffer *result) + { + return c_api->CreateArrayBufferExternal(this, external_data, length, finalizer, hint, result); + } + ani_status ArrayBuffer_GetInfo(ani_arraybuffer arraybuffer, void **data_result, size_t *length_result) + { + return c_api->ArrayBuffer_GetInfo(this, arraybuffer, data_result, length_result); + } + ani_status Promise_New(ani_resolver *result_resolver, ani_object *result_promise) + { + return c_api->Promise_New(this, result_resolver, result_promise); + } + ani_status PromiseResolver_Resolve(ani_resolver resolver, ani_ref resolution) + { + return c_api->PromiseResolver_Resolve(this, resolver, resolution); + } + ani_status PromiseResolver_Reject(ani_resolver resolver, ani_error rejection) + { + return c_api->PromiseResolver_Reject(this, resolver, rejection); + } + ani_status FixedArray_New_Boolean(ani_size length, ani_array_boolean *result) + { + return c_api->FixedArray_New_Boolean(this, length, result); + } + ani_status FixedArray_New_Char(ani_size length, ani_array_char *result) + { + return c_api->FixedArray_New_Char(this, length, result); + } + ani_status FixedArray_New_Byte(ani_size length, ani_array_byte *result) + { + return c_api->FixedArray_New_Byte(this, length, result); + } + ani_status FixedArray_New_Short(ani_size length, ani_array_short *result) + { + return c_api->FixedArray_New_Short(this, length, result); + } + ani_status FixedArray_New_Int(ani_size length, ani_array_int *result) + { + return c_api->FixedArray_New_Int(this, length, result); + } + ani_status FixedArray_New_Long(ani_size length, ani_array_long *result) + { + return c_api->FixedArray_New_Long(this, length, result); + } + ani_status FixedArray_New_Float(ani_size length, ani_array_float *result) + { + return c_api->FixedArray_New_Float(this, length, result); + } + ani_status FixedArray_New_Double(ani_size length, ani_array_double *result) + { + return c_api->FixedArray_New_Double(this, length, result); + } + ani_status FixedArray_New_Ref(ani_type type, ani_size length, ani_ref initial_element, ani_array_ref *result) + { + return c_api->FixedArray_New_Ref(this, type, length, initial_element, result); + } +#endif // __cplusplus +}; + +// NOLINTEND +#endif // __ANI_H__ diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/ani/convertors-ani.cc b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/ani/convertors-ani.cc new file mode 100644 index 0000000000000000000000000000000000000000..3352aa826f69502f83d0e373fc5ab41e0f1deffa --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/ani/convertors-ani.cc @@ -0,0 +1,192 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include + +#include +#include "convertors-ani.h" +#include "signatures.h" +#include "interop-types.h" + +static const char* callCallbackFromNative = "callCallbackFromNative"; +static const char* callCallbackFromNativeSig = "IJI:I"; + +const bool registerByOne = true; + +static bool registerNatives(ani_env *env, const ani_class clazz, const std::vector> impls) { + std::vector methods; + methods.reserve(impls.size()); + bool result = true; + for (const auto &[name, type, func, flag] : impls) { + ani_native_function method; + method.name = name.c_str(); + method.pointer = func; + method.signature = nullptr; + if (registerByOne) { + result &= env->Class_BindNativeMethods(clazz, &method, 1) == ANI_OK; + ani_boolean isError = false; + CHECK_ANI_FATAL(env->ExistUnhandledError(&isError)); + if (isError) { + CHECK_ANI_FATAL(env->DescribeError()); + CHECK_ANI_FATAL(env->ResetError()); + } + } + else { + methods.push_back(method); + } + } + if (!registerByOne) { + result = env->Class_BindNativeMethods(clazz, methods.data(), static_cast(methods.size())) == ANI_OK; + } + return registerByOne ? true : result; +} + +bool registerAllModules(ani_env *aniEnv) { + auto moduleNames = AniExports::getInstance()->getModules(); + for (auto it = moduleNames.begin(); it != moduleNames.end(); ++it) { + std::string classpath = AniExports::getInstance()->getClasspath(*it); + ani_class nativeModule = nullptr; + CHECK_ANI_FATAL(aniEnv->FindClass(classpath.c_str(), &nativeModule)); + if (nativeModule == nullptr) { + LOGE("Cannot find managed class %s", classpath.c_str()); + continue; + } + if (!registerNatives(aniEnv, nativeModule, AniExports::getInstance()->getMethods(*it))) { + return false; + } + } + return true; +} + +ANI_EXPORT ani_status ANI_Constructor(ani_vm *vm, uint32_t *result) { + LOGE("Use ANI") + ani_env* aniEnv = nullptr; + *result = 1; + CHECK_ANI_FATAL(vm->GetEnv(/* version */ 1, (ani_env**)&aniEnv)); + if (!registerAllModules(aniEnv)) { + LOGE("Failed to register ANI modules"); + return ANI_ERROR; + } + ani_boolean hasError = false; + CHECK_ANI_FATAL(aniEnv->ExistUnhandledError(&hasError)); + if (hasError) { + CHECK_ANI_FATAL(aniEnv->DescribeError()); + CHECK_ANI_FATAL(aniEnv->ResetError()); + } + auto interopClassName = AniExports::getInstance()->getClasspath("InteropNativeModule"); + ani_class interopClass = nullptr; + CHECK_ANI_FATAL(aniEnv->FindClass(interopClassName.c_str(), &interopClass)); + if (interopClass == nullptr) { + LOGE("Can not find InteropNativeModule class to set callback dispatcher"); + CHECK_ANI_FATAL(aniEnv->ExistUnhandledError(&hasError)); + if (hasError) { + CHECK_ANI_FATAL(aniEnv->DescribeError()); + CHECK_ANI_FATAL(aniEnv->ResetError()); + } + return ANI_OK; + } + if (!setKoalaANICallbackDispatcher(aniEnv, interopClass, callCallbackFromNative, callCallbackFromNativeSig)) { + LOGE("Failed to set ANI callback dispatcher"); + return ANI_ERROR; + } + return ANI_OK; +} + +AniExports* AniExports::getInstance() { + static AniExports *instance = nullptr; + if (instance == nullptr) { + instance = new AniExports(); + } + return instance; +} + +std::vector AniExports::getModules() { + std::vector result; + for (auto it = implementations.begin(); it != implementations.end(); ++it) { + result.push_back(it->first); + } + return result; +} + +const std::vector>& AniExports::getMethods(const std::string& module) { + auto it = implementations.find(module); + if (it == implementations.end()) { + LOGE("Module %s is not registered", module.c_str()); + } + return it->second; +} + +void AniExports::addMethod(const char* module, const char *name, const char *type, void *impl, int flags) { + auto it = implementations.find(module); + if (it == implementations.end()) { + it = implementations.insert(std::make_pair(module, std::vector>())).first; + } + it->second.push_back(std::make_tuple(name, convertType(name, type), impl, flags)); +} + +void AniExports::setClasspath(const char* module, const char *classpath) { + auto it = classpaths.find(module); + if (it == classpaths.end()) { + classpaths.insert(std::make_pair(module, classpath)); + } else { + LOGE("Classpath for module %s was redefined", module); + } +} + +static std::map g_defaultClasspaths = { + {"InteropNativeModule", "L@koalaui/interop/InteropNativeModule/InteropNativeModule;"}, + // todo leave just InteropNativeModule, define others via KOALA_ETS_INTEROP_MODULE_CLASSPATH + {"TestNativeModule", "L@ohos/arkui/generated/arkts/TestNativeModule/TestNativeModule;"}, + {"ArkUINativeModule", "L@ohos/arkui/generated/arkts/ArkUINativeModule/ArkUINativeModule;"}, + {"ArkUIGeneratedNativeModule", "L@ohos/arkui/generated/arkts/ArkUIGeneratedNativeModule/ArkUIGeneratedNativeModule;"}, +}; + +const std::string& AniExports::getClasspath(const std::string& module) { + auto it = classpaths.find(module); + if (it != classpaths.end()) { + return it->second; + } + auto defaultClasspath = g_defaultClasspaths.find(module); + if (defaultClasspath != g_defaultClasspaths.end()) { + return defaultClasspath->second; + } + INTEROP_FATAL("Classpath for module %s was not registered", module.c_str()); +} + +static struct { + ani_class clazz = nullptr; + ani_static_method method = nullptr; +} g_koalaANICallbackDispatcher; + +bool setKoalaANICallbackDispatcher( + ani_env* aniEnv, + ani_class clazz, + const char* dispatcherMethodName, + const char* dispatcherMethodSig +) { + g_koalaANICallbackDispatcher.clazz = clazz; + CHECK_ANI_FATAL(aniEnv->Class_FindStaticMethod( + clazz, dispatcherMethodName, dispatcherMethodSig, + &g_koalaANICallbackDispatcher.method + )); + if (g_koalaANICallbackDispatcher.method == nullptr) { + return false; + } + return true; +} + +void getKoalaANICallbackDispatcher(ani_class* clazz, ani_static_method* method) { + *clazz = g_koalaANICallbackDispatcher.clazz; + *method = g_koalaANICallbackDispatcher.method; +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/ani/convertors-ani.h b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/ani/convertors-ani.h new file mode 100644 index 0000000000000000000000000000000000000000..a277ee71a2eedbabe88d447303ce0fea064c01d4 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/ani/convertors-ani.h @@ -0,0 +1,1927 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifdef KOALA_ANI + +#include +#include +#include +#include +#include +#include +#include + +#include "ani.h" +#include "koala-types.h" +#include "interop-logging.h" + +#define CHECK_ANI_FATAL(result) \ +do { \ + if ((result) != ANI_OK) { \ + INTEROP_FATAL("ANI function failed at " __FILE__ ": %d", __LINE__); \ + } \ +} \ +while (0) + +template +struct InteropTypeConverter { + using InteropType = T; + static T convertFrom(ani_env* env, InteropType value) = delete; + static InteropType convertTo(ani_env* env, T value) = delete; + static void release(ani_env* env, InteropType value, T converted) {} +}; + +template<> +struct InteropTypeConverter { + using InteropType = ani_byte; + static inline KByte convertFrom(ani_env* env, InteropType value) { + return value; + } + static inline InteropType convertTo(ani_env* env, KByte value) { + return value; + } + static inline void release(ani_env* env, InteropType value, KByte converted) {} +}; + +template<> +struct InteropTypeConverter { + using InteropType = ani_boolean; + static inline KBoolean convertFrom(ani_env* env, InteropType value) { + return value; + } + static inline InteropType convertTo(ani_env* env, KBoolean value) { + return value; + } + static inline void release(ani_env* env, InteropType value, KBoolean converted) {} +}; + +template<> +struct InteropTypeConverter { + using InteropType = ani_int; + static inline KInt convertFrom(ani_env* env, InteropType value) { + return value; + } + static inline InteropType convertTo(ani_env* env, KInt value) { + return value; + } + static inline void release(ani_env* env, InteropType value, KInt converted) {} +}; + +template<> +struct InteropTypeConverter { + using InteropType = ani_int; + static inline KUInt convertFrom(ani_env* env, InteropType value) { + return value; + } + static inline InteropType convertTo(ani_env* env, KUInt value) { + return value; + } + static inline void release(ani_env* env, InteropType value, KUInt converted) {} +}; + + +template<> +struct InteropTypeConverter { + using InteropType = ani_float; + static inline KFloat convertFrom(ani_env* env, InteropType value) { + return value; + } + static inline InteropType convertTo(ani_env* env, KFloat value) { + return value; + } + static inline void release(ani_env* env, InteropType value, KFloat converted) {} +}; + +template<> +struct InteropTypeConverter { + using InteropType = ani_long; + static inline KLong convertFrom(ani_env* env, InteropType value) { + return value; + } + static inline InteropType convertTo(ani_env* env, KLong value) { + return value; + } + static inline void release(ani_env* env, InteropType value, KLong converted) {} +}; + + +template<> +struct InteropTypeConverter { + using InteropType = ani_object; + static inline KVMObjectHandle convertFrom(ani_env* env, InteropType value) { + return reinterpret_cast(value); + } + static inline InteropType convertTo(ani_env* env, KVMObjectHandle value) { + return reinterpret_cast(value); + } + static inline void release(ani_env* env, InteropType value, KVMObjectHandle converted) {} +}; + +template<> +struct InteropTypeConverter { + using InteropType = ani_array_byte; + static inline KInteropBuffer convertFrom(ani_env* env, InteropType value) { + if (value == nullptr) return KInteropBuffer(); + ani_size length = 0; + CHECK_ANI_FATAL(env->Array_GetLength(value, &length)); + KByte* data = new KByte[length]; + CHECK_ANI_FATAL(env->Array_GetRegion_Byte(value, 0, length, (ani_byte*)data)); + KInteropBuffer result = { 0 }; + result.data = data; + result.length = length; + return result; + } + static inline InteropType convertTo(ani_env* env, KInteropBuffer value) { + ani_array_byte result; + CHECK_ANI_FATAL(env->FixedArray_New_Byte(value.length, &result)); + CHECK_ANI_FATAL(env->Array_SetRegion_Byte(result, 0, value.length, reinterpret_cast(value.data))); + value.dispose(value.resourceId); + return result; + } + static inline void release(ani_env* env, InteropType value, KInteropBuffer converted) { + delete [] (KByte*)converted.data; + } +}; + +template<> +struct InteropTypeConverter { + using InteropType = ani_long; + static KSerializerBuffer convertFrom(ani_env* env, InteropType value) { + return reinterpret_cast(static_cast(value)); + } + static InteropType convertTo(ani_env* env, KSerializerBuffer value) = delete; + static inline void release(ani_env* env, InteropType value, KSerializerBuffer converted) {} +}; + +template<> +struct InteropTypeConverter { + using InteropType = ani_array_byte; + static inline KInteropReturnBuffer convertFrom(ani_env* env, InteropType value) = delete; + static inline InteropType convertTo(ani_env* env, KInteropReturnBuffer value) { + ani_array_byte result; + CHECK_ANI_FATAL(env->FixedArray_New_Byte(value.length, &result)); + CHECK_ANI_FATAL(env->Array_SetRegion_Byte(result, 0, value.length, reinterpret_cast(value.data))); + value.dispose(value.data, value.length); + return result; + }; + static inline void release(ani_env* env, InteropType value, KInteropReturnBuffer converted) {} +}; + +template<> +struct InteropTypeConverter { + using InteropType = ani_string; + static KStringPtr convertFrom(ani_env* env, InteropType value) { + if (value == nullptr) return KStringPtr(); + KStringPtr result; + // Notice that we use UTF length for buffer size, but counter is expressed in number of Unicode chars. + ani_size lengthUtf8 = 0; + CHECK_ANI_FATAL(env->String_GetUTF8Size(value, &lengthUtf8)); + result.resize(lengthUtf8); + ani_size count = 0; + CHECK_ANI_FATAL(env->String_GetUTF8SubString(value, 0, lengthUtf8, result.data(), lengthUtf8 + 1, &count)); + result.data()[lengthUtf8] = 0; + return result; + } + static InteropType convertTo(ani_env* env, const KStringPtr& value) { + ani_string result = nullptr; + CHECK_ANI_FATAL(env->String_NewUTF8(value.c_str(), value.length() - 1 /* drop zero terminator */, &result)); + return result; + } + static void release(ani_env* env, InteropType value, const KStringPtr& converted) {} +}; + +template<> +struct InteropTypeConverter { + using InteropType = ani_long; + static KNativePointer convertFrom(ani_env* env, InteropType value) { + return reinterpret_cast(value); + } + static InteropType convertTo(ani_env* env, KNativePointer value) { + return reinterpret_cast(value); + } + static void release(ani_env* env, InteropType value, KNativePointer converted) {} +}; + +template<> +struct InteropTypeConverter { + using InteropType = ani_array_int; + static KInt* convertFrom(ani_env* env, InteropType value) { + if (!value) return nullptr; + ani_size length = 0; + CHECK_ANI_FATAL(env->Array_GetLength(value, &length)); + KInt* data = new KInt[length]; + CHECK_ANI_FATAL(env->Array_GetRegion_Int(value, 0, length, (ani_int*)data)); + return data; + } + static InteropType convertTo(ani_env* env, KInt* value) = delete; + static void release(ani_env* env, InteropType value, KInt* converted) { + if (converted) { + ani_size length = 0; + CHECK_ANI_FATAL(env->Array_GetLength(value, &length)); + CHECK_ANI_FATAL(env->Array_SetRegion_Int(value, 0, length, (ani_int*)converted)); + } + delete [] converted; + } +}; + +template<> +struct InteropTypeConverter { + using InteropType = ani_array_float; + static KFloat* convertFrom(ani_env* env, InteropType value) { + if (!value) return nullptr; + ani_size length = 0; + CHECK_ANI_FATAL(env->Array_GetLength(value, &length)); + KFloat* data = new KFloat[length]; + CHECK_ANI_FATAL(env->Array_GetRegion_Float(value, 0, length, (ani_float*)data)); + return data; + } + static InteropType convertTo(ani_env* env, KFloat* value) = delete; + static void release(ani_env* env, InteropType value, KFloat* converted) { + if (converted) { + ani_size length = 0; + CHECK_ANI_FATAL(env->Array_GetLength(value, &length)); + CHECK_ANI_FATAL(env->Array_SetRegion_Float(value, 0, length, (ani_float*)converted)); + } + delete [] converted; + } +}; + +template<> +struct InteropTypeConverter { + using InteropType = ani_array_byte; + static KByte* convertFrom(ani_env* env, InteropType value) { + if (!value) return nullptr; + ani_size length = 0; + CHECK_ANI_FATAL(env->Array_GetLength(value, &length)); + KByte* data = new KByte[length]; + CHECK_ANI_FATAL(env->Array_GetRegion_Byte(value, 0, length, (ani_byte*)data)); + return data; + } + static InteropType convertTo(ani_env* env, KByte* value) = delete; + static void release(ani_env* env, InteropType value, KByte* converted) { + if (converted) { + ani_size length = 0; + CHECK_ANI_FATAL(env->Array_GetLength(value, &length)); + CHECK_ANI_FATAL(env->Array_SetRegion_Byte(value, 0, length, (ani_byte*)converted)); + } + delete[] converted; + } +}; + +template <> struct InteropTypeConverter { + using InteropType = ani_double; + static KInteropNumber convertFrom(ani_env *env, InteropType value) { + return KInteropNumber::fromDouble(value); + } + static InteropType convertTo(ani_env *env, KInteropNumber value) { + return value.asDouble(); + } + static void release(ani_env *env, InteropType value, + KInteropNumber converted) {} +}; + +template<> +struct InteropTypeConverter { + using InteropType = ani_ref; + static KLength convertFrom(ani_env* env, InteropType value) { + static ani_class double_class = nullptr; + static ani_class int_class = nullptr; + static ani_class string_class = nullptr; + static ani_class resource_class = nullptr; + if (!double_class) { + CHECK_ANI_FATAL(env->FindClass("Lstd/core/Double;", &double_class)); + } + if (!int_class) { + CHECK_ANI_FATAL(env->FindClass("Lstd/core/Int;", &int_class)); + } + if (!string_class) { + CHECK_ANI_FATAL(env->FindClass("Lstd/core/String;", &string_class)); + } + if (!resource_class) { + CHECK_ANI_FATAL(env->FindClass("L@ohos/arkui/generated/resource/Resource;", &resource_class)); + } + + const ani_object valueObj = reinterpret_cast(value); + + ani_boolean isInstanceOf; + CHECK_ANI_FATAL(env->Object_InstanceOf(valueObj, double_class, &isInstanceOf)); + if (isInstanceOf) { + static ani_method double_p = nullptr; + if (!double_p) CHECK_ANI_FATAL(env->Class_FindMethod(double_class, "unboxed", ":D", &double_p)); + ani_double result; + CHECK_ANI_FATAL(env->Object_CallMethod_Double(valueObj, double_p, &result)); + return KLength{ 1, (KFloat) result, 1, 0 }; + } + + CHECK_ANI_FATAL(env->Object_InstanceOf(valueObj, int_class, &isInstanceOf)); + if (isInstanceOf) { + static ani_method int_p = nullptr; + if (!int_p) CHECK_ANI_FATAL(env->Class_FindMethod(int_class, "unboxed", ":I", &int_p)); + ani_int result; + CHECK_ANI_FATAL(env->Object_CallMethod_Int(valueObj, int_p, &result)); + return KLength{ 1, (KFloat) result, 1, 0 }; + } + + CHECK_ANI_FATAL(env->Object_InstanceOf(valueObj, string_class, &isInstanceOf)); + if (isInstanceOf) { + KStringPtr ptr = InteropTypeConverter::convertFrom(env, reinterpret_cast(value)); + KLength length { 0 }; + parseKLength(ptr, &length); + length.type = 2; + length.resource = 0; + return length; + } + + CHECK_ANI_FATAL(env->Object_InstanceOf(valueObj, resource_class, &isInstanceOf)); + if (isInstanceOf) { + static ani_method resource_p = nullptr; + if (!resource_p) CHECK_ANI_FATAL(env->Class_FindMethod(resource_class, "id",":D", &resource_p)); + ani_double result; + CHECK_ANI_FATAL(env->Object_CallMethod_Double(valueObj, resource_p, &result)); + return KLength{ 3, 0, 1, (KInt) result }; + } + + return KLength( { 0, 0, 0, 0}); + } + static InteropType convertTo(ani_env* env, KLength value) = delete; + static void release(ani_env* env, InteropType value, const KLength& converted) {} +}; + +template +inline typename InteropTypeConverter::InteropType makeResult(ani_env* env, Type value) { + return InteropTypeConverter::convertTo(env, value); +} + +template +inline Type getArgument(ani_env* env, typename InteropTypeConverter::InteropType arg) { + return InteropTypeConverter::convertFrom(env, arg); +} + +template +inline void releaseArgument(ani_env* env, typename InteropTypeConverter::InteropType arg, Type& data) { + InteropTypeConverter::release(env, arg, data); +} + +template +struct DirectInteropTypeConverter { + using InteropType = T; + static T convertFrom(InteropType value) { return value; } + static InteropType convertTo(T value) { return value; } +}; + +template<> +struct DirectInteropTypeConverter { + using InteropType = ani_long; + static KNativePointer convertFrom(InteropType value) { + return reinterpret_cast(value); + } + static InteropType convertTo(KNativePointer value) { + return reinterpret_cast(value); + } +}; + +template<> +struct DirectInteropTypeConverter { + using InteropType = ani_long; + static KSerializerBuffer convertFrom(InteropType value) { + return reinterpret_cast(static_cast(value)); + } + static InteropType convertTo(KSerializerBuffer value) = delete; +}; + +template <> +struct DirectInteropTypeConverter { + using InteropType = ani_double; + static KInteropNumber convertFrom(InteropType value) { + return KInteropNumber::fromDouble(value); + } + static InteropType convertTo(KInteropNumber value) { + return value.asDouble(); + } +}; + +#define ANI_SLOW_NATIVE_FLAG 1 + +class AniExports { + std::unordered_map>> implementations; + std::unordered_map classpaths; + +public: + static AniExports* getInstance(); + + std::vector getModules(); + void addMethod(const char* module, const char* name, const char* type, void* impl, int flags); + const std::vector>& getMethods(const std::string& module); + + void setClasspath(const char* module, const char* classpath); + const std::string& getClasspath(const std::string& module); +}; + +#define KOALA_QUOTE0(x) #x +#define KOALA_QUOTE(x) KOALA_QUOTE0(x) + +#ifdef _MSC_VER +#define MAKE_ANI_EXPORT(module, name, type, flag) \ + static void __init_##name() { \ + AniExports::getInstance()->addMethod(KOALA_QUOTE(module), "_"#name, type, reinterpret_cast(Ani_##name), flag); \ + } \ + namespace { \ + struct __Init_##name { \ + __Init_##name() { __init_##name(); } \ + } __Init_##name##_v; \ + } +#define KOALA_ANI_INTEROP_MODULE_CLASSPATH(module, classpath) \ + static void __init_classpath_##module() { \ + AniExports::getInstance()->setClasspath(KOALA_QUOTE(module), "L" classpath ";"); \ + } \ + namespace { \ + struct __Init_classpath_##module { \ + __Init_classpath_##module() { __init_classpath_##module(); } \ + } __Init_classpath_##module##_v; \ + } +#else +#define MAKE_ANI_EXPORT(module, name, type, flag) \ + __attribute__((constructor)) \ + static void __init_ani_##name() { \ + AniExports::getInstance()->addMethod(KOALA_QUOTE(module), "_"#name, type, reinterpret_cast(Ani_##name), flag); \ + } +#define KOALA_ANI_INTEROP_MODULE_CLASSPATH(module, classpath) \ + __attribute__((constructor)) \ + static void __init_ani_classpath_##module() { \ + AniExports::getInstance()->setClasspath(KOALA_QUOTE(module), "L" classpath ";"); \ + } +#endif + +#define KOALA_INTEROP_0(name, Ret) \ + InteropTypeConverter::InteropType Ani_##name(ani_env *env, ani_class clazz) { \ + KOALA_MAYBE_LOG(name) \ + return makeResult(env, impl_##name()); \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret, 0) + +#define KOALA_INTEROP_1(name, Ret, P0) \ + InteropTypeConverter::InteropType Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + auto rv = makeResult(env, impl_##name(p0)); \ + releaseArgument(env, _p0, p0); \ + return rv; \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0, 0) + +#define KOALA_INTEROP_2(name, Ret, P0, P1) \ + InteropTypeConverter::InteropType Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + auto rv = makeResult(env, impl_##name(p0, p1)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + return rv; \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1, 0) + +#define KOALA_INTEROP_3(name, Ret, P0, P1, P2) \ + InteropTypeConverter::InteropType Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + return rv; \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2, 0) + +#define KOALA_INTEROP_4(name, Ret, P0, P1, P2, P3) \ + InteropTypeConverter::InteropType Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2, p3)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + return rv; \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3, 0) + +#define KOALA_INTEROP_5(name, Ret, P0, P1, P2, P3, P4) \ + InteropTypeConverter::InteropType Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2, p3, p4)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + return rv; \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4, 0) + +#define KOALA_INTEROP_6(name, Ret, P0, P1, P2, P3, P4, P5) \ +InteropTypeConverter::InteropType Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2, p3, p4, p5)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + return rv; \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5, 0) + +#define KOALA_INTEROP_7(name, Ret, P0, P1, P2, P3, P4, P5, P6) \ + InteropTypeConverter::InteropType Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2, p3, p4, p5, p6)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + return rv; \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6, 0) + +#define KOALA_INTEROP_8(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7) \ + InteropTypeConverter::InteropType Ani_##name(ani_env *env, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + return rv; \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7, 0) + +#define KOALA_INTEROP_9(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8) \ + InteropTypeConverter::InteropType Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + return rv; \ + } \ + MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8, 0) + +#define KOALA_INTEROP_10(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) \ + InteropTypeConverter::InteropType Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + return rv; \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9, 0) + +#define KOALA_INTEROP_11(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) \ + InteropTypeConverter::InteropType Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + return rv; \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10, 0) + +#define KOALA_INTEROP_12(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11) \ + InteropTypeConverter::InteropType Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + P11 p11 = getArgument(env, _p11); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + releaseArgument(env, _p11, p11); \ + return rv; \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10 "|" #P11, 0) + +#define KOALA_INTEROP_13(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12) \ + InteropTypeConverter::InteropType Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11, \ + InteropTypeConverter::InteropType _p12) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + P11 p11 = getArgument(env, _p11); \ + P12 p12 = getArgument(env, _p12); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + releaseArgument(env, _p11, p11); \ + releaseArgument(env, _p12, p12); \ + return rv; \ + } \ + MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10 "|" #P11 "|" #P12, 0) + +#define KOALA_INTEROP_14(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13) \ + InteropTypeConverter::InteropType Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11, \ + InteropTypeConverter::InteropType _p12, \ + InteropTypeConverter::InteropType _p13) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + P11 p11 = getArgument(env, _p11); \ + P12 p12 = getArgument(env, _p12); \ + P13 p13 = getArgument(env, _p13); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + releaseArgument(env, _p11, p11); \ + releaseArgument(env, _p12, p12); \ + releaseArgument(env, _p13, p13); \ + return rv; \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10 "|" #P11 "|" #P12 "|" #P13, 0) + +#define KOALA_INTEROP_V0(name) \ + void Ani_##name(ani_env *env) { \ + KOALA_MAYBE_LOG(name) \ + impl_##name(); \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void", 0) + +#define KOALA_INTEROP_V1(name, P0) \ + void Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + impl_##name(p0); \ + releaseArgument(env, _p0, p0); \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0, 0) + +#define KOALA_INTEROP_V2(name, P0, P1) \ + void Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + impl_##name(p0, p1); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1, 0) + +#define KOALA_INTEROP_V3(name, P0, P1, P2) \ + void Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + impl_##name(p0, p1, p2); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2, 0) + +#define KOALA_INTEROP_V4(name, P0, P1, P2, P3) \ + void Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + impl_##name(p0, p1, p2, p3); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ +} \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3, 0) + +#define KOALA_INTEROP_V5(name, P0, P1, P2, P3, P4) \ + void Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + impl_##name(p0, p1, p2, p3, p4); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ +} \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4, 0) + +#define KOALA_INTEROP_V6(name, P0, P1, P2, P3, P4, P5) \ + void Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + impl_##name(p0, p1, p2, p3, p4, p5); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5, 0) + +#define KOALA_INTEROP_V7(name, P0, P1, P2, P3, P4, P5, P6) \ + void Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6, 0) + +#define KOALA_INTEROP_V8(name, P0, P1, P2, P3, P4, P5, P6, P7) \ + void Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7, 0) + +#define KOALA_INTEROP_V9(name, P0, P1, P2, P3, P4, P5, P6, P7, P8) \ + void Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8, 0) + +#define KOALA_INTEROP_V10(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) \ + void Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ +} \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9, 0) + +#define KOALA_INTEROP_V11(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) \ + void Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10, 0) + +#define KOALA_INTEROP_V12(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11) \ + void Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + P11 p11 = getArgument(env, _p11); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + releaseArgument(env, _p11, p11); \ +} \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10 "|" #P11, 0) + +#define KOALA_INTEROP_V13(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12) \ + void Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11, \ + InteropTypeConverter::InteropType _p12) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + P11 p11 = getArgument(env, _p11); \ + P12 p12 = getArgument(env, _p12); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + releaseArgument(env, _p11, p11); \ + releaseArgument(env, _p12, p12); \ +} \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10 "|" #P11 "|" #P12, 0) + +#define KOALA_INTEROP_V14(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13) \ + void Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11, \ + InteropTypeConverter::InteropType _p12, \ + InteropTypeConverter::InteropType _p13) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + P11 p11 = getArgument(env, _p11); \ + P12 p12 = getArgument(env, _p12); \ + P13 p13 = getArgument(env, _p13); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + releaseArgument(env, _p11, p11); \ + releaseArgument(env, _p12, p12); \ + releaseArgument(env, _p13, p13); \ +} \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10 "|" #P11 "|" #P12 "|" #P13, 0) + +#define KOALA_INTEROP_V15(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14) \ + void Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11, \ + InteropTypeConverter::InteropType _p12, \ + InteropTypeConverter::InteropType _p13, \ + InteropTypeConverter::InteropType _p14) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + P11 p11 = getArgument(env, _p11); \ + P12 p12 = getArgument(env, _p12); \ + P13 p13 = getArgument(env, _p13); \ + P14 p14 = getArgument(env, _p14); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + releaseArgument(env, _p11, p11); \ + releaseArgument(env, _p12, p12); \ + releaseArgument(env, _p13, p13); \ + releaseArgument(env, _p14, p14); \ +} \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10 "|" #P11 "|" #P12 "|" #P13 "|" #P14, 0) + +#define KOALA_INTEROP_CTX_0(name, Ret) \ + InteropTypeConverter::InteropType Ani_##name(ani_env *env, ani_class clazz) { \ + KOALA_MAYBE_LOG(name) \ + KVMContext ctx = (KVMContext)env; \ + auto rv = makeResult(env, impl_##name(ctx)); \ + return rv; \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret, ANI_SLOW_NATIVE_FLAG) + +#define KOALA_INTEROP_CTX_1(name, Ret, P0) \ + InteropTypeConverter::InteropType Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + KVMContext ctx = (KVMContext)env; \ + auto rv = makeResult(env, impl_##name(ctx, p0)); \ + releaseArgument(env, _p0, p0); \ + return rv; \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0, ANI_SLOW_NATIVE_FLAG) + +#define KOALA_INTEROP_CTX_2(name, Ret, P0, P1) \ + InteropTypeConverter::InteropType Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + KVMContext ctx = (KVMContext)env; \ + auto rv = makeResult(env, impl_##name(ctx, p0, p1)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + return rv; \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1, ANI_SLOW_NATIVE_FLAG) + +#define KOALA_INTEROP_CTX_3(name, Ret, P0, P1, P2) \ + InteropTypeConverter::InteropType Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + KVMContext ctx = (KVMContext)env; \ + auto rv = makeResult(env, impl_##name(ctx, p0, p1, p2)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + return rv; \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2, ANI_SLOW_NATIVE_FLAG) + +#define KOALA_INTEROP_CTX_4(name, Ret, P0, P1, P2, P3) \ + InteropTypeConverter::InteropType Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + KVMContext ctx = (KVMContext)env; \ + auto rv = makeResult(env, impl_##name(ctx, p0, p1, p2, p3)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + return rv; \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3, ANI_SLOW_NATIVE_FLAG) + +#define KOALA_INTEROP_CTX_5(name, Ret, P0, P1, P2, P3, P4) \ + InteropTypeConverter::InteropType Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + KVMContext ctx = (KVMContext)env; \ + auto rv = makeResult(env, impl_##name(ctx, p0, p1, p2, p3, p4)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + return rv; \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4, ANI_SLOW_NATIVE_FLAG) + +#define KOALA_INTEROP_CTX_V0(name) \ + void Ani_##name(ani_env *env, ani_class clazz) { \ + KOALA_MAYBE_LOG(name) \ + KVMContext ctx = (KVMContext)env; \ + impl_##name(ctx); \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void", ANI_SLOW_NATIVE_FLAG) + +#define KOALA_INTEROP_CTX_V1(name, P0) \ + void Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + KVMContext ctx = (KVMContext)env; \ + impl_##name(ctx, p0); \ + releaseArgument(env, _p0, p0); \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0, ANI_SLOW_NATIVE_FLAG) + +#define KOALA_INTEROP_CTX_V2(name, P0, P1) \ + void Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + KVMContext ctx = (KVMContext)env; \ + impl_##name(ctx, p0, p1); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1, ANI_SLOW_NATIVE_FLAG) + +#define KOALA_INTEROP_CTX_V3(name, P0, P1, P2) \ + void Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + KVMContext ctx = (KVMContext)env; \ + impl_##name(ctx, p0, p1, p2); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2, ANI_SLOW_NATIVE_FLAG) + +#define KOALA_INTEROP_CTX_V4(name, P0, P1, P2, P3) \ + void Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + KVMContext ctx = (KVMContext)env; \ + impl_##name(ctx, p0, p1, p2, p3); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3, ANI_SLOW_NATIVE_FLAG) + +#define KOALA_INTEROP_CTX_V5(name, P0, P1, P2, P3, P4) \ + void Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + KVMContext ctx = (KVMContext)env; \ + impl_##name(ctx, p0, p1, p2, p3, p4); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4, ANI_SLOW_NATIVE_FLAG) + +#define KOALA_INTEROP_DIRECT_0(name, Ret) \ + inline InteropTypeConverter::InteropType Ani_##name( \ + ) { \ + KOALA_MAYBE_LOG(name) \ + return DirectInteropTypeConverter::convertTo(impl_##name()); \ + } \ + MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret, 0) +#define KOALA_INTEROP_DIRECT_1(name, Ret, P0) \ + inline InteropTypeConverter::InteropType Ani_##name( \ + InteropTypeConverter::InteropType p0 \ + ) { \ + KOALA_MAYBE_LOG(name) \ + return DirectInteropTypeConverter::convertTo(impl_##name(DirectInteropTypeConverter::convertFrom(p0))); \ + } \ + MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0, 0) +#define KOALA_INTEROP_DIRECT_2(name, Ret, P0, P1) \ + inline InteropTypeConverter::InteropType Ani_##name( \ + InteropTypeConverter::InteropType p0, \ + InteropTypeConverter::InteropType p1 \ + ) { \ + KOALA_MAYBE_LOG(name) \ + return DirectInteropTypeConverter::convertTo(impl_##name(DirectInteropTypeConverter::convertFrom(p0), DirectInteropTypeConverter::convertFrom(p1))); \ + } \ + MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1, 0) +#define KOALA_INTEROP_DIRECT_3(name, Ret, P0, P1, P2) \ + inline InteropTypeConverter::InteropType Ani_##name( \ + InteropTypeConverter::InteropType p0, \ + InteropTypeConverter::InteropType p1, \ + InteropTypeConverter::InteropType p2 \ + ) { \ + KOALA_MAYBE_LOG(name) \ + return DirectInteropTypeConverter::convertTo(impl_##name(DirectInteropTypeConverter::convertFrom(p0), DirectInteropTypeConverter::convertFrom(p1), DirectInteropTypeConverter::convertFrom(p2))); \ + } \ + MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2, 0) +#define KOALA_INTEROP_DIRECT_4(name, Ret, P0, P1, P2, P3) \ + inline InteropTypeConverter::InteropType Ani_##name( \ + InteropTypeConverter::InteropType p0, \ + InteropTypeConverter::InteropType p1, \ + InteropTypeConverter::InteropType p2, \ + InteropTypeConverter::InteropType p3 \ + ) { \ + KOALA_MAYBE_LOG(name) \ + return DirectInteropTypeConverter::convertTo(impl_##name(DirectInteropTypeConverter::convertFrom(p0), DirectInteropTypeConverter::convertFrom(p1), DirectInteropTypeConverter::convertFrom(p2), DirectInteropTypeConverter::convertFrom(p3))); \ + } \ + MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3, 0) +#define KOALA_INTEROP_DIRECT_5(name, Ret, P0, P1, P2, P3, P4) \ + inline InteropTypeConverter::InteropType Ani_##name( \ + InteropTypeConverter::InteropType p0, \ + InteropTypeConverter::InteropType p1, \ + InteropTypeConverter::InteropType p2, \ + InteropTypeConverter::InteropType p3, \ + InteropTypeConverter::InteropType p4 \ + ) { \ + KOALA_MAYBE_LOG(name) \ + return DirectInteropTypeConverter::convertTo(impl_##name(DirectInteropTypeConverter::convertFrom(p0), DirectInteropTypeConverter::convertFrom(p1), DirectInteropTypeConverter::convertFrom(p2), DirectInteropTypeConverter::convertFrom(p3), DirectInteropTypeConverter::convertFrom(p4))); \ + } \ + MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4, 0) +#define KOALA_INTEROP_DIRECT_6(name, Ret, P0, P1, P2, P3, P4, P5) \ + inline InteropTypeConverter::InteropType Ani_##name( \ + InteropTypeConverter::InteropType p0, \ + InteropTypeConverter::InteropType p1, \ + InteropTypeConverter::InteropType p2, \ + InteropTypeConverter::InteropType p3, \ + InteropTypeConverter::InteropType p4, \ + InteropTypeConverter::InteropType p5 \ + ) { \ + KOALA_MAYBE_LOG(name) \ + return DirectInteropTypeConverter::convertTo(impl_##name(DirectInteropTypeConverter::convertFrom(p0), DirectInteropTypeConverter::convertFrom(p1), DirectInteropTypeConverter::convertFrom(p2), DirectInteropTypeConverter::convertFrom(p3), DirectInteropTypeConverter::convertFrom(p4), DirectInteropTypeConverter::convertFrom(p5))); \ + } \ + MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5, 0) +#define KOALA_INTEROP_DIRECT_7(name, Ret, P0, P1, P2, P3, P4, P5, P6) \ + inline InteropTypeConverter::InteropType Ani_##name( \ + InteropTypeConverter::InteropType p0, \ + InteropTypeConverter::InteropType p1, \ + InteropTypeConverter::InteropType p2, \ + InteropTypeConverter::InteropType p3, \ + InteropTypeConverter::InteropType p4, \ + InteropTypeConverter::InteropType p5, \ + InteropTypeConverter::InteropType p6 \ + ) { \ + KOALA_MAYBE_LOG(name) \ + return DirectInteropTypeConverter::convertTo(impl_##name(DirectInteropTypeConverter::convertFrom(p0), DirectInteropTypeConverter::convertFrom(p1), DirectInteropTypeConverter::convertFrom(p2), DirectInteropTypeConverter::convertFrom(p3), DirectInteropTypeConverter::convertFrom(p4), DirectInteropTypeConverter::convertFrom(p5), DirectInteropTypeConverter::convertFrom(p6))); \ + } \ + MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6, 0) +#define KOALA_INTEROP_DIRECT_8(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7) \ + inline InteropTypeConverter::InteropType Ani_##name( \ + InteropTypeConverter::InteropType p0, \ + InteropTypeConverter::InteropType p1, \ + InteropTypeConverter::InteropType p2, \ + InteropTypeConverter::InteropType p3, \ + InteropTypeConverter::InteropType p4, \ + InteropTypeConverter::InteropType p5, \ + InteropTypeConverter::InteropType p6, \ + InteropTypeConverter::InteropType p7 \ + ) { \ + KOALA_MAYBE_LOG(name) \ + return DirectInteropTypeConverter::convertTo(impl_##name(DirectInteropTypeConverter::convertFrom(p0), DirectInteropTypeConverter::convertFrom(p1), DirectInteropTypeConverter::convertFrom(p2), DirectInteropTypeConverter::convertFrom(p3), DirectInteropTypeConverter::convertFrom(p4), DirectInteropTypeConverter::convertFrom(p5), DirectInteropTypeConverter::convertFrom(p6), DirectInteropTypeConverter::convertFrom(p7))); \ + } \ + MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7, 0) +#define KOALA_INTEROP_DIRECT_9(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8) \ + inline InteropTypeConverter::InteropType Ani_##name( \ + InteropTypeConverter::InteropType p0, \ + InteropTypeConverter::InteropType p1, \ + InteropTypeConverter::InteropType p2, \ + InteropTypeConverter::InteropType p3, \ + InteropTypeConverter::InteropType p4, \ + InteropTypeConverter::InteropType p5, \ + InteropTypeConverter::InteropType p6, \ + InteropTypeConverter::InteropType p7, \ + InteropTypeConverter::InteropType p8 \ + ) { \ + KOALA_MAYBE_LOG(name) \ + return DirectInteropTypeConverter::convertTo(impl_##name(DirectInteropTypeConverter::convertFrom(p0), DirectInteropTypeConverter::convertFrom(p1), DirectInteropTypeConverter::convertFrom(p2), DirectInteropTypeConverter::convertFrom(p3), DirectInteropTypeConverter::convertFrom(p4), DirectInteropTypeConverter::convertFrom(p5), DirectInteropTypeConverter::convertFrom(p6), DirectInteropTypeConverter::convertFrom(p7), DirectInteropTypeConverter::convertFrom(p8))); \ + } \ + MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8, 0) +#define KOALA_INTEROP_DIRECT_10(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) \ + inline InteropTypeConverter::InteropType Ani_##name( \ + InteropTypeConverter::InteropType p0, \ + InteropTypeConverter::InteropType p1, \ + InteropTypeConverter::InteropType p2, \ + InteropTypeConverter::InteropType p3, \ + InteropTypeConverter::InteropType p4, \ + InteropTypeConverter::InteropType p5, \ + InteropTypeConverter::InteropType p6, \ + InteropTypeConverter::InteropType p7, \ + InteropTypeConverter::InteropType p8, \ + InteropTypeConverter::InteropType p9 \ + ) { \ + KOALA_MAYBE_LOG(name) \ + return DirectInteropTypeConverter::convertTo(impl_##name(DirectInteropTypeConverter::convertFrom(p0), DirectInteropTypeConverter::convertFrom(p1), DirectInteropTypeConverter::convertFrom(p2), DirectInteropTypeConverter::convertFrom(p3), DirectInteropTypeConverter::convertFrom(p4), DirectInteropTypeConverter::convertFrom(p5), DirectInteropTypeConverter::convertFrom(p6), DirectInteropTypeConverter::convertFrom(p7), DirectInteropTypeConverter::convertFrom(p8), DirectInteropTypeConverter::convertFrom(p9))); \ + } \ + MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9, 0) +#define KOALA_INTEROP_DIRECT_11(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) \ + inline InteropTypeConverter::InteropType Ani_##name( \ + InteropTypeConverter::InteropType p0, \ + InteropTypeConverter::InteropType p1, \ + InteropTypeConverter::InteropType p2, \ + InteropTypeConverter::InteropType p3, \ + InteropTypeConverter::InteropType p4, \ + InteropTypeConverter::InteropType p5, \ + InteropTypeConverter::InteropType p6, \ + InteropTypeConverter::InteropType p7, \ + InteropTypeConverter::InteropType p8, \ + InteropTypeConverter::InteropType p9, \ + InteropTypeConverter::InteropType p10 \ + ) { \ + KOALA_MAYBE_LOG(name) \ + return DirectInteropTypeConverter::convertTo(impl_##name(DirectInteropTypeConverter::convertFrom(p0), DirectInteropTypeConverter::convertFrom(p1), DirectInteropTypeConverter::convertFrom(p2), DirectInteropTypeConverter::convertFrom(p3), DirectInteropTypeConverter::convertFrom(p4), DirectInteropTypeConverter::convertFrom(p5), DirectInteropTypeConverter::convertFrom(p6), DirectInteropTypeConverter::convertFrom(p7), DirectInteropTypeConverter::convertFrom(p8), DirectInteropTypeConverter::convertFrom(p9), DirectInteropTypeConverter::convertFrom(p10))); \ + } \ + MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10, 0) +#define KOALA_INTEROP_DIRECT_V0(name) \ + inline void Ani_##name( \ + ) { \ + KOALA_MAYBE_LOG(name) \ + impl_##name(); \ + } \ + MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void", 0) +#define KOALA_INTEROP_DIRECT_V1(name, P0) \ + inline void Ani_##name( \ + InteropTypeConverter::InteropType p0 \ + ) { \ + KOALA_MAYBE_LOG(name) \ + impl_##name(DirectInteropTypeConverter::convertFrom(p0)); \ + } \ + MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void" "|" #P0, 0) +#define KOALA_INTEROP_DIRECT_V2(name, P0, P1) \ + inline void Ani_##name( \ + InteropTypeConverter::InteropType p0, \ + InteropTypeConverter::InteropType p1 \ + ) { \ + KOALA_MAYBE_LOG(name) \ + impl_##name(DirectInteropTypeConverter::convertFrom(p0), DirectInteropTypeConverter::convertFrom(p1)); \ + } \ + MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void" "|" #P0 "|" #P1, 0) +#define KOALA_INTEROP_DIRECT_V3(name, P0, P1, P2) \ + inline void Ani_##name( \ + InteropTypeConverter::InteropType p0, \ + InteropTypeConverter::InteropType p1, \ + InteropTypeConverter::InteropType p2 \ + ) { \ + KOALA_MAYBE_LOG(name) \ + impl_##name(DirectInteropTypeConverter::convertFrom(p0), DirectInteropTypeConverter::convertFrom(p1), DirectInteropTypeConverter::convertFrom(p2)); \ + } \ + MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void" "|" #P0 "|" #P1 "|" #P2, 0) +#define KOALA_INTEROP_DIRECT_V4(name, P0, P1, P2, P3) \ + inline void Ani_##name( \ + InteropTypeConverter::InteropType p0, \ + InteropTypeConverter::InteropType p1, \ + InteropTypeConverter::InteropType p2, \ + InteropTypeConverter::InteropType p3 \ + ) { \ + KOALA_MAYBE_LOG(name) \ + impl_##name(DirectInteropTypeConverter::convertFrom(p0), DirectInteropTypeConverter::convertFrom(p1), DirectInteropTypeConverter::convertFrom(p2), DirectInteropTypeConverter::convertFrom(p3)); \ + } \ + MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void" "|" #P0 "|" #P1 "|" #P2 "|" #P3, 0) +#define KOALA_INTEROP_DIRECT_V5(name, P0, P1, P2, P3, P4) \ + inline void Ani_##name( \ + InteropTypeConverter::InteropType p0, \ + InteropTypeConverter::InteropType p1, \ + InteropTypeConverter::InteropType p2, \ + InteropTypeConverter::InteropType p3, \ + InteropTypeConverter::InteropType p4 \ + ) { \ + KOALA_MAYBE_LOG(name) \ + impl_##name(DirectInteropTypeConverter::convertFrom(p0), DirectInteropTypeConverter::convertFrom(p1), DirectInteropTypeConverter::convertFrom(p2), DirectInteropTypeConverter::convertFrom(p3), DirectInteropTypeConverter::convertFrom(p4)); \ + } \ + MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void" "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4, 0) +#define KOALA_INTEROP_DIRECT_V6(name, P0, P1, P2, P3, P4, P5) \ + inline void Ani_##name( \ + InteropTypeConverter::InteropType p0, \ + InteropTypeConverter::InteropType p1, \ + InteropTypeConverter::InteropType p2, \ + InteropTypeConverter::InteropType p3, \ + InteropTypeConverter::InteropType p4, \ + InteropTypeConverter::InteropType p5 \ + ) { \ + KOALA_MAYBE_LOG(name) \ + impl_##name(DirectInteropTypeConverter::convertFrom(p0), DirectInteropTypeConverter::convertFrom(p1), DirectInteropTypeConverter::convertFrom(p2), DirectInteropTypeConverter::convertFrom(p3), DirectInteropTypeConverter::convertFrom(p4), DirectInteropTypeConverter::convertFrom(p5)); \ + } \ + MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void" "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5, 0) +#define KOALA_INTEROP_DIRECT_V7(name, P0, P1, P2, P3, P4, P5, P6) \ + inline void Ani_##name( \ + InteropTypeConverter::InteropType p0, \ + InteropTypeConverter::InteropType p1, \ + InteropTypeConverter::InteropType p2, \ + InteropTypeConverter::InteropType p3, \ + InteropTypeConverter::InteropType p4, \ + InteropTypeConverter::InteropType p5, \ + InteropTypeConverter::InteropType p6 \ + ) { \ + KOALA_MAYBE_LOG(name) \ + impl_##name(DirectInteropTypeConverter::convertFrom(p0), DirectInteropTypeConverter::convertFrom(p1), DirectInteropTypeConverter::convertFrom(p2), DirectInteropTypeConverter::convertFrom(p3), DirectInteropTypeConverter::convertFrom(p4), DirectInteropTypeConverter::convertFrom(p5), DirectInteropTypeConverter::convertFrom(p6)); \ + } \ + MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void" "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6, 0) +#define KOALA_INTEROP_DIRECT_V8(name, P0, P1, P2, P3, P4, P5, P6, P7) \ + inline void Ani_##name( \ + InteropTypeConverter::InteropType p0, \ + InteropTypeConverter::InteropType p1, \ + InteropTypeConverter::InteropType p2, \ + InteropTypeConverter::InteropType p3, \ + InteropTypeConverter::InteropType p4, \ + InteropTypeConverter::InteropType p5, \ + InteropTypeConverter::InteropType p6, \ + InteropTypeConverter::InteropType p7 \ + ) { \ + KOALA_MAYBE_LOG(name) \ + impl_##name(DirectInteropTypeConverter::convertFrom(p0), DirectInteropTypeConverter::convertFrom(p1), DirectInteropTypeConverter::convertFrom(p2), DirectInteropTypeConverter::convertFrom(p3), DirectInteropTypeConverter::convertFrom(p4), DirectInteropTypeConverter::convertFrom(p5), DirectInteropTypeConverter::convertFrom(p6), DirectInteropTypeConverter::convertFrom(p7)); \ + } \ + MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void" "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7, 0) +#define KOALA_INTEROP_DIRECT_V9(name, P0, P1, P2, P3, P4, P5, P6, P7, P8) \ + inline void Ani_##name( \ + InteropTypeConverter::InteropType p0, \ + InteropTypeConverter::InteropType p1, \ + InteropTypeConverter::InteropType p2, \ + InteropTypeConverter::InteropType p3, \ + InteropTypeConverter::InteropType p4, \ + InteropTypeConverter::InteropType p5, \ + InteropTypeConverter::InteropType p6, \ + InteropTypeConverter::InteropType p7, \ + InteropTypeConverter::InteropType p8 \ + ) { \ + KOALA_MAYBE_LOG(name) \ + impl_##name(DirectInteropTypeConverter::convertFrom(p0), DirectInteropTypeConverter::convertFrom(p1), DirectInteropTypeConverter::convertFrom(p2), DirectInteropTypeConverter::convertFrom(p3), DirectInteropTypeConverter::convertFrom(p4), DirectInteropTypeConverter::convertFrom(p5), DirectInteropTypeConverter::convertFrom(p6), DirectInteropTypeConverter::convertFrom(p7), DirectInteropTypeConverter::convertFrom(p8)); \ + } \ + MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void" "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8, 0) +#define KOALA_INTEROP_DIRECT_V10(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) \ + inline void Ani_##name( \ + InteropTypeConverter::InteropType p0, \ + InteropTypeConverter::InteropType p1, \ + InteropTypeConverter::InteropType p2, \ + InteropTypeConverter::InteropType p3, \ + InteropTypeConverter::InteropType p4, \ + InteropTypeConverter::InteropType p5, \ + InteropTypeConverter::InteropType p6, \ + InteropTypeConverter::InteropType p7, \ + InteropTypeConverter::InteropType p8, \ + InteropTypeConverter::InteropType p9 \ + ) { \ + KOALA_MAYBE_LOG(name) \ + impl_##name(DirectInteropTypeConverter::convertFrom(p0), DirectInteropTypeConverter::convertFrom(p1), DirectInteropTypeConverter::convertFrom(p2), DirectInteropTypeConverter::convertFrom(p3), DirectInteropTypeConverter::convertFrom(p4), DirectInteropTypeConverter::convertFrom(p5), DirectInteropTypeConverter::convertFrom(p6), DirectInteropTypeConverter::convertFrom(p7), DirectInteropTypeConverter::convertFrom(p8), DirectInteropTypeConverter::convertFrom(p9)); \ + } \ + MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void" "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9, 0) +#define KOALA_INTEROP_DIRECT_V11(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) \ + inline void Ani_##name( \ + InteropTypeConverter::InteropType p0, \ + InteropTypeConverter::InteropType p1, \ + InteropTypeConverter::InteropType p2, \ + InteropTypeConverter::InteropType p3, \ + InteropTypeConverter::InteropType p4, \ + InteropTypeConverter::InteropType p5, \ + InteropTypeConverter::InteropType p6, \ + InteropTypeConverter::InteropType p7, \ + InteropTypeConverter::InteropType p8, \ + InteropTypeConverter::InteropType p9, \ + InteropTypeConverter::InteropType p10 \ + ) { \ + KOALA_MAYBE_LOG(name) \ + impl_##name(DirectInteropTypeConverter::convertFrom(p0), DirectInteropTypeConverter::convertFrom(p1), DirectInteropTypeConverter::convertFrom(p2), DirectInteropTypeConverter::convertFrom(p3), DirectInteropTypeConverter::convertFrom(p4), DirectInteropTypeConverter::convertFrom(p5), DirectInteropTypeConverter::convertFrom(p6), DirectInteropTypeConverter::convertFrom(p7), DirectInteropTypeConverter::convertFrom(p8), DirectInteropTypeConverter::convertFrom(p9), DirectInteropTypeConverter::convertFrom(p10)); \ + } \ + MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void" "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10, 0) + +bool setKoalaANICallbackDispatcher( + ani_env* ani_env, + ani_class clazz, + const char* dispatcherMethodName, + const char* dispactherMethodSig +); +void getKoalaANICallbackDispatcher(ani_class* clazz, ani_static_method* method); + +// TODO: maybe use CreateArrayBufferExternal here instead, no need for allocations. +#define KOALA_INTEROP_CALL_VOID(venv, id, length, args) \ +{ \ + ani_class clazz = nullptr; \ + ani_static_method method = nullptr; \ + getKoalaANICallbackDispatcher(&clazz, &method); \ + ani_env* env = reinterpret_cast(venv); \ + ani_int result = 0; \ + long long args_casted = reinterpret_cast(args); \ + CHECK_ANI_FATAL(env->Class_CallStaticMethod_Int(clazz, method, &result, id, args_casted, length)); \ +} + +#define KOALA_INTEROP_CALL_INT(venv, id, length, args) \ +{ \ + ani_class clazz = nullptr; \ + ani_static_method method = nullptr; \ + getKoalaANICallbackDispatcher(&clazz, &method); \ + ani_env* env = reinterpret_cast(venv); \ + ani_int result = 0; \ + long long args_casted = reinterpret_cast(args); \ + CHECK_ANI_FATAL(env->Class_CallStaticMethod_Int(clazz, method, &result, id, args_casted, length)); \ + return result; \ +} + +#define KOALA_INTEROP_CALL_VOID_INTS32(venv, id, argc, args) KOALA_INTEROP_CALL_VOID(venv, id, (argc) * sizeof(int32_t), args) +#define KOALA_INTEROP_CALL_INT_INTS32(venv, id, argc, args) KOALA_INTEROP_CALL_INT(venv, id, (argc) * sizeof(int32_t), args) + +#define KOALA_INTEROP_THROW(vmContext, object, ...) \ + do { \ + ani_env* env = reinterpret_cast(vmContext); \ + CHECK_ANI_FATAL(env->ThrowError(object)); \ + return __VA_ARGS__; \ + } while (0) + +#define KOALA_INTEROP_THROW_STRING(vmContext, message, ...) \ + do { \ + ani_env* env = reinterpret_cast(vmContext); \ + ani_class errorClass {}; \ + CHECK_ANI_FATAL(env->FindClass("Lescompat/Error;", &errorClass)); \ + ani_method errorCtor {}; \ + CHECK_ANI_FATAL(env->Class_FindMethod(errorClass, "", \ + "Lstd/core/String;Lescompat/ErrorOptions;:V", &errorCtor)); \ + ani_string messageObject{}; \ + CHECK_ANI_FATAL(env->String_NewUTF8(message, strlen(message), &messageObject)); \ + ani_ref undefined{}; \ + CHECK_ANI_FATAL(env->GetUndefined(&undefined)); \ + ani_object throwObject{}; \ + CHECK_ANI_FATAL(env->Object_New(errorClass, errorCtor, &throwObject, messageObject, undefined)); \ + CHECK_ANI_FATAL(env->ThrowError(static_cast(throwObject))); \ + return __VA_ARGS__; \ + } while (0) + +#endif // KOALA_ANI diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/callback-resource.cc b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/callback-resource.cc new file mode 100644 index 0000000000000000000000000000000000000000..32b54ae794167f4750eee9687637de42f46ef47d --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/callback-resource.cc @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define KOALA_INTEROP_MODULE InteropNativeModule +#include "common-interop.h" +#include "interop-types.h" +#include "callback-resource.h" +#include +#include + + +static bool needReleaseFront = false; +static std::deque callbackEventsQueue; +static std::deque callbackCallSubqueue; +static std::deque callbackResourceSubqueue; + +void enqueueCallback(const CallbackBuffer* event) { + callbackEventsQueue.push_back(Event_CallCallback); + callbackCallSubqueue.push_back(*event); +} + +void holdManagedCallbackResource(InteropInt32 resourceId) { + callbackEventsQueue.push_back(Event_HoldManagedResource); + callbackResourceSubqueue.push_back(resourceId); +} + +void releaseManagedCallbackResource(InteropInt32 resourceId) { + callbackEventsQueue.push_back(Event_ReleaseManagedResource); + callbackResourceSubqueue.push_back(resourceId); +} + +KInt impl_CheckCallbackEvent(KSerializerBuffer buffer, KInt size) { + KByte* result = (KByte*)buffer; + if (needReleaseFront) + { + switch (callbackEventsQueue.front()) + { + case Event_CallCallback: + callbackCallSubqueue.front().resourceHolder.release(); + callbackCallSubqueue.pop_front(); + break; + case Event_HoldManagedResource: + case Event_ReleaseManagedResource: + callbackResourceSubqueue.pop_front(); + break; + default: + INTEROP_FATAL("Unknown event kind"); + } + callbackEventsQueue.pop_front(); + needReleaseFront = false; + } + if (callbackEventsQueue.empty()) { + return 0; + } + const CallbackEventKind frontEventKind = callbackEventsQueue.front(); + memcpy(result, &frontEventKind, 4); + switch (frontEventKind) + { + case Event_CallCallback: + memcpy(result + 4, callbackCallSubqueue.front().buffer, sizeof(CallbackBuffer::buffer)); + break; + case Event_HoldManagedResource: + case Event_ReleaseManagedResource: { + const InteropInt32 resourceId = callbackResourceSubqueue.front(); + memcpy(result + 4, &resourceId, 4); + break; + } + default: + INTEROP_FATAL("Unknown event kind"); + } + needReleaseFront = true; + return 1; +} +KOALA_INTEROP_DIRECT_2(CheckCallbackEvent, KInt, KSerializerBuffer, KInt) + +void impl_ReleaseCallbackResource(InteropInt32 resourceId) { + releaseManagedCallbackResource(resourceId); +} +KOALA_INTEROP_V1(ReleaseCallbackResource, KInt) + +void impl_HoldCallbackResource(InteropInt32 resourceId) { + holdManagedCallbackResource(resourceId); +} +KOALA_INTEROP_V1(HoldCallbackResource, KInt) diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/callback-resource.h b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/callback-resource.h new file mode 100644 index 0000000000000000000000000000000000000000..c7a742a052dad85cd6cbd148d73fb0a63afd50a0 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/callback-resource.h @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _INTEROP_CALLBACK_RESOURCE_H +#define _INTEROP_CALLBACK_RESOURCE_H + +#include +#include "interop-types.h" + +#ifdef KOALA_WINDOWS +#define DLL_EXPORT __declspec(dllexport) +#else +#define DLL_EXPORT __attribute__ ((visibility ("default"))) +#endif + +class CallbackResourceHolder { +private: + std::vector heldResources; +public: + void holdCallbackResource(const InteropCallbackResource* resource) { + resource->hold(resource->resourceId); + this->heldResources.push_back(*resource); + } + void release() { + for (auto resource : this->heldResources) { + resource.release(resource.resourceId); + } + this->heldResources.clear(); + } +}; + +struct CallbackBuffer { + InteropInt32 kind; + uint8_t buffer[4096]; + CallbackResourceHolder resourceHolder; +}; + +enum CallbackEventKind { + Event_CallCallback = 0, + Event_HoldManagedResource = 1, + Event_ReleaseManagedResource = 2, +}; + +extern "C" DLL_EXPORT void enqueueCallback(const CallbackBuffer* event); +extern "C" DLL_EXPORT void holdManagedCallbackResource(InteropInt32 resourceId); +extern "C" DLL_EXPORT void releaseManagedCallbackResource(InteropInt32 resourceId); + +#endif diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/cangjie/convertors-cj.cc b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/cangjie/convertors-cj.cc new file mode 100644 index 0000000000000000000000000000000000000000..724c5bbb040488b154d4bc240393cb0c13c59b58 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/cangjie/convertors-cj.cc @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/cangjie/convertors-cj.h b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/cangjie/convertors-cj.h new file mode 100644 index 0000000000000000000000000000000000000000..084cf879f45a026be8f0643c376580fb1b0101d0 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/cangjie/convertors-cj.h @@ -0,0 +1,940 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include +#include +#include +#include + +#include "koala-types.h" + +#define KOALA_INTEROP_EXPORT extern "C" + +#define MAKE_CJ_EXPORT(name, type, flag) \ + __attribute__((constructor)) \ + static void __init_ets_##name() { \ + CJExports::getInstance()->addImpl("_"#name, type, reinterpret_cast(Ark_##name), flag); \ + } + +class CJExports { + std::vector> implementations; + +public: + static CJExports* getInstance(); + + void addImpl(const char* name, const char* type, void* impl); + const std::vector>& getImpls() { + return implementations; + } +}; + +template +struct InteropTypeConverter { + using InteropType = T; + static inline T convertFrom(InteropType value) { return value; } + static inline InteropType convertTo(T value) { return value; } +}; + +template +inline T getArgument(typename InteropTypeConverter::InteropType arg) { + return InteropTypeConverter::convertFrom(arg); +} + +template +inline typename InteropTypeConverter::InteropType makeResult(T value) { + return InteropTypeConverter::convertTo(value); +} + +template<> +struct InteropTypeConverter { + using InteropType = KDouble; + static inline KInteropNumber convertFrom(InteropType value) { + return KInteropNumber::fromDouble(value); + } + static inline InteropType convertTo(KInteropNumber value) { + return value.asDouble(); + } +}; + +template<> +struct InteropTypeConverter { + using InteropType = char*; + static KStringPtr convertFrom(InteropType value) { + return KStringPtr(value); + } + static InteropType convertTo(const KStringPtr& value) { + return value.data(); + } +}; + +// TODO: Rewrite all others to typed convertors. + +#define KOALA_INTEROP_0(name, Ret) \ +KOALA_INTEROP_EXPORT InteropTypeConverter::InteropType name() { \ + KOALA_MAYBE_LOG(name) \ + return makeResult(impl_##name()); \ +} +// MAKE_CJ_EXPORT(name, #Ret, 0) + +#define KOALA_INTEROP_1(name, Ret, P0) \ +KOALA_INTEROP_EXPORT InteropTypeConverter::InteropType name(InteropTypeConverter::InteropType _p0) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + return makeResult(impl_##name(p0)); \ +} +// MAKE_CJ_EXPORT(name, #Ret "|" #P0, 0) + +#define KOALA_INTEROP_2(name, Ret, P0, P1) \ +KOALA_INTEROP_EXPORT InteropTypeConverter::InteropType name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + return makeResult(impl_##name(p0, p1)); \ +} +// MAKE_CJ_EXPORT(name, #Ret "|" #P0 "|" #P1, 0) + +#define KOALA_INTEROP_3(name, Ret, P0, P1, P2) \ +KOALA_INTEROP_EXPORT InteropTypeConverter::InteropType name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + return makeResult(impl_##name(p0, p1, p2)); \ +} +// MAKE_CJ_EXPORT(name, #Ret "|" #P0 "|" #P1 "|" #P2, 0) + +#define KOALA_INTEROP_4(name, Ret, P0, P1, P2, P3) \ +KOALA_INTEROP_EXPORT InteropTypeConverter::InteropType name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + return makeResult(impl_##name(p0, p1, p2, p3)); \ +} +// MAKE_CJ_EXPORT(name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3, 0) + +#define KOALA_INTEROP_5(name, Ret, P0, P1, P2, P3, P4) \ +KOALA_INTEROP_EXPORT InteropTypeConverter::InteropType name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + return makeResult(impl_##name(p0, p1, p2, p3, p4)); \ +} +// MAKE_CJ_EXPORT(name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4, 0) + +#define KOALA_INTEROP_6(name, Ret, P0, P1, P2, P3, P4, P5) \ +KOALA_INTEROP_EXPORT InteropTypeConverter::InteropType name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + return makeResult(impl_##name(p0, p1, p2, p3, p4, p5)); \ +} +// MAKE_CJ_EXPORT(name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5, 0) + +#define KOALA_INTEROP_7(name, Ret, P0, P1, P2, P3, P4, P5, P6) \ +KOALA_INTEROP_EXPORT InteropTypeConverter::InteropType name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + return makeResult(impl_##name(p0, p1, p2, p3, p4, p5, p6)); \ +} +// MAKE_CJ_EXPORT(name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6, 0) + +#define KOALA_INTEROP_8(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7) \ +KOALA_INTEROP_EXPORT InteropTypeConverter::InteropType name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + return makeResult(impl_##name(p0, p1, p2, p3, p4, p5, p6, p7)); \ +} +// MAKE_CJ_EXPORT(name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7, 0) + +#define KOALA_INTEROP_9(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8) \ +KOALA_INTEROP_EXPORT InteropTypeConverter::InteropType name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + return makeResult(impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8)); \ +} +// MAKE_CJ_EXPORT(name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8, 0) + +#define KOALA_INTEROP_10(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) \ +KOALA_INTEROP_EXPORT InteropTypeConverter::InteropType name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + P9 p9 = getArgument(_p9); \ + return makeResult(impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)); \ +} +// MAKE_CJ_EXPORT(name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9, 0) + +#define KOALA_INTEROP_11(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) \ +KOALA_INTEROP_EXPORT InteropTypeConverter::InteropType name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + P9 p9 = getArgument(_p9); \ + P10 p10 = getArgument(_p10); \ + return makeResult(impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10)); \ +} +// MAKE_CJ_EXPORT(name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10, 0) + +#define KOALA_INTEROP_12(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11) \ +KOALA_INTEROP_EXPORT InteropTypeConverter::InteropType name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + P9 p9 = getArgument(_p9); \ + P10 p10 = getArgument(_p10); \ + P11 p11 = getArgument(_p11); \ + return makeResult(impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11)); \ +} +// MAKE_CJ_EXPORT(name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10 "|" #P11, 0) + +#define KOALA_INTEROP_13(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12) \ +KOALA_INTEROP_EXPORT InteropTypeConverter::InteropType name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11, \ + InteropTypeConverter::InteropType _p12 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + P9 p9 = getArgument(_p9); \ + P10 p10 = getArgument(_p10); \ + P11 p11 = getArgument(_p11); \ + P12 p12 = getArgument(_p12); \ + return makeResult(impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12)); \ +} +// MAKE_CJ_EXPORT(name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10 "|" #P11 "|" #P12, 0) + +#define KOALA_INTEROP_14(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13) \ +KOALA_INTEROP_EXPORT InteropTypeConverter::InteropType name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11, \ + InteropTypeConverter::InteropType _p12, \ + InteropTypeConverter::InteropType _p13 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + P9 p9 = getArgument(_p9); \ + P10 p10 = getArgument(_p10); \ + P11 p11 = getArgument(_p11); \ + P12 p12 = getArgument(_p12); \ + P13 p13 = getArgument(_p13); \ + return makeResult(impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13)); \ +} +// MAKE_CJ_EXPORT(name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10 "|" #P11 "|" #P12 "|" #P13, 0) + +#define KOALA_INTEROP_V0(name) \ +KOALA_INTEROP_EXPORT void name() { \ + KOALA_MAYBE_LOG(name) \ + impl_##name(); \ + return; \ +} + +#define KOALA_INTEROP_V1(name, P0) \ +KOALA_INTEROP_EXPORT void name(typename InteropTypeConverter::InteropType _p0) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + impl_##name(p0); \ + return; \ +} + +#define KOALA_INTEROP_V2(name, P0, P1) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + impl_##name(p0, p1); \ + return; \ +} + +#define KOALA_INTEROP_V3(name, P0, P1, P2) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + impl_##name(p0, p1, p2); \ + return; \ +} + +#define KOALA_INTEROP_V4(name, P0, P1, P2, P3) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2, \ + typename InteropTypeConverter::InteropType _p3 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + impl_##name(p0, p1, p2, p3); \ + return; \ +} + +#define KOALA_INTEROP_V5(name, P0, P1, P2, P3, P4) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2, \ + typename InteropTypeConverter::InteropType _p3, \ + typename InteropTypeConverter::InteropType _p4 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + impl_##name(p0, p1, p2, p3, p4); \ + return; \ +} + +#define KOALA_INTEROP_V6(name, P0, P1, P2, P3, P4, P5) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2, \ + typename InteropTypeConverter::InteropType _p3, \ + typename InteropTypeConverter::InteropType _p4, \ + typename InteropTypeConverter::InteropType _p5 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + impl_##name(p0, p1, p2, p3, p4, p5); \ + return; \ +} + +#define KOALA_INTEROP_V7(name, P0, P1, P2, P3, P4, P5, P6) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2, \ + typename InteropTypeConverter::InteropType _p3, \ + typename InteropTypeConverter::InteropType _p4, \ + typename InteropTypeConverter::InteropType _p5, \ + typename InteropTypeConverter::InteropType _p6 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6); \ + return; \ +} + +#define KOALA_INTEROP_V8(name, P0, P1, P2, P3, P4, P5, P6, P7) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2, \ + typename InteropTypeConverter::InteropType _p3, \ + typename InteropTypeConverter::InteropType _p4, \ + typename InteropTypeConverter::InteropType _p5, \ + typename InteropTypeConverter::InteropType _p6, \ + typename InteropTypeConverter::InteropType _p7 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7); \ + return; \ +} + +#define KOALA_INTEROP_V9(name, P0, P1, P2, P3, P4, P5, P6, P7, P8) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2, \ + typename InteropTypeConverter::InteropType _p3, \ + typename InteropTypeConverter::InteropType _p4, \ + typename InteropTypeConverter::InteropType _p5, \ + typename InteropTypeConverter::InteropType _p6, \ + typename InteropTypeConverter::InteropType _p7, \ + typename InteropTypeConverter::InteropType _p8 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8); \ + return; \ +} + +#define KOALA_INTEROP_V10(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2, \ + typename InteropTypeConverter::InteropType _p3, \ + typename InteropTypeConverter::InteropType _p4, \ + typename InteropTypeConverter::InteropType _p5, \ + typename InteropTypeConverter::InteropType _p6, \ + typename InteropTypeConverter::InteropType _p7, \ + typename InteropTypeConverter::InteropType _p8, \ + typename InteropTypeConverter::InteropType _p9 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + P9 p9 = getArgument(_p9); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9); \ + return; \ +} + +#define KOALA_INTEROP_V11(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2, \ + typename InteropTypeConverter::InteropType _p3, \ + typename InteropTypeConverter::InteropType _p4, \ + typename InteropTypeConverter::InteropType _p5, \ + typename InteropTypeConverter::InteropType _p6, \ + typename InteropTypeConverter::InteropType _p7, \ + typename InteropTypeConverter::InteropType _p8, \ + typename InteropTypeConverter::InteropType _p9, \ + typename InteropTypeConverter::InteropType _p10 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + P9 p9 = getArgument(_p9); \ + P10 p10 = getArgument(_p10); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); \ + return; \ +} + +#define KOALA_INTEROP_V12(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2, \ + typename InteropTypeConverter::InteropType _p3, \ + typename InteropTypeConverter::InteropType _p4, \ + typename InteropTypeConverter::InteropType _p5, \ + typename InteropTypeConverter::InteropType _p6, \ + typename InteropTypeConverter::InteropType _p7, \ + typename InteropTypeConverter::InteropType _p8, \ + typename InteropTypeConverter::InteropType _p9, \ + typename InteropTypeConverter::InteropType _p10, \ + typename InteropTypeConverter::InteropType _p11 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + P9 p9 = getArgument(_p9); \ + P10 p10 = getArgument(_p10); \ + P11 p11 = getArgument(_p11); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11); \ + return; \ +} + +#define KOALA_INTEROP_V13(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2, \ + typename InteropTypeConverter::InteropType _p3, \ + typename InteropTypeConverter::InteropType _p4, \ + typename InteropTypeConverter::InteropType _p5, \ + typename InteropTypeConverter::InteropType _p6, \ + typename InteropTypeConverter::InteropType _p7, \ + typename InteropTypeConverter::InteropType _p8, \ + typename InteropTypeConverter::InteropType _p9, \ + typename InteropTypeConverter::InteropType _p10, \ + typename InteropTypeConverter::InteropType _p11, \ + typename InteropTypeConverter::InteropType _p12 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + P9 p9 = getArgument(_p9); \ + P10 p10 = getArgument(_p10); \ + P11 p11 = getArgument(_p11); \ + P12 p12 = getArgument(_p12); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12); \ + return; \ +} + +#define KOALA_INTEROP_V14(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2, \ + typename InteropTypeConverter::InteropType _p3, \ + typename InteropTypeConverter::InteropType _p4, \ + typename InteropTypeConverter::InteropType _p5, \ + typename InteropTypeConverter::InteropType _p6, \ + typename InteropTypeConverter::InteropType _p7, \ + typename InteropTypeConverter::InteropType _p8, \ + typename InteropTypeConverter::InteropType _p9, \ + typename InteropTypeConverter::InteropType _p10, \ + typename InteropTypeConverter::InteropType _p11, \ + typename InteropTypeConverter::InteropType _p12, \ + typename InteropTypeConverter::InteropType _p13 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + P9 p9 = getArgument(_p9); \ + P10 p10 = getArgument(_p10); \ + P11 p11 = getArgument(_p11); \ + P12 p12 = getArgument(_p12); \ + P13 p13 = getArgument(_p13); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13); \ + return; \ +} + +#define KOALA_INTEROP_CTX_0(name, Ret) \ +KOALA_INTEROP_EXPORT InteropTypeConverter::InteropType name() { \ + KOALA_MAYBE_LOG(name) \ + KVMContext ctx = (KVMContext)0; \ + return makeResult(impl_##name(ctx)); \ +} + +#define KOALA_INTEROP_CTX_1(name, Ret, P0) \ +KOALA_INTEROP_EXPORT InteropTypeConverter::InteropType name(InteropTypeConverter::InteropType _p0) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + KVMContext ctx = (KVMContext)0; \ + return makeResult(impl_##name(ctx, p0)); \ +} + +#define KOALA_INTEROP_CTX_2(name, Ret, P0, P1) \ +KOALA_INTEROP_EXPORT InteropTypeConverter::InteropType name(InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + KVMContext ctx = (KVMContext)0; \ + return makeResult(impl_##name(ctx, p0, p1)); \ +} + + +#define KOALA_INTEROP_CTX_3(name, Ret, P0, P1, P2) \ +KOALA_INTEROP_EXPORT InteropTypeConverter::InteropType name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + KVMContext ctx = (KVMContext)0; \ + return makeResult(impl_##name(ctx, p0, p1, p2)); \ +} + +#define KOALA_INTEROP_CTX_4(name, Ret, P0, P1, P2, P3) \ +KOALA_INTEROP_EXPORT InteropTypeConverter::InteropType name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + KVMContext ctx = (KVMContext)0; \ + return makeResult(impl_##name(ctx, p0, p1, p2, p3)); \ +} + +#define KOALA_INTEROP_CTX_5(name, Ret, P0, P1, P2, P3, P4) \ +KOALA_INTEROP_EXPORT InteropTypeConverter::InteropType name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + KVMContext ctx = (KVMContext)0; \ + return makeResult(impl_##name(ctx, p0, p1, p2, p3, p4)); \ +} + +#define KOALA_INTEROP_CALL_INT(venv, id, length, args) \ +{ \ + int32_t rv = 0; \ + return rv; \ +} +#define KOALA_INTEROP_CALL_VOID(venv, id, length, args) \ +{ \ +} + + +#define KOALA_INTEROP_CALL_VOID_INTS32(venv, id, argc, args) KOALA_INTEROP_CALL_VOID(venv, id, (argc) * sizeof(int32_t), args) +#define KOALA_INTEROP_CALL_INT_INTS32(venv, id, argc, args) KOALA_INTEROP_CALL_INT(venv, id, (argc) * sizeof(int32_t), args) + + +#define KOALA_INTEROP_CTX_V1(name, P0) \ +KOALA_INTEROP_EXPORT void name(InteropTypeConverter::InteropType _p0) {\ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + impl_##name(nullptr, p0); \ +} + +#define KOALA_INTEROP_CTX_V2(name, P0, P1) \ +KOALA_INTEROP_EXPORT void name(InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + impl_##name(nullptr, p0, p1); \ +} + +#define KOALA_INTEROP_CTX_V3(name, P0, P1, P2) \ +KOALA_INTEROP_EXPORT void name(InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + impl_##name(nullptr, p0, p1, p2); \ +} + +#define KOALA_INTEROP_CTX_V4(name, P0, P1, P2, P3) \ +KOALA_INTEROP_EXPORT void name(InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + impl_##name(nullptr, p0, p1, p2, p3); \ +} + +#define KOALA_INTEROP_CTX_V5(name, P0, P1, P2, P3, P4) \ +KOALA_INTEROP_EXPORT void name(InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + impl_##name(nullptr, p0, p1, p2, p3, p4); \ +} + + #define KOALA_INTEROP_DIRECT_0(name, Ret) \ + KOALA_INTEROP_0(name, Ret) +#define KOALA_INTEROP_DIRECT_1(name, Ret, P0) \ + KOALA_INTEROP_1(name, Ret, P0) +#define KOALA_INTEROP_DIRECT_2(name, Ret, P0, P1) \ + KOALA_INTEROP_2(name, Ret, P0, P1) +#define KOALA_INTEROP_DIRECT_3(name, Ret, P0, P1, P2) \ + KOALA_INTEROP_3(name, Ret, P0, P1, P2) +#define KOALA_INTEROP_DIRECT_4(name, Ret, P0, P1, P2, P3) \ + KOALA_INTEROP_4(name, Ret, P0, P1, P2, P3) +#define KOALA_INTEROP_DIRECT_5(name, Ret, P0, P1, P2, P3, P4) \ + KOALA_INTEROP_5(name, Ret, P0, P1, P2, P3, P4) +#define KOALA_INTEROP_DIRECT_6(name, Ret, P0, P1, P2, P3, P4, P5) \ + KOALA_INTEROP_6(name, Ret, P0, P1, P2, P3, P4, P5) +#define KOALA_INTEROP_DIRECT_7(name, Ret, P0, P1, P2, P3, P4, P5, P6) \ + KOALA_INTEROP_7(name, Ret, P0, P1, P2, P3, P4, P5, P6) +#define KOALA_INTEROP_DIRECT_8(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7) \ + KOALA_INTEROP_8(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7) +#define KOALA_INTEROP_DIRECT_9(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8) \ + KOALA_INTEROP_9(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8) +#define KOALA_INTEROP_DIRECT_10(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) \ + KOALA_INTEROP_10(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) +#define KOALA_INTEROP_DIRECT_11(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) \ + KOALA_INTEROP_11(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) +#define KOALA_INTEROP_DIRECT_V0(name) \ + KOALA_INTEROP_V0(name) +#define KOALA_INTEROP_DIRECT_V1(name, P0) \ + KOALA_INTEROP_V1(name, P0) +#define KOALA_INTEROP_DIRECT_V2(name, P0, P1) \ + KOALA_INTEROP_V2(name, P0, P1) +#define KOALA_INTEROP_DIRECT_V3(name, P0, P1, P2) \ + KOALA_INTEROP_V3(name, P0, P1, P2) +#define KOALA_INTEROP_DIRECT_V4(name, P0, P1, P2, P3) \ + KOALA_INTEROP_V4(name, P0, P1, P2, P3) +#define KOALA_INTEROP_DIRECT_V5(name, P0, P1, P2, P3, P4) \ + KOALA_INTEROP_V5(name, P0, P1, P2, P3, P4) +#define KOALA_INTEROP_DIRECT_V6(name, P0, P1, P2, P3, P4, P5) \ + KOALA_INTEROP_V6(name, P0, P1, P2, P3, P4, P5) +#define KOALA_INTEROP_DIRECT_V7(name, P0, P1, P2, P3, P4, P5, P6) \ + KOALA_INTEROP_V7(name, P0, P1, P2, P3, P4, P5, P6) +#define KOALA_INTEROP_DIRECT_V8(name, P0, P1, P2, P3, P4, P5, P6, P7) \ + KOALA_INTEROP_V8(name, P0, P1, P2, P3, P4, P5, P6, P7) +#define KOALA_INTEROP_DIRECT_V9(name, P0, P1, P2, P3, P4, P5, P6, P7, P8) \ + KOALA_INTEROP_V9(name, P0, P1, P2, P3, P4, P5, P6, P7, P8) +#define KOALA_INTEROP_DIRECT_V10(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) \ + KOALA_INTEROP_V10(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) +#define KOALA_INTEROP_DIRECT_V11(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) \ + KOALA_INTEROP_V11(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) + +#define KOALA_INTEROP_THROW(vmContext, object, ...) \ + do { \ + /* TODO: implement*/ assert(false); \ + return __VA_ARGS__; \ + } while (0) + +#define KOALA_INTEROP_THROW_STRING(vmContext, message, ...) \ + do { \ + /* TODO: implement*/ assert(false); \ + return __VA_ARGS__; \ + } while (0) diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/common-interop.cc b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/common-interop.cc new file mode 100644 index 0000000000000000000000000000000000000000..4686a831433114cadd56d2670bea827052ede181 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/common-interop.cc @@ -0,0 +1,680 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include +#include + +#ifndef KOALA_INTEROP_MEM_ANALYZER +#include +#endif + +#ifdef KOALA_INTEROP_MODULE +#undef KOALA_INTEROP_MODULE +#endif + +#define KOALA_INTEROP_MODULE InteropNativeModule +#include "common-interop.h" +#include "interop-logging.h" +#include "dynamic-loader.h" + +#ifdef KOALA_FOREIGN_NAPI +#ifndef KOALA_FOREIGN_NAPI_OHOS +#include +#else +#include +#include +#endif +#endif + +#if KOALA_INTEROP_PROFILER +#include "profiler.h" + +InteropProfiler* InteropProfiler::_instance = nullptr; + +#endif + +using std::string; + +#ifndef KOALA_INTEROP_MEM_ANALYZER +static std::atomic mallocCounter{0}; +#endif + +#ifdef KOALA_NAPI +// Callback dispatcher MOVED to convertors-napi.cc. +// Let's keep platform-specific parts of the code together + +typedef void (*hold_t)(KInt); + +KInteropBuffer impl_MaterializeBuffer(KNativePointer data, KLong length, KInt resourceId, KNativePointer holdPtr, KNativePointer releasePtr) { + auto hold = reinterpret_cast(holdPtr); + auto release = reinterpret_cast(releasePtr); + hold(resourceId); + return KInteropBuffer { length, data, resourceId, release }; +} +KOALA_INTEROP_5(MaterializeBuffer, KInteropBuffer, KNativePointer, KLong, KInt, KNativePointer, KNativePointer) + +KNativePointer impl_GetNativeBufferPointer(KInteropBuffer buffer) { + return buffer.data; +} +KOALA_INTEROP_1(GetNativeBufferPointer, KNativePointer, KInteropBuffer) + +#endif + +#ifdef KOALA_ETS_NAPI +#include "etsapi.h" + +static struct { + ets_class clazz = nullptr; + ets_method method = nullptr; +} g_koalaEtsNapiCallbackDispatcher; + +bool setKoalaEtsNapiCallbackDispatcher( + EtsEnv* etsEnv, + ets_class clazz, + const char* dispatcherMethodName, + const char* dispactherMethodSig +) { + g_koalaEtsNapiCallbackDispatcher.clazz = clazz; + etsEnv->NewGlobalRef(clazz); + ets_method method = etsEnv->GetStaticp_method( + clazz, dispatcherMethodName, dispactherMethodSig + ); + if (method == nullptr) { + return false; + } + g_koalaEtsNapiCallbackDispatcher.method = method; + return true; +} + +void getKoalaEtsNapiCallbackDispatcher(ets_class* clazz, ets_method* method) { + *clazz = g_koalaEtsNapiCallbackDispatcher.clazz; + *method = g_koalaEtsNapiCallbackDispatcher.method; +} +#endif + + +// TODO: move callback dispetchers to convertors-.cc. +#ifdef KOALA_JNI +#include "jni.h" +static struct { + jclass clazz = nullptr; + jmethodID method = nullptr; +} g_koalaJniCallbackDispatcher; + +bool setKoalaJniCallbackDispatcher( + JNIEnv* jniEnv, + jclass clazz, + const char* dispatcherMethodName, + const char* dispactherMethodSig +) { + g_koalaJniCallbackDispatcher.clazz = clazz; + jniEnv->NewGlobalRef(clazz); + jmethodID method = jniEnv->GetStaticMethodID( + clazz, dispatcherMethodName, dispactherMethodSig + ); + if (method == nullptr) { + return false; + } + g_koalaJniCallbackDispatcher.method = method; + return true; +} + +void getKoalaJniCallbackDispatcher(jclass* clazz, jmethodID* method) { + *clazz = g_koalaJniCallbackDispatcher.clazz; + *method = g_koalaJniCallbackDispatcher.method; +} +#endif + +KInt impl_StringLength(KNativePointer ptr) { + string* s = reinterpret_cast(ptr); + return s->length(); +} +KOALA_INTEROP_1(StringLength, KInt, KNativePointer) + +void impl_StringData(KNativePointer ptr, KByte* bytes, KUInt size) { + string* s = reinterpret_cast(ptr); + if (s) memcpy(bytes, s->c_str(), size); +} +KOALA_INTEROP_V3(StringData, KNativePointer, KByte*, KUInt) + + +#ifdef KOALA_JNI +// For Java only yet. +KInteropBuffer impl_StringDataBytes(KVMContext vmContext, KNativePointer ptr) { + string* s = reinterpret_cast(ptr); + KInteropBuffer result = { (int32_t)s->length(), (void*)s->c_str()}; + return result; +} +KOALA_INTEROP_CTX_1(StringDataBytes, KInteropBuffer, KNativePointer) +#endif + +KNativePointer impl_StringMake(const KStringPtr& str) { + return new string(str.c_str()); +} +KOALA_INTEROP_1(StringMake, KNativePointer, KStringPtr) + +// For slow runtimes w/o fast encoders. +KInt impl_ManagedStringWrite(const KStringPtr& string, KSerializerBuffer buffer, KInt offset) { + memcpy((uint8_t*)buffer + offset, string.c_str(), string.length() + 1); + return string.length() + 1; +} +KOALA_INTEROP_3(ManagedStringWrite, KInt, KStringPtr, KSerializerBuffer, KInt) + +void stringFinalizer(string* ptr) { + delete ptr; +} +KNativePointer impl_GetStringFinalizer() { + return fnPtr(stringFinalizer); +} +KOALA_INTEROP_0(GetStringFinalizer, KNativePointer) + +void impl_InvokeFinalizer(KNativePointer obj, KNativePointer finalizer) { + auto finalizer_f = reinterpret_cast(finalizer); + finalizer_f(obj); +} +KOALA_INTEROP_V2(InvokeFinalizer, KNativePointer, KNativePointer) + +KInt impl_GetPtrVectorSize(KNativePointer ptr) { + return reinterpret_cast*>(ptr)->size(); +} +KOALA_INTEROP_1(GetPtrVectorSize, KInt, KNativePointer) + +KNativePointer impl_GetPtrVectorElement(KNativePointer ptr, KInt index) { + auto vector = reinterpret_cast*>(ptr); + auto element = vector->at(index); + return nativePtr(element); +} +KOALA_INTEROP_2(GetPtrVectorElement, KNativePointer, KNativePointer, KInt) + +inline KUInt unpackUInt(const KByte* bytes) { + return (bytes[0] | (bytes[1] << 8) | (bytes[2] << 16) | (bytes[3] << 24)); +} + +KNativePointer impl_GetGroupedLog(KInt index) { + return new std::string(GetDefaultLogger()->getGroupedLog(index)); +} +KOALA_INTEROP_1(GetGroupedLog, KNativePointer, KInt) + +void impl_StartGroupedLog(KInt index) { + GetDefaultLogger()->startGroupedLog(index); +} +KOALA_INTEROP_V1(StartGroupedLog, KInt) + +void impl_StopGroupedLog(KInt index) { + GetDefaultLogger()->stopGroupedLog(index); +} +KOALA_INTEROP_V1(StopGroupedLog, KInt) + +void impl_AppendGroupedLog(KInt index, const KStringPtr& message) { + if (GetDefaultLogger()->needGroupedLog(index)) + GetDefaultLogger()->appendGroupedLog(index, message.c_str()); +} +KOALA_INTEROP_V2(AppendGroupedLog, KInt, KStringPtr) + +void impl_PrintGroupedLog(KInt index) { +#ifdef KOALA_OHOS + LOGI("%" LOG_PUBLIC "s", GetDefaultLogger()->getGroupedLog(index)); +#else + fprintf(stdout, "%s\n", GetDefaultLogger()->getGroupedLog(index)); + fflush(stdout); +#endif +} +KOALA_INTEROP_V1(PrintGroupedLog, KInt) + +int32_t callCallback(KVMContext context, int32_t methodId, uint8_t* argsData, int32_t argsLength) { +#if KOALA_USE_NODE_VM || KOALA_USE_HZ_VM || KOALA_USE_PANDA_VM || KOALA_USE_JAVA_VM || KOALA_CJ + KOALA_INTEROP_CALL_INT(context, methodId, argsLength, argsData); + return 0; +#else + return 0; +#endif +} + +struct ForeignVMContext { + KVMContext vmContext; + int32_t (*callSync)(KVMContext vmContext, int32_t callback, uint8_t* data, int32_t length); +}; +typedef KInt (*LoadVirtualMachine_t)(KInt vmKind, const char* classPath, const char* libraryPath, const struct ForeignVMContext* foreignVM); +typedef KNativePointer (*StartApplication_t)(const char* appUrl, const char* appParams); +typedef KBoolean (*RunApplication_t)(const KInt arg0, const KInt arg1); +typedef const char* (*EmitEvent_t)(const KInt type, const KInt target, const KInt arg0, const KInt arg1); +typedef void (*RestartWith_t)(const char* page); + +void* getImpl(const char* path, const char* name) { + static void* lib = nullptr; + if (!lib && name) { + auto name = +#ifndef KOALA_OHOS // dlopen on OHOS doesn't like paths + std::string(path) + "/" + +#endif + libName("vmloader"); + lib = loadLibrary(name); + if (!lib) { + fprintf(stderr, "Ensure vmloader library %s was built\n", name.c_str()); + } + } + return findSymbol(lib, name); +} + +KInt impl_LoadVirtualMachine(KVMContext vmContext, KInt vmKind, const KStringPtr& classPath, const KStringPtr& libraryPath) { + const char* envClassPath = std::getenv("PANDA_CLASS_PATH"); + if (envClassPath) { + LOGI("CLASS PATH updated from env var PANDA_CLASS_PATH, %" LOG_PUBLIC "s", envClassPath); + } + const char* appClassPath = envClassPath ? envClassPath : classPath.c_str(); + const char* nativeLibPath = envClassPath ? envClassPath : libraryPath.c_str(); + + static LoadVirtualMachine_t impl = nullptr; + if (!impl) impl = reinterpret_cast(getImpl(nativeLibPath, "LoadVirtualMachine")); + if (!impl) KOALA_INTEROP_THROW_STRING(vmContext, "Cannot load VM", -1); + const ForeignVMContext foreignVM = { + vmContext, &callCallback + }; + return impl(vmKind, appClassPath, nativeLibPath, &foreignVM); +} +KOALA_INTEROP_CTX_3(LoadVirtualMachine, KInt, KInt, KStringPtr, KStringPtr) + +KNativePointer impl_StartApplication(const KStringPtr& appUrl, const KStringPtr& appParams) { + static StartApplication_t impl = nullptr; + if (!impl) impl = reinterpret_cast(getImpl(nullptr, "StartApplication")); + return impl(appUrl.c_str(), appParams.c_str()); +} +KOALA_INTEROP_2(StartApplication, KNativePointer, KStringPtr, KStringPtr) + +KBoolean impl_RunApplication(const KInt arg0, const KInt arg1) { + static RunApplication_t impl = nullptr; + if (!impl) impl = reinterpret_cast(getImpl(nullptr, "RunApplication")); + return impl(arg0, arg1); +} +KOALA_INTEROP_2(RunApplication, KBoolean, KInt, KInt) + +KStringPtr impl_EmitEvent(KVMContext vmContext, KInt type, KInt target, KInt arg0, KInt arg1) { + static EmitEvent_t impl = nullptr; + if (!impl) impl = reinterpret_cast(getImpl(nullptr, "EmitEvent")); + const char* out = impl(type, target, arg0, arg1); + auto size = std::string(out).size(); + KStringPtr result(out, size, true); + return result; +} +KOALA_INTEROP_CTX_4(EmitEvent, KStringPtr, KInt, KInt, KInt, KInt) + +void impl_RestartWith(const KStringPtr& page) { + static RestartWith_t impl = nullptr; + if (!impl) impl = reinterpret_cast(getImpl(nullptr, "RestartWith")); + impl(page.c_str()); +} +KOALA_INTEROP_V1(RestartWith, KStringPtr) + +KNativePointer impl_Malloc(KLong length) { + const auto ptr = static_cast(malloc(length)); + if (ptr == nullptr) { + INTEROP_FATAL("Memory allocation failed!"); + } +#ifndef KOALA_INTEROP_MEM_ANALYZER + mallocCounter.fetch_add(1, std::memory_order_release); +#endif + return ptr; +} +KOALA_INTEROP_DIRECT_1(Malloc, KNativePointer, KLong) + +void impl_Free(KNativePointer data) { + if (data) { + free(data); +#ifndef KOALA_INTEROP_MEM_ANALYZER + if (mallocCounter.fetch_sub(1, std::memory_order_release) == 0) { + INTEROP_FATAL("Double-free detected!"); + } +#endif + } +} +KOALA_INTEROP_DIRECT_V1(Free, KNativePointer) + +KInt impl_ReadByte(KNativePointer data, KLong index, KLong length) { + if (index >= length) INTEROP_FATAL("impl_ReadByte: index %lld is equal or greater than length %lld", (long long)index, (long long) length); + uint8_t* ptr = reinterpret_cast(data); + return ptr[index]; +} +KOALA_INTEROP_DIRECT_3(ReadByte, KInt, KNativePointer, KLong, KLong) + +void impl_WriteByte(KNativePointer data, KInt index, KLong length, KInt value) { + if (index >= length) INTEROP_FATAL("impl_WriteByte: index %lld is equal or greater than length %lld", (long long)index, (long long) length); + uint8_t* ptr = reinterpret_cast(data); + ptr[index] = value; +} +KOALA_INTEROP_DIRECT_V4(WriteByte, KNativePointer, KLong, KLong, KInt) + +void impl_CopyArray(KNativePointer data, KLong length, KByte* array) { + memcpy(data, array, length); +} +KOALA_INTEROP_V3(CopyArray, KNativePointer, KLong, KByte*) + +static Callback_Caller_t g_callbackCaller = nullptr; +void setCallbackCaller(Callback_Caller_t callbackCaller) { + g_callbackCaller = callbackCaller; +} + +void impl_CallCallback(KInt callbackKind, KSerializerBuffer args, KInt argsSize) { + if (g_callbackCaller) { + g_callbackCaller(callbackKind, args, argsSize); + } +} +KOALA_INTEROP_V3(CallCallback, KInt, KSerializerBuffer, KInt) + +static Callback_Caller_Sync_t g_callbackCallerSync = nullptr; +void setCallbackCallerSync(Callback_Caller_Sync_t callbackCallerSync) { + g_callbackCallerSync = callbackCallerSync; +} + +void impl_CallCallbackSync(KVMContext vmContext, KInt callbackKind, KSerializerBuffer args, KInt argsSize) { + if (g_callbackCallerSync) { + g_callbackCallerSync(vmContext, callbackKind, args, argsSize); + } +} +KOALA_INTEROP_CTX_V3(CallCallbackSync, KInt, KSerializerBuffer, KInt) + +void impl_CallCallbackResourceHolder(KNativePointer holder, KInt resourceId) { + reinterpret_cast(holder)(resourceId); +} +KOALA_INTEROP_V2(CallCallbackResourceHolder, KNativePointer, KInt) + +void impl_CallCallbackResourceReleaser(KNativePointer releaser, KInt resourceId) { + reinterpret_cast(releaser)(resourceId); +} +KOALA_INTEROP_V2(CallCallbackResourceReleaser, KNativePointer, KInt) + +KInt impl_CallForeignVM(KNativePointer foreignContextRaw, KInt function, KByte* data, KInt length) { + const ForeignVMContext* foreignContext = (const ForeignVMContext*)foreignContextRaw; + // TODO: set actuall callbacks caller/holder/releaser. + /* + *(int64_t*)(data + 8) = impl_CallCallbackSync; + *(int64_t*)(data + 16) = 0; + *(int64_t*)(data + 24) = 0; */ + return foreignContext->callSync(foreignContext->vmContext, function, data, length); +} +KOALA_INTEROP_4(CallForeignVM, KInt, KNativePointer, KInt, KByte*, KInt) + +#ifdef KOALA_FOREIGN_NAPI +KVMContext g_foreignVMContext = nullptr; +#endif +void impl_SetForeignVMContext(KNativePointer foreignVMContextRaw) { +#ifdef KOALA_FOREIGN_NAPI + if (foreignVMContextRaw == nullptr) { + g_foreignVMContext = nullptr; + } else { + auto foreignContext = (const ForeignVMContext*)foreignVMContextRaw; + g_foreignVMContext = foreignContext->vmContext; + } +#endif + + /* supress unused private fields */ + (void)foreignVMContextRaw; +} +KOALA_INTEROP_V1(SetForeignVMContext, KNativePointer) + +#define __QUOTE(x) #x +#define QUOTE(x) __QUOTE(x) + +void impl_NativeLog(const KStringPtr& str) { +#ifdef KOALA_OHOS + LOGI("%{public}s: %{public}s", QUOTE(INTEROP_LIBRARY_NAME), str.c_str()); +#else + fprintf(stdout, "%s: %s\n", QUOTE(INTEROP_LIBRARY_NAME), str.c_str()); + fflush(stdout); +#endif +} +KOALA_INTEROP_V1(NativeLog, KStringPtr) + +void resolveDeferred(KVMDeferred* deferred, uint8_t* argsData, int32_t argsLength) { +#ifdef KOALA_NAPI + auto status = napi_call_threadsafe_function((napi_threadsafe_function)deferred->handler, deferred, napi_tsfn_nonblocking); + if (status != napi_ok) LOGE("cannot call thread-safe function; status=%d", status); + napi_release_threadsafe_function((napi_threadsafe_function)deferred->handler, napi_tsfn_release); +#endif +} + +void rejectDeferred(KVMDeferred* deferred, const char* message) { +#ifdef KOALA_NAPI + napi_release_threadsafe_function((napi_threadsafe_function)deferred->handler, napi_tsfn_release); +#endif +} + +#ifdef KOALA_NAPI +void resolveDeferredImpl(napi_env env, napi_value js_callback, KVMDeferred* deferred, void* data) { + napi_value undefined = nullptr; + napi_get_undefined(env, &undefined); + auto status = napi_resolve_deferred(env, (napi_deferred)deferred->context, undefined); + if (status != napi_ok) LOGE("cannot resolve deferred; status=%d", status); + delete deferred; +} +#endif + +KVMDeferred* CreateDeferred(KVMContext vmContext, KVMObjectHandle* promiseHandle) { + KVMDeferred* deferred = new KVMDeferred(); + deferred->resolve = resolveDeferred; + deferred->reject = rejectDeferred; +#ifdef KOALA_NAPI + // TODO: move to interop! + napi_env env = (napi_env)vmContext; + napi_value promise; + napi_value resourceName; + napi_create_string_utf8(env, "Async", 5, &resourceName); + auto status = napi_create_promise(env, (napi_deferred*)&deferred->context, &promise); + if (status != napi_ok) LOGE("cannot make a promise; status=%d", status); + status = napi_create_threadsafe_function(env, + nullptr, + nullptr, + resourceName, + 0, + 1, + nullptr, + nullptr, + deferred, + (napi_threadsafe_function_call_js)resolveDeferredImpl, + (napi_threadsafe_function*)&deferred->handler); + if (status != napi_ok) LOGE("cannot make threadsafe function; status=%d", status); + *promiseHandle = (KVMObjectHandle)promise; +#endif + return deferred; +} + +class KoalaWork { +protected: + InteropVMContext vmContext; +#ifdef KOALA_FOREIGN_NAPI + KVMContext foreignVMContext; +#endif + void* vmWork; + void* handle; + void (*execute)(void* handle); + void (*complete)(void* handle); +public: + KoalaWork(InteropVMContext vmContext, + InteropNativePointer handle, + void (*execute)(InteropNativePointer handle), + void (*complete)(InteropNativePointer handle)); + void Queue(); + void Execute(); + void Cancel(); + void Complete(); +}; +static void DoQueue(void* handle) { + ((KoalaWork*)handle)->Queue(); +} +static void DoCancel(void* handle) { + ((KoalaWork*)handle)->Cancel(); +} + +InteropAsyncWork koalaCreateWork( + InteropVMContext vmContext, + InteropNativePointer handle, + void (*execute)(InteropNativePointer handle), + void (*complete)(InteropNativePointer handle) +) { + return { + new KoalaWork(vmContext, handle, execute, complete), + DoQueue, + DoCancel, + }; +} + +const InteropAsyncWorker* GetAsyncWorker() { + static InteropAsyncWorker worker = { + koalaCreateWork + }; + return &worker; +} + +#if defined(KOALA_NAPI) +static void DoExecute(napi_env env, void* handle) { + ((KoalaWork*)handle)->Execute(); +} +static void DoComplete(napi_env env, napi_status status, void* handle) { + ((KoalaWork*)handle)->Complete(); +} +KoalaWork::KoalaWork(InteropVMContext vmContext, + InteropNativePointer handle, + void (*execute)(InteropNativePointer handle), + void (*complete)(InteropNativePointer handle) +): vmContext(vmContext), handle(handle), execute(execute), complete(complete) { + napi_env env = (napi_env)vmContext; + napi_value resourceName = nullptr; + napi_create_string_utf8(env, "KoalaAsyncOperation", NAPI_AUTO_LENGTH, &resourceName); + napi_create_async_work(env, nullptr, resourceName, DoExecute, DoComplete, this, (napi_async_work*)&vmWork); + /* supress unused private fields */ + (void)vmContext; + (void)vmWork; +} +void KoalaWork::Queue() { + napi_env env = (napi_env)vmContext; + napi_queue_async_work(env, (napi_async_work)vmWork); +} +void KoalaWork::Execute() { + execute(handle); +} +void KoalaWork::Cancel() { + napi_env env = (napi_env)vmContext; + napi_cancel_async_work(env, (napi_async_work)vmWork); +} +void KoalaWork::Complete() { + complete(handle); + delete this; +} +#else +#ifdef KOALA_FOREIGN_NAPI +static void DoExecute(napi_env env, void* handle) { + ((KoalaWork*)handle)->Execute(); +} +static void DoComplete(napi_env env, napi_status status, void* handle) { + ((KoalaWork*)handle)->Complete(); +} +#endif +KoalaWork::KoalaWork(InteropVMContext vmContext, + InteropNativePointer handle, + void (*execute)(InteropNativePointer handle), + void (*complete)(InteropNativePointer handle) +): vmContext(vmContext), handle(handle), execute(execute), complete(complete) { +#ifdef KOALA_FOREIGN_NAPI + if (g_foreignVMContext == nullptr) + INTEROP_FATAL("Can not launch async work while foreign VM context is not available. Please ensure you have called SetForeignVMContext"); + foreignVMContext = g_foreignVMContext; + napi_env env = (napi_env)foreignVMContext; + napi_value resourceName = nullptr; + napi_create_string_utf8(env, "KoalaAsyncOperation", NAPI_AUTO_LENGTH, &resourceName); + napi_create_async_work(env, nullptr, resourceName, DoExecute, DoComplete, this, (napi_async_work*)&vmWork); +#endif + /* supress unused private fields */ + (void)vmContext; + (void)vmWork; +} +void KoalaWork::Queue() { +#ifdef KOALA_FOREIGN_NAPI + napi_env env = (napi_env)foreignVMContext; + napi_queue_async_work(env, (napi_async_work)vmWork); +#else + Execute(); + Complete(); +#endif +} +void KoalaWork::Execute() { + execute(handle); +} +void KoalaWork::Cancel() { +#ifdef KOALA_FOREIGN_NAPI + napi_env env = (napi_env)foreignVMContext; + napi_cancel_async_work(env, (napi_async_work)vmWork); +#else + INTEROP_FATAL("Cancelling async work is disabled for any VM except of Node"); +#endif +} +void KoalaWork::Complete() { + complete(handle); + delete this; +} +#endif + + +#if defined(KOALA_ETS_NAPI) || defined(KOALA_ANI) +KStringPtr impl_Utf8ToString(KVMContext vmContext, KNativePointer data, KInt offset, KInt length) { + KStringPtr result((const char*)data + offset, length, false); + return result; +} +KOALA_INTEROP_CTX_3(Utf8ToString, KStringPtr, KNativePointer, KInt, KInt) +#elif defined(KOALA_NAPI) || defined(KOALA_JNI) || defined(KOALA_CJ) +// Allocate, so CTX versions. +KStringPtr impl_Utf8ToString(KVMContext vmContext, KByte* data, KInt offset, KInt length) { + KStringPtr result((const char*)(data + offset), length, false); + return result; +} +KOALA_INTEROP_CTX_3(Utf8ToString, KStringPtr, KByte*, KInt, KInt) +#endif + +#if defined(KOALA_NAPI) || defined(KOALA_JNI) || defined(KOALA_CJ) || defined(KOALA_ETS_NAPI) || defined(KOALA_ANI) +KStringPtr impl_StdStringToString(KVMContext vmContext, KNativePointer stringPtr) { + std::string* string = reinterpret_cast(stringPtr); + KStringPtr result(string->c_str(), string->size(), false); + return result; +} +KOALA_INTEROP_CTX_1(StdStringToString, KStringPtr, KNativePointer) + +KInteropReturnBuffer impl_RawReturnData(KVMContext vmContext, KInt v1, KInt v2) { + void* data = new int8_t[v1]; + memset(data, v2, v1); + KInteropReturnBuffer buffer = { v1, data, [](KNativePointer ptr, KInt) { delete[] (int8_t*)ptr; }}; + return buffer; +} +KOALA_INTEROP_CTX_2(RawReturnData, KInteropReturnBuffer, KInt, KInt) + +KInteropNumber impl_IncrementNumber(KInteropNumber number) { + if (number.tag == 102) + number.i32++; + else + number.f32 += 1.f; + return number; +} +KOALA_INTEROP_1(IncrementNumber, KInteropNumber, KInteropNumber) + +void impl_ReportMemLeaks() { +#ifndef KOALA_INTEROP_MEM_ANALYZER + const auto count = mallocCounter.load(std::memory_order_acquire); + if (count > 0) { + fprintf(stderr, "Memory leaks detected: %d blocks\n", count); + } else { + fprintf(stderr, "No memory leaks\n"); + } +#endif +} +KOALA_INTEROP_V0(ReportMemLeaks) + +#endif \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/common-interop.h b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/common-interop.h new file mode 100644 index 0000000000000000000000000000000000000000..bbbb3db53d63d71b6ecbdea565139b5a966094f3 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/common-interop.h @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef COMMON_INTEROP_BASE_H +#define COMMON_INTEROP_BASE_H + +#include + +#include "koala-types.h" + +#define KOALA_INTEROP_PROFILER 0 +#define KOALA_INTEROP_TRACER 0 + +#if KOALA_INTEROP_PROFILER +#include "profiler.h" +#define KOALA_INTEROP_LOGGER(name) InteropMethodCall logger(#name); +#endif + +#if KOALA_INTEROP_TRACER +#include "tracer.h" +#define KOALA_INTEROP_LOGGER(name) InteropMethodCall logger(#name); +#endif + + +#ifdef KOALA_INTEROP_LOGGER +#define KOALA_MAYBE_LOG(name) KOALA_INTEROP_LOGGER(name); +#else +#define KOALA_MAYBE_LOG(name) +#endif + +#ifdef KOALA_WINDOWS +#define DLL_EXPORT __declspec(dllexport) +#else +#define DLL_EXPORT __attribute__ ((visibility ("default"))) +#endif + +typedef void (*Callback_Caller_t)(KInt callbackKind, KSerializerBuffer argsData, KInt argsLength); +typedef void (*Callback_Caller_Sync_t)(KVMContext vmContext, KInt callbackKind, KSerializerBuffer argsData, KInt argsLength); +extern "C" DLL_EXPORT void setCallbackCaller(Callback_Caller_t caller); +extern "C" DLL_EXPORT void setCallbackCallerSync(Callback_Caller_Sync_t callerSync); + +extern "C" DLL_EXPORT KVMDeferred* CreateDeferred(KVMContext context, KVMObjectHandle* promise); +extern "C" DLL_EXPORT const InteropAsyncWorker* GetAsyncWorker(); + +#if KOALA_USE_NODE_VM || KOALA_USE_HZ_VM +#include "convertors-napi.h" +#elif KOALA_USE_JSC_VM +#include "convertors-jsc.h" +#elif KOALA_ETS_NAPI +#include "convertors-ets.h" +#elif KOALA_USE_JAVA_VM +#include "convertors-jni.h" +#elif KOALA_WASM +#include "convertors-wasm.h" +#elif KOALA_CJ +#include "convertors-cj.h" +#elif KOALA_ANI +#include "convertors-ani.h" +#else +#error "One of above branches must be taken" +#endif + +#endif // COMMON_INTEROP_BASE_H diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/crashdump.h b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/crashdump.h new file mode 100644 index 0000000000000000000000000000000000000000..128f7ba61715fd378f73511dede93f01cd38b7ec --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/crashdump.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _INTEROP_CRASHDUMP_H +#define _INTEROP_CRASHDUMP_H + +#ifdef KOALA_LINUX +#include +#include + +sighandler_t oldCrashHandler = nullptr; + +static void onCrashHandler(int signo) { + void* stack[20]; + size_t size = backtrace(stack, 20); + backtrace_symbols_fd(stack, size, STDERR_FILENO); + if (oldCrashHandler) oldCrashHandler(signo); +} + +static void installCrashHandlers() { + static bool installed = false; + if (!installed) { + oldCrashHandler = signal(SIGSEGV, onCrashHandler); + installed = true; + } +} +#else +static void installCrashHandlers() {} +#endif + +#endif // _INTEROP_CRASHDUMP_H \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/dynamic-loader.h b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/dynamic-loader.h new file mode 100644 index 0000000000000000000000000000000000000000..f51ea33a75e8d51cd6ce296140ab457a9f1383d4 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/dynamic-loader.h @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _DYNAMIC_LOADER_H +#define _DYNAMIC_LOADER_H + +#include + +#ifdef KOALA_WINDOWS +#include +// Here we need to find module where GetArkUINodeAPI() +// function is implemented. +inline void* loadLibrary(const std::string& libPath) { + return LoadLibraryA(libPath.c_str()); +} + +inline const char* libraryError() { + static char error[256]; + snprintf(error, sizeof error, "error %lu", GetLastError()); + return error; +} + +inline void* findSymbol(void* library, const char* name) { + return (void*)GetProcAddress(reinterpret_cast(library), name); +} + +inline std::string libName(const char* lib) { + return std::string(lib) + ".dll"; +} + +#elif defined(KOALA_LINUX) || defined(KOALA_MACOS) || defined(KOALA_OHOS) +#include + +inline void* loadLibrary(const std::string& libPath) { + void* handle = dlopen(libPath.c_str(), RTLD_LOCAL | RTLD_NOW); + if (!handle) { + return nullptr; + } + return handle; +} + +inline const char* libraryError() { + return dlerror(); +} + +inline std::string symbolName(const char* name) { + return name; +} + +inline void* findSymbol(void* library, const char* name) { + return dlsym(library, symbolName(name).c_str()); +} + +inline std::string libName(const char* lib) { + std::string result; + std::string suffix = +#ifdef KOALA_MACOS + ".dylib" +#else + ".so" +#endif + ; + result = "lib" + std::string(lib) + suffix; + return result; +} + +#else + +#include + +inline void* loadLibrary(const std::string& libPath) { + fprintf(stderr, "No loadLibrary() on this platform\n"); + return nullptr; +} + +inline const char* libraryError() { + fprintf(stderr, "No libraryError() on this platform\n"); + return nullptr; +} + +inline std::string symbolName(const char* name) { + fprintf(stderr, "No symbolName() on this platform\n"); + return ""; +} + +inline void* findSymbol(void* library, const char* name) { + fprintf(stderr, "No findSymbol() on this platform\n"); + return nullptr; +} + +inline std::string libName(const char* lib) { + fprintf(stderr, "No libName() on this platform\n"); + return ""; +} + +#endif + +#endif // _DYNAMIC_LOADER_H \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/ets/convertors-ets.cc b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/ets/convertors-ets.cc new file mode 100644 index 0000000000000000000000000000000000000000..cf4c85df4723f589a0b7cde3bc8fd40d43d68401 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/ets/convertors-ets.cc @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "convertors-ets.h" +#include "signatures.h" +#include "interop-logging.h" +#include "interop-types.h" + +static const char* callCallbackFromNative = "callCallbackFromNative"; +static const char* callCallbackFromNativeSig = "IJI:I"; + +static const char* FAST_NATIVE_PREFIX = "#F$"; + +const bool registerByOne = true; + +static bool registerNatives(ets_env *env, const ets_class clazz, const std::vector> impls) { + std::vector methods; + methods.reserve(impls.size()); + bool result = true; + for (const auto &[name, type, func, flag] : impls) { + EtsNativeMethod method; + method.name = name.c_str(); + method.func = func; + method.signature = (flag & ETS_SLOW_NATIVE_FLAG) == 0 ? FAST_NATIVE_PREFIX : nullptr; + if (registerByOne) { + result &= env->RegisterNatives(clazz, &method, 1) >= 0; + if (env->ErrorCheck()) { + //env->ErrorDescribe(); + env->ErrorClear(); + } + } + else { + methods.push_back(method); + } + } + if (!registerByOne) { + result = env->RegisterNatives(clazz, methods.data(), static_cast(methods.size())) >= 0; + } + return registerByOne ? true : result; +} + +bool registerAllModules(ets_env *env) { + auto moduleNames = EtsExports::getInstance()->getModules(); + + for (auto it = moduleNames.begin(); it != moduleNames.end(); ++it) { + std::string className = EtsExports::getInstance()->getClasspath(*it); + ets_class nativeModule = env->FindClass(className.c_str()); + if (nativeModule == nullptr) { + LOGE("Cannot find managed class %s", className.c_str()); + continue; + } + if (!registerNatives(env, nativeModule, EtsExports::getInstance()->getMethods(*it))) { + return false; + } + } + + return true; +} + +extern "C" ETS_EXPORT ets_int ETS_CALL EtsNapiOnLoad(ets_env *env) { + LOGE("Use ETSNAPI") + if (!registerAllModules(env)) { + LOGE("Failed to register ets modules"); + return ETS_ERR; + } + auto interopClasspath = EtsExports::getInstance()->getClasspath("InteropNativeModule"); + auto interopClass = env->FindClass(interopClasspath.c_str()); + if (interopClass == nullptr) { + LOGE("Can not find InteropNativeModule classpath to set callback dispatcher"); + return ETS_ERR; + } + if (!setKoalaEtsNapiCallbackDispatcher(env, interopClass, callCallbackFromNative, callCallbackFromNativeSig)) { + LOGE("Failed to set koala ets callback dispatcher"); + return ETS_ERR; + } + return ETS_NAPI_VERSION_1_0; +} + +EtsExports* EtsExports::getInstance() { + static EtsExports *instance = nullptr; + if (instance == nullptr) { + instance = new EtsExports(); + } + return instance; +} + +std::vector EtsExports::getModules() { + std::vector result; + for (auto it = implementations.begin(); it != implementations.end(); ++it) { + result.push_back(it->first); + } + return result; +} + +const std::vector>& EtsExports::getMethods(const std::string& module) { + auto it = implementations.find(module); + if (it == implementations.end()) { + LOGE("Module %s is not registered", module.c_str()); + } + return it->second; +} + +void EtsExports::addMethod(const char* module, const char *name, const char *type, void *impl, int flags) { + auto it = implementations.find(module); + if (it == implementations.end()) { + it = implementations.insert(std::make_pair(module, std::vector>())).first; + } + it->second.push_back(std::make_tuple(name, convertType(name, type), impl, flags)); +} + +void EtsExports::setClasspath(const char* module, const char *classpath) { + auto it = classpaths.find(module); + if (it == classpaths.end()) { + classpaths.insert(std::make_pair(module, classpath)); + } else { + LOGE("Classpath for module %s was redefined", module); + } +} + +static std::map g_defaultClasspaths = { + {"InteropNativeModule", "@koalaui/interop/InteropNativeModule/InteropNativeModule"}, + // todo leave just InteropNativeModule, define others via KOALA_ETS_INTEROP_MODULE_CLASSPATH + {"TestNativeModule", "@ohos/arkui/generated/arkts/TestNativeModule/TestNativeModule"}, + {"ArkUINativeModule", "@ohos/arkui/generated/arkts/ArkUINativeModule/ArkUINativeModule"}, + {"ArkUIGeneratedNativeModule", "@ohos/arkui/generated/arkts/ArkUIGeneratedNativeModule/ArkUIGeneratedNativeModule"}, +}; +const std::string& EtsExports::getClasspath(const std::string& module) { + auto it = classpaths.find(module); + if (it != classpaths.end()) { + return it->second; + } + auto defaultClasspath = g_defaultClasspaths.find(module); + if (defaultClasspath != g_defaultClasspaths.end()) { + return defaultClasspath->second; + } + INTEROP_FATAL("Classpath for module %s was not registered", module.c_str()); +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/ets/convertors-ets.h b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/ets/convertors-ets.h new file mode 100644 index 0000000000000000000000000000000000000000..126bd44dbf6f2f4f22e4401726e81a84997a268b --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/ets/convertors-ets.h @@ -0,0 +1,1831 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#ifdef KOALA_ETS_NAPI + +#include +#include +#include +#include +#include +#include +#include + +#include "etsapi.h" +#include "koala-types.h" + +template +struct InteropTypeConverter { + using InteropType = T; + static T convertFrom(EtsEnv* env, InteropType value) = delete; + static InteropType convertTo(EtsEnv* env, T value) = delete; + static void release(EtsEnv* env, InteropType value, T converted) {} +}; + +template<> +struct InteropTypeConverter { + using InteropType = ets_boolean; + static KBoolean convertFrom(EtsEnv* env, InteropType value) { return value; } + static InteropType convertTo(EtsEnv* env, KBoolean value) { return value; } + static void release(EtsEnv* env, InteropType value, KBoolean converted) {} +}; + + +template<> +struct InteropTypeConverter { + using InteropType = ets_int; + static KInt convertFrom(EtsEnv* env, InteropType value) { return value; } + static InteropType convertTo(EtsEnv* env, KInt value) { return value; } + static void release(EtsEnv* env, InteropType value, KInt converted) {} +}; + +template<> +struct InteropTypeConverter { + using InteropType = ets_int; + static KUInt convertFrom(EtsEnv* env, InteropType value) { return value; } + static InteropType convertTo(EtsEnv* env, KUInt value) { return value; } + static void release(EtsEnv* env, InteropType value, KUInt converted) {} +}; + +template<> +struct InteropTypeConverter { + using InteropType = ets_byte; + static KByte convertFrom(EtsEnv* env, InteropType value) { return value; } + static InteropType convertTo(EtsEnv* env, KByte value) { return value; } + static void release(EtsEnv* env, InteropType value, KByte converted) {} +}; + +template<> +struct InteropTypeConverter { + using InteropType = ets_float; + static KFloat convertFrom(EtsEnv* env, InteropType value) { return value; } + static InteropType convertTo(EtsEnv* env, InteropFloat32 value) { return value; } + static void release(EtsEnv* env, InteropType value, KFloat converted) {} +}; + +template<> +struct InteropTypeConverter { + using InteropType = ets_long; + static KSerializerBuffer convertFrom(EtsEnv* env, InteropType value) { + return reinterpret_cast(static_cast(value)); + } + static InteropType convertTo(EtsEnv* env, KSerializerBuffer value) = delete; + static void release(EtsEnv* env, InteropType value, KSerializerBuffer converted) {} +}; + +template<> +struct InteropTypeConverter { + using InteropType = ets_object; + static KVMObjectHandle convertFrom(EtsEnv* env, InteropType value) { + return reinterpret_cast(value); + } + static InteropType convertTo(EtsEnv* env, KVMObjectHandle value) { + return reinterpret_cast(value); + } + static void release(EtsEnv* env, InteropType value, KVMObjectHandle converted) {} +}; + +template<> +struct InteropTypeConverter { + using InteropType = ets_byteArray; + static KInteropBuffer convertFrom(EtsEnv* env, InteropType value) { + if (!value) return KInteropBuffer(); + KInteropBuffer result; + result.data = (KByte*)env->PinByteArray(value); + result.length = env->GetArrayLength(value); + return result; + } + static InteropType convertTo(EtsEnv* env, KInteropBuffer value) { + ets_byteArray array = env->NewByteArray(value.length); + KByte* data = (KByte*)env->PinByteArray(array); + memcpy(data, (KByte*)value.data, value.length); + env->UnpinByteArray(array); + value.dispose(value.resourceId); + return array; + } + static void release(EtsEnv* env, InteropType value, KInteropBuffer converted) { + env->UnpinByteArray(value); + } +}; + +template<> +struct InteropTypeConverter { + using InteropType = ets_string; + static KStringPtr convertFrom(EtsEnv* env, InteropType value) { + if (value == nullptr) return KStringPtr(); + KStringPtr result; + // Notice that we use UTF length for buffer size, but counter is expressed in number of Unicode chars. + result.resize(env->GetStringUTFLength(value)); + env->GetStringUTFRegion(value, 0, env->GetStringLength(value), result.data()); + return result; + } + static InteropType convertTo(EtsEnv* env, const KStringPtr& value) { + return env->NewStringUTF(value.c_str()); + } + static void release(EtsEnv* env, InteropType value, const KStringPtr& converted) {} +}; + +template<> +struct InteropTypeConverter { + using InteropType = ets_long; + static KNativePointer convertFrom(EtsEnv* env, InteropType value) { + return reinterpret_cast(value); + } + static InteropType convertTo(EtsEnv* env, KNativePointer value) { + return reinterpret_cast(value); + } + static void release(EtsEnv* env, InteropType value, KNativePointer converted) {} +}; + +template<> +struct InteropTypeConverter { + using InteropType = ets_long; + static KLong convertFrom(EtsEnv* env, InteropType value) { + return value; + } + static InteropType convertTo(EtsEnv* env, KLong value) { + return value; + } + static void release(EtsEnv* env, InteropType value, KLong converted) {} +}; + +template<> +struct InteropTypeConverter { + using InteropType = ets_long; + static KULong convertFrom(EtsEnv* env, InteropType value) { + return static_cast(value); + } + static InteropType convertTo(EtsEnv* env, KULong value) { + return static_cast(value); + } + static void release(EtsEnv* env, InteropType value, KULong converted) {} +}; + + +template<> +struct InteropTypeConverter { + using InteropType = ets_intArray; + static KInt* convertFrom(EtsEnv* env, InteropType value) { + if (!value) return nullptr; + return env->PinIntArray(value); + } + static InteropType convertTo(EtsEnv* env, KInt* value) = delete; + static void release(EtsEnv* env, InteropType value, KInt* converted) { + if (value) env->UnpinIntArray(value); + } +}; + +template<> +struct InteropTypeConverter { + using InteropType = ets_floatArray; + static KFloat* convertFrom(EtsEnv* env, InteropType value) { + if (!value) return nullptr; + return env->PinFloatArray(value); + } + static InteropType convertTo(EtsEnv* env, KFloat* value) = delete; + static void release(EtsEnv* env, InteropType value, KFloat* converted) { + if (value) env->UnpinFloatArray(value); + } +}; + +template<> +struct InteropTypeConverter { + using InteropType = ets_byteArray; + static KInteropReturnBuffer convertFrom(EtsEnv* env, InteropType value) = delete; + static InteropType convertTo(EtsEnv* env, KInteropReturnBuffer value) { + ets_byteArray array = env->NewByteArray(value.length); + KByte* data = (KByte*)env->PinByteArray(array); + memcpy(data, (KByte*)value.data, value.length); + env->UnpinByteArray(array); + value.dispose(value.data, value.length); + return array; + }; + static void release(EtsEnv* env, InteropType value, KInteropReturnBuffer converted) {} +}; + +template<> +struct InteropTypeConverter { + using InteropType = ets_byteArray; + static KByte* convertFrom(EtsEnv* env, InteropType value) { + if (!value) return nullptr; + return (KByte*)env->PinByteArray(value); + } + static InteropType convertTo(EtsEnv* env, KByte* value) = delete; + static void release(EtsEnv* env, InteropType value, KByte* converted) { + if (value) env->UnpinByteArray((ets_byteArray)value); + } +}; + +template <> struct InteropTypeConverter { + using InteropType = ets_double; + static KInteropNumber convertFrom(EtsEnv *env, InteropType value) { + return KInteropNumber::fromDouble(value); + } + static InteropType convertTo(EtsEnv *env, KInteropNumber value) { + return value.asDouble(); + } + static void release(EtsEnv *env, InteropType value, KInteropNumber converted) {} +}; + +template<> +struct InteropTypeConverter { + using InteropType = ets_object; + static KLength convertFrom(EtsEnv* env, InteropType value) { + const static ets_class double_class = reinterpret_cast(env->NewGlobalRef(env->FindClass("std/core/Double"))); + const static ets_class int_class = reinterpret_cast(env->NewGlobalRef(env->FindClass("std/core/Int"))); + const static ets_class string_class = reinterpret_cast(env->NewGlobalRef(env->FindClass("std/core/String"))); + const static ets_class resource_class = reinterpret_cast( + env->NewGlobalRef(env->FindClass("@ohos/arkui/generated/resource/Resource"))); + + if (env->IsInstanceOf(value, double_class)) { + const static ets_method double_p = env->Getp_method(double_class, "unboxed", ":D"); + return KLength{ 1, (KFloat)env->CallDoubleMethod(value, double_p), 1, 0 }; + } else if (env->IsInstanceOf(value, int_class)) { + const static ets_method int_p = env->Getp_method(int_class, "unboxed", ":I"); + return KLength{ 1, (KFloat)env->CallIntMethod(value, int_p), 1, 0 }; + } else if (env->IsInstanceOf(value, string_class)) { + KStringPtr ptr = InteropTypeConverter::convertFrom(env, reinterpret_cast(value)); + KLength length { 0 }; + parseKLength(ptr, &length); + length.type = 2; + length.resource = 0; + return length; + } else if (env->IsInstanceOf(value, resource_class)) { + const static ets_method resource_p = env->Getp_method(resource_class, "id", ":D"); + return KLength{ 3, 0, 1, (KInt)env->CallDoubleMethod(value, resource_p) }; + } else { + return KLength( { 0, 0, 0, 0}); + } + } + static InteropType convertTo(EtsEnv* env, KLength value) = delete; + static void release(EtsEnv* env, InteropType value, const KLength& converted) {} +}; + +template +inline typename InteropTypeConverter::InteropType makeResult(EtsEnv* env, Type value) { + return InteropTypeConverter::convertTo(env, value); +} + +template +inline Type getArgument(EtsEnv* env, typename InteropTypeConverter::InteropType arg) { + return InteropTypeConverter::convertFrom(env, arg); +} + +template +inline void releaseArgument(EtsEnv* env, typename InteropTypeConverter::InteropType arg, Type& data) { + InteropTypeConverter::release(env, arg, data); +} + +template +struct DirectInteropTypeConverter { + using InteropType = T; + static T convertFrom(InteropType value) { return value; } + static InteropType convertTo(T value) { return value; } +}; + +template<> +struct DirectInteropTypeConverter { + using InteropType = ets_long; + static KNativePointer convertFrom(InteropType value) { + return reinterpret_cast(value); + } + static InteropType convertTo(KNativePointer value) { + return reinterpret_cast(value); + } +}; + +template<> +struct DirectInteropTypeConverter { + using InteropType = ets_long; + static KSerializerBuffer convertFrom(InteropType value) { + return reinterpret_cast(static_cast(value)); + } + static InteropType convertTo(KSerializerBuffer value) = delete; +}; + +template <> +struct DirectInteropTypeConverter { + using InteropType = ets_double; + static KInteropNumber convertFrom(InteropType value) { + return KInteropNumber::fromDouble(value); + } + static InteropType convertTo(KInteropNumber value) { + return value.asDouble(); + } +}; + +#define ETS_SLOW_NATIVE_FLAG 1 + +class EtsExports { + std::unordered_map>> implementations; + std::unordered_map classpaths; + +public: + static EtsExports* getInstance(); + + std::vector getModules(); + void addMethod(const char* module, const char* name, const char* type, void* impl, int flags); + const std::vector>& getMethods(const std::string& module); + + void setClasspath(const char* module, const char* classpath); + const std::string& getClasspath(const std::string& module); +}; + +#define KOALA_QUOTE0(x) #x +#define KOALA_QUOTE(x) KOALA_QUOTE0(x) + +#ifdef _MSC_VER +#define MAKE_ETS_EXPORT(module, name, type, flag) \ + static void __init_##name() { \ + EtsExports::getInstance()->addMethod(KOALA_QUOTE(module), "_"#name, type, reinterpret_cast(Ark_##name), flag); \ + } \ + namespace { \ + struct __Init_##name { \ + __Init_##name() { __init_##name(); } \ + } __Init_##name##_v; \ + } +#define KOALA_ETS_INTEROP_MODULE_CLASSPATH(module, classpath) \ + static void __init_classpath_##module() { \ + EtsExports::getInstance()->setClasspath(KOALA_QUOTE(module), classpath); \ + } \ + namespace { \ + struct __Init_classpath_##module { \ + __Init_classpath_##module() { __init_classpath_##module(); } \ + } __Init_classpath_##module##_v; \ + } +#else +#define MAKE_ETS_EXPORT(module, name, type, flag) \ + __attribute__((constructor)) \ + static void __init_ets_##name() { \ + EtsExports::getInstance()->addMethod(KOALA_QUOTE(module), "_"#name, type, reinterpret_cast(Ark_##name), flag); \ + } +#define KOALA_ETS_INTEROP_MODULE_CLASSPATH(module, classpath) \ + __attribute__((constructor)) \ + static void __init_ets_classpath_##module() { \ + EtsExports::getInstance()->setClasspath(KOALA_QUOTE(module), classpath); \ + } +#endif + +#define KOALA_INTEROP_0(name, Ret) \ + InteropTypeConverter::InteropType Ark_##name(EtsEnv *env, ets_class clazz) { \ + KOALA_MAYBE_LOG(name) \ + return makeResult(env, impl_##name()); \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret, 0) + +#define KOALA_INTEROP_1(name, Ret, P0) \ + InteropTypeConverter::InteropType Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + auto rv = makeResult(env, impl_##name(p0)); \ + releaseArgument(env, _p0, p0); \ + return rv; \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0, 0) + +#define KOALA_INTEROP_2(name, Ret, P0, P1) \ + InteropTypeConverter::InteropType Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + auto rv = makeResult(env, impl_##name(p0, p1)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + return rv; \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1, 0) + +#define KOALA_INTEROP_3(name, Ret, P0, P1, P2) \ + InteropTypeConverter::InteropType Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + return rv; \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2, 0) + +#define KOALA_INTEROP_4(name, Ret, P0, P1, P2, P3) \ + InteropTypeConverter::InteropType Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2, p3)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + return rv; \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3, 0) + +#define KOALA_INTEROP_5(name, Ret, P0, P1, P2, P3, P4) \ + InteropTypeConverter::InteropType Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2, p3, p4)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + return rv; \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4, 0) + +#define KOALA_INTEROP_6(name, Ret, P0, P1, P2, P3, P4, P5) \ +InteropTypeConverter::InteropType Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2, p3, p4, p5)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + return rv; \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5, 0) + +#define KOALA_INTEROP_7(name, Ret, P0, P1, P2, P3, P4, P5, P6) \ + InteropTypeConverter::InteropType Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2, p3, p4, p5, p6)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + return rv; \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6, 0) + +#define KOALA_INTEROP_8(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7) \ + InteropTypeConverter::InteropType Ark_##name(EtsEnv *env, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + return rv; \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7, 0) + +#define KOALA_INTEROP_9(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8) \ + InteropTypeConverter::InteropType Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + return rv; \ + } \ + MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8, 0) + +#define KOALA_INTEROP_10(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) \ + InteropTypeConverter::InteropType Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + return rv; \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9, 0) + +#define KOALA_INTEROP_11(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) \ + InteropTypeConverter::InteropType Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + return rv; \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10, 0) + +#define KOALA_INTEROP_12(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11) \ + InteropTypeConverter::InteropType Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + P11 p11 = getArgument(env, _p11); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + releaseArgument(env, _p11, p11); \ + return rv; \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10 "|" #P11, 0) + +#define KOALA_INTEROP_13(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12) \ + InteropTypeConverter::InteropType Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11, \ + InteropTypeConverter::InteropType _p12) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + P11 p11 = getArgument(env, _p11); \ + P12 p12 = getArgument(env, _p12); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + releaseArgument(env, _p11, p11); \ + releaseArgument(env, _p12, p12); \ + return rv; \ + } \ + MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10 "|" #P11 "|" #P12, 0) + +#define KOALA_INTEROP_14(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13) \ + InteropTypeConverter::InteropType Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11, \ + InteropTypeConverter::InteropType _p12, \ + InteropTypeConverter::InteropType _p13) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + P11 p11 = getArgument(env, _p11); \ + P12 p12 = getArgument(env, _p12); \ + P13 p13 = getArgument(env, _p13); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + releaseArgument(env, _p11, p11); \ + releaseArgument(env, _p12, p12); \ + releaseArgument(env, _p13, p13); \ + return rv; \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10 "|" #P11 "|" #P12 "|" #P13, 0) + +#define KOALA_INTEROP_V0(name) \ + void Ark_##name(EtsEnv *env) { \ + KOALA_MAYBE_LOG(name) \ + impl_##name(); \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void", 0) + +#define KOALA_INTEROP_V1(name, P0) \ + void Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + impl_##name(p0); \ + releaseArgument(env, _p0, p0); \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0, 0) + +#define KOALA_INTEROP_V2(name, P0, P1) \ + void Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + impl_##name(p0, p1); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1, 0) + +#define KOALA_INTEROP_V3(name, P0, P1, P2) \ + void Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + impl_##name(p0, p1, p2); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2, 0) + +#define KOALA_INTEROP_V4(name, P0, P1, P2, P3) \ + void Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + impl_##name(p0, p1, p2, p3); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ +} \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3, 0) + +#define KOALA_INTEROP_V5(name, P0, P1, P2, P3, P4) \ + void Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + impl_##name(p0, p1, p2, p3, p4); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ +} \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4, 0) + +#define KOALA_INTEROP_V6(name, P0, P1, P2, P3, P4, P5) \ + void Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + impl_##name(p0, p1, p2, p3, p4, p5); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5, 0) + +#define KOALA_INTEROP_V7(name, P0, P1, P2, P3, P4, P5, P6) \ + void Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6, 0) + +#define KOALA_INTEROP_V8(name, P0, P1, P2, P3, P4, P5, P6, P7) \ + void Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7, 0) + +#define KOALA_INTEROP_V9(name, P0, P1, P2, P3, P4, P5, P6, P7, P8) \ + void Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8, 0) + +#define KOALA_INTEROP_V10(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) \ + void Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ +} \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9, 0) + +#define KOALA_INTEROP_V11(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) \ + void Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10, 0) + +#define KOALA_INTEROP_V12(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11) \ + void Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + P11 p11 = getArgument(env, _p11); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + releaseArgument(env, _p11, p11); \ +} \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10 "|" #P11, 0) + +#define KOALA_INTEROP_V13(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12) \ + void Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11, \ + InteropTypeConverter::InteropType _p12) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + P11 p11 = getArgument(env, _p11); \ + P12 p12 = getArgument(env, _p12); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + releaseArgument(env, _p11, p11); \ + releaseArgument(env, _p12, p12); \ +} \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10 "|" #P11 "|" #P12, 0) + +#define KOALA_INTEROP_V14(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13) \ + void Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11, \ + InteropTypeConverter::InteropType _p12, \ + InteropTypeConverter::InteropType _p13) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + P11 p11 = getArgument(env, _p11); \ + P12 p12 = getArgument(env, _p12); \ + P13 p13 = getArgument(env, _p13); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + releaseArgument(env, _p11, p11); \ + releaseArgument(env, _p12, p12); \ + releaseArgument(env, _p13, p13); \ +} \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10 "|" #P11 "|" #P12 "|" #P13, 0) + +#define KOALA_INTEROP_V15(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14) \ + void Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11, \ + InteropTypeConverter::InteropType _p12, \ + InteropTypeConverter::InteropType _p13, \ + InteropTypeConverter::InteropType _p14) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + P11 p11 = getArgument(env, _p11); \ + P12 p12 = getArgument(env, _p12); \ + P13 p13 = getArgument(env, _p13); \ + P14 p14 = getArgument(env, _p14); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + releaseArgument(env, _p11, p11); \ + releaseArgument(env, _p12, p12); \ + releaseArgument(env, _p13, p13); \ + releaseArgument(env, _p14, p14); \ +} \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10 "|" #P11 "|" #P12 "|" #P13 "|" #P14, 0) + +#define KOALA_INTEROP_CTX_0(name, Ret) \ + InteropTypeConverter::InteropType Ark_##name(EtsEnv *env, ets_class clazz) { \ + KOALA_MAYBE_LOG(name) \ + KVMContext ctx = (KVMContext)env; \ + auto rv = makeResult(env, impl_##name(ctx)); \ + return rv; \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret, ETS_SLOW_NATIVE_FLAG) + +#define KOALA_INTEROP_CTX_1(name, Ret, P0) \ + InteropTypeConverter::InteropType Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + KVMContext ctx = (KVMContext)env; \ + auto rv = makeResult(env, impl_##name(ctx, p0)); \ + releaseArgument(env, _p0, p0); \ + return rv; \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0, ETS_SLOW_NATIVE_FLAG) + +#define KOALA_INTEROP_CTX_2(name, Ret, P0, P1) \ + InteropTypeConverter::InteropType Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + KVMContext ctx = (KVMContext)env; \ + auto rv = makeResult(env, impl_##name(ctx, p0, p1)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + return rv; \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1, ETS_SLOW_NATIVE_FLAG) + +#define KOALA_INTEROP_CTX_3(name, Ret, P0, P1, P2) \ + InteropTypeConverter::InteropType Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + KVMContext ctx = (KVMContext)env; \ + auto rv = makeResult(env, impl_##name(ctx, p0, p1, p2)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + return rv; \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2, ETS_SLOW_NATIVE_FLAG) + +#define KOALA_INTEROP_CTX_4(name, Ret, P0, P1, P2, P3) \ + InteropTypeConverter::InteropType Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + KVMContext ctx = (KVMContext)env; \ + auto rv = makeResult(env, impl_##name(ctx, p0, p1, p2, p3)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + return rv; \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3, ETS_SLOW_NATIVE_FLAG) + +#define KOALA_INTEROP_CTX_5(name, Ret, P0, P1, P2, P3, P4) \ + InteropTypeConverter::InteropType Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + KVMContext ctx = (KVMContext)env; \ + auto rv = makeResult(env, impl_##name(ctx, p0, p1, p2, p3, p4)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + return rv; \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4, ETS_SLOW_NATIVE_FLAG) + +#define KOALA_INTEROP_CTX_V0(name) \ + void Ark_##name(EtsEnv *env, ets_class clazz) { \ + KOALA_MAYBE_LOG(name) \ + KVMContext ctx = (KVMContext)env; \ + impl_##name(ctx); \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void", ETS_SLOW_NATIVE_FLAG) + +#define KOALA_INTEROP_CTX_V1(name, P0) \ + void Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + KVMContext ctx = (KVMContext)env; \ + impl_##name(ctx, p0); \ + releaseArgument(env, _p0, p0); \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0, ETS_SLOW_NATIVE_FLAG) + +#define KOALA_INTEROP_CTX_V2(name, P0, P1) \ + void Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + KVMContext ctx = (KVMContext)env; \ + impl_##name(ctx, p0, p1); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1, ETS_SLOW_NATIVE_FLAG) + +#define KOALA_INTEROP_CTX_V3(name, P0, P1, P2) \ + void Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + KVMContext ctx = (KVMContext)env; \ + impl_##name(ctx, p0, p1, p2); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2, ETS_SLOW_NATIVE_FLAG) + +#define KOALA_INTEROP_CTX_V4(name, P0, P1, P2, P3) \ + void Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + KVMContext ctx = (KVMContext)env; \ + impl_##name(ctx, p0, p1, p2, p3); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3, ETS_SLOW_NATIVE_FLAG) + +#define KOALA_INTEROP_CTX_V5(name, P0, P1, P2, P3, P4) \ + void Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + KVMContext ctx = (KVMContext)env; \ + impl_##name(ctx, p0, p1, p2, p3, p4); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4, ETS_SLOW_NATIVE_FLAG) + +#define KOALA_INTEROP_DIRECT_0(name, Ret) \ + inline InteropTypeConverter::InteropType Ark_##name( \ + ) { \ + KOALA_MAYBE_LOG(name) \ + return DirectInteropTypeConverter::convertTo(impl_##name()); \ + } \ + MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret, 0) +#define KOALA_INTEROP_DIRECT_1(name, Ret, P0) \ + inline InteropTypeConverter::InteropType Ark_##name( \ + InteropTypeConverter::InteropType p0 \ + ) { \ + KOALA_MAYBE_LOG(name) \ + return DirectInteropTypeConverter::convertTo(impl_##name(DirectInteropTypeConverter::convertFrom(p0))); \ + } \ + MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0, 0) +#define KOALA_INTEROP_DIRECT_2(name, Ret, P0, P1) \ + inline InteropTypeConverter::InteropType Ark_##name( \ + InteropTypeConverter::InteropType p0, \ + InteropTypeConverter::InteropType p1 \ + ) { \ + KOALA_MAYBE_LOG(name) \ + return DirectInteropTypeConverter::convertTo(impl_##name(DirectInteropTypeConverter::convertFrom(p0), DirectInteropTypeConverter::convertFrom(p1))); \ + } \ + MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1, 0) +#define KOALA_INTEROP_DIRECT_3(name, Ret, P0, P1, P2) \ + inline InteropTypeConverter::InteropType Ark_##name( \ + InteropTypeConverter::InteropType p0, \ + InteropTypeConverter::InteropType p1, \ + InteropTypeConverter::InteropType p2 \ + ) { \ + KOALA_MAYBE_LOG(name) \ + return DirectInteropTypeConverter::convertTo(impl_##name(DirectInteropTypeConverter::convertFrom(p0), DirectInteropTypeConverter::convertFrom(p1), DirectInteropTypeConverter::convertFrom(p2))); \ + } \ + MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2, 0) +#define KOALA_INTEROP_DIRECT_4(name, Ret, P0, P1, P2, P3) \ + inline InteropTypeConverter::InteropType Ark_##name( \ + InteropTypeConverter::InteropType p0, \ + InteropTypeConverter::InteropType p1, \ + InteropTypeConverter::InteropType p2, \ + InteropTypeConverter::InteropType p3 \ + ) { \ + KOALA_MAYBE_LOG(name) \ + return DirectInteropTypeConverter::convertTo(impl_##name(DirectInteropTypeConverter::convertFrom(p0), DirectInteropTypeConverter::convertFrom(p1), DirectInteropTypeConverter::convertFrom(p2), DirectInteropTypeConverter::convertFrom(p3))); \ + } \ + MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3, 0) +#define KOALA_INTEROP_DIRECT_5(name, Ret, P0, P1, P2, P3, P4) \ + inline InteropTypeConverter::InteropType Ark_##name( \ + InteropTypeConverter::InteropType p0, \ + InteropTypeConverter::InteropType p1, \ + InteropTypeConverter::InteropType p2, \ + InteropTypeConverter::InteropType p3, \ + InteropTypeConverter::InteropType p4 \ + ) { \ + KOALA_MAYBE_LOG(name) \ + return DirectInteropTypeConverter::convertTo(impl_##name(DirectInteropTypeConverter::convertFrom(p0), DirectInteropTypeConverter::convertFrom(p1), DirectInteropTypeConverter::convertFrom(p2), DirectInteropTypeConverter::convertFrom(p3), DirectInteropTypeConverter::convertFrom(p4))); \ + } \ + MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4, 0) +#define KOALA_INTEROP_DIRECT_6(name, Ret, P0, P1, P2, P3, P4, P5) \ + inline InteropTypeConverter::InteropType Ark_##name( \ + InteropTypeConverter::InteropType p0, \ + InteropTypeConverter::InteropType p1, \ + InteropTypeConverter::InteropType p2, \ + InteropTypeConverter::InteropType p3, \ + InteropTypeConverter::InteropType p4, \ + InteropTypeConverter::InteropType p5 \ + ) { \ + KOALA_MAYBE_LOG(name) \ + return DirectInteropTypeConverter::convertTo(impl_##name(DirectInteropTypeConverter::convertFrom(p0), DirectInteropTypeConverter::convertFrom(p1), DirectInteropTypeConverter::convertFrom(p2), DirectInteropTypeConverter::convertFrom(p3), DirectInteropTypeConverter::convertFrom(p4), DirectInteropTypeConverter::convertFrom(p5))); \ + } \ + MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5, 0) +#define KOALA_INTEROP_DIRECT_7(name, Ret, P0, P1, P2, P3, P4, P5, P6) \ + inline InteropTypeConverter::InteropType Ark_##name( \ + InteropTypeConverter::InteropType p0, \ + InteropTypeConverter::InteropType p1, \ + InteropTypeConverter::InteropType p2, \ + InteropTypeConverter::InteropType p3, \ + InteropTypeConverter::InteropType p4, \ + InteropTypeConverter::InteropType p5, \ + InteropTypeConverter::InteropType p6 \ + ) { \ + KOALA_MAYBE_LOG(name) \ + return DirectInteropTypeConverter::convertTo(impl_##name(DirectInteropTypeConverter::convertFrom(p0), DirectInteropTypeConverter::convertFrom(p1), DirectInteropTypeConverter::convertFrom(p2), DirectInteropTypeConverter::convertFrom(p3), DirectInteropTypeConverter::convertFrom(p4), DirectInteropTypeConverter::convertFrom(p5), DirectInteropTypeConverter::convertFrom(p6))); \ + } \ + MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6, 0) +#define KOALA_INTEROP_DIRECT_8(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7) \ + inline InteropTypeConverter::InteropType Ark_##name( \ + InteropTypeConverter::InteropType p0, \ + InteropTypeConverter::InteropType p1, \ + InteropTypeConverter::InteropType p2, \ + InteropTypeConverter::InteropType p3, \ + InteropTypeConverter::InteropType p4, \ + InteropTypeConverter::InteropType p5, \ + InteropTypeConverter::InteropType p6, \ + InteropTypeConverter::InteropType p7 \ + ) { \ + KOALA_MAYBE_LOG(name) \ + return DirectInteropTypeConverter::convertTo(impl_##name(DirectInteropTypeConverter::convertFrom(p0), DirectInteropTypeConverter::convertFrom(p1), DirectInteropTypeConverter::convertFrom(p2), DirectInteropTypeConverter::convertFrom(p3), DirectInteropTypeConverter::convertFrom(p4), DirectInteropTypeConverter::convertFrom(p5), DirectInteropTypeConverter::convertFrom(p6), DirectInteropTypeConverter::convertFrom(p7))); \ + } \ + MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7, 0) +#define KOALA_INTEROP_DIRECT_9(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8) \ + inline InteropTypeConverter::InteropType Ark_##name( \ + InteropTypeConverter::InteropType p0, \ + InteropTypeConverter::InteropType p1, \ + InteropTypeConverter::InteropType p2, \ + InteropTypeConverter::InteropType p3, \ + InteropTypeConverter::InteropType p4, \ + InteropTypeConverter::InteropType p5, \ + InteropTypeConverter::InteropType p6, \ + InteropTypeConverter::InteropType p7, \ + InteropTypeConverter::InteropType p8 \ + ) { \ + KOALA_MAYBE_LOG(name) \ + return DirectInteropTypeConverter::convertTo(impl_##name(DirectInteropTypeConverter::convertFrom(p0), DirectInteropTypeConverter::convertFrom(p1), DirectInteropTypeConverter::convertFrom(p2), DirectInteropTypeConverter::convertFrom(p3), DirectInteropTypeConverter::convertFrom(p4), DirectInteropTypeConverter::convertFrom(p5), DirectInteropTypeConverter::convertFrom(p6), DirectInteropTypeConverter::convertFrom(p7), DirectInteropTypeConverter::convertFrom(p8))); \ + } \ + MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8, 0) +#define KOALA_INTEROP_DIRECT_10(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) \ + inline InteropTypeConverter::InteropType Ark_##name( \ + InteropTypeConverter::InteropType p0, \ + InteropTypeConverter::InteropType p1, \ + InteropTypeConverter::InteropType p2, \ + InteropTypeConverter::InteropType p3, \ + InteropTypeConverter::InteropType p4, \ + InteropTypeConverter::InteropType p5, \ + InteropTypeConverter::InteropType p6, \ + InteropTypeConverter::InteropType p7, \ + InteropTypeConverter::InteropType p8, \ + InteropTypeConverter::InteropType p9 \ + ) { \ + KOALA_MAYBE_LOG(name) \ + return DirectInteropTypeConverter::convertTo(impl_##name(DirectInteropTypeConverter::convertFrom(p0), DirectInteropTypeConverter::convertFrom(p1), DirectInteropTypeConverter::convertFrom(p2), DirectInteropTypeConverter::convertFrom(p3), DirectInteropTypeConverter::convertFrom(p4), DirectInteropTypeConverter::convertFrom(p5), DirectInteropTypeConverter::convertFrom(p6), DirectInteropTypeConverter::convertFrom(p7), DirectInteropTypeConverter::convertFrom(p8), DirectInteropTypeConverter::convertFrom(p9))); \ + } \ + MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9, 0) +#define KOALA_INTEROP_DIRECT_11(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) \ + inline InteropTypeConverter::InteropType Ark_##name( \ + InteropTypeConverter::InteropType p0, \ + InteropTypeConverter::InteropType p1, \ + InteropTypeConverter::InteropType p2, \ + InteropTypeConverter::InteropType p3, \ + InteropTypeConverter::InteropType p4, \ + InteropTypeConverter::InteropType p5, \ + InteropTypeConverter::InteropType p6, \ + InteropTypeConverter::InteropType p7, \ + InteropTypeConverter::InteropType p8, \ + InteropTypeConverter::InteropType p9, \ + InteropTypeConverter::InteropType p10 \ + ) { \ + KOALA_MAYBE_LOG(name) \ + return DirectInteropTypeConverter::convertTo(impl_##name(DirectInteropTypeConverter::convertFrom(p0), DirectInteropTypeConverter::convertFrom(p1), DirectInteropTypeConverter::convertFrom(p2), DirectInteropTypeConverter::convertFrom(p3), DirectInteropTypeConverter::convertFrom(p4), DirectInteropTypeConverter::convertFrom(p5), DirectInteropTypeConverter::convertFrom(p6), DirectInteropTypeConverter::convertFrom(p7), DirectInteropTypeConverter::convertFrom(p8), DirectInteropTypeConverter::convertFrom(p9), DirectInteropTypeConverter::convertFrom(p10))); \ + } \ + MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10, 0) +#define KOALA_INTEROP_DIRECT_V0(name) \ + inline void Ark_##name( \ + ) { \ + KOALA_MAYBE_LOG(name) \ + impl_##name(); \ + } \ + MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void", 0) +#define KOALA_INTEROP_DIRECT_V1(name, P0) \ + inline void Ark_##name( \ + InteropTypeConverter::InteropType p0 \ + ) { \ + KOALA_MAYBE_LOG(name) \ + impl_##name(DirectInteropTypeConverter::convertFrom(p0)); \ + } \ + MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void" "|" #P0, 0) +#define KOALA_INTEROP_DIRECT_V2(name, P0, P1) \ + inline void Ark_##name( \ + InteropTypeConverter::InteropType p0, \ + InteropTypeConverter::InteropType p1 \ + ) { \ + KOALA_MAYBE_LOG(name) \ + impl_##name(DirectInteropTypeConverter::convertFrom(p0), DirectInteropTypeConverter::convertFrom(p1)); \ + } \ + MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void" "|" #P0 "|" #P1, 0) +#define KOALA_INTEROP_DIRECT_V3(name, P0, P1, P2) \ + inline void Ark_##name( \ + InteropTypeConverter::InteropType p0, \ + InteropTypeConverter::InteropType p1, \ + InteropTypeConverter::InteropType p2 \ + ) { \ + KOALA_MAYBE_LOG(name) \ + impl_##name(DirectInteropTypeConverter::convertFrom(p0), DirectInteropTypeConverter::convertFrom(p1), DirectInteropTypeConverter::convertFrom(p2)); \ + } \ + MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void" "|" #P0 "|" #P1 "|" #P2, 0) +#define KOALA_INTEROP_DIRECT_V4(name, P0, P1, P2, P3) \ + inline void Ark_##name( \ + InteropTypeConverter::InteropType p0, \ + InteropTypeConverter::InteropType p1, \ + InteropTypeConverter::InteropType p2, \ + InteropTypeConverter::InteropType p3 \ + ) { \ + KOALA_MAYBE_LOG(name) \ + impl_##name(DirectInteropTypeConverter::convertFrom(p0), DirectInteropTypeConverter::convertFrom(p1), DirectInteropTypeConverter::convertFrom(p2), DirectInteropTypeConverter::convertFrom(p3)); \ + } \ + MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void" "|" #P0 "|" #P1 "|" #P2 "|" #P3, 0) +#define KOALA_INTEROP_DIRECT_V5(name, P0, P1, P2, P3, P4) \ + inline void Ark_##name( \ + InteropTypeConverter::InteropType p0, \ + InteropTypeConverter::InteropType p1, \ + InteropTypeConverter::InteropType p2, \ + InteropTypeConverter::InteropType p3, \ + InteropTypeConverter::InteropType p4 \ + ) { \ + KOALA_MAYBE_LOG(name) \ + impl_##name(DirectInteropTypeConverter::convertFrom(p0), DirectInteropTypeConverter::convertFrom(p1), DirectInteropTypeConverter::convertFrom(p2), DirectInteropTypeConverter::convertFrom(p3), DirectInteropTypeConverter::convertFrom(p4)); \ + } \ + MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void" "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4, 0) +#define KOALA_INTEROP_DIRECT_V6(name, P0, P1, P2, P3, P4, P5) \ + inline void Ark_##name( \ + InteropTypeConverter::InteropType p0, \ + InteropTypeConverter::InteropType p1, \ + InteropTypeConverter::InteropType p2, \ + InteropTypeConverter::InteropType p3, \ + InteropTypeConverter::InteropType p4, \ + InteropTypeConverter::InteropType p5 \ + ) { \ + KOALA_MAYBE_LOG(name) \ + impl_##name(DirectInteropTypeConverter::convertFrom(p0), DirectInteropTypeConverter::convertFrom(p1), DirectInteropTypeConverter::convertFrom(p2), DirectInteropTypeConverter::convertFrom(p3), DirectInteropTypeConverter::convertFrom(p4), DirectInteropTypeConverter::convertFrom(p5)); \ + } \ + MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void" "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5, 0) +#define KOALA_INTEROP_DIRECT_V7(name, P0, P1, P2, P3, P4, P5, P6) \ + inline void Ark_##name( \ + InteropTypeConverter::InteropType p0, \ + InteropTypeConverter::InteropType p1, \ + InteropTypeConverter::InteropType p2, \ + InteropTypeConverter::InteropType p3, \ + InteropTypeConverter::InteropType p4, \ + InteropTypeConverter::InteropType p5, \ + InteropTypeConverter::InteropType p6 \ + ) { \ + KOALA_MAYBE_LOG(name) \ + impl_##name(DirectInteropTypeConverter::convertFrom(p0), DirectInteropTypeConverter::convertFrom(p1), DirectInteropTypeConverter::convertFrom(p2), DirectInteropTypeConverter::convertFrom(p3), DirectInteropTypeConverter::convertFrom(p4), DirectInteropTypeConverter::convertFrom(p5), DirectInteropTypeConverter::convertFrom(p6)); \ + } \ + MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void" "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6, 0) +#define KOALA_INTEROP_DIRECT_V8(name, P0, P1, P2, P3, P4, P5, P6, P7) \ + inline void Ark_##name( \ + InteropTypeConverter::InteropType p0, \ + InteropTypeConverter::InteropType p1, \ + InteropTypeConverter::InteropType p2, \ + InteropTypeConverter::InteropType p3, \ + InteropTypeConverter::InteropType p4, \ + InteropTypeConverter::InteropType p5, \ + InteropTypeConverter::InteropType p6, \ + InteropTypeConverter::InteropType p7 \ + ) { \ + KOALA_MAYBE_LOG(name) \ + impl_##name(DirectInteropTypeConverter::convertFrom(p0), DirectInteropTypeConverter::convertFrom(p1), DirectInteropTypeConverter::convertFrom(p2), DirectInteropTypeConverter::convertFrom(p3), DirectInteropTypeConverter::convertFrom(p4), DirectInteropTypeConverter::convertFrom(p5), DirectInteropTypeConverter::convertFrom(p6), DirectInteropTypeConverter::convertFrom(p7)); \ + } \ + MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void" "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7, 0) +#define KOALA_INTEROP_DIRECT_V9(name, P0, P1, P2, P3, P4, P5, P6, P7, P8) \ + inline void Ark_##name( \ + InteropTypeConverter::InteropType p0, \ + InteropTypeConverter::InteropType p1, \ + InteropTypeConverter::InteropType p2, \ + InteropTypeConverter::InteropType p3, \ + InteropTypeConverter::InteropType p4, \ + InteropTypeConverter::InteropType p5, \ + InteropTypeConverter::InteropType p6, \ + InteropTypeConverter::InteropType p7, \ + InteropTypeConverter::InteropType p8 \ + ) { \ + KOALA_MAYBE_LOG(name) \ + impl_##name(DirectInteropTypeConverter::convertFrom(p0), DirectInteropTypeConverter::convertFrom(p1), DirectInteropTypeConverter::convertFrom(p2), DirectInteropTypeConverter::convertFrom(p3), DirectInteropTypeConverter::convertFrom(p4), DirectInteropTypeConverter::convertFrom(p5), DirectInteropTypeConverter::convertFrom(p6), DirectInteropTypeConverter::convertFrom(p7), DirectInteropTypeConverter::convertFrom(p8)); \ + } \ + MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void" "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8, 0) +#define KOALA_INTEROP_DIRECT_V10(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) \ + inline void Ark_##name( \ + InteropTypeConverter::InteropType p0, \ + InteropTypeConverter::InteropType p1, \ + InteropTypeConverter::InteropType p2, \ + InteropTypeConverter::InteropType p3, \ + InteropTypeConverter::InteropType p4, \ + InteropTypeConverter::InteropType p5, \ + InteropTypeConverter::InteropType p6, \ + InteropTypeConverter::InteropType p7, \ + InteropTypeConverter::InteropType p8, \ + InteropTypeConverter::InteropType p9 \ + ) { \ + KOALA_MAYBE_LOG(name) \ + impl_##name(DirectInteropTypeConverter::convertFrom(p0), DirectInteropTypeConverter::convertFrom(p1), DirectInteropTypeConverter::convertFrom(p2), DirectInteropTypeConverter::convertFrom(p3), DirectInteropTypeConverter::convertFrom(p4), DirectInteropTypeConverter::convertFrom(p5), DirectInteropTypeConverter::convertFrom(p6), DirectInteropTypeConverter::convertFrom(p7), DirectInteropTypeConverter::convertFrom(p8), DirectInteropTypeConverter::convertFrom(p9)); \ + } \ + MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void" "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9, 0) +#define KOALA_INTEROP_DIRECT_V11(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) \ + inline void Ark_##name( \ + InteropTypeConverter::InteropType p0, \ + InteropTypeConverter::InteropType p1, \ + InteropTypeConverter::InteropType p2, \ + InteropTypeConverter::InteropType p3, \ + InteropTypeConverter::InteropType p4, \ + InteropTypeConverter::InteropType p5, \ + InteropTypeConverter::InteropType p6, \ + InteropTypeConverter::InteropType p7, \ + InteropTypeConverter::InteropType p8, \ + InteropTypeConverter::InteropType p9, \ + InteropTypeConverter::InteropType p10 \ + ) { \ + KOALA_MAYBE_LOG(name) \ + impl_##name(DirectInteropTypeConverter::convertFrom(p0), DirectInteropTypeConverter::convertFrom(p1), DirectInteropTypeConverter::convertFrom(p2), DirectInteropTypeConverter::convertFrom(p3), DirectInteropTypeConverter::convertFrom(p4), DirectInteropTypeConverter::convertFrom(p5), DirectInteropTypeConverter::convertFrom(p6), DirectInteropTypeConverter::convertFrom(p7), DirectInteropTypeConverter::convertFrom(p8), DirectInteropTypeConverter::convertFrom(p9), DirectInteropTypeConverter::convertFrom(p10)); \ + } \ + MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void" "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10, 0) + +bool setKoalaEtsNapiCallbackDispatcher( + EtsEnv* etsEnv, + ets_class clazz, + const char* dispatcherMethodName, + const char* dispactherMethodSig +); +void getKoalaEtsNapiCallbackDispatcher(ets_class* clazz, ets_method* method); + +#define KOALA_INTEROP_CALL_VOID(venv, id, length, args) \ +{ \ + ets_class clazz = nullptr; \ + ets_method method = nullptr; \ + getKoalaEtsNapiCallbackDispatcher(&clazz, &method); \ + EtsEnv* etsEnv = reinterpret_cast(vmContext); \ + etsEnv->PushLocalFrame(1); \ + etsEnv->CallStaticIntMethod(clazz, method, id, args, length); \ + etsEnv->PopLocalFrame(nullptr); \ +} + +#define KOALA_INTEROP_CALL_INT(venv, id, length, args) \ +{ \ + ets_class clazz = nullptr; \ + ets_method method = nullptr; \ + getKoalaEtsNapiCallbackDispatcher(&clazz, &method); \ + EtsEnv* etsEnv = reinterpret_cast(venv); \ + etsEnv->PushLocalFrame(1); \ + int32_t rv = etsEnv->CallStaticIntMethod(clazz, method, id, args, length); \ + etsEnv->PopLocalFrame(nullptr); \ + return rv; \ +} + +#define KOALA_INTEROP_CALL_VOID_INTS32(venv, id, argc, args) KOALA_INTEROP_CALL_VOID(venv, id, (argc) * sizeof(int32_t), args) +#define KOALA_INTEROP_CALL_INT_INTS32(venv, id, argc, args) KOALA_INTEROP_CALL_INT(venv, id, (argc) * sizeof(int32_t), args) + +#define KOALA_INTEROP_THROW(vmContext, object, ...) \ + do { \ + EtsEnv* env = reinterpret_cast(vmContext); \ + env->ThrowError(object); \ + return __VA_ARGS__; \ + } while (0) + +#define KOALA_INTEROP_THROW_STRING(vmContext, message, ...) \ + do { \ + EtsEnv* env = reinterpret_cast(vmContext); \ + const static ets_class errorClass = env->FindClass("std/core/Error"); \ + env->ThrowErrorNew(errorClass, message); \ + } while (0) + +#endif // KOALA_ETS_NAPI diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/ets/etsapi.h b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/ets/etsapi.h new file mode 100644 index 0000000000000000000000000000000000000000..41641c97eb5e6588876fa795dd09278ab491a54e --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/ets/etsapi.h @@ -0,0 +1,1545 @@ +/** + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef PANDA_RUNTIME_INTEROP_ETS_NAPI_H +#define PANDA_RUNTIME_INTEROP_ETS_NAPI_H + +// NOLINTBEGIN(modernize-use-using, readability-identifier-naming, cppcoreguidelines-pro-type-vararg) + +#ifdef __cplusplus +#include +#include +#else +#include +#include +#endif + +// NOLINTBEGIN(cppcoreguidelines-macro-usage) + +// Version Constants +#define ETS_NAPI_VERSION_1_0 0x00010000 + +// General return value constants +#define ETS_OK 0 // success +#define ETS_ERR (-1) // unknown error +#define ETS_ERR_VER (-2) // ETS version error +#define ETS_ERR_NOMEM (-3) // not enough memory +#define ETS_ERR_EXIST (-4) // VM already created +#define ETS_ERR_INVAL (-5) // invalid arguments + +// Boolean Constants +#define ETS_FALSE 0 +#define ETS_TRUE 1 + +// Mode Constants +#define ETS_COMMIT 1 +#define ETS_ABORT 2 + +// NOLINTEND(cppcoreguidelines-macro-usage) + +// Primitive Types +typedef uint8_t ets_boolean; +typedef int8_t ets_byte; +typedef uint16_t ets_char; +typedef int16_t ets_short; +typedef int32_t ets_int; +typedef int64_t ets_long; +typedef float ets_float; +typedef double ets_double; +typedef ets_int ets_size; + +// Reference Types +#ifdef __cplusplus +class __ets_object {}; +class __ets_class : public __ets_object {}; +class __ets_string : public __ets_object {}; +class __ets_array : public __ets_object {}; +class __ets_objectArray : public __ets_array {}; +class __ets_booleanArray : public __ets_array {}; +class __ets_byteArray : public __ets_array {}; +class __ets_charArray : public __ets_array {}; +class __ets_shortArray : public __ets_array {}; +class __ets_intArray : public __ets_array {}; +class __ets_longArray : public __ets_array {}; +class __ets_floatArray : public __ets_array {}; +class __ets_doubleArray : public __ets_array {}; +class __ets_error : public __ets_object {}; + +typedef __ets_object *ets_object; +typedef __ets_class *ets_class; +typedef __ets_string *ets_string; +typedef __ets_array *ets_array; +typedef __ets_objectArray *ets_objectArray; +typedef __ets_booleanArray *ets_booleanArray; +typedef __ets_byteArray *ets_byteArray; +typedef __ets_charArray *ets_charArray; +typedef __ets_shortArray *ets_shortArray; +typedef __ets_intArray *ets_intArray; +typedef __ets_longArray *ets_longArray; +typedef __ets_floatArray *ets_floatArray; +typedef __ets_doubleArray *ets_doubleArray; +typedef __ets_error *ets_error; +typedef __ets_object *ets_weak; + +#else // __cplusplus + +struct __ets_object; +typedef struct __ets_object *ets_object; +typedef ets_object ets_class; +typedef ets_object ets_string; +typedef ets_object ets_error; +typedef ets_object ets_weak; +typedef ets_object ets_array; +typedef ets_array ets_objectArray; +typedef ets_array ets_booleanArray; +typedef ets_array ets_byteArray; +typedef ets_array ets_charArray; +typedef ets_array ets_shortArray; +typedef ets_array ets_intArray; +typedef ets_array ets_longArray; +typedef ets_array ets_floatArray; +typedef ets_array ets_doubleArray; +#endif // __cplusplus + +struct __ets_deferred; +typedef struct __ets_deferred *ets_deferred; + +// Field and Method IDs +struct __ets_method; +struct __ets_field; +typedef struct __ets_method *ets_method; +typedef struct __ets_field *ets_field; + +// The Value Type +typedef union ets_value { + ets_boolean z; + ets_byte b; + ets_char c; + ets_short s; + ets_int i; + ets_long j; + ets_float f; + ets_double d; + ets_object l; +} ets_value; + +// Describe native method by name, signature and function pointer +typedef struct { + const char *name; + const char *signature; + void *func; +} EtsNativeMethod; + +// The object reference types +typedef enum { + ETS_INVALID_REF_TYPE = 0, + ETS_LOCAL_REF_TYPE = 1, + ETS_GLOBAL_REF_TYPE = 2, + ETS_WEAK_GLOBAL_REF_TYPE = 3 +} ets_objectRefType; + +#ifdef __cplusplus +typedef struct __EtsVM EtsVM; +typedef struct __EtsEnv ets_env; +#else +typedef const struct ETS_InvokeInterface *EtsVM; +typedef const struct ETS_NativeInterface *ets_env; +#endif + +// Deprecated types: +typedef ets_env EtsEnv; + +typedef enum { + ETS_OKAY, + ETS_INVALID_ARG, + ETS_GENERIC_FAILURE, + ETS_PENDING_EXCEPTION, + ETS_INVALID_VERSION, // NOTE(v.cherkashin): This status code doesn't match to napi interface. + // Should we probably delete this status code? +} ets_status; + +// clang-format off +// Interface Function Table +struct ETS_NativeInterface { + // NOTE(a.urakov): solve the "Array" naming problem + ets_int (*GetVersion)(EtsEnv *env); +#ifdef ETS_NAPI_DESIGN_FINISHED + ets_class (*DefineClass)(EtsEnv *env, const char *name, ets_object loader, const ets_byte *buf, ets_size bufLen); +#endif + ets_class (*FindClass)(EtsEnv *env, const char *name); +#ifdef ETS_NAPI_DESIGN_FINISHED + ets_method (*FromReflectedMethod)(EtsEnv *env, ets_object method); + ets_field (*FromReflectedField)(EtsEnv *env, ets_object field); + ets_object (*ToReflectedMethod)(EtsEnv *env, ets_class cls, ets_method p_method, ets_boolean isStatic); +#endif + ets_class (*GetSuperclass)(EtsEnv *env, ets_class cls); + ets_boolean (*IsAssignableFrom)(EtsEnv *env, ets_class cls1, ets_class cls2); +#ifdef ETS_NAPI_DESIGN_FINISHED + ets_object (*ToReflectedField)(EtsEnv *env, ets_class cls, ets_field p_field, ets_boolean isStatic); +#endif + ets_int (*ThrowError)(EtsEnv *env, ets_error obj); + ets_int (*ThrowErrorNew)(EtsEnv *env, ets_class cls, const char *message); + ets_error (*ErrorOccurred)(EtsEnv *env); + void (*ErrorDescribe)(EtsEnv *env); + void (*ErrorClear)(EtsEnv *env); + void (*FatalError)(EtsEnv *env, const char *message); + ets_int (*PushLocalFrame)(EtsEnv *env, ets_int capacity); + ets_object (*PopLocalFrame)(EtsEnv *env, ets_object result); + ets_object (*NewGlobalRef)(EtsEnv *env, ets_object obj); + void (*DeleteGlobalRef)(EtsEnv *env, ets_object globalRef); + void (*DeleteLocalRef)(EtsEnv *env, ets_object localRef); + ets_boolean (*IsSameObject)(EtsEnv *env, ets_object ref1, ets_object ref2); + ets_object (*NewLocalRef)(EtsEnv *env, ets_object ref); + ets_int (*EnsureLocalCapacity)(EtsEnv *env, ets_int capacity); + ets_object (*AllocObject)(EtsEnv *env, ets_class cls); + ets_object (*NewObject)(EtsEnv *env, ets_class cls, ets_method p_method, ...); + ets_object (*NewObjectList)(EtsEnv *env, ets_class cls, ets_method p_method, va_list args); + ets_object (*NewObjectArray)(EtsEnv *env, ets_class cls, ets_method p_method, const ets_value *args); + ets_class (*GetObjectClass)(EtsEnv *env, ets_object obj); + ets_boolean (*IsInstanceOf)(EtsEnv *env, ets_object obj, ets_class cls); + ets_method (*Getp_method)(EtsEnv *env, ets_class cls, const char *name, const char *sig); + ets_object (*CallObjectMethod)(EtsEnv *env, ets_object obj, ets_method p_method, ...); + ets_object (*CallObjectMethodList)(EtsEnv *env, ets_object obj, ets_method p_method, va_list args); + ets_object (*CallObjectMethodArray)(EtsEnv *env, ets_object obj, ets_method p_method, const ets_value *args); + ets_boolean (*CallBooleanMethod)(EtsEnv *env, ets_object obj, ets_method p_method, ...); + ets_boolean (*CallBooleanMethodList)(EtsEnv *env, ets_object obj, ets_method p_method, va_list args); + ets_boolean (*CallBooleanMethodArray)(EtsEnv *env, ets_object obj, ets_method p_method, const ets_value *args); + ets_byte (*CallByteMethod)(EtsEnv *env, ets_object obj, ets_method p_method, ...); + ets_byte (*CallByteMethodList)(EtsEnv *env, ets_object obj, ets_method p_method, va_list args); + ets_byte (*CallByteMethodArray)(EtsEnv *env, ets_object obj, ets_method p_method, const ets_value *args); + ets_char (*CallCharMethod)(EtsEnv *env, ets_object obj, ets_method p_method, ...); + ets_char (*CallCharMethodList)(EtsEnv *env, ets_object obj, ets_method p_method, va_list args); + ets_char (*CallCharMethodArray)(EtsEnv *env, ets_object obj, ets_method p_method, const ets_value *args); + ets_short (*CallShortMethod)(EtsEnv *env, ets_object obj, ets_method p_method, ...); + ets_short (*CallShortMethodList)(EtsEnv *env, ets_object obj, ets_method p_method, va_list args); + ets_short (*CallShortMethodArray)(EtsEnv *env, ets_object obj, ets_method p_method, const ets_value *args); + ets_int (*CallIntMethod)(EtsEnv *env, ets_object obj, ets_method p_method, ...); + ets_int (*CallIntMethodList)(EtsEnv *env, ets_object obj, ets_method p_method, va_list args); + ets_int (*CallIntMethodArray)(EtsEnv *env, ets_object obj, ets_method p_method, const ets_value *args); + ets_long (*CallLongMethod)(EtsEnv *env, ets_object obj, ets_method p_method, ...); + ets_long (*CallLongMethodList)(EtsEnv *env, ets_object obj, ets_method p_method, va_list args); + ets_long (*CallLongMethodArray)(EtsEnv *env, ets_object obj, ets_method p_method, const ets_value *args); + ets_float (*CallFloatMethod)(EtsEnv *env, ets_object obj, ets_method p_method, ...); + ets_float (*CallFloatMethodList)(EtsEnv *env, ets_object obj, ets_method p_method, va_list args); + ets_float (*CallFloatMethodArray)(EtsEnv *env, ets_object obj, ets_method p_method, const ets_value *args); + ets_double (*CallDoubleMethod)(EtsEnv *env, ets_object obj, ets_method p_method, ...); + ets_double (*CallDoubleMethodList)(EtsEnv *env, ets_object obj, ets_method p_method, va_list args); + ets_double (*CallDoubleMethodArray)(EtsEnv *env, ets_object obj, ets_method p_method, const ets_value *args); + void (*CallVoidMethod)(EtsEnv *env, ets_object obj, ets_method p_method, ...); + void (*CallVoidMethodList)(EtsEnv *env, ets_object obj, ets_method p_method, va_list args); + void (*CallVoidMethodArray)(EtsEnv *env, ets_object obj, ets_method p_method, const ets_value *args); + + ets_object (*CallNonvirtualObjectMethod)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, ...); + ets_object (*CallNonvirtualObjectMethodList)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, + va_list args); + ets_object (*CallNonvirtualObjectMethodArray)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, + const ets_value *args); + ets_boolean (*CallNonvirtualBooleanMethod)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, ...); + ets_boolean (*CallNonvirtualBooleanMethodList)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, + va_list args); + ets_boolean (*CallNonvirtualBooleanMethodArray)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, + const ets_value *args); + ets_byte (*CallNonvirtualByteMethod)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, ...); + ets_byte (*CallNonvirtualByteMethodList)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, + va_list args); + ets_byte (*CallNonvirtualByteMethodArray)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, + const ets_value *args); + ets_char (*CallNonvirtualCharMethod)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, ...); + ets_char (*CallNonvirtualCharMethodList)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, + va_list args); + ets_char (*CallNonvirtualCharMethodArray)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, + const ets_value *args); + ets_short (*CallNonvirtualShortMethod)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, ...); + ets_short (*CallNonvirtualShortMethodList)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, + va_list args); + ets_short (*CallNonvirtualShortMethodArray)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, + const ets_value *args); + ets_int (*CallNonvirtualIntMethod)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, ...); + ets_int (*CallNonvirtualIntMethodList)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, + va_list args); + ets_int (*CallNonvirtualIntMethodArray)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, + const ets_value *args); + ets_long (*CallNonvirtualLongMethod)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, ...); + ets_long (*CallNonvirtualLongMethodList)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, + va_list args); + ets_long (*CallNonvirtualLongMethodArray)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, + const ets_value *args); + ets_float (*CallNonvirtualFloatMethod)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, ...); + ets_float (*CallNonvirtualFloatMethodList)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, + va_list args); + ets_float (*CallNonvirtualFloatMethodArray)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, + const ets_value *args); + ets_double (*CallNonvirtualDoubleMethod)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, ...); + ets_double (*CallNonvirtualDoubleMethodList)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, + va_list args); + ets_double (*CallNonvirtualDoubleMethodArray)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, + const ets_value *args); + void (*CallNonvirtualVoidMethod)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, ...); + void (*CallNonvirtualVoidMethodList)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, va_list args); + void (*CallNonvirtualVoidMethodArray)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, + const ets_value *args); + ets_field (*Getp_field)(EtsEnv *env, ets_class cls, const char *name, const char *sig); + ets_object (*GetObjectField)(EtsEnv *env, ets_object obj, ets_field p_field); + ets_boolean (*GetBooleanField)(EtsEnv *env, ets_object obj, ets_field p_field); + ets_byte (*GetByteField)(EtsEnv *env, ets_object obj, ets_field p_field); + ets_char (*GetCharField)(EtsEnv *env, ets_object obj, ets_field p_field); + ets_short (*GetShortField)(EtsEnv *env, ets_object obj, ets_field p_field); + ets_int (*GetIntField)(EtsEnv *env, ets_object obj, ets_field p_field); + ets_long (*GetLongField)(EtsEnv *env, ets_object obj, ets_field p_field); + ets_float (*GetFloatField)(EtsEnv *env, ets_object obj, ets_field p_field); + ets_double (*GetDoubleField)(EtsEnv *env, ets_object obj, ets_field p_field); + void (*SetObjectField)(EtsEnv *env, ets_object obj, ets_field p_field, ets_object value); + void (*SetBooleanField)(EtsEnv *env, ets_object obj, ets_field p_field, ets_boolean value); + void (*SetByteField)(EtsEnv *env, ets_object obj, ets_field p_field, ets_byte value); + void (*SetCharField)(EtsEnv *env, ets_object obj, ets_field p_field, ets_char value); + void (*SetShortField)(EtsEnv *env, ets_object obj, ets_field p_field, ets_short value); + void (*SetIntField)(EtsEnv *env, ets_object obj, ets_field p_field, ets_int value); + void (*SetLongField)(EtsEnv *env, ets_object obj, ets_field p_field, ets_long value); + void (*SetFloatField)(EtsEnv *env, ets_object obj, ets_field p_field, ets_float value); + void (*SetDoubleField)(EtsEnv *env, ets_object obj, ets_field p_field, ets_double value); + ets_method (*GetStaticp_method)(EtsEnv *env, ets_class cls, const char *name, const char *sig); + ets_object (*CallStaticObjectMethod)(EtsEnv *env, ets_class cls, ets_method p_method, ...); + ets_object (*CallStaticObjectMethodList)(EtsEnv *env, ets_class cls, ets_method p_method, va_list args); + ets_object (*CallStaticObjectMethodArray)(EtsEnv *env, ets_class cls, ets_method p_method, ets_value *args); + ets_boolean (*CallStaticBooleanMethod)(EtsEnv *env, ets_class cls, ets_method p_method, ...); + ets_boolean (*CallStaticBooleanMethodList)(EtsEnv *env, ets_class cls, ets_method p_method, va_list args); + ets_boolean (*CallStaticBooleanMethodArray)(EtsEnv *env, ets_class cls, ets_method p_method, ets_value *args); + ets_byte (*CallStaticByteMethod)(EtsEnv *env, ets_class cls, ets_method p_method, ...); + ets_byte (*CallStaticByteMethodList)(EtsEnv *env, ets_class cls, ets_method p_method, va_list args); + ets_byte (*CallStaticByteMethodArray)(EtsEnv *env, ets_class cls, ets_method p_method, ets_value *args); + ets_char (*CallStaticCharMethod)(EtsEnv *env, ets_class cls, ets_method p_method, ...); + ets_char (*CallStaticCharMethodList)(EtsEnv *env, ets_class cls, ets_method p_method, va_list args); + ets_char (*CallStaticCharMethodArray)(EtsEnv *env, ets_class cls, ets_method p_method, ets_value *args); + ets_short (*CallStaticShortMethod)(EtsEnv *env, ets_class cls, ets_method p_method, ...); + ets_short (*CallStaticShortMethodList)(EtsEnv *env, ets_class cls, ets_method p_method, va_list args); + ets_short (*CallStaticShortMethodArray)(EtsEnv *env, ets_class cls, ets_method p_method, ets_value *args); + ets_int (*CallStaticIntMethod)(EtsEnv *env, ets_class cls, ets_method p_method, ...); + ets_int (*CallStaticIntMethodList)(EtsEnv *env, ets_class cls, ets_method p_method, va_list args); + ets_int (*CallStaticIntMethodArray)(EtsEnv *env, ets_class cls, ets_method p_method, ets_value *args); + ets_long (*CallStaticLongMethod)(EtsEnv *env, ets_class cls, ets_method p_method, ...); + ets_long (*CallStaticLongMethodList)(EtsEnv *env, ets_class cls, ets_method p_method, va_list args); + ets_long (*CallStaticLongMethodArray)(EtsEnv *env, ets_class cls, ets_method p_method, ets_value *args); + ets_float (*CallStaticFloatMethod)(EtsEnv *env, ets_class cls, ets_method p_method, ...); + ets_float (*CallStaticFloatMethodList)(EtsEnv *env, ets_class cls, ets_method p_method, va_list args); + ets_float (*CallStaticFloatMethodArray)(EtsEnv *env, ets_class cls, ets_method p_method, ets_value *args); + ets_double (*CallStaticDoubleMethod)(EtsEnv *env, ets_class cls, ets_method p_method, ...); + ets_double (*CallStaticDoubleMethodList)(EtsEnv *env, ets_class cls, ets_method p_method, va_list args); + ets_double (*CallStaticDoubleMethodArray)(EtsEnv *env, ets_class cls, ets_method p_method, ets_value *args); + void (*CallStaticVoidMethod)(EtsEnv *env, ets_class cls, ets_method p_method, ...); + void (*CallStaticVoidMethodList)(EtsEnv *env, ets_class cls, ets_method p_method, va_list args); + void (*CallStaticVoidMethodArray)(EtsEnv *env, ets_class cls, ets_method p_method, ets_value *args); + ets_field (*GetStaticp_field)(EtsEnv *env, ets_class cls, const char *name, const char *sig); + ets_object (*GetStaticObjectField)(EtsEnv *env, ets_class cls, ets_field p_field); + ets_boolean (*GetStaticBooleanField)(EtsEnv *env, ets_class cls, ets_field p_field); + ets_byte (*GetStaticByteField)(EtsEnv *env, ets_class cls, ets_field p_field); + ets_char (*GetStaticCharField)(EtsEnv *env, ets_class cls, ets_field p_field); + ets_short (*GetStaticShortField)(EtsEnv *env, ets_class cls, ets_field p_field); + ets_int (*GetStaticIntField)(EtsEnv *env, ets_class cls, ets_field p_field); + ets_long (*GetStaticLongField)(EtsEnv *env, ets_class cls, ets_field p_field); + ets_float (*GetStaticFloatField)(EtsEnv *env, ets_class cls, ets_field p_field); + ets_double (*GetStaticDoubleField)(EtsEnv *env, ets_class cls, ets_field p_field); + void (*SetStaticObjectField)(EtsEnv *env, ets_class cls, ets_field p_field, ets_object value); + void (*SetStaticBooleanField)(EtsEnv *env, ets_class cls, ets_field p_field, ets_boolean value); + void (*SetStaticByteField)(EtsEnv *env, ets_class cls, ets_field p_field, ets_byte value); + void (*SetStaticCharField)(EtsEnv *env, ets_class cls, ets_field p_field, ets_char value); + void (*SetStaticShortField)(EtsEnv *env, ets_class cls, ets_field p_field, ets_short value); + void (*SetStaticIntField)(EtsEnv *env, ets_class cls, ets_field p_field, ets_int value); + void (*SetStaticLongField)(EtsEnv *env, ets_class cls, ets_field p_field, ets_long value); + void (*SetStaticFloatField)(EtsEnv *env, ets_class cls, ets_field p_field, ets_float value); + void (*SetStaticDoubleField)(EtsEnv *env, ets_class cls, ets_field p_field, ets_double value); + ets_string (*NewString)(EtsEnv *env, const ets_char *unicodeChars, ets_size len); + ets_size (*GetStringLength)(EtsEnv *env, ets_string string); + const ets_char *(*GetStringChars)(EtsEnv *env, ets_string string, ets_boolean *isCopy); + void (*ReleaseStringChars)(EtsEnv *env, ets_string string, const ets_char *chars); + ets_string (*NewStringUTF)(EtsEnv *env, const char *bytes); + ets_size (*GetStringUTFLength)(EtsEnv *env, ets_string string); + const char *(*GetStringUTFChars)(EtsEnv *env, ets_string string, ets_boolean *isCopy); + void (*ReleaseStringUTFChars)(EtsEnv *env, ets_string string, const char *utf); + ets_size (*GetArrayLength)(EtsEnv *env, ets_array array); + ets_objectArray (*NewObjectsArray)(EtsEnv *env, ets_size length, ets_class element_class, + ets_object initial_element); + ets_object (*GetObjectArrayElement)(EtsEnv *env, ets_objectArray array, ets_size index); + void (*SetObjectArrayElement)(EtsEnv *env, ets_objectArray array, ets_size index, ets_object value); + ets_booleanArray (*NewBooleanArray)(EtsEnv *env, ets_size length); + ets_byteArray (*NewByteArray)(EtsEnv *env, ets_size length); + ets_charArray (*NewCharArray)(EtsEnv *env, ets_size length); + ets_shortArray (*NewShortArray)(EtsEnv *env, ets_size length); + ets_intArray (*NewIntArray)(EtsEnv *env, ets_size length); + ets_longArray (*NewLongArray)(EtsEnv *env, ets_size length); + ets_floatArray (*NewFloatArray)(EtsEnv *env, ets_size length); + ets_doubleArray (*NewDoubleArray)(EtsEnv *env, ets_size length); + ets_boolean *(*PinBooleanArray)(EtsEnv *env, ets_booleanArray array); + ets_byte *(*PinByteArray)(EtsEnv *env, ets_byteArray array); + ets_char *(*PinCharArray)(EtsEnv *env, ets_charArray array); + ets_short *(*PinShortArray)(EtsEnv *env, ets_shortArray array); + ets_int *(*PinIntArray)(EtsEnv *env, ets_intArray array); + ets_long *(*PinLongArray)(EtsEnv *env, ets_longArray array); + ets_float *(*PinFloatArray)(EtsEnv *env, ets_floatArray array); + ets_double *(*PinDoubleArray)(EtsEnv *env, ets_doubleArray array); + void (*UnpinBooleanArray)(EtsEnv *env, ets_booleanArray array); + void (*UnpinByteArray)(EtsEnv *env, ets_byteArray array); + void (*UnpinCharArray)(EtsEnv *env, ets_charArray array); + void (*UnpinShortArray)(EtsEnv *env, ets_shortArray array); + void (*UnpinIntArray)(EtsEnv *env, ets_intArray array); + void (*UnpinLongArray)(EtsEnv *env, ets_longArray array); + void (*UnpinFloatArray)(EtsEnv *env, ets_floatArray array); + void (*UnpinDoubleArray)(EtsEnv *env, ets_doubleArray array); + void (*GetBooleanArrayRegion)(EtsEnv *env, ets_booleanArray array, ets_size start, ets_size len, ets_boolean *buf); + void (*GetByteArrayRegion)(EtsEnv *env, ets_byteArray array, ets_size start, ets_size len, ets_byte *buf); + void (*GetCharArrayRegion)(EtsEnv *env, ets_charArray array, ets_size start, ets_size len, ets_char *buf); + void (*GetShortArrayRegion)(EtsEnv *env, ets_shortArray array, ets_size start, ets_size len, ets_short *buf); + void (*GetIntArrayRegion)(EtsEnv *env, ets_intArray array, ets_size start, ets_size len, ets_int *buf); + void (*GetLongArrayRegion)(EtsEnv *env, ets_longArray array, ets_size start, ets_size len, ets_long *buf); + void (*GetFloatArrayRegion)(EtsEnv *env, ets_floatArray array, ets_size start, ets_size len, ets_float *buf); + void (*GetDoubleArrayRegion)(EtsEnv *env, ets_doubleArray array, ets_size start, ets_size len, ets_double *buf); + void (*SetBooleanArrayRegion)(EtsEnv *env, ets_booleanArray array, ets_size start, ets_size len, + const ets_boolean *buf); + void (*SetByteArrayRegion)(EtsEnv *env, ets_byteArray array, ets_size start, ets_size len, const ets_byte *buf); + void (*SetCharArrayRegion)(EtsEnv *env, ets_charArray array, ets_size start, ets_size len, const ets_char *buf); + void (*SetShortArrayRegion)(EtsEnv *env, ets_shortArray array, ets_size start, ets_size len, const ets_short *buf); + void (*SetIntArrayRegion)(EtsEnv *env, ets_intArray array, ets_size start, ets_size len, const ets_int *buf); + void (*SetLongArrayRegion)(EtsEnv *env, ets_longArray array, ets_size start, ets_size len, const ets_long *buf); + void (*SetFloatArrayRegion)(EtsEnv *env, ets_floatArray array, ets_size start, ets_size len, const ets_float *buf); + void (*SetDoubleArrayRegion)(EtsEnv *env, ets_doubleArray array, ets_size start, ets_size len, + const ets_double *buf); + ets_int (*RegisterNatives)(EtsEnv *env, ets_class cls, const EtsNativeMethod *methods, ets_int nMethods); + ets_int (*UnregisterNatives)(EtsEnv *env, ets_class cls); + ets_int (*GetEtsVM)(EtsEnv *env, EtsVM **vm); + void (*GetStringRegion)(EtsEnv *env, ets_string str, ets_size start, ets_size len, ets_char *buf); + void (*GetStringUTFRegion)(EtsEnv *env, ets_string str, ets_size start, ets_size len, char *buf); + ets_weak (*NewWeakGlobalRef)(EtsEnv *env, ets_object obj); + void (*DeleteWeakGlobalRef)(EtsEnv *env, ets_weak obj); + ets_boolean (*ErrorCheck)(EtsEnv *env); +#ifdef ETS_NAPI_DESIGN_FINISHED + ets_object (*NewDirectByteBuffer)(EtsEnv *env, void *address, ets_long capacity); + void *(*GetDirectBufferAddress)(EtsEnv *env, ets_object buf); + ets_long (*GetDirectBufferCapacity)(EtsEnv *env, ets_object buf); +#endif + ets_objectRefType (*GetObjectRefType)(EtsEnv *env, ets_object obj); + + /* 227 methods */ + + // Promise API + ets_status (*PromiseCreate)(EtsEnv *env, ets_deferred *deferred, ets_object *promise); + ets_status (*DeferredResolve)(EtsEnv *env, ets_deferred deferred, ets_object resolution); + ets_status (*DeferredReject)(EtsEnv *env, ets_deferred deferred, ets_object rejection); +}; +// clang-format on + +// Invocation API Functions +typedef enum { + ETS_LOG_LEVEL, + ETS_MOBILE_LOG, + ETS_BOOT_FILE, + ETS_AOT_FILE, + ETS_ARK_FILE, + ETS_JIT, + ETS_NO_JIT, + ETS_AOT, + ETS_NO_AOT, + ETS_GC_TRIGGER_TYPE, + ETS_GC_TYPE, + ETS_RUN_GC_IN_PLACE, + ETS_INTERPRETER_TYPE, + ETS_NATIVE_LIBRARY_PATH, + ETS_VERIFICATION_MODE +} EtsOptionType; + +typedef struct EtsVMOption { + EtsOptionType option; + const void *extraInfo; +} EtsVMOption; + +typedef struct EtsVMInitArgs { + ets_int version; + ets_int nOptions; + EtsVMOption *options; +} EtsVMInitArgs; + +typedef enum { + ETS_MOBILE_LOG_LEVEL_UNKNOWN = 0, + ETS_MOBILE_LOG_LEVEL_DEFAULT, + ETS_MOBILE_LOG_LEVEL_VERBOSE, + ETS_MOBILE_LOG_LEVEL_DEBUG, + ETS_MOBILE_LOG_LEVEL_INFO, + ETS_MOBILE_LOG_LEVEL_WARN, + ETS_MOBILE_LOG_LEVEL_ERROR, + ETS_MOBILE_LOG_LEVEL_FATAL, + ETS_MOBILE_LOG_LEVEL_SILENT +} EtsMobileLogggerLevel; + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _MSC_VER +#define ETS_EXPORT __declspec(dllexport) +#else +#define ETS_EXPORT __attribute__((visibility("default"))) +#endif +#define ETS_IMPORT +#define ETS_CALL + +ETS_EXPORT ets_int ETS_GetDefaultVMInitArgs(EtsVMInitArgs *vmArgs); +ETS_EXPORT ets_int ETS_GetCreatedVMs(EtsVM **vmBuf, ets_size bufLen, ets_size *nVms); +ETS_EXPORT ets_int ETS_CreateVM(EtsVM **pVm, EtsEnv **pEnv, EtsVMInitArgs *vmArgs); + +#ifdef __cplusplus +} +#endif + +struct ETS_InvokeInterface { + ets_int (*DestroyEtsVM)(EtsVM *vm); + ets_int (*GetEnv)(EtsVM *vm, EtsEnv **pEnv, ets_int version); +}; + +struct __EtsVM { + // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) + const struct ETS_InvokeInterface *invoke_interface; + +#ifdef __cplusplus + ets_int DestroyEtsVM() + { + return invoke_interface->DestroyEtsVM(this); + } + + ets_int GetEnv(EtsEnv **pEnv, ets_int version) + { + return invoke_interface->GetEnv(this, pEnv, version); + } +#endif +}; + +struct __EtsEnv { + // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) + const struct ETS_NativeInterface *native_interface; + +#ifdef __cplusplus + + ets_int GetVersion() + { + return native_interface->GetVersion(this); + } + // DefineClass, + ets_class FindClass(const char *name) + { + return native_interface->FindClass(this, name); + } + // FromReflectedMethod, + // FromReflectedField, + // ToReflectedMethod, + ets_class GetSuperclass(ets_class cls) + { + return native_interface->GetSuperclass(this, cls); + } + ets_boolean IsAssignableFrom(ets_class cls1, ets_class cls2) + { + return native_interface->IsAssignableFrom(this, cls1, cls2); + } + // ToReflectedField, + ets_int ThrowError(ets_error obj) + { + return native_interface->ThrowError(this, obj); + } + ets_int ThrowErrorNew(ets_class cls, const char *message) + { + return native_interface->ThrowErrorNew(this, cls, message); + } + ets_error ErrorOccurred() + { + return native_interface->ErrorOccurred(this); + } + void ErrorDescribe() + { + native_interface->ErrorDescribe(this); + } + void ErrorClear() + { + native_interface->ErrorClear(this); + } + void FatalError(const char *message) + { + native_interface->FatalError(this, message); + } + ets_int PushLocalFrame(ets_int capacity) + { + return native_interface->PushLocalFrame(this, capacity); + } + ets_object PopLocalFrame(ets_object result) + { + return native_interface->PopLocalFrame(this, result); + } + ets_object NewGlobalRef(ets_object obj) + { + return native_interface->NewGlobalRef(this, obj); + } + void DeleteGlobalRef(ets_object globalRef) + { + native_interface->DeleteGlobalRef(this, globalRef); + } + void DeleteLocalRef(ets_object localRef) + { + native_interface->DeleteLocalRef(this, localRef); + } + ets_boolean IsSameObject(ets_object ref1, ets_object ref2) + { + return native_interface->IsSameObject(this, ref1, ref2); + } + ets_object NewLocalRef(ets_object ref) + { + return native_interface->NewLocalRef(this, ref); + } + ets_int EnsureLocalCapacity(ets_int capacity) + { + return native_interface->EnsureLocalCapacity(this, capacity); + } + ets_object AllocObject(ets_class cls) + { + return native_interface->AllocObject(this, cls); + } + ets_object NewObject(ets_class cls, ets_method p_method, ...) + { + va_list args; + va_start(args, p_method); + ets_object ret = native_interface->NewObjectList(this, cls, p_method, args); + va_end(args); + return ret; + } + ets_object NewObjectList(ets_class cls, ets_method p_method, va_list args) + { + return native_interface->NewObjectList(this, cls, p_method, args); + } + ets_object NewObjectArray(ets_class cls, ets_method p_method, const ets_value *args) + { + return native_interface->NewObjectArray(this, cls, p_method, args); + } + ets_class GetObjectClass(ets_object obj) + { + return native_interface->GetObjectClass(this, obj); + } + ets_boolean IsInstanceOf(ets_object obj, ets_class cls) + { + return native_interface->IsInstanceOf(this, obj, cls); + } + ets_method Getp_method(ets_class cls, const char *name, const char *sig) + { + return native_interface->Getp_method(this, cls, name, sig); + } + ets_object CallObjectMethod(ets_object obj, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_object res = native_interface->CallObjectMethodList(this, obj, method_id, args); + va_end(args); + return res; + } + ets_object CallObjectMethodList(ets_object obj, ets_method method_id, va_list args) + { + return native_interface->CallObjectMethodList(this, obj, method_id, args); + } + ets_object CallObjectMethodArray(ets_object obj, ets_method method_id, const ets_value *args) + { + return native_interface->CallObjectMethodArray(this, obj, method_id, args); + } + ets_boolean CallBooleanMethod(ets_object obj, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_boolean res = native_interface->CallBooleanMethodList(this, obj, method_id, args); + va_end(args); + return res; + } + ets_boolean CallBooleanMethodList(ets_object obj, ets_method method_id, va_list args) + { + return native_interface->CallBooleanMethodList(this, obj, method_id, args); + } + ets_boolean CallBooleanMethodArray(ets_object obj, ets_method method_id, const ets_value *args) + { + return native_interface->CallBooleanMethodArray(this, obj, method_id, args); + } + ets_byte CallByteMethod(ets_object obj, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_byte res = native_interface->CallByteMethodList(this, obj, method_id, args); + va_end(args); + return res; + } + ets_byte CallByteMethodList(ets_object obj, ets_method method_id, va_list args) + { + return native_interface->CallByteMethodList(this, obj, method_id, args); + } + ets_byte CallByteMethodArray(ets_object obj, ets_method method_id, const ets_value *args) + { + return native_interface->CallByteMethodArray(this, obj, method_id, args); + } + ets_char CallCharMethod(ets_object obj, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_char res = native_interface->CallCharMethodList(this, obj, method_id, args); + va_end(args); + return res; + } + ets_char CallCharMethodList(ets_object obj, ets_method method_id, va_list args) + { + return native_interface->CallCharMethodList(this, obj, method_id, args); + } + ets_char CallCharMethodArray(ets_object obj, ets_method method_id, const ets_value *args) + { + return native_interface->CallCharMethodArray(this, obj, method_id, args); + } + ets_short CallShortMethod(ets_object obj, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_short res = native_interface->CallShortMethodList(this, obj, method_id, args); + va_end(args); + return res; + } + ets_short CallShortMethodList(ets_object obj, ets_method method_id, va_list args) + { + return native_interface->CallShortMethodList(this, obj, method_id, args); + } + ets_short CallShortMethodArray(ets_object obj, ets_method method_id, const ets_value *args) + { + return native_interface->CallShortMethodArray(this, obj, method_id, args); + } + ets_int CallIntMethod(ets_object obj, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_int res = native_interface->CallIntMethodList(this, obj, method_id, args); + va_end(args); + return res; + } + ets_int CallIntMethodList(ets_object obj, ets_method method_id, va_list args) + { + return native_interface->CallIntMethodList(this, obj, method_id, args); + } + ets_int CallIntMethodArray(ets_object obj, ets_method method_id, const ets_value *args) + { + return native_interface->CallIntMethodArray(this, obj, method_id, args); + } + ets_long CallLongMethod(ets_object obj, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_long res = native_interface->CallLongMethodList(this, obj, method_id, args); + va_end(args); + return res; + } + ets_long CallLongMethodList(ets_object obj, ets_method method_id, va_list args) + { + return native_interface->CallLongMethodList(this, obj, method_id, args); + } + ets_long CallLongMethodArray(ets_object obj, ets_method method_id, const ets_value *args) + { + return native_interface->CallLongMethodArray(this, obj, method_id, args); + } + ets_float CallFloatMethod(ets_object obj, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_float res = native_interface->CallFloatMethodList(this, obj, method_id, args); + va_end(args); + return res; + } + ets_float CallFloatMethodList(ets_object obj, ets_method method_id, va_list args) + { + return native_interface->CallFloatMethodList(this, obj, method_id, args); + } + ets_float CallFloatMethodArray(ets_object obj, ets_method method_id, const ets_value *args) + { + return native_interface->CallFloatMethodArray(this, obj, method_id, args); + } + ets_double CallDoubleMethod(ets_object obj, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_double res = native_interface->CallDoubleMethodList(this, obj, method_id, args); + va_end(args); + return res; + } + ets_double CallDoubleMethodList(ets_object obj, ets_method method_id, va_list args) + { + return native_interface->CallDoubleMethodList(this, obj, method_id, args); + } + ets_double CallDoubleMethodArray(ets_object obj, ets_method method_id, const ets_value *args) + { + return native_interface->CallDoubleMethodArray(this, obj, method_id, args); + } + void CallVoidMethod(ets_object obj, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + native_interface->CallVoidMethodList(this, obj, method_id, args); + va_end(args); + } + void CallVoidMethodList(ets_object obj, ets_method method_id, va_list args) + { + native_interface->CallVoidMethodList(this, obj, method_id, args); + } + void CallVoidMethodArray(ets_object obj, ets_method method_id, const ets_value *args) + { + native_interface->CallVoidMethodArray(this, obj, method_id, args); + } + ets_object CallNonvirtualObjectMethod(ets_object obj, ets_class cls, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_object res = native_interface->CallNonvirtualObjectMethodList(this, obj, cls, method_id, args); + va_end(args); + return res; + } + ets_object CallNonvirtualObjectMethodList(ets_object obj, ets_class cls, ets_method method_id, va_list args) + { + return native_interface->CallNonvirtualObjectMethodList(this, obj, cls, method_id, args); + } + ets_object CallNonvirtualObjectMethodArray(ets_object obj, ets_class cls, ets_method method_id, + const ets_value *args) + { + return native_interface->CallNonvirtualObjectMethodArray(this, obj, cls, method_id, args); + } + ets_boolean CallNonvirtualBooleanMethod(ets_object obj, ets_class cls, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_boolean res = native_interface->CallNonvirtualBooleanMethodList(this, obj, cls, method_id, args); + va_end(args); + return res; + } + ets_boolean CallNonvirtualBooleanMethodList(ets_object obj, ets_class cls, ets_method method_id, va_list args) + { + return native_interface->CallNonvirtualBooleanMethodList(this, obj, cls, method_id, args); + } + ets_boolean CallNonvirtualBooleanMethodArray(ets_object obj, ets_class cls, ets_method method_id, + const ets_value *args) + { + return native_interface->CallNonvirtualBooleanMethodArray(this, obj, cls, method_id, args); + } + ets_byte CallNonvirtualByteMethod(ets_object obj, ets_class cls, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_byte res = native_interface->CallNonvirtualByteMethodList(this, obj, cls, method_id, args); + va_end(args); + return res; + } + ets_byte CallNonvirtualByteMethodList(ets_object obj, ets_class cls, ets_method method_id, va_list args) + { + return native_interface->CallNonvirtualByteMethodList(this, obj, cls, method_id, args); + } + ets_byte CallNonvirtualByteMethodArray(ets_object obj, ets_class cls, ets_method method_id, const ets_value *args) + { + return native_interface->CallNonvirtualByteMethodArray(this, obj, cls, method_id, args); + } + ets_char CallNonvirtualCharMethod(ets_object obj, ets_class cls, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_char res = native_interface->CallNonvirtualCharMethodList(this, obj, cls, method_id, args); + va_end(args); + return res; + } + ets_char CallNonvirtualCharMethodList(ets_object obj, ets_class cls, ets_method method_id, va_list args) + { + return native_interface->CallNonvirtualCharMethodList(this, obj, cls, method_id, args); + } + ets_char CallNonvirtualCharMethodArray(ets_object obj, ets_class cls, ets_method method_id, const ets_value *args) + { + return native_interface->CallNonvirtualCharMethodArray(this, obj, cls, method_id, args); + } + ets_short CallNonvirtualShortMethod(ets_object obj, ets_class cls, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_short res = native_interface->CallNonvirtualShortMethodList(this, obj, cls, method_id, args); + va_end(args); + return res; + } + ets_short CallNonvirtualShortMethodList(ets_object obj, ets_class cls, ets_method method_id, va_list args) + { + return native_interface->CallNonvirtualShortMethodList(this, obj, cls, method_id, args); + } + ets_short CallNonvirtualShortMethodArray(ets_object obj, ets_class cls, ets_method method_id, const ets_value *args) + { + return native_interface->CallNonvirtualShortMethodArray(this, obj, cls, method_id, args); + } + ets_int CallNonvirtualIntMethod(ets_object obj, ets_class cls, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_int res = native_interface->CallNonvirtualIntMethodList(this, obj, cls, method_id, args); + va_end(args); + return res; + } + ets_int CallNonvirtualIntMethodList(ets_object obj, ets_class cls, ets_method method_id, va_list args) + { + return native_interface->CallNonvirtualIntMethodList(this, obj, cls, method_id, args); + } + ets_int CallNonvirtualIntMethodArray(ets_object obj, ets_class cls, ets_method method_id, const ets_value *args) + { + return native_interface->CallNonvirtualIntMethodArray(this, obj, cls, method_id, args); + } + ets_long CallNonvirtualLongMethod(ets_object obj, ets_class cls, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_long res = native_interface->CallNonvirtualLongMethodList(this, obj, cls, method_id, args); + va_end(args); + return res; + } + ets_long CallNonvirtualLongMethodList(ets_object obj, ets_class cls, ets_method method_id, va_list args) + { + return native_interface->CallNonvirtualLongMethodList(this, obj, cls, method_id, args); + } + ets_long CallNonvirtualLongMethodArray(ets_object obj, ets_class cls, ets_method method_id, const ets_value *args) + { + return native_interface->CallNonvirtualLongMethodArray(this, obj, cls, method_id, args); + } + ets_float CallNonvirtualFloatMethod(ets_object obj, ets_class cls, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_float res = native_interface->CallNonvirtualFloatMethodList(this, obj, cls, method_id, args); + va_end(args); + return res; + } + ets_float CallNonvirtualFloatMethodList(ets_object obj, ets_class cls, ets_method method_id, va_list args) + { + return native_interface->CallNonvirtualFloatMethodList(this, obj, cls, method_id, args); + } + ets_float CallNonvirtualFloatMethodArray(ets_object obj, ets_class cls, ets_method method_id, const ets_value *args) + { + return native_interface->CallNonvirtualFloatMethodArray(this, obj, cls, method_id, args); + } + ets_double CallNonvirtualDoubleMethod(ets_object obj, ets_class cls, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_double res = native_interface->CallNonvirtualDoubleMethodList(this, obj, cls, method_id, args); + va_end(args); + return res; + } + ets_double CallNonvirtualDoubleMethodList(ets_object obj, ets_class cls, ets_method method_id, va_list args) + { + return native_interface->CallNonvirtualDoubleMethodList(this, obj, cls, method_id, args); + } + ets_double CallNonvirtualDoubleMethodArray(ets_object obj, ets_class cls, ets_method method_id, + const ets_value *args) + { + return native_interface->CallNonvirtualDoubleMethodArray(this, obj, cls, method_id, args); + } + void CallNonvirtualVoidMethod(ets_object obj, ets_class cls, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + native_interface->CallNonvirtualVoidMethodList(this, obj, cls, method_id, args); + va_end(args); + } + void CallNonvirtualVoidMethodList(ets_object obj, ets_class cls, ets_method method_id, va_list args) + { + native_interface->CallNonvirtualVoidMethodList(this, obj, cls, method_id, args); + } + void CallNonvirtualVoidMethodArray(ets_object obj, ets_class cls, ets_method method_id, const ets_value *args) + { + native_interface->CallNonvirtualVoidMethodArray(this, obj, cls, method_id, args); + } + ets_field Getp_field(ets_class cls, const char *name, const char *sig) + { + return native_interface->Getp_field(this, cls, name, sig); + } + ets_object GetObjectField(ets_object obj, ets_field p_field) + { + return native_interface->GetObjectField(this, obj, p_field); + } + ets_boolean GetBooleanField(ets_object obj, ets_field p_field) + { + return native_interface->GetBooleanField(this, obj, p_field); + } + ets_byte GetByteField(ets_object obj, ets_field p_field) + { + return native_interface->GetByteField(this, obj, p_field); + } + ets_char GetCharField(ets_object obj, ets_field p_field) + { + return native_interface->GetCharField(this, obj, p_field); + } + ets_short GetShortField(ets_object obj, ets_field p_field) + { + return native_interface->GetShortField(this, obj, p_field); + } + ets_int GetIntField(ets_object obj, ets_field p_field) + { + return native_interface->GetIntField(this, obj, p_field); + } + ets_long GetLongField(ets_object obj, ets_field p_field) + { + return native_interface->GetLongField(this, obj, p_field); + } + ets_float GetFloatField(ets_object obj, ets_field p_field) + { + return native_interface->GetFloatField(this, obj, p_field); + } + ets_double GetDoubleField(ets_object obj, ets_field p_field) + { + return native_interface->GetDoubleField(this, obj, p_field); + } + void SetObjectField(ets_object obj, ets_field p_field, ets_object value) + { + return native_interface->SetObjectField(this, obj, p_field, value); + } + void SetBooleanField(ets_object obj, ets_field p_field, ets_boolean value) + { + return native_interface->SetBooleanField(this, obj, p_field, value); + } + void SetByteField(ets_object obj, ets_field p_field, ets_byte value) + { + return native_interface->SetByteField(this, obj, p_field, value); + } + void SetCharField(ets_object obj, ets_field p_field, ets_char value) + { + return native_interface->SetCharField(this, obj, p_field, value); + } + void SetShortField(ets_object obj, ets_field p_field, ets_short value) + { + return native_interface->SetShortField(this, obj, p_field, value); + } + void SetIntField(ets_object obj, ets_field p_field, ets_int value) + { + return native_interface->SetIntField(this, obj, p_field, value); + } + void SetLongField(ets_object obj, ets_field p_field, ets_long value) + { + return native_interface->SetLongField(this, obj, p_field, value); + } + void SetFloatField(ets_object obj, ets_field p_field, ets_float value) + { + return native_interface->SetFloatField(this, obj, p_field, value); + } + void SetDoubleField(ets_object obj, ets_field p_field, ets_double value) + { + return native_interface->SetDoubleField(this, obj, p_field, value); + } + ets_method GetStaticp_method(ets_class cls, const char *name, const char *sig) + { + return native_interface->GetStaticp_method(this, cls, name, sig); + } + ets_object CallStaticObjectMethod(ets_class cls, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_object res = native_interface->CallStaticObjectMethodList(this, cls, method_id, args); + va_end(args); + return res; + } + ets_object CallStaticObjectMethodList(ets_class cls, ets_method method_id, va_list args) + { + return native_interface->CallStaticObjectMethodList(this, cls, method_id, args); + } + ets_object CallStaticObjectMethodArray(ets_class cls, ets_method method_id, ets_value *args) + { + return native_interface->CallStaticObjectMethodArray(this, cls, method_id, args); + } + ets_boolean CallStaticBooleanMethod(ets_class cls, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_boolean res = native_interface->CallStaticBooleanMethodList(this, cls, method_id, args); + va_end(args); + return res; + } + ets_boolean CallStaticBooleanMethodList(ets_class cls, ets_method method_id, va_list args) + { + return native_interface->CallStaticBooleanMethodList(this, cls, method_id, args); + } + ets_boolean CallStaticBooleanMethodArray(ets_class cls, ets_method method_id, ets_value *args) + { + return native_interface->CallStaticBooleanMethodArray(this, cls, method_id, args); + } + ets_byte CallStaticByteMethod(ets_class cls, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_byte res = native_interface->CallStaticByteMethodList(this, cls, method_id, args); + va_end(args); + return res; + } + ets_byte CallStaticByteMethodList(ets_class cls, ets_method method_id, va_list args) + { + return native_interface->CallStaticByteMethodList(this, cls, method_id, args); + } + ets_byte CallStaticByteMethodArray(ets_class cls, ets_method method_id, ets_value *args) + { + return native_interface->CallStaticByteMethodArray(this, cls, method_id, args); + } + ets_char CallStaticCharMethod(ets_class cls, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_char res = native_interface->CallStaticCharMethodList(this, cls, method_id, args); + va_end(args); + return res; + } + ets_char CallStaticCharMethodList(ets_class cls, ets_method method_id, va_list args) + { + return native_interface->CallStaticCharMethodList(this, cls, method_id, args); + } + ets_char CallStaticCharMethodArray(ets_class cls, ets_method method_id, ets_value *args) + { + return native_interface->CallStaticCharMethodArray(this, cls, method_id, args); + } + ets_short CallStaticShortMethod(ets_class cls, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_short res = native_interface->CallStaticShortMethodList(this, cls, method_id, args); + va_end(args); + return res; + } + ets_short CallStaticShortMethodList(ets_class cls, ets_method method_id, va_list args) + { + return native_interface->CallStaticShortMethodList(this, cls, method_id, args); + } + ets_short CallStaticShortMethodArray(ets_class cls, ets_method method_id, ets_value *args) + { + return native_interface->CallStaticShortMethodArray(this, cls, method_id, args); + } + ets_int CallStaticIntMethod(ets_class cls, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_int res = native_interface->CallStaticIntMethodList(this, cls, method_id, args); + va_end(args); + return res; + } + ets_int CallStaticIntMethodList(ets_class cls, ets_method method_id, va_list args) + { + return native_interface->CallStaticIntMethodList(this, cls, method_id, args); + } + ets_int CallStaticIntMethodArray(ets_class cls, ets_method method_id, ets_value *args) + { + return native_interface->CallStaticIntMethodArray(this, cls, method_id, args); + } + ets_long CallStaticLongMethod(ets_class cls, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_long res = native_interface->CallStaticLongMethodList(this, cls, method_id, args); + va_end(args); + return res; + } + ets_long CallStaticLongMethodList(ets_class cls, ets_method method_id, va_list args) + { + return native_interface->CallStaticLongMethodList(this, cls, method_id, args); + } + ets_long CallStaticLongMethodArray(ets_class cls, ets_method method_id, ets_value *args) + { + return native_interface->CallStaticLongMethodArray(this, cls, method_id, args); + } + ets_float CallStaticFloatMethod(ets_class cls, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_float res = native_interface->CallStaticFloatMethodList(this, cls, method_id, args); + va_end(args); + return res; + } + ets_float CallStaticFloatMethodList(ets_class cls, ets_method method_id, va_list args) + { + return native_interface->CallStaticFloatMethodList(this, cls, method_id, args); + } + ets_float CallStaticFloatMethodArray(ets_class cls, ets_method method_id, ets_value *args) + { + return native_interface->CallStaticFloatMethodArray(this, cls, method_id, args); + } + ets_double CallStaticDoubleMethod(ets_class cls, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_double res = native_interface->CallStaticDoubleMethodList(this, cls, method_id, args); + va_end(args); + return res; + } + ets_double CallStaticDoubleMethodList(ets_class cls, ets_method method_id, va_list args) + { + return native_interface->CallStaticDoubleMethodList(this, cls, method_id, args); + } + ets_double CallStaticDoubleMethodArray(ets_class cls, ets_method method_id, ets_value *args) + { + return native_interface->CallStaticDoubleMethodArray(this, cls, method_id, args); + } + void CallStaticVoidMethod(ets_class cls, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + native_interface->CallStaticVoidMethodList(this, cls, method_id, args); + va_end(args); + } + void CallStaticVoidMethodList(ets_class cls, ets_method method_id, va_list args) + { + native_interface->CallStaticVoidMethodList(this, cls, method_id, args); + } + void CallStaticVoidMethodArray(ets_class cls, ets_method method_id, ets_value *args) + { + native_interface->CallStaticVoidMethodArray(this, cls, method_id, args); + } + ets_field GetStaticp_field(ets_class cls, const char *name, const char *sig) + { + return native_interface->GetStaticp_field(this, cls, name, sig); + } + ets_object GetStaticObjectField(ets_class cls, ets_field p_field) + { + return native_interface->GetStaticObjectField(this, cls, p_field); + } + ets_boolean GetStaticBooleanField(ets_class cls, ets_field p_field) + { + return native_interface->GetStaticBooleanField(this, cls, p_field); + } + ets_byte GetStaticByteField(ets_class cls, ets_field p_field) + { + return native_interface->GetStaticByteField(this, cls, p_field); + } + ets_char GetStaticCharField(ets_class cls, ets_field p_field) + { + return native_interface->GetStaticCharField(this, cls, p_field); + } + ets_short GetStaticShortField(ets_class cls, ets_field p_field) + { + return native_interface->GetStaticShortField(this, cls, p_field); + } + ets_int GetStaticIntField(ets_class cls, ets_field p_field) + { + return native_interface->GetStaticIntField(this, cls, p_field); + } + ets_long GetStaticLongField(ets_class cls, ets_field p_field) + { + return native_interface->GetStaticLongField(this, cls, p_field); + } + ets_float GetStaticFloatField(ets_class cls, ets_field p_field) + { + return native_interface->GetStaticFloatField(this, cls, p_field); + } + ets_double GetStaticDoubleField(ets_class cls, ets_field p_field) + { + return native_interface->GetStaticDoubleField(this, cls, p_field); + } + void SetStaticObjectField(ets_class cls, ets_field p_field, ets_object value) + { + return native_interface->SetStaticObjectField(this, cls, p_field, value); + } + void SetStaticBooleanField(ets_class cls, ets_field p_field, ets_boolean value) + { + return native_interface->SetStaticBooleanField(this, cls, p_field, value); + } + void SetStaticByteField(ets_class cls, ets_field p_field, ets_byte value) + { + return native_interface->SetStaticByteField(this, cls, p_field, value); + } + void SetStaticCharField(ets_class cls, ets_field p_field, ets_char value) + { + return native_interface->SetStaticCharField(this, cls, p_field, value); + } + void SetStaticShortField(ets_class cls, ets_field p_field, ets_short value) + { + return native_interface->SetStaticShortField(this, cls, p_field, value); + } + void SetStaticIntField(ets_class cls, ets_field p_field, ets_int value) + { + return native_interface->SetStaticIntField(this, cls, p_field, value); + } + void SetStaticLongField(ets_class cls, ets_field p_field, ets_long value) + { + return native_interface->SetStaticLongField(this, cls, p_field, value); + } + void SetStaticFloatField(ets_class cls, ets_field p_field, ets_float value) + { + return native_interface->SetStaticFloatField(this, cls, p_field, value); + } + void SetStaticDoubleField(ets_class cls, ets_field p_field, ets_double value) + { + return native_interface->SetStaticDoubleField(this, cls, p_field, value); + } + ets_string NewString(const ets_char *unicode_chars, ets_size len) + { + return native_interface->NewString(this, unicode_chars, len); + } + ets_size GetStringLength(ets_string string) + { + return native_interface->GetStringLength(this, string); + } + const ets_char *GetStringChars(ets_string string, ets_boolean *is_copy) + { + return native_interface->GetStringChars(this, string, is_copy); + } + void ReleaseStringChars(ets_string string, const ets_char *chars) + { + native_interface->ReleaseStringChars(this, string, chars); + } + ets_string NewStringUTF(const char *bytes) + { + return native_interface->NewStringUTF(this, bytes); + } + ets_size GetStringUTFLength(ets_string string) + { + return native_interface->GetStringUTFLength(this, string); + } + const char *GetStringUTFChars(ets_string string, ets_boolean *is_copy) + { + return native_interface->GetStringUTFChars(this, string, is_copy); + } + void ReleaseStringUTFChars(ets_string string, const char *chars) + { + native_interface->ReleaseStringUTFChars(this, string, chars); + } + ets_size GetArrayLength(ets_array array) + { + return native_interface->GetArrayLength(this, array); + } + ets_objectArray NewObjectsArray(ets_size length, ets_class element_class, ets_object initial_element) + { + return native_interface->NewObjectsArray(this, length, element_class, initial_element); + } + ets_object GetObjectArrayElement(ets_objectArray array, ets_size index) + { + return native_interface->GetObjectArrayElement(this, array, index); + } + + void SetObjectArrayElement(ets_objectArray array, ets_size index, ets_object value) + { + native_interface->SetObjectArrayElement(this, array, index, value); + } + + // SetObjectArrayElement, + ets_booleanArray NewBooleanArray(ets_size length) + { + return native_interface->NewBooleanArray(this, length); + } + ets_byteArray NewByteArray(ets_size length) + { + return native_interface->NewByteArray(this, length); + } + ets_charArray NewCharArray(ets_size length) + { + return native_interface->NewCharArray(this, length); + } + ets_shortArray NewShortArray(ets_size length) + { + return native_interface->NewShortArray(this, length); + } + ets_intArray NewIntArray(ets_size length) + { + return native_interface->NewIntArray(this, length); + } + ets_longArray NewLongArray(ets_size length) + { + return native_interface->NewLongArray(this, length); + } + ets_floatArray NewFloatArray(ets_size length) + { + return native_interface->NewFloatArray(this, length); + } + ets_doubleArray NewDoubleArray(ets_size length) + { + return native_interface->NewDoubleArray(this, length); + } + ets_boolean *PinBooleanArray(ets_booleanArray array) + { + return native_interface->PinBooleanArray(this, array); + } + ets_byte *PinByteArray(ets_byteArray array) + { + return native_interface->PinByteArray(this, array); + } + ets_char *PinCharArray(ets_charArray array) + { + return native_interface->PinCharArray(this, array); + } + ets_short *PinShortArray(ets_shortArray array) + { + return native_interface->PinShortArray(this, array); + } + ets_int *PinIntArray(ets_intArray array) + { + return native_interface->PinIntArray(this, array); + } + ets_long *PinLongArray(ets_longArray array) + { + return native_interface->PinLongArray(this, array); + } + ets_float *PinFloatArray(ets_floatArray array) + { + return native_interface->PinFloatArray(this, array); + } + ets_double *PinDoubleArray(ets_doubleArray array) + { + return native_interface->PinDoubleArray(this, array); + } + void UnpinBooleanArray(ets_booleanArray array) + { + return native_interface->UnpinBooleanArray(this, array); + } + void UnpinByteArray(ets_byteArray array) + { + return native_interface->UnpinByteArray(this, array); + } + void UnpinCharArray(ets_charArray array) + { + return native_interface->UnpinCharArray(this, array); + } + void UnpinShortArray(ets_shortArray array) + { + return native_interface->UnpinShortArray(this, array); + } + void UnpinIntArray(ets_intArray array) + { + return native_interface->UnpinIntArray(this, array); + } + void UnpinLongArray(ets_longArray array) + { + return native_interface->UnpinLongArray(this, array); + } + void UnpinFloatArray(ets_floatArray array) + { + return native_interface->UnpinFloatArray(this, array); + } + void UnpinDoubleArray(ets_doubleArray array) + { + return native_interface->UnpinDoubleArray(this, array); + } + void GetBooleanArrayRegion(ets_booleanArray array, ets_size start, ets_size len, ets_boolean *buf) + { + return native_interface->GetBooleanArrayRegion(this, array, start, len, buf); + } + void GetByteArrayRegion(ets_byteArray array, ets_size start, ets_size len, ets_byte *buf) + { + return native_interface->GetByteArrayRegion(this, array, start, len, buf); + } + void GetCharArrayRegion(ets_charArray array, ets_size start, ets_size len, ets_char *buf) + { + return native_interface->GetCharArrayRegion(this, array, start, len, buf); + } + void GetShortArrayRegion(ets_shortArray array, ets_size start, ets_size len, ets_short *buf) + { + return native_interface->GetShortArrayRegion(this, array, start, len, buf); + } + void GetIntArrayRegion(ets_intArray array, ets_size start, ets_size len, ets_int *buf) + { + return native_interface->GetIntArrayRegion(this, array, start, len, buf); + } + void GetLongArrayRegion(ets_longArray array, ets_size start, ets_size len, ets_long *buf) + { + return native_interface->GetLongArrayRegion(this, array, start, len, buf); + } + void GetFloatArrayRegion(ets_floatArray array, ets_size start, ets_size len, ets_float *buf) + { + return native_interface->GetFloatArrayRegion(this, array, start, len, buf); + } + void GetDoubleArrayRegion(ets_doubleArray array, ets_size start, ets_size len, ets_double *buf) + { + return native_interface->GetDoubleArrayRegion(this, array, start, len, buf); + } + void SetBooleanArrayRegion(ets_booleanArray array, ets_size start, ets_size length, const ets_boolean *buf) + { + native_interface->SetBooleanArrayRegion(this, array, start, length, buf); + } + void SetByteArrayRegion(ets_byteArray array, ets_size start, ets_size length, const ets_byte *buf) + { + native_interface->SetByteArrayRegion(this, array, start, length, buf); + } + void SetCharArrayRegion(ets_charArray array, ets_size start, ets_size length, const ets_char *buf) + { + native_interface->SetCharArrayRegion(this, array, start, length, buf); + } + void SetShortArrayRegion(ets_shortArray array, ets_size start, ets_size length, const ets_short *buf) + { + native_interface->SetShortArrayRegion(this, array, start, length, buf); + } + void SetIntArrayRegion(ets_intArray array, ets_size start, ets_size length, const ets_int *buf) + { + native_interface->SetIntArrayRegion(this, array, start, length, buf); + } + void SetLongArrayRegion(ets_longArray array, ets_size start, ets_size length, const ets_long *buf) + { + native_interface->SetLongArrayRegion(this, array, start, length, buf); + } + void SetFloatArrayRegion(ets_floatArray array, ets_size start, ets_size length, const ets_float *buf) + { + native_interface->SetFloatArrayRegion(this, array, start, length, buf); + } + void SetDoubleArrayRegion(ets_doubleArray array, ets_size start, ets_size length, const ets_double *buf) + { + native_interface->SetDoubleArrayRegion(this, array, start, length, buf); + } + ets_int RegisterNatives(ets_class cls, const EtsNativeMethod *methods, ets_int nMethods) + { + return native_interface->RegisterNatives(this, cls, methods, nMethods); + } + ets_int UnregisterNatives(ets_class cls) + { + return native_interface->UnregisterNatives(this, cls); + } + ets_int GetEtsVM(EtsVM **vm) + { + return native_interface->GetEtsVM(this, vm); + } + void GetStringRegion(ets_string str, ets_size start, ets_size len, ets_char *buf) + { + native_interface->GetStringRegion(this, str, start, len, buf); + } + void GetStringUTFRegion(ets_string str, ets_size start, ets_size len, char *buf) + { + native_interface->GetStringUTFRegion(this, str, start, len, buf); + } + ets_weak NewWeakGlobalRef(ets_object obj) + { + return native_interface->NewWeakGlobalRef(this, obj); + } + void DeleteWeakGlobalRef(ets_weak obj) + { + native_interface->DeleteWeakGlobalRef(this, obj); + } + ets_boolean ErrorCheck() + { + return native_interface->ErrorCheck(this); + } + // NewDirectByteBuffer, + // GetDirectBufferAddress, + // GetDirectBufferCapacity, + ets_objectRefType GetObjectRefType(ets_object obj) + { + return native_interface->GetObjectRefType(this, obj); + } + + // Promise + ets_status PromiseCreate(ets_deferred *deferred, ets_object *promise) + { + return native_interface->PromiseCreate(this, deferred, promise); + } + ets_status DeferredResolve(ets_deferred deferred, ets_object resolution) + { + return native_interface->DeferredResolve(this, deferred, resolution); + } + ets_status DeferredReject(ets_deferred deferred, ets_object rejection) + { + return native_interface->DeferredReject(this, deferred, rejection); + } +#endif +}; + +// NOLINTEND(modernize-use-using, readability-identifier-naming, cppcoreguidelines-pro-type-vararg) + +#endif // PANDA_RUNTIME_INTEROP_ETS_NAPI_H diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/interop-logging.cc b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/interop-logging.cc new file mode 100644 index 0000000000000000000000000000000000000000..1b128eb0b2c3f75461103d5815b2dcc292347718 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/interop-logging.cc @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include +#include + +#include "interop-logging.h" + +namespace { + +struct Log { + std::string log; + bool isActive = true; +}; + +std::vector groupedLogs; + +void startGroupedLog(int index) { + if (index >= (int)groupedLogs.size()) { + groupedLogs.resize(index + 1); + for (int i = 0; i <= index; i++) { + if (!groupedLogs[i]) groupedLogs[i] = new Log(); + } + } + groupedLogs[index]->isActive = true; + groupedLogs[index]->log.clear(); +} + +void stopGroupedLog(int index) { + if (index < (int)groupedLogs.size()) { + groupedLogs[index]->isActive = false; + } +} + +void appendGroupedLog(int index, const char* str) { + if (index < (int)groupedLogs.size()) { + groupedLogs[index]->log.append(str); + } +} + +const char* getGroupedLog(int index) { + if (index < (int)groupedLogs.size()) { + auto result = groupedLogs[index]->log.c_str(); + return result; + } + return ""; +} + +int needGroupedLog(int index) { + if (index < (int)groupedLogs.size()) { + return groupedLogs[index]->isActive; + } + return 0; +} + +const GroupLogger defaultInstance = { + startGroupedLog, + stopGroupedLog, + appendGroupedLog, + getGroupedLog, + needGroupedLog, +}; + +} // namespace + +const GroupLogger* GetDefaultLogger() { + return &defaultInstance; +} + +extern "C" [[noreturn]] void InteropLogFatal(const char* format, ...) { + va_list args; + va_start(args, format); + char buffer[4096]; + vsnprintf(buffer, sizeof(buffer) - 1, format, args); + LOGE("FATAL: %s", buffer); + va_end(args); + abort(); +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/interop-logging.h b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/interop-logging.h new file mode 100644 index 0000000000000000000000000000000000000000..e8d6bbb2d4ebaff5e1ad6fb9481efae30befeb92 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/interop-logging.h @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef _INTEROP_LGGING_H +#define _INTEROP_LGGING_H + +#include +#include + +#if defined(KOALA_OHOS) +#include "oh_sk_log.h" +#define LOG(msg) OH_SK_LOG_INFO(msg); +#define LOGI(msg, ...) OH_SK_LOG_INFO_A(msg, ##__VA_ARGS__); +#define LOGE(msg, ...) OH_SK_LOG_ERROR_A(msg, ##__VA_ARGS__); +#define LOG_PUBLIC "{public}" +#else +#define LOG(msg) fprintf(stdout, msg "\n"); +#define LOGI(msg, ...) fprintf(stdout, msg "\n", ##__VA_ARGS__); +#define LOGE(msg, ...) fprintf(stderr, msg "\n", ##__VA_ARGS__); +#define LOG_PUBLIC "" +#endif + +#if defined(KOALA_WINDOWS) +#define INTEROP_API_EXPORT __declspec(dllexport) +#else +#define INTEROP_API_EXPORT __attribute__((visibility("default"))) +#endif + +// Grouped logs. Keep consistent with type in ServiceGroupLogger +typedef struct GroupLogger { + void (*startGroupedLog)(int kind); + void (*stopGroupedLog)(int kind); + void (*appendGroupedLog)(int kind, const char* str); + const char* (*getGroupedLog)(int kind); + int (*needGroupedLog)(int kind); +} GroupLogger; + +extern "C" INTEROP_API_EXPORT const GroupLogger* GetDefaultLogger(); + +#endif // _INTEROP_LOGGING_H \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/interop-types.h b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/interop-types.h new file mode 100644 index 0000000000000000000000000000000000000000..7efb52ea64241e538fbd74d0874d02a9405004d7 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/interop-types.h @@ -0,0 +1,168 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _INTEROP_TYPES_H_ +#define _INTEROP_TYPES_H_ + +#include +#ifdef __cplusplus +extern "C" [[noreturn]] +#endif +void InteropLogFatal(const char* format, ...); +#define INTEROP_FATAL(msg, ...) do { InteropLogFatal(msg, ##__VA_ARGS__); } while (0) + +typedef enum InteropTag +{ + INTEROP_TAG_UNDEFINED = 101, + INTEROP_TAG_INT32 = 102, + INTEROP_TAG_FLOAT32 = 103, + INTEROP_TAG_STRING = 104, + INTEROP_TAG_LENGTH = 105, + INTEROP_TAG_RESOURCE = 106, + INTEROP_TAG_OBJECT = 107, +} InteropTag; + +typedef enum InteropRuntimeType +{ + INTEROP_RUNTIME_UNEXPECTED = -1, + INTEROP_RUNTIME_NUMBER = 1, + INTEROP_RUNTIME_STRING = 2, + INTEROP_RUNTIME_OBJECT = 3, + INTEROP_RUNTIME_BOOLEAN = 4, + INTEROP_RUNTIME_UNDEFINED = 5, + INTEROP_RUNTIME_BIGINT = 6, + INTEROP_RUNTIME_FUNCTION = 7, + INTEROP_RUNTIME_SYMBOL = 8, + INTEROP_RUNTIME_MATERIALIZED = 9, +} InteropRuntimeType; + +typedef float InteropFloat32; +typedef double InteropFloat64; +typedef int32_t InteropInt32; +typedef unsigned int InteropUInt32; // TODO: update unsigned int +typedef int64_t InteropInt64; +typedef uint64_t InteropUInt64; +typedef int8_t InteropInt8; +typedef uint8_t InteropUInt8; +typedef int64_t InteropDate; +typedef int8_t InteropBoolean; +typedef const char* InteropCharPtr; +typedef void* InteropNativePointer; + +struct _InteropVMContext; +typedef struct _InteropVMContext* InteropVMContext; +struct _InteropPipelineContext; +typedef struct _InteropPipelineContext* InteropPipelineContext; +struct _InteropVMObject; +typedef struct _InteropVMObject* InteropVMObject; +struct _InteropNode; +typedef struct _InteropNode* InteropNodeHandle; +typedef struct InteropDeferred { + void* handler; + void* context; + void (*resolve)(struct InteropDeferred* thiz, uint8_t* data, int32_t length); + void (*reject)(struct InteropDeferred* thiz, const char* message); +} InteropDeferred; + +// Binary layout of InteropString must match that of KStringPtrImpl. +typedef struct InteropString { + const char* chars; + InteropInt32 length; +} InteropString; + +typedef struct InteropEmpty { + InteropInt32 dummy; // Empty structs are forbidden in C. +} InteropEmpty; + +typedef struct InteropNumber { + InteropInt8 tag; + union { + InteropFloat32 f32; + InteropInt32 i32; + }; +} InteropNumber; + +// Binary layout of InteropLength must match that of KLength. +typedef struct InteropLength +{ + InteropInt8 type; + InteropFloat32 value; + InteropInt32 unit; + InteropInt32 resource; +} InteropLength; + +typedef struct InteropCustomObject { + char kind[20]; + InteropInt32 id; + // Data of custom object. + union { + InteropInt32 ints[4]; + InteropFloat32 floats[4]; + void* pointers[4]; + InteropString string; + }; +} InteropCustomObject; + +typedef struct InteropUndefined { + InteropInt32 dummy; // Empty structs are forbidden in C. +} InteropUndefined; + +typedef struct InteropVoid { + InteropInt32 dummy; // Empty structs are forbidden in C. +} InteropVoid; + +typedef struct InteropFunction { + InteropInt32 id; +} InteropFunction; +typedef InteropFunction InteropCallback; +typedef InteropFunction InteropErrorCallback; + +typedef struct InteropMaterialized { + InteropNativePointer ptr; +} InteropMaterialized; + +typedef struct InteropCallbackResource { + InteropInt32 resourceId; + void (*hold)(InteropInt32 resourceId); + void (*release)(InteropInt32 resourceId); +} InteropCallbackResource; + +typedef struct InteropBuffer { + InteropCallbackResource resource; + InteropNativePointer data; + InteropInt64 length; +} InteropBuffer; + +typedef struct InteropAsyncWork { + InteropNativePointer workId; + void (*queue)(InteropNativePointer workId); + void (*cancel)(InteropNativePointer workId); +} InteropAsyncWork; + +typedef struct InteropAsyncWorker { + InteropAsyncWork (*createWork)( + InteropVMContext context, + InteropNativePointer handle, + void (*execute)(InteropNativePointer handle), + void (*complete)(InteropNativePointer handle) + ); +} InteropAsyncWorker; +typedef const InteropAsyncWorker* InteropAsyncWorkerPtr; + +typedef struct InteropObject { + InteropCallbackResource resource; +} InteropObject; + +#endif // _INTEROP_TYPES_H_ diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/jni/convertors-jni.cc b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/jni/convertors-jni.cc new file mode 100644 index 0000000000000000000000000000000000000000..683625b09e9e7cac39905f70d84ee8f2c7ddbd45 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/jni/convertors-jni.cc @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#define KOALA_INTEROP_MODULE +#include "convertors-jni.h" +#include "signatures.h" +#include "interop-logging.h" +#include "interop-types.h" + +static const char* nativeModule = "org/koalaui/arkoala/InteropNativeModule"; +static const char* nativeModulePrefix = "org/koalaui/arkoala/"; +static const char* callCallbackFromNative = "callCallbackFromNative"; +static const char* callCallbackFromNativeSig = "(I[BI)I"; + +const bool registerByOne = true; + +static bool registerNatives(JNIEnv *env, jclass clazz, const std::vector> impls) { + size_t numMethods = impls.size(); + JNINativeMethod *methods = new JNINativeMethod[numMethods]; + bool result = true; + for (size_t i = 0; i < numMethods; i++) + { + methods[i].name = (char *)std::get<0>(impls[i]).c_str(); + methods[i].signature = (char *)std::get<1>(impls[i]).c_str(); + methods[i].fnPtr = std::get<2>(impls[i]); + if (registerByOne) { + result &= (env->RegisterNatives(clazz, methods + i, 1) >= 0); + if (env->ExceptionCheck()) { + env->ExceptionDescribe(); + env->ExceptionClear(); + result = false; + } + } + } + return registerByOne ? true : env->RegisterNatives(clazz, methods, numMethods) >= 0; +} + +constexpr bool splitPerModule = true; + +JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) { + JNIEnv *env; + if (vm->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_8) != JNI_OK) { + return JNI_ERR; + } + auto modules = JniExports::getInstance()->getModules(); + jclass defaultNativeModule = env->FindClass(nativeModule); + for (auto it = modules.begin(); it != modules.end(); ++it) { + std::string className = std::string(nativeModulePrefix) + *it; + jclass nativeModule = + (!splitPerModule) ? defaultNativeModule : env->FindClass(className.c_str()); + if (nativeModule == nullptr) { + LOGE("Cannot find managed class %s", className.c_str()); + continue; + } + registerNatives(env, nativeModule, JniExports::getInstance()->getMethods(*it)); + } + if (!setKoalaJniCallbackDispatcher(env, defaultNativeModule, callCallbackFromNative, callCallbackFromNativeSig)) return JNI_ERR; + return JNI_VERSION_1_8; +} + +JniExports *JniExports::getInstance() +{ + static JniExports *instance = nullptr; + if (instance == nullptr) + { + instance = new JniExports(); + } + return instance; +} + +std::vector JniExports::getModules() { + std::vector result; + for (auto it = implementations.begin(); it != implementations.end(); ++it) { + result.push_back(it->first); + } + return result; +} + +const std::vector>& JniExports::getMethods(const std::string& module) { + auto it = implementations.find(module); + if (it == implementations.end()) { + LOGE("Module %s is not registered", module.c_str()); + INTEROP_FATAL("Fatal error: not registered module %s", module.c_str()); + } + return it->second; +} + +void JniExports::addMethod(const char* module, const char *name, const char *type, void *impl) { + auto it = implementations.find(module); + if (it == implementations.end()) { + it = implementations.insert(std::make_pair(module, std::vector>())).first; + } + it->second.push_back(std::make_tuple(name, convertType(name, type), impl)); +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/jni/convertors-jni.h b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/jni/convertors-jni.h new file mode 100644 index 0000000000000000000000000000000000000000..58a02c99e15e09add347da8ee961eca0828c3f68 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/jni/convertors-jni.h @@ -0,0 +1,1540 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#ifdef KOALA_JNI + +#include +#include + +#include +#include +#include +#include +#include + +#include "koala-types.h" + +#define KOALA_JNI_CALL(type) extern "C" JNIEXPORT type JNICALL + +class JniExports { + std::unordered_map>> implementations; + +public: + static JniExports* getInstance(); + + std::vector getModules(); + void addMethod(const char* module, const char* name, const char* type, void* impl); + const std::vector>& getMethods(const std::string& module); +}; + +#define KOALA_QUOTE0(x) #x +#define KOALA_QUOTE(x) KOALA_QUOTE0(x) + +#ifdef _MSC_VER +#define MAKE_JNI_EXPORT(module, name, type) \ + static void __init_##name() { \ + JniExports::getInstance()->addMethod(KOALA_QUOTE(module), "_"#name, type, reinterpret_cast(Java_org_##name)); \ + } \ + namespace { \ + struct __Init_##name { \ + __Init_##name() { __init_##name(); } \ + } __Init_##name##_v; \ + } +#else +#define MAKE_JNI_EXPORT(module, name, type) \ + __attribute__((constructor)) \ + static void __init_jni_##name() { \ + JniExports::getInstance()->addMethod(KOALA_QUOTE(module), "_"#name, type, reinterpret_cast(Java_org_##name)); \ + } +#endif + +template +struct InteropTypeConverter { + using InteropType = T; + static T convertFrom(JNIEnv* env, InteropType value) { return value; } + static InteropType convertTo(JNIEnv* env, T value) { return value; } + static void release(JNIEnv* env, InteropType value, T converted) {} +}; + +template +struct SlowInteropTypeConverter { + using InteropType = T; + static inline T convertFrom(JNIEnv* env, InteropType value) { return value; } + static inline InteropType convertTo(JNIEnv* env, T value) { return value; } + static void release(JNIEnv* env, InteropType value, T converted) {} +}; + +template<> +struct InteropTypeConverter { + using InteropType = jstring; + static inline KStringPtr convertFrom0(JNIEnv* env, InteropType value) { + if (value == nullptr) return KStringPtr(); + jboolean isCopy; + // TODO: use GetStringCritical() instead and utf-8 encode manually. + const char* str_value = env->GetStringUTFChars(value, &isCopy); + int len = env->GetStringUTFLength(value); + KStringPtr result(str_value, len, false); + return result; + } + static KStringPtr convertFrom(JNIEnv* env, InteropType value) { + if (value == nullptr) return KStringPtr(); + KStringPtr result; + // Notice that we use UTF length for buffer size, but counter is expressed in number of Unicode chars. + result.resize( env->GetStringUTFLength(value)); + env->GetStringUTFRegion(value, 0, env->GetStringLength(value), result.data()); + return result; + } + static InteropType convertTo(JNIEnv* env, KStringPtr value) { + return env->NewStringUTF(value.c_str()); + } + static inline void release(JNIEnv* env, InteropType value, const KStringPtr& converted) { + } +}; + +template<> +struct SlowInteropTypeConverter { + using InteropType = jobject; + static inline KVMObjectHandle convertFrom(JNIEnv* env, InteropType value) { + return reinterpret_cast(value); + } + static InteropType convertTo(JNIEnv* env, KVMObjectHandle value) { + return reinterpret_cast(value); + } + static inline void release(JNIEnv* env, InteropType value, KVMObjectHandle converted) { + } +}; + +template<> +struct SlowInteropTypeConverter { + using InteropType = jstring; + static inline KStringPtr convertFrom(JNIEnv* env, InteropType value) { + if (value == nullptr) return KStringPtr(); + jboolean isCopy; + const char* str_value = env->GetStringUTFChars(value, &isCopy); + int len = env->GetStringLength(value); + KStringPtr result(str_value, len, false); + return result; + } + static InteropType convertTo(JNIEnv* env, KStringPtr value) { + return env->NewStringUTF(value.c_str()); + } + static inline void release(JNIEnv* env, InteropType value, const KStringPtr& converted) { + env->ReleaseStringUTFChars(value, converted.data()); + } +}; + +template<> +struct SlowInteropTypeConverter { + using InteropType = jarray; + static inline KInteropBuffer convertFrom(JNIEnv* env, InteropType value) { + if (value == nullptr) return KInteropBuffer(); + KInteropBuffer result({env->GetArrayLength(value), reinterpret_cast(env->GetPrimitiveArrayCritical(value, nullptr))}); + return result; + } + static InteropType convertTo(JNIEnv* env, KInteropBuffer value) { + jarray result = env->NewByteArray(value.length); + void* data = env->GetPrimitiveArrayCritical(result, nullptr); + memcpy(data, value.data, value.length); + env->ReleasePrimitiveArrayCritical(result, data, 0); + return result; + } + static inline void release(JNIEnv* env, InteropType value, const KInteropBuffer& converted) { + env->ReleasePrimitiveArrayCritical(value, converted.data, 0); + } +}; + +template<> +struct SlowInteropTypeConverter { + using InteropType = jarray; + static inline KInteropReturnBuffer convertFrom(JNIEnv* env, InteropType value) = delete; + static InteropType convertTo(JNIEnv* env, KInteropReturnBuffer value) { + jarray result = env->NewByteArray(value.length); + void* data = env->GetPrimitiveArrayCritical(result, nullptr); + memcpy(data, value.data, value.length); + env->ReleasePrimitiveArrayCritical(result, data, 0); + value.dispose(value.data, value.length); + return result; + } + static inline void release(JNIEnv* env, InteropType value, const KInteropReturnBuffer& converted) = delete; +}; + +template<> +struct InteropTypeConverter { + using InteropType = jbyteArray; + static inline KByte* convertFrom(JNIEnv* env, InteropType value) { + return value ? reinterpret_cast(env->GetPrimitiveArrayCritical(value, nullptr)) : nullptr; + } + static InteropType convertTo(JNIEnv* env, KByte* value) = delete; + static inline void release(JNIEnv* env, InteropType value, KByte* converted) { + if (converted) env->ReleasePrimitiveArrayCritical(value, converted, 0); + } +}; + +template<> +struct SlowInteropTypeConverter { + using InteropType = jbyteArray; + static inline KByte* convertFrom(JNIEnv* env, InteropType value) { + return value ? reinterpret_cast(env->GetByteArrayElements(value, nullptr)) : nullptr; + } + static InteropType convertTo(JNIEnv* env, KByte* value) = delete; + static inline void release(JNIEnv* env, InteropType value, KByte* converted) { + if (converted) env->ReleaseByteArrayElements(value, reinterpret_cast(converted), 0); + } +}; + +template<> +struct InteropTypeConverter { + using InteropType = jintArray; + static KInt* convertFrom(JNIEnv* env, InteropType value) { + return value ? reinterpret_cast(env->GetPrimitiveArrayCritical(value, nullptr)) : nullptr; + } + static InteropType convertTo(JNIEnv* env, KInt* value) = delete; + static void release(JNIEnv* env, InteropType value, KInt* converted) { + env->ReleasePrimitiveArrayCritical(value, converted, 0); + } +}; + +template<> +struct SlowInteropTypeConverter { + using InteropType = jintArray; + static KInt* convertFrom(JNIEnv* env, InteropType value) { + return value ? reinterpret_cast(env->GetIntArrayElements(value, nullptr)) : nullptr; + } + static InteropType convertTo(JNIEnv* env, KInt* value) = delete; + static void release(JNIEnv* env, InteropType value, KInt* converted) { + env->ReleaseIntArrayElements(value, reinterpret_cast(converted), 0); + } +}; + +template<> +struct InteropTypeConverter { + using InteropType = jfloatArray; + static KFloat* convertFrom(JNIEnv* env, InteropType value) { + return value ? reinterpret_cast(env->GetPrimitiveArrayCritical(value, nullptr)) : nullptr; + } + static InteropType convertTo(JNIEnv* env, KFloat* value) = delete; + static void release(JNIEnv* env, InteropType value, KFloat* converted) { + env->ReleasePrimitiveArrayCritical(value, converted, 0); + } +}; + +template<> +struct SlowInteropTypeConverter { + using InteropType = jfloatArray; + static KFloat* convertFrom(JNIEnv* env, InteropType value) { + return value ? reinterpret_cast(env->GetFloatArrayElements(value, nullptr)) : nullptr; + } + static InteropType convertTo(JNIEnv* env, KFloat* value) = delete; + static void release(JNIEnv* env, InteropType value, KFloat* converted) { + env->ReleaseFloatArrayElements(value, reinterpret_cast(converted), 0); + } +}; + +template<> +struct InteropTypeConverter { + using InteropType = jlong; + static KNativePointer convertFrom(JNIEnv* env, InteropType value) { + return reinterpret_cast(value); + } + static InteropType convertTo(JNIEnv* env, KNativePointer value) { + return reinterpret_cast(value); + } + static inline void release(JNIEnv* env, InteropType value, KNativePointer converted) {} +}; + +template<> +struct SlowInteropTypeConverter { + using InteropType = jlong; + static KNativePointer convertFrom(JNIEnv* env, InteropType value) { + return reinterpret_cast(value); + } + static InteropType convertTo(JNIEnv* env, KNativePointer value) { + return reinterpret_cast(value); + } + static void release(JNIEnv* env, InteropType value, KNativePointer converted) {} +}; + +template<> +struct InteropTypeConverter { + using InteropType = jdouble; + static KInteropNumber convertFrom(JNIEnv* env, InteropType value) { + return KInteropNumber::fromDouble(value); + } + static InteropType convertTo(JNIEnv* env, KInteropNumber value) { + return value.asDouble(); + } + static inline void release(JNIEnv* env, InteropType value, KInteropNumber converted) {} +}; + +template<> +struct SlowInteropTypeConverter { + using InteropType = jdouble; + static KInteropNumber convertFrom(JNIEnv* env, InteropType value) { + return KInteropNumber::fromDouble(value); + } + static InteropType convertTo(JNIEnv* env, KInteropNumber value) { + return value.asDouble(); + } + static void release(JNIEnv* env, InteropType value, KInteropNumber converted) {} +}; + +template<> +struct InteropTypeConverter { + using InteropType = jstring; + static KLength convertFrom(JNIEnv* env, InteropType value) { + KLength result { 0 }; + + if (value == nullptr) { + result.type = -1; // ARK_RUNTIME_UNEXPECTED + return result; + } + jboolean isCopy; + const char* str_value = env->GetStringUTFChars(value, &isCopy); + int len = env->GetStringLength(value); + KStringPtr kStr(str_value, len, false); + parseKLength(kStr, &result); + env->ReleaseStringUTFChars(value, str_value); + result.type = 2; // ARK_RUNTIME_STRING + result.resource = 0; + + return result; + } + static InteropType convertTo(JNIEnv* env, KLength value) = delete; + static inline void release(JNIEnv* env, InteropType value, KLength converted) {} +}; + +template +inline Type getArgument(JNIEnv* env, typename InteropTypeConverter::InteropType arg) { + return InteropTypeConverter::convertFrom(env, arg); +} + +template +inline void releaseArgument(JNIEnv* env, typename InteropTypeConverter::InteropType arg, Type& data) { + InteropTypeConverter::release(env, arg, data); +} + +#ifndef KOALA_INTEROP_MODULE +#error KOALA_INTEROP_MODULE is undefined +#endif + +#define KOALA_INTEROP_0(name, Ret) \ + KOALA_JNI_CALL(InteropTypeConverter::InteropType) Java_org_##name(JNIEnv* env, jclass instance) { \ + KOALA_MAYBE_LOG(name) \ + return InteropTypeConverter::convertTo(env, impl_##name()); \ + } \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret) + +#define KOALA_INTEROP_1(name, Ret, P0) \ + KOALA_JNI_CALL(InteropTypeConverter::InteropType) \ + Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + auto rv = InteropTypeConverter::convertTo(env, impl_##name(p0)); \ + releaseArgument(env, _p0, p0); \ + return rv; \ + } \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0) + +#define KOALA_INTEROP_2(name, Ret, P0, P1) \ + KOALA_JNI_CALL(InteropTypeConverter::InteropType) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + auto rv = InteropTypeConverter::convertTo(env, impl_##name(p0, p1)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + return rv; \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1) + +#define KOALA_INTEROP_3(name, Ret, P0, P1, P2) \ + KOALA_JNI_CALL(InteropTypeConverter::InteropType) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + auto rv = InteropTypeConverter::convertTo(env, impl_##name(p0, p1, p2)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + return rv; \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2) + +#define KOALA_INTEROP_4(name, Ret, P0, P1, P2, P3) \ + KOALA_JNI_CALL(InteropTypeConverter::InteropType) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + auto rv = InteropTypeConverter::convertTo(env, impl_##name(p0, p1, p2, p3)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + return rv; \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3) + +#define KOALA_INTEROP_5(name, Ret, P0, P1, P2, P3, P4) \ + KOALA_JNI_CALL(InteropTypeConverter::InteropType) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + auto rv = InteropTypeConverter::convertTo(env, impl_##name(p0, p1, p2, p3, p4)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + return rv; \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4) + +#define KOALA_INTEROP_6(name, Ret, P0, P1, P2, P3, P4, P5) \ + KOALA_JNI_CALL(InteropTypeConverter::InteropType) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + auto rv = InteropTypeConverter::convertTo(env, impl_##name(p0, p1, p2, p3, p4, p5)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + return rv; \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5) + +#define KOALA_INTEROP_7(name, Ret, P0, P1, P2, P3, P4, P5, P6) \ + KOALA_JNI_CALL(InteropTypeConverter::InteropType) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + auto rv = InteropTypeConverter::convertTo(env, impl_##name(p0, p1, p2, p3, p4, p5, p6)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + return rv; \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6) + +#define KOALA_INTEROP_8(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7) \ + KOALA_JNI_CALL(InteropTypeConverter::InteropType) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + auto rv = InteropTypeConverter::convertTo(env, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + return rv; \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7) + +#define KOALA_INTEROP_9(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8) \ + KOALA_JNI_CALL(InteropTypeConverter::InteropType) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + auto rv = InteropTypeConverter::convertTo(env, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + return rv; \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8) + +#define KOALA_INTEROP_10(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) \ + KOALA_JNI_CALL(InteropTypeConverter::InteropType) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + auto rv = InteropTypeConverter::convertTo(env, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + return rv; \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9) + +#define KOALA_INTEROP_11(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) \ + KOALA_JNI_CALL(InteropTypeConverter::InteropType) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + auto rv = InteropTypeConverter::convertTo(env, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + return rv; \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10) + +#define KOALA_INTEROP_12(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11) \ + KOALA_JNI_CALL(InteropTypeConverter::InteropType) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + P11 p11 = getArgument(env, _p11); \ + auto rv = InteropTypeConverter::convertTo(env, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + releaseArgument(env, _p11, p11); \ + return rv; \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10 "|" #P11) + +#define KOALA_INTEROP_13(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12) \ + KOALA_JNI_CALL(InteropTypeConverter::InteropType) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11, \ + InteropTypeConverter::InteropType _p12) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + P11 p11 = getArgument(env, _p11); \ + P12 p12 = getArgument(env, _p12); \ + auto rv = InteropTypeConverter::convertTo(env, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + releaseArgument(env, _p11, p11); \ + releaseArgument(env, _p12, p12); \ + return rv; \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9"|" #P10 "|" #P11 "|" #P12) + +#define KOALA_INTEROP_14(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13) \ + KOALA_JNI_CALL(InteropTypeConverter::InteropType) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11, \ + InteropTypeConverter::InteropType _p12, \ + InteropTypeConverter::InteropType _p13) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + P11 p11 = getArgument(env, _p11); \ + P12 p12 = getArgument(env, _p12); \ + P13 p13 = getArgument(env, _p13); \ + auto rv = InteropTypeConverter::convertTo(env, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + releaseArgument(env, _p11, p11); \ + releaseArgument(env, _p12, p12); \ + releaseArgument(env, _p13, p13); \ + return rv; \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9"|" #P10 "|" #P11 "|" #P12 "|" #P13) + + +#define KOALA_INTEROP_V0(name) \ + KOALA_JNI_CALL(void) Java_org_##name(JNIEnv* env, jclass instance) { \ + KOALA_MAYBE_LOG(name) \ + impl_##name(); \ + } \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, "void") + +#define KOALA_INTEROP_V1(name, P0) \ + KOALA_JNI_CALL(void) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + impl_##name(p0); \ + releaseArgument(env, _p0, p0); \ + } \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0) + +#define KOALA_INTEROP_V2(name, P0, P1) \ + KOALA_JNI_CALL(void) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + impl_##name(p0, p1); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1) + +#define KOALA_INTEROP_V3(name, P0, P1, P2) \ + KOALA_JNI_CALL(void) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + impl_##name(p0, p1, p2); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2) + +#define KOALA_INTEROP_V4(name, P0, P1, P2, P3) \ + KOALA_JNI_CALL(void) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + impl_##name(p0, p1, p2, p3); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3) + +#define KOALA_INTEROP_V5(name, P0, P1, P2, P3, P4) \ + KOALA_JNI_CALL(void) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + impl_##name(p0, p1, p2, p3, p4); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4) + +#define KOALA_INTEROP_V6(name, P0, P1, P2, P3, P4, P5) \ + KOALA_JNI_CALL(void) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + impl_##name(p0, p1, p2, p3, p4, p5); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5) + +#define KOALA_INTEROP_V7(name, P0, P1, P2, P3, P4, P5, P6) \ + KOALA_JNI_CALL(void) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6) + +#define KOALA_INTEROP_V8(name, P0, P1, P2, P3, P4, P5, P6, P7) \ + KOALA_JNI_CALL(void) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7) + +#define KOALA_INTEROP_V9(name, P0, P1, P2, P3, P4, P5, P6, P7, P8) \ + KOALA_JNI_CALL(void) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8) + +#define KOALA_INTEROP_V10(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) \ + KOALA_JNI_CALL(void) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9) + +#define KOALA_INTEROP_V11(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) \ + KOALA_JNI_CALL(void) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10) + +#define KOALA_INTEROP_V12(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11) \ + KOALA_JNI_CALL(void) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + P11 p11 = getArgument(env, _p11); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + releaseArgument(env, _p11, p11); \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10 "|" #P11) + +#define KOALA_INTEROP_V13(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12) \ + KOALA_JNI_CALL(void) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11, \ + InteropTypeConverter::InteropType _p12) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + P11 p11 = getArgument(env, _p11); \ + P12 p12 = getArgument(env, _p12); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + releaseArgument(env, _p11, p11); \ + releaseArgument(env, _p12, p12); \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10 "|" #P11 "|" #P12) + +#define KOALA_INTEROP_V14(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13) \ + KOALA_JNI_CALL(void) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11, \ + InteropTypeConverter::InteropType _p12, \ + InteropTypeConverter::InteropType _p13) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + P11 p11 = getArgument(env, _p11); \ + P12 p12 = getArgument(env, _p12); \ + P13 p13 = getArgument(env, _p13); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + releaseArgument(env, _p11, p11); \ + releaseArgument(env, _p12, p12); \ + releaseArgument(env, _p13, p13); \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10 "|" #P11 "|" #P12 "|" #P13) + +#define KOALA_INTEROP_V15(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14) \ + KOALA_JNI_CALL(void) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11, \ + InteropTypeConverter::InteropType _p12, \ + InteropTypeConverter::InteropType _p13, \ + InteropTypeConverter::InteropType _p14) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + P11 p11 = getArgument(env, _p11); \ + P12 p12 = getArgument(env, _p12); \ + P13 p13 = getArgument(env, _p13); \ + P14 p14 = getArgument(env, _p14); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + releaseArgument(env, _p11, p11); \ + releaseArgument(env, _p12, p12); \ + releaseArgument(env, _p13, p13); \ + releaseArgument(env, _p14, p14); \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10 "|" #P11 "|" #P12 "|" #P13 "|" #P14) + +#define KOALA_INTEROP_CTX_0(name, Ret) \ + KOALA_JNI_CALL(SlowInteropTypeConverter::InteropType) \ + Java_org_##name(JNIEnv* env, jclass instance) { \ + KOALA_MAYBE_LOG(name) \ + KVMContext ctx = (KVMContext)env; \ + auto rv = SlowInteropTypeConverter::convertTo(env, impl_##name(ctx)); \ + return rv; \ + } \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret) + +#define KOALA_INTEROP_CTX_1(name, Ret, P0) \ + KOALA_JNI_CALL(SlowInteropTypeConverter::InteropType) \ + Java_org_##name(JNIEnv* env, jclass instance, \ + SlowInteropTypeConverter::InteropType _p0) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + KVMContext ctx = (KVMContext)env; \ + auto rv = SlowInteropTypeConverter::convertTo(env, impl_##name(ctx, p0)); \ + releaseArgument(env, _p0, p0); \ + return rv; \ + } \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0) + +#define KOALA_INTEROP_CTX_2(name, Ret, P0, P1) \ + KOALA_JNI_CALL(SlowInteropTypeConverter::InteropType) Java_org_##name(JNIEnv* env, jclass instance, \ + SlowInteropTypeConverter::InteropType _p0, \ + SlowInteropTypeConverter::InteropType _p1) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + KVMContext ctx = (KVMContext)env; \ + auto rv = SlowInteropTypeConverter::convertTo(env, impl_##name(ctx, p0, p1)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + return rv; \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1) + +#define KOALA_INTEROP_CTX_3(name, Ret, P0, P1, P2) \ + KOALA_JNI_CALL(SlowInteropTypeConverter::InteropType) Java_org_##name(JNIEnv* env, jclass instance, \ + SlowInteropTypeConverter::InteropType _p0, \ + SlowInteropTypeConverter::InteropType _p1, \ + SlowInteropTypeConverter::InteropType _p2) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + KVMContext ctx = (KVMContext)env; \ + auto rv = SlowInteropTypeConverter::convertTo(env, impl_##name(ctx, p0, p1, p2)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + return rv; \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2) + +#define KOALA_INTEROP_CTX_4(name, Ret, P0, P1, P2, P3) \ + KOALA_JNI_CALL(SlowInteropTypeConverter::InteropType) Java_org_##name(JNIEnv* env, jclass instance, \ + SlowInteropTypeConverter::InteropType _p0, \ + SlowInteropTypeConverter::InteropType _p1, \ + SlowInteropTypeConverter::InteropType _p2, \ + SlowInteropTypeConverter::InteropType _p3) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + KVMContext ctx = (KVMContext)env; \ + auto rv = SlowInteropTypeConverter::convertTo(env, impl_##name(ctx, p0, p1, p2, p3)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + return rv; \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3) + +#define KOALA_INTEROP_CTX_5(name, Ret, P0, P1, P2, P3, P4) \ + KOALA_JNI_CALL(SlowInteropTypeConverter::InteropType) Java_org_##name(JNIEnv* env, jclass instance, \ + SlowInteropTypeConverter::InteropType _p0, \ + SlowInteropTypeConverter::InteropType _p1, \ + SlowInteropTypeConverter::InteropType _p2, \ + SlowInteropTypeConverter::InteropType _p3, \ + SlowInteropTypeConverter::InteropType _p4) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + KVMContext ctx = (KVMContext)env; \ + auto rv = SlowInteropTypeConverter::convertTo(env, impl_##name(ctx, p0, p1, p2, p3, p4)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + return rv; \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4) + +#define KOALA_INTEROP_CTX_V0(name) \ + KOALA_JNI_CALL(void) Java_org_##name(JNIEnv* env, jclass instance) { \ + KOALA_MAYBE_LOG(name) \ + KVMContext ctx = (KVMContext)env; \ + impl_##name(ctx); \ + } \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, "void") + +#define KOALA_INTEROP_CTX_V1(name, P0) \ + KOALA_JNI_CALL(void) Java_org_##name(JNIEnv* env, jclass instance, \ + SlowInteropTypeConverter::InteropType _p0) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + KVMContext ctx = (KVMContext)env; \ + impl_##name(ctx, p0); \ + releaseArgument(env, _p0, p0); \ + } \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0) + +#define KOALA_INTEROP_CTX_V2(name, P0, P1) \ + KOALA_JNI_CALL(void) Java_org_##name(JNIEnv* env, jclass instance, \ + SlowInteropTypeConverter::InteropType _p0, \ + SlowInteropTypeConverter::InteropType _p1) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + KVMContext ctx = (KVMContext)env; \ + impl_##name(ctx, p0, p1); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1) + +#define KOALA_INTEROP_CTX_V3(name, P0, P1, P2) \ + KOALA_JNI_CALL(void) Java_org_##name(JNIEnv* env, jclass instance, \ + SlowInteropTypeConverter::InteropType _p0, \ + SlowInteropTypeConverter::InteropType _p1, \ + SlowInteropTypeConverter::InteropType _p2) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + KVMContext ctx = (KVMContext)env; \ + impl_##name(ctx, p0, p1, p2); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2) + +#define KOALA_INTEROP_CTX_V4(name, P0, P1, P2, P3) \ + KOALA_JNI_CALL(void) Java_org_##name(JNIEnv* env, jclass instance, \ + SlowInteropTypeConverter::InteropType _p0, \ + SlowInteropTypeConverter::InteropType _p1, \ + SlowInteropTypeConverter::InteropType _p2, \ + SlowInteropTypeConverter::InteropType _p3) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + KVMContext ctx = (KVMContext)env; \ + impl_##name(ctx, p0, p1, p2, p3); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3) + +#define KOALA_INTEROP_CTX_V5(name, P0, P1, P2, P3, P4) \ + KOALA_JNI_CALL(void) Java_org_##name(JNIEnv* env, jclass instance, \ + SlowInteropTypeConverter::InteropType _p0, \ + SlowInteropTypeConverter::InteropType _p1, \ + SlowInteropTypeConverter::InteropType _p2, \ + SlowInteropTypeConverter::InteropType _p3, \ + SlowInteropTypeConverter::InteropType _p4) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + KVMContext ctx = (KVMContext)env; \ + impl_##name(ctx, p0, p1, p2, p3, p4); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4) + +#define KOALA_INTEROP_DIRECT_0(name, Ret) \ + KOALA_INTEROP_0(name, Ret) +#define KOALA_INTEROP_DIRECT_1(name, Ret, P0) \ + KOALA_INTEROP_1(name, Ret, P0) +#define KOALA_INTEROP_DIRECT_2(name, Ret, P0, P1) \ + KOALA_INTEROP_2(name, Ret, P0, P1) +#define KOALA_INTEROP_DIRECT_3(name, Ret, P0, P1, P2) \ + KOALA_INTEROP_3(name, Ret, P0, P1, P2) +#define KOALA_INTEROP_DIRECT_4(name, Ret, P0, P1, P2, P3) \ + KOALA_INTEROP_4(name, Ret, P0, P1, P2, P3) +#define KOALA_INTEROP_DIRECT_5(name, Ret, P0, P1, P2, P3, P4) \ + KOALA_INTEROP_5(name, Ret, P0, P1, P2, P3, P4) +#define KOALA_INTEROP_DIRECT_6(name, Ret, P0, P1, P2, P3, P4, P5) \ + KOALA_INTEROP_6(name, Ret, P0, P1, P2, P3, P4, P5) +#define KOALA_INTEROP_DIRECT_7(name, Ret, P0, P1, P2, P3, P4, P5, P6) \ + KOALA_INTEROP_7(name, Ret, P0, P1, P2, P3, P4, P5, P6) +#define KOALA_INTEROP_DIRECT_8(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7) \ + KOALA_INTEROP_8(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7) +#define KOALA_INTEROP_DIRECT_9(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8) \ + KOALA_INTEROP_9(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8) +#define KOALA_INTEROP_DIRECT_10(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) \ + KOALA_INTEROP_10(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) +#define KOALA_INTEROP_DIRECT_11(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) \ + KOALA_INTEROP_11(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) +#define KOALA_INTEROP_DIRECT_V0(name) \ + KOALA_INTEROP_V0(name) +#define KOALA_INTEROP_DIRECT_V1(name, P0) \ + KOALA_INTEROP_V1(name, P0) +#define KOALA_INTEROP_DIRECT_V2(name, P0, P1) \ + KOALA_INTEROP_V2(name, P0, P1) +#define KOALA_INTEROP_DIRECT_V3(name, P0, P1, P2) \ + KOALA_INTEROP_V3(name, P0, P1, P2) +#define KOALA_INTEROP_DIRECT_V4(name, P0, P1, P2, P3) \ + KOALA_INTEROP_V4(name, P0, P1, P2, P3) +#define KOALA_INTEROP_DIRECT_V5(name, P0, P1, P2, P3, P4) \ + KOALA_INTEROP_V5(name, P0, P1, P2, P3, P4) +#define KOALA_INTEROP_DIRECT_V6(name, P0, P1, P2, P3, P4, P5) \ + KOALA_INTEROP_V6(name, P0, P1, P2, P3, P4, P5) +#define KOALA_INTEROP_DIRECT_V7(name, P0, P1, P2, P3, P4, P5, P6) \ + KOALA_INTEROP_V7(name, P0, P1, P2, P3, P4, P5, P6) +#define KOALA_INTEROP_DIRECT_V8(name, P0, P1, P2, P3, P4, P5, P6, P7) \ + KOALA_INTEROP_V8(name, P0, P1, P2, P3, P4, P5, P6, P7) +#define KOALA_INTEROP_DIRECT_V9(name, P0, P1, P2, P3, P4, P5, P6, P7, P8) \ + KOALA_INTEROP_V9(name, P0, P1, P2, P3, P4, P5, P6, P7, P8) +#define KOALA_INTEROP_DIRECT_V10(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) \ + KOALA_INTEROP_V10(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) +#define KOALA_INTEROP_DIRECT_V11(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) \ + KOALA_INTEROP_V11(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) + +bool setKoalaJniCallbackDispatcher( + JNIEnv* env, + jclass clazz, + const char* dispatcherMethodName, + const char* dispactherMethodSig +); +void getKoalaJniCallbackDispatcher(jclass* clazz, jmethodID* method); + +#define KOALA_INTEROP_CALL_VOID(venv, id, length, args) \ +{ \ + jclass clazz = nullptr; \ + jmethodID method = nullptr; \ + getKoalaJniCallbackDispatcher(&clazz, &method); \ + JNIEnv* jniEnv = reinterpret_cast(venv); \ + jniEnv->PushLocalFrame(1); \ + jbyteArray args_jni = jniEnv->NewByteArray(length); \ + jniEnv->SetByteArrayRegion(args_jni, 0, length, reinterpret_cast(args)); \ + jniEnv->CallStaticIntMethod(clazz, method, id, args_jni, length); \ + jniEnv->GetByteArrayRegion(args_jni, 0, length, reinterpret_cast(args)); \ + jniEnv->PopLocalFrame(nullptr); \ +} + +#define KOALA_INTEROP_CALL_INT(venv, id, length, args) \ +{ \ + jclass clazz = nullptr; \ + jmethodID method = nullptr; \ + getKoalaJniCallbackDispatcher(&clazz, &method); \ + JNIEnv* jniEnv = reinterpret_cast(venv); \ + jniEnv->PushLocalFrame(1); \ + jbyteArray args_jni = jniEnv->NewByteArray(length); \ + jniEnv->SetByteArrayRegion(args_jni, 0, length, reinterpret_cast(args)); \ + int32_t rv = jniEnv->CallStaticIntMethod(clazz, method, id, args_jni, length); \ + jniEnv->GetByteArrayRegion(args_jni, 0, length, reinterpret_cast(args)); \ + jniEnv->PopLocalFrame(nullptr); \ + return rv; \ +} + +#define KOALA_INTEROP_CALL_VOID_INTS32(venv, id, argc, args) KOALA_INTEROP_CALL_VOID(venv, id, (argc) * sizeof(int32_t), args) +#define KOALA_INTEROP_CALL_INT_INTS32(venv, id, argc, args) KOALA_INTEROP_CALL_INT(venv, id, (argc) * sizeof(int32_t), args) + +#define KOALA_INTEROP_THROW(vmContext, object, ...) \ + do { \ + JNIEnv* env = reinterpret_cast(vmContext); \ + env->Throw(object); \ + return __VA_ARGS__; \ + } while (0) + +#define KOALA_INTEROP_THROW_STRING(vmContext, message, ...) \ + do { \ + JNIEnv* env = reinterpret_cast(vmContext); \ + const static jclass errorClass = env->FindClass("java/lang/RuntimeException"); \ + env->ThrowNew(errorClass, message); \ + } while (0) + +#endif // KOALA_JNI_CALL diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/jsc/convertors-jsc.cc b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/jsc/convertors-jsc.cc new file mode 100644 index 0000000000000000000000000000000000000000..2cfbe14644f8764a798b2e82cebd7334ab6a5104 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/jsc/convertors-jsc.cc @@ -0,0 +1,285 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include <_types/_uint32_t.h> +#include <_types/_uint8_t.h> +#include +#include + +#include "convertors-jsc.h" + +// See https://github.com/BabylonJS/BabylonNative/blob/master/Dependencies/napi/napi-direct/source/js_native_api_javascriptcore.cc +// for convertors logic. + + +KInt* getInt32Elements(JSContextRef context, const JSValueRef arguments) { + return getTypedElements(context, arguments); +} + +uint32_t* getUInt32Elements(JSContextRef context, const JSValueRef arguments) { + return getTypedElements(context, arguments); +} + +float* getFloat32Elements(JSContextRef context, const JSValueRef arguments) { + return getTypedElements(context, arguments); +} + +KByte* getByteElements(JSContextRef context, const JSValueRef arguments) { + return getTypedElements(context, arguments); +} + +KStringArray getKStringArray(JSContextRef context, const JSValueRef arguments) { + return getTypedElements(context, arguments); +} + +KUShort* getUShortElements(JSContextRef context, const JSValueRef arguments) { + return getTypedElements(context, arguments); +} + +KShort* getShortElements(JSContextRef context, const JSValueRef arguments) { + return getTypedElements(context, arguments); +} + +int32_t getInt32(JSContextRef context, JSValueRef value) { + JSValueRef exception {}; + if (JSValueIsNull(context, value)) { + return 0; + } + if (JSValueIsUndefined(context, value)) { + assert(false); + return 0; + } + double result = JSValueToNumber(context, value, &exception); + return static_cast(result); +} + +uint32_t getUInt32(JSContextRef context, JSValueRef value) { + JSValueRef exception {}; + if (JSValueIsNull(context, value)) { + return 0; + } + if (JSValueIsUndefined(context, value)) { + assert(false); + return 0; + } + double result = JSValueToNumber(context, value, &exception); + return static_cast(result); +} + +uint8_t getUInt8(JSContextRef context, JSValueRef value) { + JSValueRef exception {}; + if (JSValueIsNull(context, value)) { + return 0; + } + if (JSValueIsUndefined(context, value)) { + assert(false); + return 0; + } + double result = JSValueToNumber(context, value, &exception); + return static_cast(result); +} + +/* +static JSStringRef bigintToArrayCastFuncName = JSStringCreateWithUTF8CString("__JSC__castFromBigInt"); +static JSStringRef bigintToArrayCastFuncParams[] = { JSStringCreateWithUTF8CString("ptr") }; +static JSStringRef bigintToArrayCastFuncBody = JSStringCreateWithUTF8CString( + "return new Uint32Array([ptr & 0xFFFFFFFFn, (ptr >> 32n) & 0xFFFFFFFFn]);" +); + +static JSStringRef arrayToBigintCastFuncName = JSStringCreateWithUTF8CString("__JSC__castToBigInt"); +static JSStringRef arrayToBigintCastFuncParams[] = { JSStringCreateWithUTF8CString("ptr") }; +static JSStringRef arrayToBigintCastFuncBody = JSStringCreateWithUTF8CString( + "return BigInt(ptr[1]) << 32n | BigInt(ptr[0])" +); +*/ + +#ifdef KOALA_JSC_USE_CALLBACK_CAST + +static JSStringRef bigIntFromPartsFuncName = JSStringCreateWithUTF8CString("__JSC__bigIntFromParts"); +static JSStringRef bigIntFromPartsFuncParams[] = { JSStringCreateWithUTF8CString("hi"), JSStringCreateWithUTF8CString("lo") }; +static JSStringRef bigIntFromPartsFuncBody = JSStringCreateWithUTF8CString( + "return BigInt(hi) << 32n | BigInt(lo);" +); + +static JSObjectRef getGlobalCallback(JSContextRef context, JSStringRef name, JSStringRef params[], JSStringRef body) { + JSObjectRef globalThis = JSContextGetGlobalObject(context); + JSValueRef propname = JSValueMakeString(context, name); + JSValueRef castFunc = JSObjectGetPropertyForKey(context, globalThis, propname, nullptr); + if (JSValueIsUndefined(context, castFunc)) { + JSObjectRef castFuncObj = JSObjectMakeFunction(context, name, 1, params, body, nullptr, 0, nullptr); + JSPropertyAttributes attributes = kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum; + JSObjectSetPropertyForKey(context, globalThis, propname, castFuncObj, attributes, nullptr); + return castFuncObj; + } + return JSValueToObject(context, castFunc, nullptr); +} + +static JSObjectRef getBigIntFromParts(JSContextRef context) { + return getGlobalCallback(context, bigIntFromPartsFuncName, bigIntFromPartsFuncParams, bigIntFromPartsFuncBody); +} + +#endif + +static JSValueRef u64ToBigInt(JSContextRef context, uint64_t value) { + JSValueRef bigint; +#ifdef KOALA_JSC_USE_CALLBACK_CAST + // TODO benchmark this + JSObjectRef bigIntFromParts = getBigIntFromParts(context); + JSValueRef parts[2] = { + JSValueMakeNumber(context, (double) (value >> 32)), + JSValueMakeNumber(context, (double) (value & 0xFFFFFFFF)), + }; + bigint = JSObjectCallAsFunction(context, bigIntFromParts, nullptr, 2, parts, nullptr); +#else + char buffer[128] = {0}; + std::snprintf(buffer, sizeof(buffer) - 1, "%zun", (size_t) value); + JSStringRef script = JSStringCreateWithUTF8CString(buffer); + bigint = JSEvaluateScript(context, script, nullptr, nullptr, 0, nullptr); + JSStringRelease(script); +#endif + return bigint; +} + +static uint64_t bigIntToU64(JSContextRef ctx, JSValueRef value) { + char buf[128]; + JSStringRef strRef = JSValueToStringCopy(ctx, value, nullptr); + size_t len = JSStringGetUTF8CString(strRef, buf, sizeof(buf)); + JSStringRelease(strRef); + assert(len < sizeof(buf)); + char* suf; + uint64_t numValue = std::strtoull(buf, &suf, 10); + assert(*suf == '\0'); + return numValue; +} + +KNativePointer getPointer(JSContextRef context, JSValueRef value) { + uint64_t raw = bigIntToU64(context, value); + return reinterpret_cast(static_cast(raw)); +} + +KNativePointerArray getPointerElements(JSContextRef context, JSValueRef value) { + if (JSValueIsNull(context, value) || JSValueIsUndefined(context, value)) { + return nullptr; + } + + assert(JSValueIsObject(context, value)); + assert(JSValueGetTypedArrayType(context, value, nullptr) == kJSTypedArrayTypeBigUint64Array); + + JSObjectRef typedArray = JSValueToObject(context, value, nullptr); + return reinterpret_cast(JSObjectGetTypedArrayBytesPtr(context, typedArray, nullptr)); +} + +KFloat getFloat(JSContextRef context, JSValueRef value) { + JSValueRef exception {}; + if (JSValueIsNull(context, value)) { + return 0; + } + if (JSValueIsUndefined(context, value)) { + assert(false); + return 0; + } + double result = JSValueToNumber(context, value, &exception); + return static_cast(result); +} + +KShort getShort(JSContextRef context, JSValueRef value) { + JSValueRef exception {}; + if (JSValueIsNull(context, value)) { + return 0; + } + if (JSValueIsUndefined(context, value)) { + assert(false); + return 0; + } + double result = JSValueToNumber(context, value, &exception); + return static_cast(result); +} + +KUShort getUShort(JSContextRef context, JSValueRef value) { + JSValueRef exception {}; + if (JSValueIsNull(context, value)) { + return 0; + } + if (JSValueIsUndefined(context, value)) { + assert(false); + return 0; + } + double result = JSValueToNumber(context, value, &exception); + return static_cast(result); +} + +KStringPtr getString(JSContextRef context, JSValueRef value) { + if (JSValueIsNull(context, value)) { + return KStringPtr(); + } + if (JSValueIsUndefined(context, value)) { + return KStringPtr(); + } + KStringPtr result; + JSStringRef valueString = JSValueToStringCopy(context, value, NULL); + size_t size = JSStringGetMaximumUTF8CStringSize(valueString); + result.resize(size); + JSStringGetUTF8CString(valueString, result.data(), size); + JSStringRelease(valueString); + return result; +} + +KBoolean getBoolean(JSContextRef context, JSValueRef value) { + bool result = JSValueToBoolean(context, value); + return static_cast(result); +} + +JSValueRef makeInt32(JSContextRef context, int32_t value) { + return JSValueMakeNumber(context, value); +} + +JSValueRef makeUInt32(JSContextRef context, uint32_t value) { + return JSValueMakeNumber(context, value); +} + +JSValueRef makePointer(JSContextRef context, KNativePointer value) { + return u64ToBigInt(context, static_cast(reinterpret_cast(value))); +} + +JSValueRef makeFloat(JSContextRef context, KFloat value) { + return JSValueMakeNumber(context, value); +} + +JSValueRef makeBoolean(JSContextRef context, KBoolean value) { + return JSValueMakeBoolean(context, value); +} + +JSValueRef makeVoid(JSContextRef context) { + return JSValueMakeUndefined(context); +} + +Exports* Exports::getInstance() { + static Exports *instance = nullptr; + if (instance == nullptr) { + instance = new Exports(); + } + return instance; +} + +void InitExports(JSGlobalContextRef globalContext) { + JSObjectRef globalObject = JSContextGetGlobalObject(globalContext); + for (auto impl: Exports::getInstance()->getImpls()) { + JSStringRef functionName = JSStringCreateWithUTF8CString(impl.first.c_str()); + JSObjectRef functionObject = JSObjectMakeFunctionWithCallback(globalContext, functionName, impl.second); + JSObjectSetProperty(globalContext, globalObject, functionName, functionObject, kJSPropertyAttributeNone, nullptr); + JSStringRelease(functionName); + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/jsc/convertors-jsc.h b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/jsc/convertors-jsc.h new file mode 100644 index 0000000000000000000000000000000000000000..86f430b78d4dfecf55bb1a32135198110d961333 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/jsc/convertors-jsc.h @@ -0,0 +1,771 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#if defined(linux) +#include // For IDE completion +#else +#include +#endif +#include <_types/_uint8_t.h> +#include +#include +#include + +#include + +#include "koala-types.h" + +template +inline ElemType* getTypedElements(JSContextRef context, const JSValueRef arguments) { + if (JSValueIsNull(context, arguments)) { + return nullptr; + } + if (JSValueIsUndefined(context, arguments)) { + assert(false); + return nullptr; + } + JSValueRef exception {}; + ElemType* data = reinterpret_cast(JSObjectGetTypedArrayBytesPtr(context, + JSValueToObject(context, arguments, &exception), &exception)); + return data; +} + +template +inline ElemType* getTypedElements(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) { + assert(index < argumentCount); + return getTypedElements(context, arguments[index]); +} + +uint8_t* getUInt8Elements(JSContextRef context, const JSValueRef arguments); +int32_t* getInt32Elements(JSContextRef context, const JSValueRef arguments); +uint32_t* getUInt32Elements(JSContextRef context, const JSValueRef arguments); +float* getFloat32Elements(JSContextRef context, const JSValueRef arguments); +KByte* getByteElements(JSContextRef context, const JSValueRef arguments); +KUShort* getUShortElements(JSContextRef context, const JSValueRef arguments); +KShort* getShortElements(JSContextRef context, const JSValueRef arguments); +KNativePointerArray getPointerElements(JSContextRef context, const JSValueRef arguments); +KStringArray getKStringArray(JSContextRef context, const JSValueRef arguments); + +uint8_t getUInt8(JSContextRef context, JSValueRef value); +int32_t getInt32(JSContextRef context, JSValueRef value); +uint32_t getUInt32(JSContextRef context, JSValueRef value); +KNativePointer getPointer(JSContextRef context, JSValueRef value); +KFloat getFloat(JSContextRef context, JSValueRef value); +KStringPtr getString(JSContextRef context, JSValueRef value); +KBoolean getBoolean(JSContextRef context, JSValueRef value); +KStringPtr getString(JSContextRef context, JSValueRef value); + +template +inline Type getArgument(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) = delete; + +template <> +inline int32_t getArgument(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) { + assert(index < argumentCount); + return getInt32(context, arguments[index]); +} + +template <> +inline uint32_t getArgument(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) { + assert(index < argumentCount); + return getUInt32(context, arguments[index]); +} + +template <> +inline uint8_t getArgument(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) { + assert(index < argumentCount); + return getUInt8(context, arguments[index]); +} + +template <> +inline KNativePointer getArgument(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) { + assert(index < argumentCount); + return getPointer(context, arguments[index]); +} + +template <> +inline KFloat getArgument(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) { + assert(index < argumentCount); + return getFloat(context, arguments[index]); +} + +template <> +inline KStringPtr getArgument(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) { + assert(index < argumentCount); + return getString(context, arguments[index]); +} + +template <> +inline KBoolean getArgument(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) { + assert(index < argumentCount); + return getBoolean(context, arguments[index]); +} + +template <> +inline KInt* getArgument(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) { + assert(index < argumentCount); + return getInt32Elements(context, arguments[index]); +} + +template <> +inline float* getArgument(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) { + assert(index < argumentCount); + return getFloat32Elements(context, arguments[index]); +} + +template <> +inline KByte* getArgument(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) { + assert(index < argumentCount); + return getByteElements(context, arguments[index]); +} + +template <> +inline KStringArray getArgument(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) { + assert(index < argumentCount); + return getKStringArray(context, arguments[index]); +} + +template <> +inline KUShort* getArgument(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) { + assert(index < argumentCount); + return getUShortElements(context, arguments[index]); +} + +template <> +inline KNativePointerArray getArgument(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) { + assert(index < argumentCount); + return getPointerElements(context, arguments[index]); +} + +template <> +inline KShort* getArgument(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) { + assert(index < argumentCount); + return getShortElements(context, arguments[index]); +} + +JSValueRef makeInt32(JSContextRef context, int32_t value); +JSValueRef makeUInt32(JSContextRef context, uint32_t value); +JSValueRef makePointer(JSContextRef context, KNativePointer value); +JSValueRef makeFloat(JSContextRef context, KFloat value); +JSValueRef makeBoolean(JSContextRef context, KBoolean value); +JSValueRef makeVoid(JSContextRef context); + +template +inline JSValueRef makeResult(JSContextRef context, Type value) = delete; + +template <> +inline JSValueRef makeResult(JSContextRef context, int32_t value) { + return makeInt32(context, value); +} + +template <> +inline JSValueRef makeResult(JSContextRef context, uint32_t value) { + return makeUInt32(context, value); +} + +template <> +inline JSValueRef makeResult(JSContextRef context, KNativePointer value) { + return makePointer(context, value); +} + +template <> +inline JSValueRef makeResult(JSContextRef context, KFloat value) { + return makeFloat(context, value); +} + +template <> +inline JSValueRef makeResult(JSContextRef context, KBoolean value) { + return makeBoolean(context, value); +} + +typedef JSValueRef (*jsc_type_t)(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); + +class Exports { + std::vector> implementations; + +public: + static Exports* getInstance(); + + void addImpl(const char* name, jsc_type_t impl) { + implementations.push_back(std::make_pair(name, impl)); + } + + const std::vector>& getImpls() { + return implementations; + } +}; + +void InitExports(JSGlobalContextRef globalContext); + +#define MAKE_JSC_EXPORT(name) \ + __attribute__((constructor)) \ + static void __init_##name() { \ + Exports::getInstance()->addImpl("_"#name, Jsc_##name); \ + } + +#define MAKE_JSC_EXPORT_V1(name) \ + __attribute__((constructor)) \ + static void __init_##name() { \ + Exports::getInstance()->addImpl(#name, Jsc_##name); \ + } + +#define KOALA_INTEROP_0(name, Ret) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + return makeResult(ctx, impl_##name()); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_1(name, Ret, P0) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + return makeResult(ctx, impl_##name(p0)); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_2(name, Ret, P0, P1) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + return makeResult(ctx, impl_##name(p0, p1)); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_3(name, Ret, P0, P1, P2) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + return makeResult(ctx, impl_##name(p0,p1,p2)); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_4(name, Ret, P0, P1, P2, P3) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + return makeResult(ctx, impl_##name(p0,p1,p2,p3)); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_5(name, Ret, P0, P1, P2, P3, P4) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + P4 p4 = getArgument(ctx, argumentCount, arguments, 4); \ + return makeResult(ctx, impl_##name(p0,p1,p2,p3,p4)); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_6(name, Ret, P0, P1, P2, P3, P4, P5) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + P4 p4 = getArgument(ctx, argumentCount, arguments, 4); \ + P5 p5 = getArgument(ctx, argumentCount, arguments, 5); \ + return makeResult(ctx, impl_##name(p0,p1,p2,p3,p4,p5)); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_7(name, Ret, P0, P1, P2, P3, P4, P5, P6) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + P4 p4 = getArgument(ctx, argumentCount, arguments, 4); \ + P5 p5 = getArgument(ctx, argumentCount, arguments, 5); \ + P6 p6 = getArgument(ctx, argumentCount, arguments, 6); \ + return makeResult(ctx, impl_##name(p0,p1,p2,p3,p4,p5,p6)); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_8(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + P4 p4 = getArgument(ctx, argumentCount, arguments, 4); \ + P5 p5 = getArgument(ctx, argumentCount, arguments, 5); \ + P6 p6 = getArgument(ctx, argumentCount, arguments, 6); \ + P7 p7 = getArgument(ctx, argumentCount, arguments, 7); \ + return makeResult(ctx, impl_##name(p0,p1,p2,p3,p4,p5,p6,p7)); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_9(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + P4 p4 = getArgument(ctx, argumentCount, arguments, 4); \ + P5 p5 = getArgument(ctx, argumentCount, arguments, 5); \ + P6 p6 = getArgument(ctx, argumentCount, arguments, 6); \ + P7 p7 = getArgument(ctx, argumentCount, arguments, 7); \ + P8 p8 = getArgument(ctx, argumentCount, arguments, 8); \ + return makeResult(ctx, impl_##name(p0,p1,p2,p3,p4,p5,p6,p7,p8)); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_10(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + P4 p4 = getArgument(ctx, argumentCount, arguments, 4); \ + P5 p5 = getArgument(ctx, argumentCount, arguments, 5); \ + P6 p6 = getArgument(ctx, argumentCount, arguments, 6); \ + P7 p7 = getArgument(ctx, argumentCount, arguments, 7); \ + P8 p8 = getArgument(ctx, argumentCount, arguments, 8); \ + P9 p9 = getArgument(ctx, argumentCount, arguments, 9); \ + return makeResult(ctx, impl_##name(p0,p1,p2,p3,p4,p5,p6,p7,p8,p9)); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_11(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + P4 p4 = getArgument(ctx, argumentCount, arguments, 4); \ + P5 p5 = getArgument(ctx, argumentCount, arguments, 5); \ + P6 p6 = getArgument(ctx, argumentCount, arguments, 6); \ + P7 p7 = getArgument(ctx, argumentCount, arguments, 7); \ + P8 p8 = getArgument(ctx, argumentCount, arguments, 8); \ + P9 p9 = getArgument(ctx, argumentCount, arguments, 9); \ + P10 p10 = getArgument(ctx, argumentCount, arguments, 10); \ + return makeResult(ctx, impl_##name(p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10)); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_12(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + P4 p4 = getArgument(ctx, argumentCount, arguments, 4); \ + P5 p5 = getArgument(ctx, argumentCount, arguments, 5); \ + P6 p6 = getArgument(ctx, argumentCount, arguments, 6); \ + P7 p7 = getArgument(ctx, argumentCount, arguments, 7); \ + P8 p8 = getArgument(ctx, argumentCount, arguments, 8); \ + P9 p9 = getArgument(ctx, argumentCount, arguments, 9); \ + P10 p10 = getArgument(ctx, argumentCount, arguments, 10); \ + P11 p11 = getArgument(ctx, argumentCount, arguments, 11); \ + return makeResult(ctx, impl_##name(p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11)); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_13(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + P4 p4 = getArgument(ctx, argumentCount, arguments, 4); \ + P5 p5 = getArgument(ctx, argumentCount, arguments, 5); \ + P6 p6 = getArgument(ctx, argumentCount, arguments, 6); \ + P7 p7 = getArgument(ctx, argumentCount, arguments, 7); \ + P8 p8 = getArgument(ctx, argumentCount, arguments, 8); \ + P9 p9 = getArgument(ctx, argumentCount, arguments, 9); \ + P10 p10 = getArgument(ctx, argumentCount, arguments, 10); \ + P11 p11 = getArgument(ctx, argumentCount, arguments, 11); \ + P12 p12 = getArgument(ctx, argumentCount, arguments, 12); \ + return makeResult(ctx, impl_##name(p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12)); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_14(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + P4 p4 = getArgument(ctx, argumentCount, arguments, 4); \ + P5 p5 = getArgument(ctx, argumentCount, arguments, 5); \ + P6 p6 = getArgument(ctx, argumentCount, arguments, 6); \ + P7 p7 = getArgument(ctx, argumentCount, arguments, 7); \ + P8 p8 = getArgument(ctx, argumentCount, arguments, 8); \ + P9 p9 = getArgument(ctx, argumentCount, arguments, 9); \ + P10 p10 = getArgument(ctx, argumentCount, arguments, 10); \ + P11 p11 = getArgument(ctx, argumentCount, arguments, 11); \ + P12 p12 = getArgument(ctx, argumentCount, arguments, 12); \ + P13 p13 = getArgument(ctx, argumentCount, arguments, 13); \ + return makeResult(ctx, impl_##name(p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13)); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_V0(name) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + impl_##name(); \ + return makeVoid(ctx); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_V1(name, P0) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + impl_##name(p0); \ + return makeVoid(ctx); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_V2(name, P0, P1) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + impl_##name(p0,p1); \ + return makeVoid(ctx); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_V3(name, P0, P1, P2) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + impl_##name(p0,p1,p2); \ + return makeVoid(ctx); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_V4(name, P0, P1, P2, P3) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + impl_##name(p0,p1,p2,p3); \ + return makeVoid(ctx); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_V5(name, P0, P1, P2, P3, P4) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + P4 p4 = getArgument(ctx, argumentCount, arguments, 4); \ + impl_##name(p0,p1,p2,p3,p4); \ + return makeVoid(ctx); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_V6(name, P0, P1, P2, P3, P4, P5) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + P4 p4 = getArgument(ctx, argumentCount, arguments, 4); \ + P5 p5 = getArgument(ctx, argumentCount, arguments, 5); \ + impl_##name(p0,p1,p2,p3,p4,p5); \ + return makeVoid(ctx); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_V7(name, P0, P1, P2, P3, P4, P5, P6) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + P4 p4 = getArgument(ctx, argumentCount, arguments, 4); \ + P5 p5 = getArgument(ctx, argumentCount, arguments, 5); \ + P6 p6 = getArgument(ctx, argumentCount, arguments, 6); \ + impl_##name(p0,p1,p2,p3,p4,p5,p6); \ + return makeVoid(ctx); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_V8(name, P0, P1, P2, P3, P4, P5, P6, P7) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + P4 p4 = getArgument(ctx, argumentCount, arguments, 4); \ + P5 p5 = getArgument(ctx, argumentCount, arguments, 5); \ + P6 p6 = getArgument(ctx, argumentCount, arguments, 6); \ + P7 p7 = getArgument(ctx, argumentCount, arguments, 7); \ + impl_##name(p0,p1,p2,p3,p4,p5,p6,p7); \ + return makeVoid(ctx); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_V9(name, P0, P1, P2, P3, P4, P5, P6, P7, P8) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + P4 p4 = getArgument(ctx, argumentCount, arguments, 4); \ + P5 p5 = getArgument(ctx, argumentCount, arguments, 5); \ + P6 p6 = getArgument(ctx, argumentCount, arguments, 6); \ + P7 p7 = getArgument(ctx, argumentCount, arguments, 7); \ + P8 p8 = getArgument(ctx, argumentCount, arguments, 8); \ + impl_##name(p0,p1,p2,p3,p4,p5,p6,p7,p8); \ + return makeVoid(ctx); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_V10(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + P4 p4 = getArgument(ctx, argumentCount, arguments, 4); \ + P5 p5 = getArgument(ctx, argumentCount, arguments, 5); \ + P6 p6 = getArgument(ctx, argumentCount, arguments, 6); \ + P7 p7 = getArgument(ctx, argumentCount, arguments, 7); \ + P8 p8 = getArgument(ctx, argumentCount, arguments, 8); \ + P9 p9 = getArgument(ctx, argumentCount, arguments, 9); \ + impl_##name(p0,p1,p2,p3,p4,p5,p6,p7,p8,p9); \ + return makeVoid(ctx); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_V11(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + P4 p4 = getArgument(ctx, argumentCount, arguments, 4); \ + P5 p5 = getArgument(ctx, argumentCount, arguments, 5); \ + P6 p6 = getArgument(ctx, argumentCount, arguments, 6); \ + P7 p7 = getArgument(ctx, argumentCount, arguments, 7); \ + P8 p8 = getArgument(ctx, argumentCount, arguments, 8); \ + P9 p9 = getArgument(ctx, argumentCount, arguments, 9); \ + P10 p10 = getArgument(ctx, argumentCount, arguments, 10); \ + impl_##name(p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10); \ + return makeVoid(ctx); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_V12(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + P4 p4 = getArgument(ctx, argumentCount, arguments, 4); \ + P5 p5 = getArgument(ctx, argumentCount, arguments, 5); \ + P6 p6 = getArgument(ctx, argumentCount, arguments, 6); \ + P7 p7 = getArgument(ctx, argumentCount, arguments, 7); \ + P8 p8 = getArgument(ctx, argumentCount, arguments, 8); \ + P9 p9 = getArgument(ctx, argumentCount, arguments, 9); \ + P10 p10 = getArgument(ctx, argumentCount, arguments, 10); \ + P11 p11 = getArgument(ctx, argumentCount, arguments, 11); \ + impl_##name(p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11); \ + return makeVoid(ctx); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_V13(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + P4 p4 = getArgument(ctx, argumentCount, arguments, 4); \ + P5 p5 = getArgument(ctx, argumentCount, arguments, 5); \ + P6 p6 = getArgument(ctx, argumentCount, arguments, 6); \ + P7 p7 = getArgument(ctx, argumentCount, arguments, 7); \ + P8 p8 = getArgument(ctx, argumentCount, arguments, 8); \ + P9 p9 = getArgument(ctx, argumentCount, arguments, 9); \ + P10 p10 = getArgument(ctx, argumentCount, arguments, 10); \ + P11 p11 = getArgument(ctx, argumentCount, arguments, 11); \ + P12 p12 = getArgument(ctx, argumentCount, arguments, 12); \ + impl_##name(p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12); \ + return makeVoid(ctx); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_V14(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + P4 p4 = getArgument(ctx, argumentCount, arguments, 4); \ + P5 p5 = getArgument(ctx, argumentCount, arguments, 5); \ + P6 p6 = getArgument(ctx, argumentCount, arguments, 6); \ + P7 p7 = getArgument(ctx, argumentCount, arguments, 7); \ + P8 p8 = getArgument(ctx, argumentCount, arguments, 8); \ + P9 p9 = getArgument(ctx, argumentCount, arguments, 9); \ + P10 p10 = getArgument(ctx, argumentCount, arguments, 10); \ + P11 p11 = getArgument(ctx, argumentCount, arguments, 11); \ + P12 p12 = getArgument(ctx, argumentCount, arguments, 12); \ + P13 p13 = getArgument(ctx, argumentCount, arguments, 13); \ + impl_##name(p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13); \ + return makeVoid(ctx); \ + } \ + MAKE_JSC_EXPORT(name) + +// todo: implement properly +#define KOALA_INTEROP_CTX_3(name, Ret, P0, P1, P2) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef *exception) \ + { \ + printf("TODO: implement KOALA_INTEROP_CTX_3 for jsc"); \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + return makeResult(ctx, impl_##name(nullptr, p0, p1, p2)); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_CTX_4(name, Ret, P0, P1, P2, P4) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef *exception) \ + { \ + printf("TODO: implement KOALA_INTEROP_CTX_4 for jsc"); \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + return makeResult(ctx, impl_##name(nullptr, p0, p1, p2, p3)); \ + } \ + MAKE_JSC_EXPORT(name) + +// todo: implement properly +#define KOALA_INTEROP_CTX_V3(name, P0, P1, P2) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + printf("TODO: implement KOALA_INTEROP_CTX_V3 for jsc"); \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + impl_##name(nullptr, p0, p1, p2); \ + return makeVoid(ctx); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_CTX_V4(name, P0, P1, P2, P3) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + printf("TODO: implement KOALA_INTEROP_CTX_V4 for jsc"); \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + impl_##name(nullptr, p0, p1, p2, p3); \ + return makeVoid(ctx); \ + } \ + MAKE_JSC_EXPORT(name) + + #define KOALA_INTEROP_DIRECT_0(name, Ret) \ + KOALA_INTEROP_0(name, Ret) +#define KOALA_INTEROP_DIRECT_1(name, Ret, P0) \ + KOALA_INTEROP_1(name, Ret, P0) +#define KOALA_INTEROP_DIRECT_2(name, Ret, P0, P1) \ + KOALA_INTEROP_2(name, Ret, P0, P1) +#define KOALA_INTEROP_DIRECT_3(name, Ret, P0, P1, P2) \ + KOALA_INTEROP_3(name, Ret, P0, P1, P2) +#define KOALA_INTEROP_DIRECT_4(name, Ret, P0, P1, P2, P3) \ + KOALA_INTEROP_4(name, Ret, P0, P1, P2, P3) +#define KOALA_INTEROP_DIRECT_5(name, Ret, P0, P1, P2, P3, P4) \ + KOALA_INTEROP_5(name, Ret, P0, P1, P2, P3, P4) +#define KOALA_INTEROP_DIRECT_6(name, Ret, P0, P1, P2, P3, P4, P5) \ + KOALA_INTEROP_6(name, Ret, P0, P1, P2, P3, P4, P5) +#define KOALA_INTEROP_DIRECT_7(name, Ret, P0, P1, P2, P3, P4, P5, P6) \ + KOALA_INTEROP_7(name, Ret, P0, P1, P2, P3, P4, P5, P6) +#define KOALA_INTEROP_DIRECT_8(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7) \ + KOALA_INTEROP_8(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7) +#define KOALA_INTEROP_DIRECT_9(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8) \ + KOALA_INTEROP_9(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8) +#define KOALA_INTEROP_DIRECT_10(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) \ + KOALA_INTEROP_10(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) +#define KOALA_INTEROP_DIRECT_11(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) \ + KOALA_INTEROP_11(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) +#define KOALA_INTEROP_DIRECT_V0(name) \ + KOALA_INTEROP_V0(name) +#define KOALA_INTEROP_DIRECT_V1(name, P0) \ + KOALA_INTEROP_V1(name, P0) +#define KOALA_INTEROP_DIRECT_V2(name, P0, P1) \ + KOALA_INTEROP_V2(name, P0, P1) +#define KOALA_INTEROP_DIRECT_V3(name, P0, P1, P2) \ + KOALA_INTEROP_V3(name, P0, P1, P2) +#define KOALA_INTEROP_DIRECT_V4(name, P0, P1, P2, P3) \ + KOALA_INTEROP_V4(name, P0, P1, P2, P3) +#define KOALA_INTEROP_DIRECT_V5(name, P0, P1, P2, P3, P4) \ + KOALA_INTEROP_V5(name, P0, P1, P2, P3, P4) +#define KOALA_INTEROP_DIRECT_V6(name, P0, P1, P2, P3, P4, P5) \ + KOALA_INTEROP_V6(name, P0, P1, P2, P3, P4, P5) +#define KOALA_INTEROP_DIRECT_V7(name, P0, P1, P2, P3, P4, P5, P6) \ + KOALA_INTEROP_V7(name, P0, P1, P2, P3, P4, P5, P6) +#define KOALA_INTEROP_DIRECT_V8(name, P0, P1, P2, P3, P4, P5, P6, P7) \ + KOALA_INTEROP_V8(name, P0, P1, P2, P3, P4, P5, P6, P7) +#define KOALA_INTEROP_DIRECT_V9(name, P0, P1, P2, P3, P4, P5, P6, P7, P8) \ + KOALA_INTEROP_V9(name, P0, P1, P2, P3, P4, P5, P6, P7, P8) +#define KOALA_INTEROP_DIRECT_V10(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) \ + KOALA_INTEROP_V10(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) +#define KOALA_INTEROP_DIRECT_V11(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) \ + KOALA_INTEROP_V11(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) + +#define KOALA_INTEROP_THROW(vmContext, object, ...) \ + do { \ + /* TODO: implement*/ assert(false); \ + return __VA_ARGS__; \ + } while (0) + +#define KOALA_INTEROP_THROW_STRING(vmContext, message, ...) \ + do { \ + assert(false); /* TODO: implement*/ \ + return __VA_ARGS__; \ + } while (0) diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/napi/convertors-napi.cc b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/napi/convertors-napi.cc new file mode 100644 index 0000000000000000000000000000000000000000..98ddac13d1afd0177b223738676f9988023ab56d --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/napi/convertors-napi.cc @@ -0,0 +1,395 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include +#include +#include + +#include "interop-logging.h" +#define KOALA_INTEROP_MODULE InteropNativeModule +#include "convertors-napi.h" + + +// Adapter for NAPI_MODULE +#define NODE_API_MODULE_ADAPTER(modname, regfunc) \ + static napi_value __napi_##regfunc(napi_env env, napi_value exports) { \ + return Napi::RegisterModule(env, exports, regfunc); \ + } \ + NAPI_MODULE(modname, __napi_##regfunc) + +napi_valuetype getValueTypeChecked(napi_env env, napi_value value) { + napi_valuetype type; + napi_status status = napi_typeof(env, value, &type); + KOALA_NAPI_THROW_IF_FAILED(env, status, napi_undefined); + return type; +} + +bool isTypedArray(napi_env env, napi_value value) { + bool result = false; + napi_status status = napi_is_typedarray(env, value, &result); + KOALA_NAPI_THROW_IF_FAILED(env, status, false); + return result; +} + +KBoolean getBoolean(napi_env env, napi_value value) { + if (getValueTypeChecked(env, value) == napi_valuetype::napi_boolean) { + bool result = false; + napi_get_value_bool(env, value, &result); + return static_cast(result); + } + return static_cast(getInt32(env, value) != 0); +} + +KInt getInt32(napi_env env, napi_value value) { + if (getValueTypeChecked(env, value) != napi_valuetype::napi_number) { + napi_throw_error(env, nullptr, "Expected Number"); + return 0; + } + int32_t result = false; + napi_get_value_int32(env, value, &result); + return static_cast(result); +} + +KUInt getUInt32(napi_env env, napi_value value) { + if (getValueTypeChecked(env, value) != napi_valuetype::napi_number) { + napi_throw_error(env, nullptr, "Expected Number"); + return 0; + } + uint32_t result = false; + napi_get_value_uint32(env, value, &result); + return static_cast(result); +} + +KFloat getFloat32(napi_env env, napi_value value) { + if (getValueTypeChecked(env, value) != napi_valuetype::napi_number) { + napi_throw_error(env, nullptr, "Expected Number"); + return 0.0f; + } + double result = false; + napi_get_value_double(env, value, &result); + return static_cast(static_cast(result)); +} + +KDouble getFloat64(napi_env env, napi_value value) { + if (getValueTypeChecked(env, value) != napi_valuetype::napi_number) { + napi_throw_error(env, nullptr, "Expected Number"); + return 0.0; + } + double result = false; + napi_get_value_double(env, value, &result); + return static_cast(result); +} + +KStringPtr getString(napi_env env, napi_value value) { + KStringPtr result {}; + napi_valuetype valueType = getValueTypeChecked(env, value); + if (valueType == napi_valuetype::napi_null || valueType == napi_valuetype::napi_undefined) { + return result; + } + + if (valueType != napi_valuetype::napi_string) { + napi_throw_error(env, nullptr, "Expected String"); + return result; + } + + size_t length = 0; + napi_status status = napi_get_value_string_utf8(env, value, nullptr, 0, &length); + if (status != 0) return result; + result.resize(length); + status = napi_get_value_string_utf8(env, value, result.data(), length + 1, nullptr); + return result; +} + +KNativePointer getPointer(napi_env env, napi_value value) { + napi_valuetype valueType = getValueTypeChecked(env, value); + if (valueType == napi_valuetype::napi_external) { + KNativePointer result = nullptr; + napi_status status = napi_get_value_external(env, value, &result); + KOALA_NAPI_THROW_IF_FAILED(env, status, nullptr); + return result; + } + + if (valueType != napi_valuetype::napi_bigint) { + napi_throw_error(env, nullptr, "cannot be coerced to pointer"); + return nullptr; + } + + bool isWithinRange = true; + uint64_t ptrU64 = 0; + napi_status status = napi_get_value_bigint_uint64(env, value, &ptrU64, &isWithinRange); + KOALA_NAPI_THROW_IF_FAILED(env, status, nullptr); + if (!isWithinRange) { + napi_throw_error(env, nullptr, "cannot be coerced to uint64, value is too large"); + return nullptr; + } + return reinterpret_cast(ptrU64); +} + +KLong getInt64(napi_env env, napi_value value) { + if (getValueTypeChecked(env, value) == napi_valuetype::napi_number) { + int64_t result = 0; + if (napi_get_value_int64(env, value, &result) != napi_ok) { + napi_throw_error(env, nullptr, "cannot be coerced to int64"); + return -1; + } + return static_cast(result); + } + if (getValueTypeChecked(env, value) == napi_valuetype::napi_bigint) { + bool isWithinRange = true; + int64_t ptr64 = 0; + if (napi_get_value_bigint_int64(env, value, &ptr64, &isWithinRange) != napi_ok) { + napi_throw_error(env, nullptr, "cannot be coerced to int64"); + return -1; + } + if (!isWithinRange) { + napi_throw_error(env, nullptr, "cannot be coerced to int64, value is too large"); + return -1; + } + return static_cast(ptr64); + } + napi_throw_error(env, nullptr, "cannot be coerced to int64"); + return -1; +} + +KULong getUInt64(napi_env env, napi_value value) { + if (getValueTypeChecked(env, value) != napi_valuetype::napi_bigint) { + napi_throw_error(env, nullptr, "cannot be coerced to uint64"); + return -1; + } + + bool isWithinRange = true; + uint64_t ptr64 = 0; + napi_get_value_bigint_uint64(env, value, &ptr64, &isWithinRange); + if (!isWithinRange) { + napi_throw_error(env, nullptr, "cannot be coerced to uint64, value is too large"); + return -1; + } + return static_cast(ptr64); +} + +napi_value makeString(napi_env env, const KStringPtr& value) { + napi_value result; + napi_status status; + status = napi_create_string_utf8(env, value.isNull() ? "" : value.data(), value.length(), &result); + KOALA_NAPI_THROW_IF_FAILED(env, status, result); + return result; +} + +napi_value makeString(napi_env env, const std::string& value) { + napi_value result; + napi_status status; + status = napi_create_string_utf8(env, value.c_str(), value.length(), &result); + KOALA_NAPI_THROW_IF_FAILED(env, status, result); + return result; +} + +napi_value makeBoolean(napi_env env, int8_t value) { + napi_value result; + napi_status status; + status = napi_get_boolean(env, value != 0, &result); + KOALA_NAPI_THROW_IF_FAILED(env, status, result); + return result; +} + +napi_value makeInt32(napi_env env, int32_t value) { + napi_value result; + napi_status status; + status = napi_create_int32(env, value, &result); + KOALA_NAPI_THROW_IF_FAILED(env, status, result); + return result; +} + +napi_value makeUInt32(napi_env env, uint32_t value) { + napi_value result; + napi_status status; + status = napi_create_uint32(env, value, &result); + KOALA_NAPI_THROW_IF_FAILED(env, status, result); + return result; +} + +napi_value makeInt64(napi_env env, int64_t value) { + napi_value result; + napi_status status; + status = napi_create_bigint_int64(env, value, &result); + KOALA_NAPI_THROW_IF_FAILED(env, status, result); + return result; +} + +napi_value makeUInt64(napi_env env, uint64_t value) { + napi_value result; + napi_status status; + status = napi_create_bigint_uint64(env, value, &result); + KOALA_NAPI_THROW_IF_FAILED(env, status, result); + return result; +} + +napi_value makeFloat32(napi_env env, float value) { + napi_value result; + napi_status status; + status = napi_create_double(env, value, &result); + KOALA_NAPI_THROW_IF_FAILED(env, status, result); + return result; +} + +napi_value makePointer(napi_env env, void* value) { + napi_value result; + napi_status status; + status = napi_create_bigint_uint64(env, static_cast(reinterpret_cast(value)), &result); + KOALA_NAPI_THROW_IF_FAILED(env, status, result); + return result; +} + +napi_value makeVoid(napi_env env) { + napi_value result; + napi_status status; + status = napi_get_undefined(env, &result); + KOALA_NAPI_THROW_IF_FAILED(env, status, result); + return result; +} + +napi_value makeObject(napi_env env, napi_value object) { + napi_value result; + napi_status status; + status = napi_create_object(env, &result); + KOALA_NAPI_THROW_IF_FAILED(env, status, result); + return result; +} + +#if _MSC_VER >= 1932 // Visual Studio 2022 version 17.2+ +# pragma comment(linker, "/alternatename:__imp___std_init_once_complete=__imp_InitOnceComplete") +# pragma comment(linker, "/alternatename:__imp___std_init_once_begin_initialize=__imp_InitOnceBeginInitialize") +#endif + +Exports* Exports::getInstance() { + static Exports *instance = nullptr; + if (instance == nullptr) { + instance = new Exports(); + } + return instance; +} + +std::vector Exports::getModules() { + std::vector result; + for (auto it = implementations.begin(); it != implementations.end(); ++it) { + result.push_back(it->first); + } + return result; +} + +void Exports::addMethod(const char* module, const char* name, napi_type_t impl) { + auto it = implementations.find(module); + if (it == implementations.end()) { + it = implementations.insert(std::make_pair(module, std::vector>())).first; + } + it->second.push_back(std::make_pair(name, impl)); + +} + +const std::vector>& Exports::getMethods(const std::string& module) { + auto it = implementations.find(module); + if (it == implementations.end()) { + LOGE("Module %s is not registered", module.c_str()); + INTEROP_FATAL("Fatal error"); + } + return it->second; +} + +// +// Callback dispatcher +// +// TODO Should we get rid of explicit Node_* declrations and hide the naming convention behind the macro definitions? + +static napi_ref g_koalaNapiCallbackDispatcher = nullptr; + +// TODO: shall we pass name in globalThis instead of object reference? +napi_value Node_SetCallbackDispatcher(napi_env env, napi_callback_info cbinfo) { + fprintf(stderr, "Node_SetCallbackDispatcher!\n"); + + CallbackInfo info(env, cbinfo); + napi_value dispatcher = info[0]; + napi_value result = makeVoid(env); + napi_status status = napi_create_reference(env, dispatcher, 1, &g_koalaNapiCallbackDispatcher); + KOALA_NAPI_THROW_IF_FAILED(env, status, result); + + return result; +} +MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, SetCallbackDispatcher) + +napi_value Node_CleanCallbackDispatcher(napi_env env, napi_callback_info cbinfo) { + napi_value result = makeVoid(env); + if (g_koalaNapiCallbackDispatcher) { + napi_status status = napi_delete_reference(env, g_koalaNapiCallbackDispatcher); + g_koalaNapiCallbackDispatcher = nullptr; + KOALA_NAPI_THROW_IF_FAILED(env, status, result); + } + return result; +} +MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, CleanCallbackDispatcher) + +napi_value getKoalaNapiCallbackDispatcher(napi_env env) { + if (!g_koalaNapiCallbackDispatcher) { + abort(); + } + napi_value value; + napi_status status = napi_get_reference_value(env, g_koalaNapiCallbackDispatcher, &value); + KOALA_NAPI_THROW_IF_FAILED(env, status, makeVoid(env)); + return value; +} + +// +// Module initialization +// + +using ModuleRegisterCallback = napi_value (*)(napi_env env, napi_value exports); + +/** + * Sets a new callback and returns its previous value. + */ +ModuleRegisterCallback ProvideModuleRegisterCallback(ModuleRegisterCallback value = nullptr) { + static const ModuleRegisterCallback DEFAULT_CB = [](napi_env env, napi_value exports) { return exports; }; + static ModuleRegisterCallback curCallback = DEFAULT_CB; + + ModuleRegisterCallback prevCallback = curCallback; + curCallback = value ? value : DEFAULT_CB; + return prevCallback; +} + +static constexpr bool splitModules = true; + +static napi_value InitModule(napi_env env, napi_value exports) { + // LOG("InitModule: " QUOTE(INTEROP_LIBRARY_NAME)); + Exports* inst = Exports::getInstance(); + napi_status status; + napi_value target = exports; + for (const auto &module : inst->getModules()) { + if (splitModules) { + status = napi_create_object(env, &target); + KOALA_NAPI_THROW_IF_FAILED(env, status, exports); + status = napi_set_named_property(env, exports, module.c_str(), target); + KOALA_NAPI_THROW_IF_FAILED(env, status, exports); + } + + for (const auto &impl : inst->getMethods(module)) { + napi_value implFunc; + status = napi_create_function(env, impl.first.c_str(), NAPI_AUTO_LENGTH, impl.second, nullptr, &implFunc); + KOALA_NAPI_THROW_IF_FAILED(env, status, exports); + status = napi_set_named_property(env, target, impl.first.c_str(), implFunc); + KOALA_NAPI_THROW_IF_FAILED(env, status, exports); + } + } + return ProvideModuleRegisterCallback()(env, exports); +} + +NAPI_MODULE(INTEROP_LIBRARY_NAME, InitModule) diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/napi/convertors-napi.h b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/napi/convertors-napi.h new file mode 100644 index 0000000000000000000000000000000000000000..90e9a1fc061257effde15084729c5b14d7529eaa --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/napi/convertors-napi.h @@ -0,0 +1,1471 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _CONVERTORS_NAPI_H_ +#define _CONVERTORS_NAPI_H_ + +#ifdef KOALA_NAPI + +#include +#include +#include + +#ifndef KOALA_NAPI_OHOS +#include +#else +#include +#include +#endif +#include "koala-types.h" +#include "interop-types.h" + +// TODO: switch to more generic convertors eventually. +template +struct InteropTypeConverter { + using InteropType = T; + static T convertFrom(napi_env env, InteropType value) { return value; } + static InteropType convertTo(napi_env env, T value) { return value; } + static void release(napi_env env, InteropType value, T converted) {} +}; + +template +inline typename InteropTypeConverter::InteropType makeResult(napi_env env, Type value) { + return InteropTypeConverter::convertTo(env, value); +} + +template +inline Type getArgument(napi_env env, typename InteropTypeConverter::InteropType arg) { + return InteropTypeConverter::convertFrom(env, arg); +} + +template +inline void releaseArgument(napi_env env, typename InteropTypeConverter::InteropType arg, Type data) { + InteropTypeConverter::release(env, arg, data); +} + + +napi_value makeString(napi_env env, KStringPtr value); +napi_value makeString(napi_env env, const std::string& value); +napi_value makeBoolean(napi_env env, KBoolean value); +napi_value makeInt32(napi_env env, int32_t value); +napi_value makeUInt32(napi_env env, uint32_t value); +napi_value makeInt64(napi_env env, int64_t value); +napi_value makeUInt64(napi_env env, uint64_t value); +napi_value makeFloat32(napi_env env, float value); +napi_value makePointer(napi_env env, void* value); +napi_value makeVoid(napi_env env); +// napi_value makeObject(napi_env env, napi_value object); + +void* getPointer(napi_env env, napi_value value); +void* getSerializerBufferPointer(napi_env env, napi_value value); + +template<> +struct InteropTypeConverter { + using InteropType = napi_value; + static KInteropBuffer convertFrom(napi_env env, InteropType value) { + KInteropBuffer result {}; + bool isArrayBuffer = false; + napi_is_arraybuffer(env, value, &isArrayBuffer); + if (isArrayBuffer) { + napi_get_arraybuffer_info(env, value, &result.data, (size_t*)&result.length); + } else { + bool isDataView = false; + napi_is_dataview(env, value, &isDataView); + if (isDataView) { + napi_get_dataview_info(env, value, (size_t*)&result.length, &result.data, nullptr, nullptr); + } + } + return result; + } + static InteropType convertTo(napi_env env, KInteropBuffer value) { + KInteropBuffer* copy = new KInteropBuffer(value); + napi_value result; + napi_status status = napi_create_external_arraybuffer( + env, + value.data, + value.length, + [](napi_env env, void* finalize_data, void* finalize_hint) { + KInteropBuffer* buffer = reinterpret_cast(finalize_hint); + buffer->dispose(buffer->resourceId); + delete buffer; + }, + (void*)copy, + &result + ); + if (status != napi_ok) { + // do smth here + } + return result; + }; + static void release(napi_env env, InteropType value, KInteropBuffer converted) {} +}; + +template<> +struct InteropTypeConverter { + using InteropType = napi_value; + static KStringPtr convertFrom(napi_env env, InteropType value) { + if (value == nullptr) return KStringPtr(); + KStringPtr result; + size_t length = 0; + napi_status status = napi_get_value_string_utf8(env, value, nullptr, 0, &length); + if (status != 0) return result; + result.resize(length); + status = napi_get_value_string_utf8(env, value, result.data(), length + 1, nullptr); + return result; + } + static InteropType convertTo(napi_env env, const KStringPtr& value) { + napi_value result; + napi_create_string_utf8(env, value.c_str(), value.length(), &result); + return result; + } + static void release(napi_env env, InteropType value, const KStringPtr& converted) {} +}; + +template<> +struct InteropTypeConverter { + using InteropType = napi_value; + static KInteropNumber convertFrom(napi_env env, InteropType interopValue) { + double value = 0.0; + napi_get_value_double(env, interopValue, &value); + return KInteropNumber::fromDouble(value); + } + static InteropType convertTo(napi_env env, KInteropNumber value) { + napi_value result; + napi_create_double(env, value.asDouble(), &result); + return result; + } + static void release(napi_env env, InteropType value, KInteropNumber converted) {} +}; + +template<> +struct InteropTypeConverter { + using InteropType = napi_value; + static KSerializerBuffer convertFrom(napi_env env, InteropType value) { + return (KSerializerBuffer)getSerializerBufferPointer(env, value); // TODO we are receiving Uint8Array from the native side + } + static InteropType convertTo(napi_env env, KSerializerBuffer value) { + return makePointer(env, value); + } + static void release(napi_env env, InteropType value, KSerializerBuffer converted) {} +}; + +template<> +struct InteropTypeConverter { + using InteropType = napi_value; + static inline KVMObjectHandle convertFrom(napi_env env, InteropType value) { + return reinterpret_cast(value); + } + static InteropType convertTo(napi_env env, KVMObjectHandle value) { + return reinterpret_cast(value); + } + static inline void release(napi_env env, InteropType value, KVMObjectHandle converted) { + } +}; + +template<> +struct InteropTypeConverter { + using InteropType = napi_value; + static inline KInteropReturnBuffer convertFrom(napi_env env, InteropType value) = delete; + static void disposer(napi_env env, void* data, void* hint) { + KInteropReturnBuffer* bufferCopy = (KInteropReturnBuffer*)hint; + bufferCopy->dispose(bufferCopy->data, bufferCopy->length); + delete bufferCopy; + } + static InteropType convertTo(napi_env env, KInteropReturnBuffer value) { + napi_value result = nullptr; + napi_value arrayBuffer = nullptr; + auto clone = new KInteropReturnBuffer(); + *clone = value; + napi_create_external_arraybuffer(env, value.data, value.length, disposer, clone, &arrayBuffer); + napi_create_typedarray(env, napi_uint8_array, value.length, arrayBuffer, 0, &result); + return result; + } + static inline void release(napi_env env, InteropType value, const KInteropReturnBuffer& converted) = delete; +}; + + +#define KOALA_INTEROP_THROW(vmContext, object, ...) \ + do { \ + napi_env env = (napi_env)vmContext; \ + napi_handle_scope scope = nullptr; \ + napi_open_handle_scope(env, &scope); \ + napi_throw(env, object); \ + napi_close_handle_scope(env, scope); \ + return __VA_ARGS__; \ + } while (0) + +#define KOALA_INTEROP_THROW_STRING(vmContext, message, ...) \ + do { \ + napi_env env = (napi_env)vmContext; \ + napi_handle_scope scope = nullptr; \ + napi_open_handle_scope(env, &scope); \ + napi_throw_error(env, nullptr, message); \ + napi_close_handle_scope(env, scope); \ + return __VA_ARGS__; \ + } while (0) + +#define NAPI_ASSERT_INDEX(info, index, result) \ + do { \ + if (static_cast(index) >= info.Length()) { \ + napi_throw_error(info.Env(), nullptr, "No such element");\ + return result; \ + } \ + } while (0) + +// Helpers from node-addon-api +#define KOALA_NAPI_THROW_IF_FAILED(env, status, ...) \ + if ((status) != napi_ok) { \ + const napi_extended_error_info* errorInfo; \ + napi_get_last_error_info(env, &errorInfo); \ + napi_throw_error(env, nullptr, errorInfo->error_message); \ + return __VA_ARGS__; \ + } +#define KOALA_NAPI_THROW_IF_FAILED_VOID(env, status) \ + if ((status) != napi_ok) { \ + const napi_extended_error_info* errorInfo; \ + napi_get_last_error_info(env, &errorInfo); \ + napi_throw_error(env, nullptr, errorInfo->error_message); \ + return; \ + } + +class CallbackInfo { +public: + CallbackInfo(napi_env env, napi_callback_info info) : _env(env) { + size_t size = 0; + napi_status status; + status = napi_get_cb_info(env, info, &size, nullptr, nullptr, nullptr); + KOALA_NAPI_THROW_IF_FAILED_VOID(env, status); + if (size > 0) { + args.resize(size); // TODO statically allocate small array for common case with few arguments passed + status = napi_get_cb_info(env, info, &size, args.data(), nullptr, nullptr); + KOALA_NAPI_THROW_IF_FAILED_VOID(env, status); + } + } + + napi_value operator[](size_t idx) const { + if (idx >= Length()) { + napi_value result; + napi_get_undefined(_env, &result); + return result; + } + return args[idx]; + } + + napi_env Env() const { + return _env; + } + + size_t Length() const { + return args.size(); + } +private: + napi_env _env; + // napi_callback_info _info; + std::vector args; +}; + +template +inline napi_typedarray_type getNapiType() = delete; + +template <> +inline napi_typedarray_type getNapiType() { + return napi_float32_array; +} + +template <> +inline napi_typedarray_type getNapiType() { + return napi_int8_array; +} + +template <> +inline napi_typedarray_type getNapiType() { + return napi_uint8_array; +} + +template <> +inline napi_typedarray_type getNapiType() { + return napi_int16_array; +} + +template <> +inline napi_typedarray_type getNapiType() { + return napi_uint16_array; +} + +template <> +inline napi_typedarray_type getNapiType() { + return napi_int32_array; +} + +template <> +inline napi_typedarray_type getNapiType() { + return napi_uint32_array; +} + +template <> +inline napi_typedarray_type getNapiType() { + return napi_biguint64_array; +} + +napi_valuetype getValueTypeChecked(napi_env env, napi_value value); +bool isTypedArray(napi_env env, napi_value value); + +template +inline ElemType* getTypedElements(napi_env env, napi_value value) { + napi_valuetype valueType = getValueTypeChecked(env, value); + if (valueType == napi_null) { + return nullptr; + } + if (!isTypedArray(env, value)) { + napi_throw_error(env, nullptr, "Expected TypedArray"); + return nullptr; + } + napi_value arrayBuffer; + void* data = nullptr; + size_t byteLength; + size_t byteOffset; + napi_typedarray_type type; + napi_status status = napi_get_typedarray_info(env, + value, + &type, + &byteLength, + &data, + &arrayBuffer, + &byteOffset); + KOALA_NAPI_THROW_IF_FAILED(env, status, nullptr); + if (type != getNapiType()) { + printf("Array type mismatch. Expected %d got %d\n", getNapiType(), type); + napi_throw_error(env, nullptr, "Array type mismatch"); + return nullptr; + } + return reinterpret_cast(data); +} + +template +inline ElemType* getTypedElements(const CallbackInfo& info, int index) { + NAPI_ASSERT_INDEX(info, index, nullptr); + return getTypedElements(info.Env(), info[index]); +} + +inline uint8_t* getUInt8Elements(const CallbackInfo& info, int index) { + return getTypedElements(info, index); +} + +inline int8_t* getInt8Elements(const CallbackInfo& info, int index) { + return getTypedElements(info, index); +} + +inline uint16_t* getUInt16Elements(const CallbackInfo& info, int index) { + return getTypedElements(info, index); +} + +inline int16_t* getInt16Elements(const CallbackInfo& info, int index) { + return getTypedElements(info, index); +} + +inline uint32_t* getUInt32Elements(const CallbackInfo& info, int index) { + return getTypedElements(info, index); +} + +inline uint32_t* getUInt32Elements(napi_env env, napi_value value) { + return getTypedElements(env, value); +} + +inline int32_t* getInt32Elements(const CallbackInfo& info, int index) { + return getTypedElements(info, index); +} + +inline float* getFloat32Elements(const CallbackInfo& info, int index) { + return getTypedElements(info, index); +} + +inline KNativePointer* getPointerElements(const CallbackInfo& info, int index) { + return getTypedElements(info, index); +} + +inline void* getSerializerBufferPointer(napi_env env, napi_value value) { + return getTypedElements(env, value); +} + +KInt getInt32(napi_env env, napi_value value); +inline int32_t getInt32(const CallbackInfo& info, int index) { + NAPI_ASSERT_INDEX(info, index, 0); + return getInt32(info.Env(), info[index]); +} +KUInt getUInt32(napi_env env, napi_value value); +inline uint32_t getUInt32(const CallbackInfo& info, int index) { + NAPI_ASSERT_INDEX(info, index, 0); + return getUInt32(info.Env(), info[index]); +} +KFloat getFloat32(napi_env env, napi_value value); +inline float getFloat32(const CallbackInfo& info, int index) { + NAPI_ASSERT_INDEX(info, index, 0.0f); + return getFloat32(info.Env(), info[index]); +} +KDouble getFloat64(napi_env env, napi_value value); +inline KDouble getFloat64(const CallbackInfo& info, int index) { + NAPI_ASSERT_INDEX(info, index, 0.0); + return getFloat64(info.Env(), info[index]); +} +KStringPtr getString(napi_env env, napi_value value); +inline KStringPtr getString(const CallbackInfo& info, int index) { + NAPI_ASSERT_INDEX(info, index, KStringPtr()); + return getString(info.Env(), info[index]); +} +inline void* getPointer(const CallbackInfo& info, int index) { + NAPI_ASSERT_INDEX(info, index, nullptr); + return getPointer(info.Env(), info[index]); +} +KULong getUInt64(napi_env env, napi_value value); +inline KULong getUInt64(const CallbackInfo& info, int index) { + NAPI_ASSERT_INDEX(info, index, 0); + return getUInt64(info.Env(), info[index]); +} +KLong getInt64(napi_env env, napi_value value); +inline KLong getInt64(const CallbackInfo& info, int index) { + NAPI_ASSERT_INDEX(info, index, 0); + return getInt64(info.Env(), info[index]); +} +KBoolean getBoolean(napi_env env, napi_value value); +inline KBoolean getBoolean(const CallbackInfo& info, int index) { + NAPI_ASSERT_INDEX(info, index, false); + return getBoolean(info.Env(), info[index]); +} +// TODO should we keep supporting conversion to and from raw JS object values? +// napi_value getObject(napi_env env, napi_value value); +// inline napi_value getObject(const CallbackInfo& info, int index) { +// NAPI_ASSERT_INDEX(info, index, info.Env().Global()); +// return getObject(info.Env(), info[index]); +// } + +template +inline Type getArgument(const CallbackInfo& info, int index) = delete; + +template <> +inline KBoolean getArgument(const CallbackInfo& info, int index) { + return getBoolean(info, index); +} + +template <> +inline KUInt getArgument(const CallbackInfo& info, int index) { + return getUInt32(info, index); +} + +template <> +inline KInt getArgument(const CallbackInfo& info, int index) { + return getInt32(info, index); +} + +template <> +inline KInteropNumber getArgument(const CallbackInfo& info, int index) { + NAPI_ASSERT_INDEX(info, index, { 0 }); + return getArgument(info.Env(), info[index]); +} + +template <> +inline KSerializerBuffer getArgument(const CallbackInfo& info, int index) { + NAPI_ASSERT_INDEX(info, index, nullptr); + return getArgument(info.Env(), info[index]); +} + +template <> +inline KLength getArgument(const CallbackInfo& info, int index) { + KLength result { 0 }; + NAPI_ASSERT_INDEX(info, index, result); + auto value = info[index]; + napi_valuetype type; + auto status = napi_typeof(info.Env(), value, &type); + if (status != 0) return result; + switch (type) { + case napi_number: { + result.value = getFloat32(info.Env(), value); + result.unit = 1; + result.type = 0; + break; + } + case napi_string: { + KStringPtr string = getString(info.Env(), value); + parseKLength(string, &result); + result.type = 1; + result.resource = 0; + break; + } + case napi_object: { + result.value = 0; + result.unit = 1; + result.type = 2; + napi_value field; + napi_status status = napi_get_named_property(info.Env(), value, "id", &field); + if (status == 0) { + status = napi_get_value_int32(info.Env(), field, &result.resource); + if (status != 0) result.resource = 0; + } else { + result.resource = 0; + } + break; + } + default: + INTEROP_FATAL("Error, unexpected KLength type"); + } + return result; +} + + +template <> +inline KInteropBuffer getArgument(const CallbackInfo& info, int index) { + NAPI_ASSERT_INDEX(info, index, {}); + return getArgument((napi_env)info.Env(), (napi_value)info[index]); +} + +template <> +inline KFloat getArgument(const CallbackInfo& info, int index) { + return getFloat32(info, index); +} + +template <> +inline KDouble getArgument(const CallbackInfo& info, int index) { + return getFloat64(info, index); +} + +template <> +inline KNativePointer getArgument(const CallbackInfo& info, int index) { + return getPointer(info, index); +} + +template <> +inline KLong getArgument(const CallbackInfo& info, int index) { + return getInt64(info, index); +} + +template <> +inline KULong getArgument(const CallbackInfo& info, int index) { + return getUInt64(info, index); +} + +template <> +inline KNativePointerArray getArgument(const CallbackInfo& info, int index) { + return getPointerElements(info, index); +} + +// template <> +// inline napi_value getArgument(const CallbackInfo& info, int index) { +// return getObject(info, index); +// } + +template <> +inline uint8_t* getArgument(const CallbackInfo& info, int index) { + return getUInt8Elements(info, index); +} + +template <> +inline const uint8_t* getArgument(const CallbackInfo& info, int index) { + return getUInt8Elements(info, index); +} + +template <> +inline int8_t* getArgument(const CallbackInfo& info, int index) { + return getInt8Elements(info, index); +} + +template <> +inline int16_t* getArgument(const CallbackInfo& info, int index) { + return getInt16Elements(info, index); +} + +template <> +inline uint16_t* getArgument(const CallbackInfo& info, int index) { + return getUInt16Elements(info, index); +} + +template <> +inline int32_t* getArgument(const CallbackInfo& info, int index) { + return getInt32Elements(info, index); +} + +template <> +inline uint32_t* getArgument(const CallbackInfo& info, int index) { + return getUInt32Elements(info, index); +} + +template <> +inline float* getArgument(const CallbackInfo& info, int index) { + return getFloat32Elements(info, index); +} + +template <> +inline KStringPtr getArgument(const CallbackInfo& info, int index) { + return getString(info, index); +} + +inline napi_value makeVoid(const CallbackInfo& info) { + return makeVoid(info.Env()); +} + +template +inline napi_value makeResult(const CallbackInfo& info, Type value) = delete; + +template <> +inline napi_value makeResult(const CallbackInfo& info, KBoolean value) { + return makeBoolean(info.Env(), value); +} + +template <> +inline napi_value makeResult(const CallbackInfo& info, int32_t value) { + return makeInt32(info.Env(), value); +} + +template <> +inline napi_value makeResult(const CallbackInfo& info, uint32_t value) { + return makeUInt32(info.Env(), value); +} + +template <> +inline napi_value makeResult(const CallbackInfo& info, int64_t value) { + return makeInt64(info.Env(), value); +} + +template <> +inline napi_value makeResult(const CallbackInfo& info, uint64_t value) { + return makeUInt64(info.Env(), value); +} + +template <> +inline napi_value makeResult(const CallbackInfo& info, float value) { + return makeFloat32(info.Env(), value); +} + +template <> +inline napi_value makeResult(const CallbackInfo& info, KNativePointer value) { + return makePointer(info.Env(), value); +} + +template <> +inline napi_value makeResult(const CallbackInfo& info, KVMObjectHandle value) { + return InteropTypeConverter::convertTo(info.Env(), value); +} + +template <> +inline napi_value makeResult(const CallbackInfo& info, KStringPtr value) { + return InteropTypeConverter::convertTo(info.Env(), value); +} + +template <> +inline napi_value makeResult(const CallbackInfo& info, KInteropBuffer value) { + return InteropTypeConverter::convertTo(info.Env(), value); +} + +template <> +inline napi_value makeResult(const CallbackInfo& info, KInteropReturnBuffer value) { + return InteropTypeConverter::convertTo(info.Env(), value); +} + +template <> +inline napi_value makeResult(const CallbackInfo& info, KInteropNumber value) { + return InteropTypeConverter::convertTo(info.Env(), value); +} + +typedef napi_value (*napi_type_t)(napi_env, napi_callback_info); + +class Exports { + std::unordered_map>> implementations; + +public: + static Exports* getInstance(); + + std::vector getModules(); + void addMethod(const char* module, const char* name, napi_type_t impl); + const std::vector>& getMethods(const std::string& module); +}; + +#define __QUOTE(x) #x +#define QUOTE(x) __QUOTE(x) + +#ifdef _MSC_VER +#define MAKE_NODE_EXPORT(module, name) \ + static void __init_##name() { \ + Exports::getInstance()->addMethod(QUOTE(module), "_"#name, Node_##name); \ + } \ + namespace { \ + struct __Init_##name { \ + __Init_##name() { __init_##name(); } \ + } __Init_##name##_v; \ + } +#else +#define MAKE_NODE_EXPORT(module, name) \ + __attribute__((constructor)) \ + static void __init_##name() { \ + Exports::getInstance()->addMethod(QUOTE(module), "_"#name, Node_##name); \ + } +#endif + +#ifndef KOALA_INTEROP_MODULE +#error KOALA_INTEROP_MODULE is undefined +#endif + +#define MAKE_INTEROP_NODE_EXPORT(name) MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_0(name, Ret) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + return makeResult(info, impl_##name()); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_1(name, Ret, P0) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + return makeResult(info, impl_##name(p0)); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_2(name, Ret, P0, P1) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + return makeResult(info, impl_##name(p0, p1)); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_3(name, Ret, P0, P1, P2) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + return makeResult(info, impl_##name(p0, p1, p2)); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_4(name, Ret, P0, P1, P2, P3) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + return makeResult(info, impl_##name(p0, p1, p2, p3)); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_5(name, Ret, P0, P1, P2, P3, P4) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + P4 p4 = getArgument(info, 4); \ + return makeResult(info, impl_##name(p0, p1, p2, p3, p4)); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_6(name, Ret, P0, P1, P2, P3, P4, P5) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + P4 p4 = getArgument(info, 4); \ + P5 p5 = getArgument(info, 5); \ + return makeResult(info, impl_##name(p0, p1, p2, p3, p4, p5)); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_7(name, Ret, P0, P1, P2, P3, P4, P5, P6) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + P4 p4 = getArgument(info, 4); \ + P5 p5 = getArgument(info, 5); \ + P6 p6 = getArgument(info, 6); \ + return makeResult(info, impl_##name(p0, p1, p2, p3, p4, p5, p6)); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_8(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + P4 p4 = getArgument(info, 4); \ + P5 p5 = getArgument(info, 5); \ + P6 p6 = getArgument(info, 6); \ + P7 p7 = getArgument(info, 7); \ + return makeResult(info, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7)); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_9(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + P4 p4 = getArgument(info, 4); \ + P5 p5 = getArgument(info, 5); \ + P6 p6 = getArgument(info, 6); \ + P7 p7 = getArgument(info, 7); \ + P8 p8 = getArgument(info, 8); \ + return makeResult(info, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8)); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_10(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + P4 p4 = getArgument(info, 4); \ + P5 p5 = getArgument(info, 5); \ + P6 p6 = getArgument(info, 6); \ + P7 p7 = getArgument(info, 7); \ + P8 p8 = getArgument(info, 8); \ + P9 p9 = getArgument(info, 9); \ + return makeResult(info, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_11(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + P4 p4 = getArgument(info, 4); \ + P5 p5 = getArgument(info, 5); \ + P6 p6 = getArgument(info, 6); \ + P7 p7 = getArgument(info, 7); \ + P8 p8 = getArgument(info, 8); \ + P9 p9 = getArgument(info, 9); \ + P10 p10 = getArgument(info, 10); \ + return makeResult(info, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10)); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_12(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + P4 p4 = getArgument(info, 4); \ + P5 p5 = getArgument(info, 5); \ + P6 p6 = getArgument(info, 6); \ + P7 p7 = getArgument(info, 7); \ + P8 p8 = getArgument(info, 8); \ + P9 p9 = getArgument(info, 9); \ + P10 p10 = getArgument(info, 10); \ + P11 p11 = getArgument(info, 11); \ + return makeResult(info, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11)); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_13(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + P4 p4 = getArgument(info, 4); \ + P5 p5 = getArgument(info, 5); \ + P6 p6 = getArgument(info, 6); \ + P7 p7 = getArgument(info, 7); \ + P8 p8 = getArgument(info, 8); \ + P9 p9 = getArgument(info, 9); \ + P10 p10 = getArgument(info, 10); \ + P11 p11 = getArgument(info, 11); \ + P12 p12 = getArgument(info, 12); \ + return makeResult(info, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12)); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_14(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + P4 p4 = getArgument(info, 4); \ + P5 p5 = getArgument(info, 5); \ + P6 p6 = getArgument(info, 6); \ + P7 p7 = getArgument(info, 7); \ + P8 p8 = getArgument(info, 8); \ + P9 p9 = getArgument(info, 9); \ + P10 p10 = getArgument(info, 10); \ + P11 p11 = getArgument(info, 11); \ + P12 p12 = getArgument(info, 12); \ + P13 p13 = getArgument(info, 13); \ + return makeResult(info, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13)); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_V0(name) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + impl_##name(); \ + return makeVoid(info); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_V1(name, P0) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + impl_##name(p0); \ + return makeVoid(info); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_V2(name, P0, P1) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + impl_##name(p0, p1); \ + return makeVoid(info); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_V3(name, P0, P1, P2) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + impl_##name(p0, p1, p2); \ + return makeVoid(info); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_V4(name, P0, P1, P2, P3) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + impl_##name(p0, p1, p2, p3); \ + return makeVoid(info); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_V5(name, P0, P1, P2, P3, P4) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + P4 p4 = getArgument(info, 4); \ + impl_##name(p0, p1, p2, p3, p4); \ + return makeVoid(info); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_V6(name, P0, P1, P2, P3, P4, P5) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + P4 p4 = getArgument(info, 4); \ + P5 p5 = getArgument(info, 5); \ + impl_##name(p0, p1, p2, p3, p4, p5); \ + return makeVoid(info); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_V7(name, P0, P1, P2, P3, P4, P5, P6) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + P4 p4 = getArgument(info, 4); \ + P5 p5 = getArgument(info, 5); \ + P6 p6 = getArgument(info, 6); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6); \ + return makeVoid(info); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_V8(name, P0, P1, P2, P3, P4, P5, P6, P7) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + P4 p4 = getArgument(info, 4); \ + P5 p5 = getArgument(info, 5); \ + P6 p6 = getArgument(info, 6); \ + P7 p7 = getArgument(info, 7); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7); \ + return makeVoid(info); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_V9(name, P0, P1, P2, P3, P4, P5, P6, P7, P8) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(impl_##name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + P4 p4 = getArgument(info, 4); \ + P5 p5 = getArgument(info, 5); \ + P6 p6 = getArgument(info, 6); \ + P7 p7 = getArgument(info, 7); \ + P8 p8 = getArgument(info, 8); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8); \ + return makeVoid(info); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_V10(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + P4 p4 = getArgument(info, 4); \ + P5 p5 = getArgument(info, 5); \ + P6 p6 = getArgument(info, 6); \ + P7 p7 = getArgument(info, 7); \ + P8 p8 = getArgument(info, 8); \ + P9 p9 = getArgument(info, 9); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9); \ + return makeVoid(info); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_V11(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(impl_##name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + P4 p4 = getArgument(info, 4); \ + P5 p5 = getArgument(info, 5); \ + P6 p6 = getArgument(info, 6); \ + P7 p7 = getArgument(info, 7); \ + P8 p8 = getArgument(info, 8); \ + P9 p9 = getArgument(info, 9); \ + P10 p10 = getArgument(info, 10); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); \ + return makeVoid(info); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_V12(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(impl_##name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + P4 p4 = getArgument(info, 4); \ + P5 p5 = getArgument(info, 5); \ + P6 p6 = getArgument(info, 6); \ + P7 p7 = getArgument(info, 7); \ + P8 p8 = getArgument(info, 8); \ + P9 p9 = getArgument(info, 9); \ + P10 p10 = getArgument(info, 10); \ + P11 p11 = getArgument(info, 11); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11); \ + return makeVoid(info); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_V13(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(impl_##name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + P4 p4 = getArgument(info, 4); \ + P5 p5 = getArgument(info, 5); \ + P6 p6 = getArgument(info, 6); \ + P7 p7 = getArgument(info, 7); \ + P8 p8 = getArgument(info, 8); \ + P9 p9 = getArgument(info, 9); \ + P10 p10 = getArgument(info, 10); \ + P11 p11 = getArgument(info, 11); \ + P12 p12 = getArgument(info, 12); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12); \ + return makeVoid(info); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_V14(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + P4 p4 = getArgument(info, 4); \ + P5 p5 = getArgument(info, 5); \ + P6 p6 = getArgument(info, 6); \ + P7 p7 = getArgument(info, 7); \ + P8 p8 = getArgument(info, 8); \ + P9 p9 = getArgument(info, 9); \ + P10 p10 = getArgument(info, 10); \ + P11 p11 = getArgument(info, 11); \ + P12 p12 = getArgument(info, 12); \ + P13 p13 = getArgument(info, 13); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13); \ + return makeVoid(info); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_V15(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + P4 p4 = getArgument(info, 4); \ + P5 p5 = getArgument(info, 5); \ + P6 p6 = getArgument(info, 6); \ + P7 p7 = getArgument(info, 7); \ + P8 p8 = getArgument(info, 8); \ + P9 p9 = getArgument(info, 9); \ + P10 p10 = getArgument(info, 10); \ + P11 p11 = getArgument(info, 11); \ + P12 p12 = getArgument(info, 12); \ + P13 p13 = getArgument(info, 13); \ + P14 p14 = getArgument(info, 14); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14); \ + return makeVoid(info); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_CTX_0(name, Ret) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(impl_##name) \ + CallbackInfo info(env, cbinfo); \ + KVMContext ctx = reinterpret_cast((napi_env)info.Env()); \ + return makeResult(info, impl_##name(ctx)); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_CTX_1(name, Ret, P0) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(impl_##name) \ + CallbackInfo info(env, cbinfo); \ + KVMContext ctx = reinterpret_cast((napi_env)info.Env()); \ + P0 p0 = getArgument(info, 0); \ + return makeResult(info, impl_##name(ctx, p0)); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_CTX_2(name, Ret, P0, P1) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + KVMContext ctx = reinterpret_cast((napi_env)info.Env()); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + return makeResult(info, impl_##name(ctx, p0, p1)); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_CTX_3(name, Ret, P0, P1, P2) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + KVMContext ctx = reinterpret_cast((napi_env)info.Env()); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + return makeResult(info, impl_##name(ctx, p0, p1, p2)); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_CTX_4(name, Ret, P0, P1, P2, P3) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + KVMContext ctx = reinterpret_cast((napi_env)info.Env()); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + return makeResult(info, impl_##name(ctx, p0, p1, p2, p3)); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_CTX_5(name, Ret, P0, P1, P2, P3, P4) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + KVMContext ctx = reinterpret_cast((napi_env)info.Env()); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + P4 p4 = getArgument(info, 4); \ + return makeResult(info, impl_##name(ctx, p0, p1, p2, p3, p4)); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_CTX_V0(name) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + KVMContext ctx = reinterpret_cast((napi_env)info.Env()); \ + impl_##name(ctx); \ + return makeVoid(info); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + + +#define KOALA_INTEROP_CTX_V1(name, P0) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + KVMContext ctx = reinterpret_cast((napi_env)info.Env()); \ + P0 p0 = getArgument(info, 0); \ + impl_##name(ctx, p0); \ + return makeVoid(info); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_CTX_V2(name, P0, P1) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + KVMContext ctx = reinterpret_cast((napi_env)info.Env()); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + impl_##name(ctx, p0, p1); \ + return makeVoid(info); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_CTX_V3(name, P0, P1, P2) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + KVMContext ctx = reinterpret_cast((napi_env)info.Env()); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + impl_##name(ctx, p0, p1, p2); \ + return makeVoid(info); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_CTX_V4(name, P0, P1, P2, P3) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + KVMContext ctx = reinterpret_cast((napi_env)info.Env()); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + impl_##name(ctx, p0, p1, p2, p3); \ + return makeVoid(info); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_CTX_V5(name, P0, P1, P2, P3, P4) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + KVMContext ctx = reinterpret_cast((napi_env)info.Env()); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + P4 p4 = getArgument(info, 4); \ + impl_##name(ctx, p0, p1, p2, p3, p4); \ + return makeVoid(info); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define NODEJS_GET_AND_THROW_LAST_ERROR(env) \ + do { \ + const napi_extended_error_info *error_info; \ + napi_get_last_error_info((env), &error_info); \ + bool is_pending; \ + napi_is_exception_pending((env), &is_pending); \ + /* If an exception is already pending, don't rethrow it */ \ + if (!is_pending) { \ + const char* error_message = error_info->error_message != NULL ? \ + error_info->error_message : \ + "empty error message"; \ + napi_throw_error((env), NULL, error_message); \ + } \ + } while (0) + + #define KOALA_INTEROP_DIRECT_0(name, Ret) \ + KOALA_INTEROP_0(name, Ret) +#define KOALA_INTEROP_DIRECT_1(name, Ret, P0) \ + KOALA_INTEROP_1(name, Ret, P0) +#define KOALA_INTEROP_DIRECT_2(name, Ret, P0, P1) \ + KOALA_INTEROP_2(name, Ret, P0, P1) +#define KOALA_INTEROP_DIRECT_3(name, Ret, P0, P1, P2) \ + KOALA_INTEROP_3(name, Ret, P0, P1, P2) +#define KOALA_INTEROP_DIRECT_4(name, Ret, P0, P1, P2, P3) \ + KOALA_INTEROP_4(name, Ret, P0, P1, P2, P3) +#define KOALA_INTEROP_DIRECT_5(name, Ret, P0, P1, P2, P3, P4) \ + KOALA_INTEROP_5(name, Ret, P0, P1, P2, P3, P4) +#define KOALA_INTEROP_DIRECT_6(name, Ret, P0, P1, P2, P3, P4, P5) \ + KOALA_INTEROP_6(name, Ret, P0, P1, P2, P3, P4, P5) +#define KOALA_INTEROP_DIRECT_7(name, Ret, P0, P1, P2, P3, P4, P5, P6) \ + KOALA_INTEROP_7(name, Ret, P0, P1, P2, P3, P4, P5, P6) +#define KOALA_INTEROP_DIRECT_8(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7) \ + KOALA_INTEROP_8(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7) +#define KOALA_INTEROP_DIRECT_9(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8) \ + KOALA_INTEROP_9(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8) +#define KOALA_INTEROP_DIRECT_10(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) \ + KOALA_INTEROP_10(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) +#define KOALA_INTEROP_DIRECT_11(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) \ + KOALA_INTEROP_11(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) +#define KOALA_INTEROP_DIRECT_V0(name) \ + KOALA_INTEROP_V0(name) +#define KOALA_INTEROP_DIRECT_V1(name, P0) \ + KOALA_INTEROP_V1(name, P0) +#define KOALA_INTEROP_DIRECT_V2(name, P0, P1) \ + KOALA_INTEROP_V2(name, P0, P1) +#define KOALA_INTEROP_DIRECT_V3(name, P0, P1, P2) \ + KOALA_INTEROP_V3(name, P0, P1, P2) +#define KOALA_INTEROP_DIRECT_V4(name, P0, P1, P2, P3) \ + KOALA_INTEROP_V4(name, P0, P1, P2, P3) +#define KOALA_INTEROP_DIRECT_V5(name, P0, P1, P2, P3, P4) \ + KOALA_INTEROP_V5(name, P0, P1, P2, P3, P4) +#define KOALA_INTEROP_DIRECT_V6(name, P0, P1, P2, P3, P4, P5) \ + KOALA_INTEROP_V6(name, P0, P1, P2, P3, P4, P5) +#define KOALA_INTEROP_DIRECT_V7(name, P0, P1, P2, P3, P4, P5, P6) \ + KOALA_INTEROP_V7(name, P0, P1, P2, P3, P4, P5, P6) +#define KOALA_INTEROP_DIRECT_V8(name, P0, P1, P2, P3, P4, P5, P6, P7) \ + KOALA_INTEROP_V8(name, P0, P1, P2, P3, P4, P5, P6, P7) +#define KOALA_INTEROP_DIRECT_V9(name, P0, P1, P2, P3, P4, P5, P6, P7, P8) \ + KOALA_INTEROP_V9(name, P0, P1, P2, P3, P4, P5, P6, P7, P8) +#define KOALA_INTEROP_DIRECT_V10(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) \ + KOALA_INTEROP_V10(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) +#define KOALA_INTEROP_DIRECT_V11(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) \ + KOALA_INTEROP_V11(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) + +napi_value getKoalaNapiCallbackDispatcher(napi_env env); +// TODO: can/shall we cache bridge reference? + +#define KOALA_INTEROP_CALL_VOID(venv, id, length, args) \ +{ \ + napi_env env = reinterpret_cast(venv); \ + napi_value bridge = getKoalaNapiCallbackDispatcher(env), \ + global = nullptr, return_val = nullptr; \ + napi_handle_scope scope = nullptr; \ + napi_open_handle_scope(env, &scope); \ + napi_status status = napi_get_global(env, &global); \ + napi_value node_args[3]; \ + napi_create_int32(env, id, &node_args[0]); \ + napi_value buffer = nullptr; \ + napi_create_external_arraybuffer(env, \ + args, length, \ + [](napi_env, void* data, void* hint) {}, nullptr, &buffer); \ + napi_create_typedarray(env, napi_uint8_array, length, buffer, 0, &node_args[1]); \ + napi_create_int32(env, length, &node_args[2]); \ + status = napi_call_function(env, global, bridge, 3, node_args, &return_val); \ + if (status != napi_ok) NODEJS_GET_AND_THROW_LAST_ERROR((env)); \ + napi_close_handle_scope(env, scope); \ +} + +#define KOALA_INTEROP_CALL_INT(venv, id, length, args) \ +{ \ + napi_env env = reinterpret_cast(venv); \ + napi_value bridge = getKoalaNapiCallbackDispatcher(env), \ + global = nullptr, return_val = nullptr; \ + napi_handle_scope scope = nullptr; \ + napi_open_handle_scope(env, &scope); \ + napi_status status = napi_get_global(env, &global); \ + napi_value node_args[3]; \ + napi_create_int32(env, id, &node_args[0]); \ + napi_value buffer = nullptr; \ + napi_create_external_arraybuffer(env, \ + args, length, \ + [](napi_env, void* data, void* hint) {}, nullptr, &buffer); \ + napi_create_typedarray(env, napi_uint8_array, length, buffer, 0, &node_args[1]); \ + napi_create_int32(env, length, &node_args[2]); \ + status = napi_call_function(env, global, bridge, 3, node_args, &return_val); \ + if (status != napi_ok) NODEJS_GET_AND_THROW_LAST_ERROR((env)); \ + int result; \ + status = napi_get_value_int32(env, return_val, &result); \ + napi_close_handle_scope(env, scope); \ + return result; \ +} + +#define KOALA_INTEROP_CALL_VOID_INTS32(venv, id, argc, args) KOALA_INTEROP_CALL_VOID(venv, id, (argc) * sizeof(int32_t), args) +#define KOALA_INTEROP_CALL_INT_INTS32(venv, id, argc, args) KOALA_INTEROP_CALL_INT(venv, id, (argc) * sizeof(int32_t), args) + +#endif // KOALA_NAPI + +#endif // _CONVERTORS_NAPI_H_ \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/napi/win-dynamic-node.cc b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/napi/win-dynamic-node.cc new file mode 100644 index 0000000000000000000000000000000000000000..81ea1d185c837710c4df839c0a3ec1e874be65fb --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/napi/win-dynamic-node.cc @@ -0,0 +1,637 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include +#include +#include "node_api.h" + +#define NAPI_CDECL __cdecl + +#define NAPI_FUNCTIONS(op) \ + op(napi_module_register) \ + op(napi_create_function) \ + op(napi_set_named_property) \ + op(napi_create_string_utf8) \ + op(napi_add_env_cleanup_hook) \ + op(napi_get_last_error_info) \ + op(napi_get_value_bigint_int64) \ + op(napi_get_value_bigint_uint64) \ + op(napi_create_object) \ + op(napi_get_arraybuffer_info) \ + op(napi_create_bigint_uint64) \ + op(napi_is_typedarray) \ + op(napi_add_finalizer) \ + op(napi_get_typedarray_info) \ + op(napi_set_property) \ + op(napi_get_value_bool) \ + op(napi_coerce_to_string) \ + op(napi_get_value_uint32) \ + op(napi_get_value_int32) \ + op(napi_throw) \ + op(napi_get_cb_info) \ + op(napi_create_error) \ + op(napi_get_value_string_utf8) \ + op(napi_define_properties) \ + op(napi_delete_reference) \ + op(napi_get_reference_value) \ + op(napi_open_handle_scope) \ + op(napi_close_handle_scope) \ + op(napi_open_escapable_handle_scope) \ + op(napi_close_escapable_handle_scope) \ + op(napi_is_exception_pending) \ + op(napi_create_type_error) \ + op(napi_escape_handle) \ + op(napi_get_and_clear_last_exception) \ + op(napi_fatal_error) \ + op(napi_create_double) \ + op(napi_typeof) \ + op(napi_get_property) \ + op(napi_get_named_property) \ + op(napi_create_reference) \ + op(napi_get_global) \ + op(napi_has_property) \ + op(napi_get_undefined) \ + op(napi_get_value_double) \ + op(napi_close_callback_scope) \ + op(napi_async_destroy) \ + op(napi_call_function) \ + op(napi_get_value_external) \ + op(napi_throw_error) \ + op(napi_create_int32) \ + op(napi_create_external_arraybuffer) \ + op(napi_create_typedarray) \ + op(napi_create_string_latin1) \ + op(napi_create_async_work) \ + op(napi_delete_async_work) \ + op(napi_queue_async_work) \ + op(napi_resolve_deferred) \ + op(napi_reject_deferred) \ + op(napi_create_promise) \ + op(napi_create_threadsafe_function) \ + op(napi_acquire_threadsafe_function) \ + op(napi_release_threadsafe_function) \ + op(napi_call_threadsafe_function) \ + op(napi_is_dataview) \ + op(napi_is_arraybuffer) \ + op(napi_get_dataview_info) + +#define DECL_NAPI_IMPL(fn_name, ...) decltype(&fn_name) p_##fn_name; + +NAPI_FUNCTIONS(DECL_NAPI_IMPL) + +bool LoadNapiFunctions() { + static bool isLoaded = false; + if (isLoaded) return true; + HMODULE nodeModule = GetModuleHandle(NULL); + FARPROC fn_addr = GetProcAddress(nodeModule, "napi_module_register"); + + if (fn_addr == NULL) { + nodeModule = GetModuleHandleA("node.dll"); + if (nodeModule == NULL) return false; + fn_addr = GetProcAddress(nodeModule, "napi_module_register"); + if (fn_addr == NULL) { + return false; + } + } + bool apiLoadFailed = false; + +#define GET_NAPI_IMPL(fn_name) \ + fn_addr = GetProcAddress(nodeModule, #fn_name); \ + if (fn_addr == NULL) apiLoadFailed = true; \ + p_##fn_name = (decltype(p_##fn_name))fn_addr; + + // Assign the addresses of the needed functions to the "p*" named pointers. + NAPI_FUNCTIONS(GET_NAPI_IMPL); + + // If any required APIs failed to load, return false + if (apiLoadFailed) return false; + + isLoaded = true; + + return true; +} + +NAPI_EXTERN void NAPI_CDECL +napi_module_register(napi_module* mod) { + LoadNapiFunctions(); + p_napi_module_register(mod); +} + +NAPI_EXTERN napi_status NAPI_CDECL +napi_get_last_error_info(napi_env env, const napi_extended_error_info** result) { + LoadNapiFunctions(); + return p_napi_get_last_error_info(env, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_get_value_bigint_int64( + napi_env env, napi_value value, int64_t* result, bool* lossless) { + LoadNapiFunctions(); + return p_napi_get_value_bigint_int64(env, value, result, lossless); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_get_value_bigint_uint64( + napi_env env, napi_value value, uint64_t* result, bool* lossless) { + LoadNapiFunctions(); + return p_napi_get_value_bigint_uint64(env, value, result, lossless); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_create_object(napi_env env, napi_value* result) { + LoadNapiFunctions(); + return p_napi_create_object(env, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_get_arraybuffer_info(napi_env env, napi_value arraybuffer, void** data, size_t* byte_length) { + LoadNapiFunctions(); + return p_napi_get_arraybuffer_info(env, arraybuffer, data, byte_length); +} + +NAPI_EXTERN napi_status NAPI_CDECL +napi_create_bigint_uint64(napi_env env, uint64_t value, napi_value* result) { + LoadNapiFunctions(); + return p_napi_create_bigint_uint64(env, value, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_is_typedarray(napi_env env, napi_value value, bool* result) { + LoadNapiFunctions(); + return p_napi_is_typedarray(env, value, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL +napi_add_finalizer(napi_env env, + napi_value js_object, + void* finalize_data, + napi_finalize finalize_cb, + void* finalize_hint, + napi_ref* result) { + LoadNapiFunctions(); + return p_napi_add_finalizer(env, js_object, finalize_data, finalize_cb, finalize_hint, result); +} + + +NAPI_EXTERN napi_status NAPI_CDECL +napi_get_typedarray_info(napi_env env, + napi_value typedarray, + napi_typedarray_type* type, + size_t* length, + void** data, + napi_value* arraybuffer, + size_t* byte_offset) { + LoadNapiFunctions(); + return p_napi_get_typedarray_info(env, typedarray, type, length, data, arraybuffer, byte_offset); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_set_property(napi_env env, + napi_value object, + napi_value key, + napi_value value) { + LoadNapiFunctions(); + return p_napi_set_property(env, object, key, value); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_get_value_bool(napi_env env, + napi_value value, + bool* result) { + LoadNapiFunctions(); + return p_napi_get_value_bool(env, value, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_coerce_to_string(napi_env env, + napi_value value, + napi_value* result) { + LoadNapiFunctions(); + return p_napi_coerce_to_string(env, value, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_get_value_int32(napi_env env, + napi_value value, + int32_t* result) { + LoadNapiFunctions(); + return p_napi_get_value_int32(env, value, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_get_cb_info( + napi_env env, + napi_callback_info cbinfo, + size_t* argc, + napi_value* argv, + napi_value* this_arg, + void** data) { + LoadNapiFunctions(); + return p_napi_get_cb_info(env, cbinfo, argc, argv, this_arg, data); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_create_string_utf8(napi_env env, + const char* str, + size_t length, + napi_value* result) { + LoadNapiFunctions(); + return p_napi_create_string_utf8(env, str, length, result); +} + + +NAPI_EXTERN napi_status NAPI_CDECL napi_throw(napi_env env, napi_value error) { + LoadNapiFunctions(); + return p_napi_throw(env, error); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_create_error(napi_env env, + napi_value code, + napi_value msg, + napi_value* result) { + LoadNapiFunctions(); + return p_napi_create_error(env, code, msg, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_get_value_string_utf8( + napi_env env, napi_value value, char* buf, size_t bufsize, size_t* result) { + LoadNapiFunctions(); + return p_napi_get_value_string_utf8(env, value, buf, bufsize, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL +napi_define_properties(napi_env env, + napi_value object, + size_t property_count, + const napi_property_descriptor* properties) { + LoadNapiFunctions(); + return p_napi_define_properties(env, object, property_count, properties); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_delete_reference(napi_env env, + napi_ref ref) { + LoadNapiFunctions(); + return p_napi_delete_reference(env, ref); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_get_reference_value(napi_env env, + napi_ref ref, + napi_value* result) { + LoadNapiFunctions(); + return p_napi_get_reference_value(env, ref, result); +} +NAPI_EXTERN napi_status NAPI_CDECL +napi_open_handle_scope(napi_env env, napi_handle_scope* result) { + LoadNapiFunctions(); + return p_napi_open_handle_scope(env, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL +napi_close_handle_scope(napi_env env, napi_handle_scope scope) { + LoadNapiFunctions(); + return p_napi_close_handle_scope(env, scope); +} +NAPI_EXTERN napi_status NAPI_CDECL napi_open_escapable_handle_scope( + napi_env env, napi_escapable_handle_scope* result) { + return p_napi_open_escapable_handle_scope(env, result); +} +NAPI_EXTERN napi_status NAPI_CDECL napi_close_escapable_handle_scope( + napi_env env, napi_escapable_handle_scope scope) { + LoadNapiFunctions(); + return p_napi_close_escapable_handle_scope(env, scope); +} +NAPI_EXTERN napi_status NAPI_CDECL napi_is_exception_pending(napi_env env, + bool* result) { + LoadNapiFunctions(); + return p_napi_is_exception_pending(env, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_get_property(napi_env env, + napi_value object, + napi_value key, + napi_value* result) { + LoadNapiFunctions(); + return p_napi_get_property(env, object, key, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_get_value_uint32(napi_env env, + napi_value value, + uint32_t* result) { + LoadNapiFunctions(); + return p_napi_get_value_uint32(env, value, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_typeof(napi_env env, + napi_value value, + napi_valuetype* result) { + LoadNapiFunctions(); + return p_napi_typeof(env, value, result); +} +NAPI_EXTERN napi_status NAPI_CDECL +napi_get_and_clear_last_exception(napi_env env, napi_value* result) { + LoadNapiFunctions(); + return p_napi_get_and_clear_last_exception(env, result); +} +NAPI_EXTERN NAPI_NO_RETURN void NAPI_CDECL +napi_fatal_error(const char* location, + size_t location_len, + const char* message, + size_t message_len) { + LoadNapiFunctions(); + p_napi_fatal_error(location, location_len, message, message_len); + // Not reachable, but not represented in type signature. + exit(0); +} +NAPI_EXTERN napi_status NAPI_CDECL +napi_get_value_external(napi_env env, napi_value value, void** result) { + LoadNapiFunctions(); + return p_napi_get_value_external(env, value, result); +} +NAPI_EXTERN napi_status NAPI_CDECL napi_create_double(napi_env env, + double value, + napi_value* result) { + LoadNapiFunctions(); + return p_napi_create_double(env, value, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_create_type_error(napi_env env, + napi_value code, + napi_value msg, + napi_value* result) { + LoadNapiFunctions(); + return p_napi_create_type_error(env, code, msg, result); +} +NAPI_EXTERN napi_status NAPI_CDECL napi_get_named_property(napi_env env, + napi_value object, + const char* utf8name, + napi_value* result) { + LoadNapiFunctions(); + return p_napi_get_named_property(env, object, utf8name, result); +} +NAPI_EXTERN napi_status NAPI_CDECL +napi_create_reference(napi_env env, + napi_value value, + uint32_t initial_refcount, + napi_ref* result) { + LoadNapiFunctions(); + return p_napi_create_reference(env, value, initial_refcount, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL +napi_escape_handle(napi_env env, + napi_escapable_handle_scope scope, + napi_value escapee, + napi_value* result); +NAPI_EXTERN napi_status NAPI_CDECL napi_get_global(napi_env env, + napi_value* result) { + + LoadNapiFunctions(); + return p_napi_get_global(env, result); +} +NAPI_EXTERN napi_status NAPI_CDECL napi_has_property(napi_env env, + napi_value object, + napi_value key, + bool* result) { + LoadNapiFunctions(); + return p_napi_has_property(env, object, key, result); +} +NAPI_EXTERN napi_status NAPI_CDECL napi_create_function(napi_env env, + const char* utf8name, + size_t length, + napi_callback cb, + void* data, + napi_value* result) { + LoadNapiFunctions(); + return p_napi_create_function(env, utf8name, length, cb, data, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL +napi_escape_handle(napi_env env, + napi_escapable_handle_scope scope, + napi_value escapee, + napi_value* result) { + LoadNapiFunctions(); + return p_napi_escape_handle(env, scope, escapee, result); +} +NAPI_EXTERN napi_status NAPI_CDECL napi_get_undefined(napi_env env, + napi_value* result) { + LoadNapiFunctions(); + return p_napi_get_undefined(env, result); +} +NAPI_EXTERN napi_status NAPI_CDECL napi_get_value_double(napi_env env, + napi_value value, + double* result) { + LoadNapiFunctions(); + return p_napi_get_value_double(env, value, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL +napi_close_callback_scope(napi_env env, napi_callback_scope scope) { + LoadNapiFunctions(); + return p_napi_close_callback_scope(env, scope); +} + +NAPI_EXTERN napi_status NAPI_CDECL +napi_async_destroy(napi_env env, napi_async_context async_context) { + LoadNapiFunctions(); + return p_napi_async_destroy(env, async_context); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_call_function(napi_env env, + napi_value recv, + napi_value func, + size_t argc, + const napi_value* argv, + napi_value* result) { + LoadNapiFunctions(); + return p_napi_call_function(env, recv, func, argc, argv, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_throw_error(napi_env env, + const char* code, + const char* msg) + { + LoadNapiFunctions(); + return p_napi_throw_error(env, code, msg); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_create_int32(napi_env env, + int32_t value, + napi_value* result) + { + LoadNapiFunctions(); + return p_napi_create_int32(env, value, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_create_external_arraybuffer( + napi_env env, + void* external_data, + size_t byte_length, + napi_finalize finalize_cb, + void* finalize_hint, + napi_value* result) +{ + LoadNapiFunctions(); + return p_napi_create_external_arraybuffer(env, external_data, byte_length, finalize_cb, finalize_hint, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_create_typedarray( + napi_env env, + napi_typedarray_type type, + size_t length, + napi_value array_buffer, + size_t byte_offset, + napi_value* result +) +{ + LoadNapiFunctions(); + return p_napi_create_typedarray(env, type, length, array_buffer, byte_offset, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_create_string_latin1( + napi_env env, + const char* str, + size_t length, + napi_value* result +) +{ + LoadNapiFunctions(); + return p_napi_create_string_latin1(env, str, length, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_create_async_work( + napi_env env, + napi_value async_resource, + napi_value async_resource_name, + napi_async_execute_callback execute, + napi_async_complete_callback complete, + void* data, + napi_async_work* result +) +{ + LoadNapiFunctions(); + return p_napi_create_async_work(env, async_resource, async_resource_name, execute, complete, data, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_delete_async_work( + napi_env env, + napi_async_work work +) +{ + LoadNapiFunctions(); + return p_napi_delete_async_work(env, work); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_queue_async_work( + napi_env env, + napi_async_work work +) +{ + LoadNapiFunctions(); + return p_napi_queue_async_work(env, work); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_create_promise( + napi_env env, + napi_deferred* deferred, + napi_value* promise) +{ + LoadNapiFunctions(); + return p_napi_create_promise(env, deferred, promise); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_resolve_deferred( + napi_env env, + napi_deferred deferred, + napi_value resolution) +{ + LoadNapiFunctions(); + return p_napi_resolve_deferred(env, deferred, resolution); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_reject_deferred( + napi_env env, + napi_deferred deferred, + napi_value rejection) +{ + LoadNapiFunctions(); + return p_napi_reject_deferred(env, deferred, rejection); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_create_threadsafe_function( + napi_env env, + napi_value func, + napi_value async_resource, + napi_value async_resource_name, + size_t max_queue_size, + size_t initial_thread_count, + void* thread_finalize_data, + napi_finalize thread_finalize_cb, + void* context, + napi_threadsafe_function_call_js call_js_cb, + napi_threadsafe_function* result) +{ + LoadNapiFunctions(); + return p_napi_create_threadsafe_function(env, func, async_resource, async_resource_name, max_queue_size, initial_thread_count, thread_finalize_data, thread_finalize_cb, context, call_js_cb, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL +napi_acquire_threadsafe_function(napi_threadsafe_function func) +{ + LoadNapiFunctions(); + return p_napi_acquire_threadsafe_function(func); +} + +NAPI_EXTERN napi_status NAPI_CDECL +napi_release_threadsafe_function(napi_threadsafe_function func, napi_threadsafe_function_release_mode mode) +{ + LoadNapiFunctions(); + return p_napi_release_threadsafe_function(func, mode); +} + +NAPI_EXTERN napi_status NAPI_CDECL +napi_call_threadsafe_function( + napi_threadsafe_function func, + void* data, + napi_threadsafe_function_call_mode is_blocking) +{ + LoadNapiFunctions(); + return p_napi_call_threadsafe_function(func, data, is_blocking); +} + +NAPI_EXTERN napi_status NAPI_CDECL +napi_is_dataview(napi_env env, + napi_value value, + bool* result) { + LoadNapiFunctions(); + return p_napi_is_dataview(env, value, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL +napi_is_arraybuffer(napi_env env, + napi_value value, + bool* result) { + LoadNapiFunctions(); + return p_napi_is_arraybuffer(env, value, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL +napi_get_dataview_info(napi_env env, + napi_value dataview, + size_t* bytelength, + void** data, + napi_value* arraybuffer, + size_t* byte_offset) { + LoadNapiFunctions(); + return p_napi_get_dataview_info(env, dataview, bytelength, data, arraybuffer, byte_offset); +} + +NAPI_EXTERN napi_status NAPI_CDECL +napi_set_named_property(napi_env env, + napi_value object, + const char* utf8name, + napi_value value) { + LoadNapiFunctions(); + return p_napi_set_named_property(env, object, utf8name, value); +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/ohos/hilog/log.h b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/ohos/hilog/log.h new file mode 100644 index 0000000000000000000000000000000000000000..7452137c280d212fc271cca2f31466f0dc11bd6f --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/ohos/hilog/log.h @@ -0,0 +1,286 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef HIVIEWDFX_HILOG_H +#define HIVIEWDFX_HILOG_H +/** + * @addtogroup HiLog + * @{ + * + * @brief Provides logging functions. + * + * For example, you can use these functions to output logs of the specified log type, service domain, log tag, + * and log level. + * + * @syscap SystemCapability.HiviewDFX.HiLog + * + * @since 8 + */ + +/** + * @file log.h + * + * @brief Defines the logging functions of the HiLog module. + * + * Before outputting logs, you must define the service domain, and log tag, use the function with + * the specified log type and level, and specify the privacy identifier.\n + *

  • Service domain: used to identify the subsystem and module of a service. Its value is a hexadecimal + * integer ranging from 0x0 to 0xFFFF. \n + *
  • Log tag: a string used to identify the class, file, or service.
  • \n + *
  • Log level: DEBUG, INFO, WARN, ERROR, and FATAL
  • \n + *
  • Parameter format: a printf format string that starts with a % character, including format specifiers + * and variable parameters.
  • \n + *
  • Privacy identifier: {public} or {private} added between the % character and the format specifier in + * each parameter. Note that each parameter has a privacy identifier. If no privacy identifier is added, + * the parameter is considered to be private.
\n + * + * Sample code:\n + * Defining the service domain and log tag:\n + * #include \n + * #define LOG_DOMAIN 0x0201\n + * #define LOG_TAG "MY_TAG"\n + * Outputting logs:\n + * HILOG_WARN({@link LOG_APP}, "Failed to visit %{private}s, reason:%{public}d.", url, errno);\n + * Output result:\n + * 05-06 15:01:06.870 1051 1051 W 0201/MY_TAG: Failed to visit , reason:503.\n + * + * @since 8 + */ +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Defines the service domain for a log file. + * + * The service domain is used to identify the subsystem and module of a service. Its value is a hexadecimal integer + * ranging from 0x0 to 0xFFFF. If the value is beyond the range, its significant bits are automatically truncated. \n + * + * @since 8 + */ +#ifndef LOG_DOMAIN +#define LOG_DOMAIN 0 +#endif + +/** + * @brief Defines a string constant used to identify the class, file, or service. + * + * @since 8 + */ +#ifndef LOG_TAG +#define LOG_TAG NULL +#endif + +/** + * @brief Enumerates log types. + * + * Currently, LOG_APP is available. \n + * + * @since 8 + */ +typedef enum { + /** Third-party application logs */ + LOG_APP = 0, +} LogType; + +/** + * @brief Enumerates log levels. + * + * You are advised to select log levels based on their respective usage scenarios:\n + *
  • DEBUG: used for debugging and disabled from commercial releases
  • \n + *
  • INFO: used for logging important system running status and steps in key processes
  • \n + *
  • WARN: used for logging unexpected exceptions that have little impact on user experience and can + * automatically recover. Logs at this level are generally output when such exceptions are detected and + * captured.
  • \n + *
  • ERROR: used for logging malfunction that affects user experience and cannot automatically + * recover
  • \n + *
  • FATAL: used for logging major exceptions that have severely affected user experience and should + * not occur.
\n + * + * @since 8 + */ +typedef enum { + /** Debug level to be used by {@link OH_LOG_DEBUG} */ + LOG_DEBUG = 3, + /** Informational level to be used by {@link OH_LOG_INFO} */ + LOG_INFO = 4, + /** Warning level to be used by {@link OH_LOG_WARN} */ + LOG_WARN = 5, + /** Error level to be used by {@link OH_LOG_ERROR} */ + LOG_ERROR = 6, + /** Fatal level to be used by {@link OH_LOG_FATAL} */ + LOG_FATAL = 7, +} LogLevel; + +/** + * @brief Outputs logs. + * + * You can use this function to output logs based on the specified log type, log level, service domain, log tag, + * and variable parameters determined by the format specifier and privacy identifier in the printf format. + * + * @param type Indicates the log type. The type for third-party applications is defined by {@link LOG_APP}. + * @param level Indicates the log level, which can be LOG_DEBUG, LOG_INFO, LOG_WARN, + * LOG_ERROR, and LOG_FATAL. + * @param domain Indicates the service domain of logs. Its value is a hexadecimal integer ranging from 0x0 to 0xFFFF. + * @param tag Indicates the log tag, which is a string used to identify the class, file, or service behavior. + * @param fmt Indicates the format string, which is an enhancement of a printf format string and supports the privacy + * identifier. Specifically, {public} or {private} is added between the % character and the format specifier + * in each parameter. \n + * @param ... Indicates a list of parameters. The number and type of parameters must map onto the format specifiers + * in the format string. + * @return Returns 0 or a larger value if the operation is successful; returns a value smaller + * than 0 otherwise. + * @since 8 + */ +int OH_LOG_Print(LogType type, LogLevel level, unsigned int domain, const char *tag, const char *fmt, ...) + __attribute__((__format__(os_log, 5, 6))); + +/** + * @brief Checks whether logs of the specified service domain, log tag, and log level can be output. + * + * @param domain Indicates the service domain of logs. + * @param tag Indicates the log tag. + * @param level Indicates the log level. + * @return Returns true if the specified logs can be output; returns false otherwise. + * @since 8 + */ +bool OH_LOG_IsLoggable(unsigned int domain, const char *tag, LogLevel level); + +/** + * @brief Outputs debug logs. This is a function-like macro. + * + * Before calling this function, define the log service domain and log tag. Generally, you need to define them at + * the beginning of the source file. \n + * + * @param type Indicates the log type. The type for third-party applications is defined by {@link LOG_APP}. + * @param fmt Indicates the format string, which is an enhancement of a printf format string and supports the + * privacy identifier. Specifically, {public} or {private} is added between the % character and the format specifier + * in each parameter. \n + * @param ... Indicates a list of parameters. The number and type of parameters must map onto the format specifiers + * in the format string. + * @see OH_LOG_Print + * @since 8 + */ +#define OH_LOG_DEBUG(type, ...) ((void)OH_LOG_Print((type), LOG_DEBUG, LOG_DOMAIN, LOG_TAG, __VA_ARGS__)) + +/** + * @brief Outputs informational logs. This is a function-like macro. + * + * Before calling this function, define the log service domain and log tag. Generally, you need to define them + * at the beginning of the source file. \n + * + * @param type Indicates the log type. The type for third-party applications is defined by {@link LOG_APP}. + * @param fmt Indicates the format string, which is an enhancement of a printf format string and supports the privacy + * identifier. Specifically, {public} or {private} is added between the % character and the format specifier in + * each parameter. \n + * @param ... Indicates a list of parameters. The number and type of parameters must map onto the format specifiers + * in the format string. + * @see OH_LOG_Print + * @since 8 + */ +#define OH_LOG_INFO(type, ...) ((void)OH_LOG_Print((type), LOG_INFO, LOG_DOMAIN, LOG_TAG, __VA_ARGS__)) + +/** + * @brief Outputs warning logs. This is a function-like macro. + * + * Before calling this function, define the log service domain and log tag. Generally, you need to define them + * at the beginning of the source file. \n + * + * @param type Indicates the log type. The type for third-party applications is defined by {@link LOG_APP}. + * @param fmt Indicates the format string, which is an enhancement of a printf format string and supports the + * privacy identifier. Specifically, {public} or {private} is added between the % character and the format specifier + * in each parameter. \n + * @param ... Indicates a list of parameters. The number and type of parameters must map onto the format specifiers + * in the format string. + * @see OH_LOG_Print + * @since 8 + */ +#define OH_LOG_WARN(type, ...) ((void)OH_LOG_Print((type), LOG_WARN, LOG_DOMAIN, LOG_TAG, __VA_ARGS__)) + +/** + * @brief Outputs error logs. This is a function-like macro. + * + * Before calling this function, define the log service domain and log tag. Generally, you need to define + * them at the beginning of the source file. \n + * + * @param type Indicates the log type. The type for third-party applications is defined by {@link LOG_APP}. + * @param fmt Indicates the format string, which is an enhancement of a printf format string and supports the privacy + * identifier. Specifically, {public} or {private} is added between the % character and the format specifier in each + * parameter. \n + * @param ... Indicates a list of parameters. The number and type of parameters must map onto the format specifiers + * in the format string. + * @see OH_LOG_Print + * @since 8 + */ +#define OH_LOG_ERROR(type, ...) ((void)OH_LOG_Print((type), LOG_ERROR, LOG_DOMAIN, LOG_TAG, __VA_ARGS__)) + +/** + * @brief Outputs fatal logs. This is a function-like macro. + * + * Before calling this function, define the log service domain and log tag. Generally, you need to define them at + * the beginning of the source file. \n + * + * @param type Indicates the log type. The type for third-party applications is defined by {@link LOG_APP}. + * @param fmt Indicates the format string, which is an enhancement of a printf format string and supports the privacy + * identifier. Specifically, {public} or {private} is added between the % character and the format specifier in + * each parameter. \n + * @param ... Indicates a list of parameters. The number and type of parameters must map onto the format specifiers + * in the format string. + * @see OH_LOG_Print + * @since 8 + */ +#define OH_LOG_FATAL(type, ...) ((void)OH_LOG_Print((type), LOG_FATAL, LOG_DOMAIN, LOG_TAG, __VA_ARGS__)) + +/** + * @brief Defines the function pointer type for the user-defined log processing function. + * + * @param type Indicates the log type. The type for third-party applications is defined by {@link LOG_APP}. + * @param level Indicates the log level, which can be LOG_DEBUG, LOG_INFO, LOG_WARN, + * LOG_ERROR, and LOG_FATAL. + * @param domain Indicates the service domain of logs. Its value is a hexadecimal integer ranging from 0x0 to 0xFFFF. + * @param tag Indicates the log tag, which is a string used to identify the class, file, or service behavior. + * @param msg Indicates the log message itself, which is a formatted log string. + * @since 11 + */ +typedef void (*LogCallback)(const LogType type, const LogLevel level, const unsigned int domain, const char *tag, + const char *msg); + +/** + * @brief Set the user-defined log processing function. + * + * After calling this function, the callback function implemented by the user can receive all hilogs of the + * current process. + * Note that it will not change the default behavior of hilog logs of the current process, no matter whether this + * interface is called or not. \n + * + * @param callback Indicates the callback function implemented by the user. If you do not need to process hilog logs, + * you can transfer a null pointer. + * @since 11 + */ +void OH_LOG_SetCallback(LogCallback callback); + +#ifdef __cplusplus +} +#endif +/** @} */ + +#ifdef HILOG_RAWFORMAT +#include "hilog/log_inner.h" +#endif + +#endif // HIVIEWDFX_HILOG_C_H diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/ohos/oh_sk_log.cc b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/ohos/oh_sk_log.cc new file mode 100644 index 0000000000000000000000000000000000000000..0face6dac935d8e2fd469d899d7b93b868f7e873 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/ohos/oh_sk_log.cc @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include +#include +#include "oh_sk_log.h" + +static const char* KOALAUI_OHOS_LOG_ROOT = "/data/storage/el2/base/files/logs"; + +#define APPLY_LOG_FILE_PATTERN(buf, t, ms, pid) \ + sprintf(buf, "%s/%d_%d_%d_%lld.pid%d.log", \ + KOALAUI_OHOS_LOG_ROOT, t.tm_year + 1900, t.tm_mon + 1, t.tm_mday, ms.tv_sec, pid) + +const char* oh_sk_log_type_str(oh_sk_log_type type) { + switch (type) { + case Log_Debug: return "D"; + case Log_Info: return "I"; + case Log_Warn: return "W"; + case Log_Error: return "E"; + case Log_Fatal: return "F"; + } +} + +void oh_sk_file_log(oh_sk_log_type type, const char* msg, ...) { + time_t t = time(nullptr); + struct tm lt = *localtime(&t); + struct timeval ms{}; + gettimeofday(&ms, nullptr); + + static char* path = nullptr; + if (!path) { + path = new char[strlen(KOALAUI_OHOS_LOG_ROOT) + 100]; + APPLY_LOG_FILE_PATTERN(path, lt, ms, getpid()); + mkdir(KOALAUI_OHOS_LOG_ROOT, 0777); + } + + std::unique_ptr file(fopen(path, "a"), fclose); + if (!file) return; + + fprintf(file.get(), "%02d-%02d %02d:%02d:%02d.%03lld %s koala: ", + lt.tm_mon + 1, lt.tm_mday, lt.tm_hour, lt.tm_min, lt.tm_sec, ms.tv_usec / 1000, + oh_sk_log_type_str(type)); + + va_list args; + va_start(args, msg); + vfprintf(file.get(), msg, args); + va_end(args); + + fprintf(file.get(), "\n"); +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/ohos/oh_sk_log.h b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/ohos/oh_sk_log.h new file mode 100644 index 0000000000000000000000000000000000000000..dd133ce4e65117c5c908f64df4e5cb01dddc40e2 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/ohos/oh_sk_log.h @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +typedef enum { + Log_Debug, + Log_Info, + Log_Warn, + Log_Error, + Log_Fatal +} oh_sk_log_type; + +void oh_sk_file_log(oh_sk_log_type type, const char* msg, ...); +const char* oh_sk_log_type_str(oh_sk_log_type type); + +#ifdef OH_SK_LOG_TO_FILE + +#define OH_SK_LOG_INFO(msg) oh_sk_file_log(oh_sk_log_type::Log_Info, msg) +#define OH_SK_LOG_INFO_A(msg, ...) oh_sk_file_log(oh_sk_log_type::Log_Info, msg, ##__VA_ARGS__) +#define OH_SK_LOG_ERROR(msg) oh_sk_file_log(oh_sk_log_type::Log_Error, msg) +#define OH_SK_LOG_ERROR_A(msg, ...) oh_sk_file_log(oh_sk_log_type::Log_Error, msg, ##__VA_ARGS__) +#define OH_SK_LOG_DEBUG(msg) oh_sk_file_log(oh_sk_log_type::Log_Debug, msg) +#define OH_SK_LOG_DEBUG_A(msg, ...) oh_sk_file_log(oh_sk_log_type::Log_Debug, msg, ##__VA_ARGS__) +#define OH_SK_LOG_WARN(msg) oh_sk_file_log(oh_sk_log_type::Log_Warn, msg) +#define OH_SK_LOG_WARN_A(msg, ...) oh_sk_file_log(oh_sk_log_type::Log_Warn, msg, ##__VA_ARGS__) +#define OH_SK_LOG_FATAL(msg) oh_sk_file_log(oh_sk_log_type::Log_Fatal, msg) +#define OH_SK_LOG_FATAL_A(msg, ...) oh_sk_file_log(oh_sk_log_type::Log_Fatal, msg, ##__VA_ARGS__) + +#else + +#define OH_SK_LOG_INFO(msg) OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "Koala", msg) +#define OH_SK_LOG_INFO_A(msg, ...) OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "Koala", msg, ##__VA_ARGS__) +#define OH_SK_LOG_ERROR(msg) OH_LOG_Print(LOG_APP, LOG_ERROR, 0xFF00, "Koala", msg) +#define OH_SK_LOG_ERROR_A(msg, ...) OH_LOG_Print(LOG_APP, LOG_ERROR, 0xFF00, "Koala", msg, ##__VA_ARGS__) +#define OH_SK_LOG_DEBUG(msg) OH_LOG_Print(LOG_APP, LOG_DEBUG, 0xFF00, "Koala", msg) +#define OH_SK_LOG_DEBUG_A(msg, ...) OH_LOG_Print(LOG_APP, LOG_DEBUG, 0xFF00, "Koala", msg, ##__VA_ARGS__) +#define OH_SK_LOG_WARN(msg) OH_LOG_Print(LOG_APP, LOG_WARN, 0xFF00, "Koala", msg) +#define OH_SK_LOG_WARN_A(msg, ...) OH_LOG_Print(LOG_APP, LOG_WARN, 0xFF00, "Koala", msg, ##__VA_ARGS__) +#define OH_SK_LOG_FATAL(msg) OH_LOG_Print(LOG_APP, LOG_FATAL, 0xFF00, "Koala", msg) +#define OH_SK_LOG_FATAL_A(msg, ...) OH_LOG_Print(LOG_APP, LOG_FATAL, 0xFF00, "Koala", msg, ##__VA_ARGS__) + +#endif diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/profiler.h b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/profiler.h new file mode 100644 index 0000000000000000000000000000000000000000..4f5fbbdab0f15e85504a5437039749b557c4a8ad --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/profiler.h @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _KOALA_PROFILER_ +#define _KOALA_PROFILER_ + +#include +#include + +#include +#include +#include +#include +#include + +struct InteropProfilerRecord { + int64_t time; + int64_t count; + InteropProfilerRecord(int64_t time, int64_t count) : time(time), count(count) {} +}; + +class InteropProfiler { + private: + std::unordered_map records; + static InteropProfiler* _instance; + InteropProfiler() {} + + public: + static InteropProfiler* instance() { + if (!_instance) _instance = new InteropProfiler(); + return _instance; + } + + void record(const char* name, int64_t ns) { + auto it = records.find(name); + if (it == records.end()) { + records.insert({name, InteropProfilerRecord(ns, 1)}); + } else { + it->second.time += ns; + it->second.count++; + } + } + + std::string report() { + std::vector> elems(records.begin(), records.end()); + std::sort(elems.begin(), elems.end(), + [](const std::pair&a, const std::pair&b) { + return b.second.time < a.second.time; + }); + int64_t total = 0; + std::for_each(elems.begin(), elems.end(), [&total](const std::pair&a) { + total += a.second.time; + }); + std::string result; + std::for_each(elems.begin(), elems.end(), [total, &result](const std::pair&a) { + auto ns = a.second.time; + auto count = a.second.count; + char buffer[1024]; + snprintf(buffer, sizeof buffer, "for %s[%lld]: %.01f%% (%lld)\n", a.first.c_str(), (long long)count, (double)ns / total * 100.0, (long long)ns); + result += buffer; + }); + return result; + } + + void reset() { + records.clear(); + } +}; + + +class InteropMethodCall { + private: + const char* name; + std::chrono::steady_clock::time_point begin; + public: + InteropMethodCall(const char* name) : name(name) { + begin = std::chrono::steady_clock::now(); + } + ~InteropMethodCall() { + auto end = std::chrono::steady_clock::now(); + int64_t ns = std::chrono::duration_cast(end - begin).count(); + InteropProfiler::instance()->record(name, ns); + } +}; + +#endif // _KOALA_PROFILER_ \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/tracer.h b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/tracer.h new file mode 100644 index 0000000000000000000000000000000000000000..ac7089c86f7b5e738d1a2fb2e2aa2e54c709c976 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/tracer.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _KOALA_TRACER_ +#define _KOALA_TRACER_ + +#ifdef KOALA_OHOS +#include +#define KOALA_TRACE(msg, str) OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "Koala", msg, str) +// Also do +// hdc shell hilog -p off +// hdc shell hilog -Q pidoff +// to see the output. +#define KOALA_TRACE_PUBLIC "%{public}s" +#else +#include +#define KOALA_TRACE(msg, str) fprintf(stderr, "Koala: " msg "\n", str) +#define KOALA_TRACE_PUBLIC "%s" +#endif + +class InteropMethodCall { + private: + const char* name; + public: + InteropMethodCall(const char* name) : name(name) { + KOALA_TRACE(">>> " KOALA_TRACE_PUBLIC, name); + } + ~InteropMethodCall() { + KOALA_TRACE("<<< " KOALA_TRACE_PUBLIC, name); + } +}; + +#endif // _KOALA_TRACER_ \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/types/koala-types.h b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/types/koala-types.h new file mode 100644 index 0000000000000000000000000000000000000000..78438e8c99b8a06b045de0b6f7a524b2167b74b0 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/types/koala-types.h @@ -0,0 +1,313 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _KOALA_TYPES_H +#define _KOALA_TYPES_H + +#include +#include +#include +#include + +#include "interop-types.h" + +#ifdef _MSC_VER +#define KOALA_EXECUTE(name, code) \ + static void __init_##name() { \ + code; \ + } \ + namespace { \ + struct __Init_##name { \ + __Init_##name() { __init_##name(); } \ + } __Init_##name##_v; \ + } +#else +#define KOALA_EXECUTE(name, code) \ + __attribute__((constructor)) \ + static void __init_jni_##name() { \ + code; \ + } +#endif + +struct KStringPtrImpl { + KStringPtrImpl(const char* str) : _value(nullptr), _owned(true) { + int len = str ? strlen(str) : 0; + assign(str, len); + } + KStringPtrImpl(const char* str, int len, bool owned) : _value(nullptr), _owned(owned) { + assign(str, len); + } + KStringPtrImpl() : _value(nullptr), _length(0), _owned(true) {} + + KStringPtrImpl(const KStringPtrImpl& other) = delete; + KStringPtrImpl& operator=(const KStringPtrImpl& other) = delete; + + KStringPtrImpl(InteropString value): KStringPtrImpl(value.chars, value.length, true) {} + + KStringPtrImpl(KStringPtrImpl&& other) { + this->_value = other.release(); + this->_owned = other._owned; + other._owned = false; + this->_length = other._length; + } + + ~KStringPtrImpl() { if (_value && _owned) free(_value); } + + bool isNull() const { return _value == nullptr; } + const char* c_str() const { return _value; } + char* data() const { return _value; } + int length() const { return _length; } + + void resize(int size) { + _length = size; + if (!_owned) return; + // Ignore old content. + if (_value && _owned) free(_value); + _value = reinterpret_cast(malloc(size + 1)); + _value[size] = 0; + } + + void assign(const char* data) { + assign(data, data ? strlen(data) : 0); + } + + void assign(const char* data, int len) { + if (_value && _owned) free(_value); + if (data) { + if (_owned) { + _value = reinterpret_cast(malloc(len + 1)); + memcpy(_value, data, len); + _value[len] = 0; + } else { + _value = const_cast(data); + } + } else { + _value = nullptr; + } + _length = len; + } + + protected: + char* release() { + char* result = this->_value; + this->_value = nullptr; + return result; + } + private: + char* _value; + int _length; + bool _owned; +}; + +struct KInteropNumber { + int8_t tag; + union { + int32_t i32; + float f32; + }; + KInteropNumber() { + this->tag = 0; + this->i32 = 0; + } + KInteropNumber(int32_t value) { + this->tag = INTEROP_TAG_INT32; + this->i32 = value; + } + KInteropNumber(float value) { + this->tag = INTEROP_TAG_FLOAT32; + this->f32 = value; + } + KInteropNumber(InteropNumber value) { + this->tag = value.tag; + this->i32 = value.i32; + } + InteropNumber toCType() { + InteropNumber result; + result.tag = this->tag; + result.i32 = this->i32; + return result; + } + static inline KInteropNumber fromDouble(double value) { + KInteropNumber result; + // TODO: boundary check + if (value == std::floor(value)) { + result.tag = INTEROP_TAG_INT32; + result.i32 = (int)value; + } else { + result.tag = INTEROP_TAG_FLOAT32; + result.f32 = (float)value; + } + return result; + } + inline double asDouble() { + if (tag == INTEROP_TAG_INT32) + return (double)i32; + else + return (double)f32; + } + inline int32_t asInt32() { + if (tag == INTEROP_TAG_INT32) + return i32; + else + return (int32_t)f32; + } +}; + +typedef InteropBoolean KBoolean; +typedef InteropUInt8 KByte; +typedef int16_t KChar; +typedef int16_t KShort; +typedef uint16_t KUShort; +typedef InteropInt32 KInt; +typedef InteropUInt32 KUInt; +typedef InteropInt64 KLong; +typedef InteropUInt64 KULong; +typedef InteropFloat32 KFloat; +typedef InteropFloat64 KDouble; +typedef InteropNativePointer KNativePointer; +typedef KStringPtrImpl KStringPtr; + +typedef KFloat* KFloatArray; +typedef const uint8_t* KStringArray; +typedef KNativePointer* KNativePointerArray; + +struct KSerializerBufferOpaque { + explicit operator KByte* () { + return reinterpret_cast(this); + } +}; +typedef KSerializerBufferOpaque* KSerializerBuffer; + +struct KInteropBuffer { + + KInteropBuffer(KLong len = 0, KNativePointer ptr = nullptr, KInt resId = 0, void (*dis)(KInt) = nullptr) + : length(len), data(ptr), resourceId(resId), dispose(dis) {} + + /** + * Takes ownership of given InteropBuffer + */ + KInteropBuffer(InteropBuffer value) { + length = value.length; + data = value.data; + resourceId = value.resource.resourceId; + dispose = value.resource.release; + } + + KLong length; + KNativePointer data; + + KInt resourceId; + void (*dispose)( KInt /* resourceId for now */); +}; + +struct KInteropReturnBuffer { + KInt length; + KNativePointer data; + void (*dispose)(KNativePointer data, KInt length); +}; + +struct KLength { + KByte type; + KFloat value; + KInt unit; + KInt resource; + InteropLength toCType() { + InteropLength result; + result.type = this->type; + result.value = this->value; + result.unit = this->unit; + result.resource = this->resource; + return result; + } +}; + +inline void parseKLength(const KStringPtrImpl &string, KLength *result) +{ + char *suffixPtr = nullptr; + + float value = std::strtof(string.c_str(), &suffixPtr); + + if (!suffixPtr || suffixPtr == string.c_str()) + { + // not a numeric value + result->unit = -1; + return; + } + result->value = value; + if (suffixPtr[0] == '\0' || (suffixPtr[0] == 'v' && suffixPtr[1] == 'p')) + { + result->unit = 1; + } + else if (suffixPtr[0] == '%') + { + result->unit = 3; + } + else if (suffixPtr[0] == 'p' && suffixPtr[1] == 'x') + { + result->unit = 0; + } + else if (suffixPtr[0] == 'l' && suffixPtr[1] == 'p' && suffixPtr[2] == 'x') + { + result->unit = 4; + } + else if (suffixPtr[0] == 'f' && suffixPtr[1] == 'p') + { + result->unit = 2; + } + else + { + result->unit = -1; + } +} + +typedef _InteropVMContext *KVMContext; + +// BEWARE: this MUST never be used in user code, only in very rare service code. +struct _KVMObject; +typedef _KVMObject *KVMObjectHandle; + +typedef struct KVMDeferred { + + KVMDeferred() {} + KVMDeferred(InteropDeferred value) { + handler = value.handler; + context = value.context; + resolve = reinterpret_cast(value.resolve); + reject = reinterpret_cast(value.reject); + } + + void* handler; + void* context; + void (*resolve)(KVMDeferred* thiz, uint8_t* data, int32_t length); + void (*reject)(KVMDeferred* thiz, const char* message); +} KVMDeferred; + +template T* ptr(KNativePointer ptr) { + return reinterpret_cast(ptr); +} + +template T& ref(KNativePointer ptr) { + return *reinterpret_cast(ptr); +} + +inline KNativePointer nativePtr(void* pointer) { + return reinterpret_cast(pointer); +} + +template KNativePointer fnPtr(void (*pointer)(T*)) { + return reinterpret_cast(pointer); +} + +#endif /* _KOALA_TYPES_H */ diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/types/signatures.cc b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/types/signatures.cc new file mode 100644 index 0000000000000000000000000000000000000000..3750c592b742986acc3d1cc3f64691c1a28851f7 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/types/signatures.cc @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "stdio.h" +#include +#include + +#include "signatures.h" +#include "interop-types.h" + +// For types with the same name on ets and jni +#define KOALA_INTEROP_TYPEDEF(func, lang, CPP_TYPE, SIG_TYPE, CODE_TYPE) \ + if (std::strcmp(func, "sigType") == 0) if (type == CPP_TYPE) return SIG_TYPE; \ + if (std::strcmp(func, "codeType") == 0) if (type == CPP_TYPE) return CODE_TYPE; + +// For types with distinct names on ets and jni +#define KOALA_INTEROP_TYPEDEF_LS(func, lang, CPP_TYPE, ETS_SIG_TYPE, ETS_CODE_TYPE, JNI_SIG_TYPE, JNI_CODE_TYPE) \ + if (std::strcmp(func, "sigType") == 0 && std::strcmp(lang, "ets") == 0) if (type == CPP_TYPE) return ETS_SIG_TYPE; \ + if (std::strcmp(func, "codeType") == 0 && std::strcmp(lang, "ets") == 0) if (type == CPP_TYPE) return ETS_CODE_TYPE; \ + if (std::strcmp(func, "sigType") == 0 && std::strcmp(lang, "jni") == 0) if (type == CPP_TYPE) return JNI_SIG_TYPE; \ + if (std::strcmp(func, "codeType") == 0 && std::strcmp(lang, "jni") == 0) if (type == CPP_TYPE) return JNI_CODE_TYPE; + +#define KOALA_INTEROP_TYPEDEFS(func, lang) \ + KOALA_INTEROP_TYPEDEF(func, lang, "void", "V", "void") \ + KOALA_INTEROP_TYPEDEF(func, lang, "KBoolean", "Z", "boolean") \ + KOALA_INTEROP_TYPEDEF(func, lang, "OH_Boolean", "Z", "boolean") \ + KOALA_INTEROP_TYPEDEF(func, lang, "Ark_Boolean", "Z", "boolean") \ + KOALA_INTEROP_TYPEDEF(func, lang, "int32_t", "I", "int") \ + KOALA_INTEROP_TYPEDEF(func, lang, "uint32_t", "I", "int") \ + KOALA_INTEROP_TYPEDEF(func, lang, "int", "I", "int") \ + KOALA_INTEROP_TYPEDEF(func, lang, "KInt", "I", "int") \ + KOALA_INTEROP_TYPEDEF(func, lang, "KUInt", "I", "int") \ + KOALA_INTEROP_TYPEDEF(func, lang, "KLong", "J", "long") \ + KOALA_INTEROP_TYPEDEF(func, lang, "OH_Int32", "I", "int") \ + KOALA_INTEROP_TYPEDEF(func, lang, "OH_Int64", "J", "long") \ + KOALA_INTEROP_TYPEDEF(func, lang, "Ark_Int32", "I", "int") \ + KOALA_INTEROP_TYPEDEF(func, lang, "Ark_Int64", "J", "long") \ + KOALA_INTEROP_TYPEDEF(func, lang, "KNativePointer", "J", "long") \ + KOALA_INTEROP_TYPEDEF(func, lang, "KSerializerBuffer", "J", "long") \ + KOALA_INTEROP_TYPEDEF(func, lang, "Ark_NativePointer", "J", "long") \ + KOALA_INTEROP_TYPEDEF(func, lang, "OH_NativePointer", "J", "long") \ + KOALA_INTEROP_TYPEDEF(func, lang, "float", "F", "float") \ + KOALA_INTEROP_TYPEDEF(func, lang, "KFloat", "F", "float") \ + KOALA_INTEROP_TYPEDEF(func, lang, "Ark_Float32", "F", "float") \ + KOALA_INTEROP_TYPEDEF(func, lang, "double", "D", "double") \ + KOALA_INTEROP_TYPEDEF(func, lang, "KDouble", "D", "double") \ + KOALA_INTEROP_TYPEDEF(func, lang, "KInteropNumber", "D", "double") \ + KOALA_INTEROP_TYPEDEF(func, lang, "KVMObjectHandle", "Ljava/lang/Object;", "Object") \ + KOALA_INTEROP_TYPEDEF(func, lang, "uint8_t*", "[B", "byte[]") \ + KOALA_INTEROP_TYPEDEF(func, lang, "KByte*", "[B", "byte[]") \ + KOALA_INTEROP_TYPEDEF(func, lang, "KInteropBuffer", "[B", "byte[]") \ + KOALA_INTEROP_TYPEDEF(func, lang, "KShort*", "[S", "short[]") \ + KOALA_INTEROP_TYPEDEF(func, lang, "KUShort*", "[S", "short[]") \ + KOALA_INTEROP_TYPEDEF(func, lang, "int32_t*", "[I", "int[]") \ + KOALA_INTEROP_TYPEDEF(func, lang, "KInt*", "[I", "int[]") \ + KOALA_INTEROP_TYPEDEF(func, lang, "KNativePointerArray", "[J", "long[]") \ + KOALA_INTEROP_TYPEDEF(func, lang, "KInteropReturnBuffer", "[B", "byte[]") \ + KOALA_INTEROP_TYPEDEF(func, lang, "float*", "[F", "float[]") \ + KOALA_INTEROP_TYPEDEF(func, lang, "KFloatArray", "[F", "float[]") \ + KOALA_INTEROP_TYPEDEF(func, lang, "KFloat*", "[F", "float[]") \ + KOALA_INTEROP_TYPEDEF_LS(func, lang, "KStringPtr", "Lstd/core/String;", "String", "Ljava/lang/String;", "String") \ + KOALA_INTEROP_TYPEDEF_LS(func, lang, "KStringArray", "[Lstd/core/String;", "String[]", "[Ljava/lang/String;", "String[]") \ + KOALA_INTEROP_TYPEDEF_LS(func, lang, "KLength", "Lstd/core/String;", "String", "Ljava/lang/String;", "String") + +std::string sigType(const std::string &type) { +#if KOALA_USE_PANDA_VM + KOALA_INTEROP_TYPEDEFS("sigType", "ets") +#elif KOALA_USE_JAVA_VM + KOALA_INTEROP_TYPEDEFS("sigType", "jni") +#endif + INTEROP_FATAL("Unhandled type: %s\n", type.c_str()); + return type; +} + +std::string codeType(const std::string &type) { +#if KOALA_USE_PANDA_VM + KOALA_INTEROP_TYPEDEFS("codeType", "ets") +#elif KOALA_USE_JAVA_VM + KOALA_INTEROP_TYPEDEFS("codeType", "jni") +#endif + INTEROP_FATAL("Unhandled type: %s\n", type.c_str()); + return ""; +} + +std::string convertType(const char* name, const char* koalaType) { + std::string result; + size_t current = 0, last = 0; + std::string input(koalaType); + std::vector tokens; + while ((current = input.find('|', last)) != std::string::npos) + { + auto token = input.substr(last, current - last); + tokens.push_back(token); + last = current + 1; + } + tokens.push_back(input.substr(last, input.length() - last)); + +#if KOALA_USE_PANDA_VM + + for (int i = 1; i < (int)tokens.size(); i++) + { + result.append(sigType(tokens[i])); + } + result.append(":"); + result.append(sigType(tokens[0])); + +#elif KOALA_USE_JAVA_VM + + result.append("("); + for (int i = 1; i < (int)tokens.size(); i++) + { + result.append(sigType(tokens[i])); + } + result.append(")"); + result.append(sigType(tokens[0])); + +#endif + +#ifdef KOALA_BUILD_FOR_SIGNATURES + #ifdef KOALA_USE_PANDA_VM + std::string params; + for (int i = 1; i < (int)tokens.size(); i++) + { + params.append("arg"); + params.append(std::to_string(i)); + params.append(": "); + params.append(codeType(tokens[i])); + if (i < (int)(tokens.size() - 1)) + params.append(", "); + } + fprintf(stderr, " static native %s(%s): %s;\n", name, params.c_str(), codeType(tokens[0]).c_str()); + #elif KOALA_USE_JAVA_VM + std::string params; + for (int i = 1; i < (int)tokens.size(); i++) + { + params.append(codeType(tokens[i])); + params.append(" arg"); + params.append(std::to_string(i)); + if (i < (int)(tokens.size() - 1)) + params.append(", "); + } + fprintf(stderr, " public static native %s %s(%s);\n", codeType(tokens[0]).c_str(), name, params.c_str()); + #endif +#endif + + return result; +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/types/signatures.h b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/types/signatures.h new file mode 100644 index 0000000000000000000000000000000000000000..05ddf1cc8df0cf621f9403fbbc3caa43e33bc2e8 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/types/signatures.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _SIGNATURES_H +#define _SIGNATURES_H + +#include + +std::string sigType(const std::string &type); +std::string codeType(const std::string &type); +std::string convertType(const char* name, const char* koalaType); + +#endif // _SIGNATURES_H diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/vmloader.cc b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/vmloader.cc new file mode 100644 index 0000000000000000000000000000000000000000..6b04eefaa4924e3161f64b138bd825c3f5e5c385 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/vmloader.cc @@ -0,0 +1,1040 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include + +#include "interop-logging.h" +#include "dynamic-loader.h" +#include "koala-types.h" + +// DO NOT USE KOALA INTEROP MECHANISMS IN THIS FILE! + +#ifdef KOALA_JNI +#include "jni.h" +#endif + +#ifdef KOALA_ETS_NAPI +#include "etsapi.h" +#endif + +#ifdef KOALA_ANI +#include "ani.h" +#endif + +#if defined(KOALA_LINUX) || defined(KOALA_MACOS) || defined(KOALA_OHOS) +#include "sys/stat.h" +#include "dirent.h" +#endif + +#define OHOS_USER_LIBS "/data/storage/el1/bundle/libs" +#ifdef KOALA_OHOS_ARM32 +#define USE_SYSTEM_ARKVM 1 +#elif KOALA_OHOS_ARM64 +#define USE_SYSTEM_ARKVM 1 +#else +#define USE_SYSTEM_ARKVM 0 +#endif + +#if USE_SYSTEM_ARKVM +#define SYSTEM_ARK_STDLIB_PATH "/system/etc/etsstdlib.abc" +#endif + +#ifndef KOALA_USE_PANDA_VM +#ifdef KOALA_ANI +#define KOALA_USE_PANDA_VM 1 +#endif +#ifdef KOALA_ETS_NAPI +#define KOALA_USE_PANDA_VM 1 +#endif +#endif + +void traverseDir(const std::string& root, std::vector& paths, std::string suffix, const std::vector& fallbackPaths = {}); + +struct VMLibInfo { + const char* sdkPath; + const char* platform; + const char* lib; +}; + +#ifdef KOALA_JNI +const VMLibInfo javaVMLib = { + getenv("JAVA_HOME"), + #if defined(KOALA_LINUX) || defined(KOALA_MACOS) + "lib/server" + #elif KOALA_WINDOWS + "bin/server" + #else + #error "Unknown platform" + #endif + , + "jvm" +}; +#endif + +#if defined(KOALA_ETS_NAPI) || defined(KOALA_ANI) +const VMLibInfo pandaVMLib = { + // sdkPath + #if defined(KOALA_OHOS) + #ifdef KOALA_OHOS_ARM32 + "/system/lib" + #elif KOALA_OHOS_ARM64 + "/system/lib64" + #else + OHOS_USER_LIBS + #endif + #else + getenv("PANDA_HOME") + #endif + , + + // platform + #ifdef KOALA_LINUX + #ifdef KOALA_LINUX_ARM64 + "linux_arm64_host_tools/lib" + #else + "linux_host_tools/lib" + #endif + #elif KOALA_MACOS + "macos_host_tools/lib" + #elif KOALA_WINDOWS + "_host_tools/lib" + #elif KOALA_OHOS_ARM64 + "arm64" + #elif KOALA_OHOS_ARM32 + "arm" + #else + #error "Unknown platform" + #endif + , + + // lib + "arkruntime" +}; +#endif + +struct VMInitArgs { + int version; + int nOptions; + void* options; +}; + +#define JAVA_VM_KIND 1 +#define PANDA_VM_KIND 2 +#define ES2PANDA_KIND 3 +#define PANDA_ANI_VM_KIND 4 + +struct ForeignVMContext { + void* currentVMContext; + int32_t (*callSync)(void* vmContext, int32_t callback, int8_t* data, int32_t length); +}; + +struct VMEntry { + int vmKind; + void* env; + void* app; + void* enter; + void* emitEvent; + void* restartWith; + ForeignVMContext foreignVMContext; +}; + +VMEntry g_vmEntry = {}; + +typedef int (*createVM_t)(void** pVM, void** pEnv, void* vmInitArgs); + +#ifdef KOALA_WINDOWS +#define DLL_EXPORT __declspec(dllexport) +#else +#define DLL_EXPORT __attribute__ ((visibility ("default"))) +#endif + +int loadES2Panda(const char* appClassPath, const char* appLibPath) { + fprintf(stderr, "native: es2panda %s\n", appClassPath); + return 0; +} + +#ifdef KOALA_ETS_NAPI +namespace { + +enum PandaLog2MobileLog : int { + UNKNOWN = 0, + DEFAULT, + VERBOSE, + DEBUG, + INFO, + WARN, + ERROR, + FATAL, + SILENT, +}; + +int ArkMobileLog(int id, int level, const char *component, const char *fmt, const char *msg) { + switch (level) { + case PandaLog2MobileLog::DEFAULT: + case PandaLog2MobileLog::VERBOSE: + case PandaLog2MobileLog::DEBUG: + case PandaLog2MobileLog::INFO: + case PandaLog2MobileLog::SILENT: + LOGI("ArkRuntime [%" LOG_PUBLIC "s]: %" LOG_PUBLIC "s", component, msg); + break; + case PandaLog2MobileLog::UNKNOWN: + case PandaLog2MobileLog::WARN: + case PandaLog2MobileLog::ERROR: + case PandaLog2MobileLog::FATAL: + default: + LOGE("ArkRuntime [%" LOG_PUBLIC "s]: %" LOG_PUBLIC "s", component, msg); + break; + } + return 0; +} + +} +#endif + +#ifdef KOALA_ANI + +static void AniMobileLog([[maybe_unused]] FILE *stream, int level, + const char *component, const char *msg) { + switch (level) { + case ANI_LOGLEVEL_INFO: + case ANI_LOGLEVEL_DEBUG: + LOGI("ArkRuntime [%" LOG_PUBLIC "s]: %" LOG_PUBLIC "s", component, msg); + break; + case ANI_LOGLEVEL_FATAL: + case ANI_LOGLEVEL_ERROR: + case ANI_LOGLEVEL_WARNING: + default: + LOGE("ArkRuntime [%" LOG_PUBLIC "s]: %" LOG_PUBLIC "s", component, msg); + break; + } +} + +static std::string makeClasspath(const std::vector& files) { + std::stringstream stream; + for (size_t index = 0, end = files.size(); index < end; ++index) { + if (index > 0) { + stream << ':'; + } + stream << files[index]; + } + return stream.str(); +} + +static std::pair GetBootAndAppPandaFiles(const VMLibInfo* thisVM, const char* appClassPath) +{ + std::vector bootFiles; +#if USE_SYSTEM_ARKVM + bootFiles.push_back(SYSTEM_ARK_STDLIB_PATH); +#elif defined(KOALA_OHOS) + bootFiles.push_back(std::string(OHOS_USER_LIBS) + "/etsstdlib.abc"); +#elif defined(KOALA_LINUX) || defined(KOALA_MACOS) || defined(KOALA_WINDOWS) + bootFiles.push_back(std::string(thisVM->sdkPath) + "/ets/etsstdlib.abc"); +#endif + +#if defined(KOALA_OHOS) + traverseDir("/system/framework", bootFiles, ".abc", { + "etsstdlib_bootabc" + }); +#endif + std::sort(bootFiles.begin(), bootFiles.end()); + + std::vector files; + traverseDir(std::string(appClassPath), files, ".abc"); + std::sort(files.begin(), files.end()); + return { makeClasspath(bootFiles), makeClasspath(files) }; +} + +static std::string GetAOTFiles(const char* appClassPath) { + std::vector files; + traverseDir(std::string(appClassPath), files, ".an"); + return makeClasspath(files); +} + +static bool ResetErrorIfExists(ani_env *env) +{ + ani_boolean hasError = ANI_FALSE; + env->ExistUnhandledError(&hasError); + if (hasError == ANI_TRUE) { + env->DescribeError(); + env->ResetError(); + return true; + } + return false; +} +#endif + +extern "C" DLL_EXPORT KInt LoadVirtualMachine(KInt vmKind, const char* appClassPath, const char* appLibPath, const ForeignVMContext* foreignVMContext) { + if (vmKind == ES2PANDA_KIND) { + return loadES2Panda(appClassPath, appLibPath); + } + + const VMLibInfo* thisVM = + #ifdef KOALA_JNI + (vmKind == JAVA_VM_KIND) ? &javaVMLib : + #endif + #if defined(KOALA_ETS_NAPI) || defined(KOALA_ANI) + (vmKind == PANDA_VM_KIND || vmKind == PANDA_ANI_VM_KIND) ? &pandaVMLib : + #endif + nullptr; + + if (!thisVM) { + LOGE("Unknown VM kind: %" LOG_PUBLIC "d\n (possibly %" LOG_PUBLIC "s is compiled without expected flags)", vmKind, __FILE__); + return -1; + } + + LOGI("Starting VM %" LOG_PUBLIC "d with classpath=%" LOG_PUBLIC "s native=%" LOG_PUBLIC "s", vmKind, appClassPath, appLibPath); + + std::string libPath = +#if USE_SYSTEM_ARKVM + std::string(thisVM->sdkPath) + "/" + libName(thisVM->lib) +#elif defined(KOALA_LINUX) || defined(KOALA_MACOS) || defined(KOALA_WINDOWS) + std::string(thisVM->sdkPath) + "/" + std::string(thisVM->platform) + "/" + libName(thisVM->lib) +#elif defined(KOALA_OHOS) + std::string(OHOS_USER_LIBS) + "/" + libName(thisVM->lib) +#else + #error "Library path not specified for this platform" +#endif + ; + void *handle = loadLibrary(libPath); + if (!handle) { + LOGE("Cannot load library %" LOG_PUBLIC "s: %" LOG_PUBLIC "s\n", libPath.c_str(), libraryError()); + return -1; + } + + void* vm = nullptr; + void* env = nullptr; + int result = 0; + +#ifdef KOALA_JNI + if (vmKind == JAVA_VM_KIND) { + typedef int (*createVM_t)(void** pVM, void** pEnv, void* vmInitArgs); + createVM_t createVM = (createVM_t)findSymbol(handle, "JNI_CreateJavaVM"); + if (!createVM) { + LOGE("Cannot find %" LOG_PUBLIC "s\n", "JNI_CreateJavaVM"); + return -1; + } + JavaVMInitArgs javaVMArgs; + javaVMArgs.version = JNI_VERSION_10; + javaVMArgs.ignoreUnrecognized = false; + std::vector javaVMOptions; + javaVMOptions = { + {(char*)strdup((std::string("-Djava.class.path=") + appClassPath).c_str())}, + {(char*)strdup((std::string("-Djava.library.path=") + appLibPath).c_str())}, + }; + javaVMArgs.nOptions = javaVMOptions.size(); + javaVMArgs.options = javaVMOptions.data(); + g_vmEntry.vmKind = JAVA_VM_KIND; + result = createVM(&vm, &env, &javaVMArgs); + } +#endif + +#if defined(KOALA_ANI) + if (vmKind == PANDA_ANI_VM_KIND) { + g_vmEntry.vmKind = vmKind; + + uint32_t version = ANI_VERSION_1; + size_t nVMs = 0; + typedef int (*getVMs_t)(void** pVM, size_t bufLen, size_t* nVMs); + typedef int (*createVM_t)(const void* args, uint32_t version, void** pVM); + createVM_t createVM = (createVM_t)findSymbol(handle, "ANI_CreateVM"); + getVMs_t getVMs = (getVMs_t)findSymbol(handle, "ANI_GetCreatedVMs"); + result = getVMs ? getVMs(&vm, 1, &nVMs) : 0; + if (nVMs == 0 && result == 0) { + std::vector pandaVMOptions; + + auto [bootFiles, appFiles] = GetBootAndAppPandaFiles(thisVM, appClassPath); + LOGI("Using ANI: classpath \"%" LOG_PUBLIC "s\" from %" LOG_PUBLIC "s", appFiles.c_str(), appClassPath); + std::string delimiter = ""; + if (!bootFiles.empty() && !appFiles.empty()) { + delimiter = ":"; + } + std::string bootPandaFiles = "--ext:--boot-panda-files=" + bootFiles + delimiter + appFiles; + LOGI("ANI boot-panda-files option: \"%" LOG_PUBLIC "s\"", bootPandaFiles.c_str()); + pandaVMOptions.push_back({bootPandaFiles.c_str(), nullptr}); + + auto aotFiles = GetAOTFiles(appClassPath); + if (!aotFiles.empty()) { + LOGI("ANI AOT files: \"%" LOG_PUBLIC "s\"", aotFiles.c_str()); + aotFiles = "--ext:--aot-files=" + aotFiles; + pandaVMOptions.push_back({aotFiles.c_str(), nullptr}); + } + + pandaVMOptions.push_back({"--ext:--gc-trigger-type=heap-trigger", nullptr}); + std::string nativeLibraryPathOption = + std::string("--ext:--native-library-path=") + appLibPath; + pandaVMOptions.push_back({nativeLibraryPathOption.c_str(), nullptr}); + pandaVMOptions.push_back({"--ext:--verification-mode=on-the-fly", nullptr}); + pandaVMOptions.push_back({"--ext:--compiler-enable-jit=true", nullptr}); + pandaVMOptions.push_back({"--logger", reinterpret_cast(AniMobileLog)}); + pandaVMOptions.push_back({"--ext:--enable-an", nullptr}); + ani_options optionsPtr = {pandaVMOptions.size(), pandaVMOptions.data()}; + + result = createVM(&optionsPtr, version, &vm); + } + + if (result == 0) { + ani_vm* vmInstance = (ani_vm*)vm; + ani_env* pEnv = nullptr; + result = vmInstance->GetEnv(version, &pEnv); + env = static_cast(pEnv); + } + } +#endif /* KOALA_ANI */ + +// For now we use ETS API for VM startup and entry. +#if defined(KOALA_ETS_NAPI) + if (vmKind == PANDA_VM_KIND) { + EtsVMInitArgs pandaVMArgs; + pandaVMArgs.version = ETS_NAPI_VERSION_1_0; + std::vector etsVMOptions; + std::vector files; + traverseDir(std::string(appClassPath), files, ".abc"); + std::sort(files.begin(), files.end()); + std::vector files_aot; + traverseDir(std::string(appClassPath), files_aot, ".an"); + std::sort(files_aot.begin(), files_aot.end()); + etsVMOptions = { +#if USE_SYSTEM_ARKVM + {EtsOptionType::ETS_BOOT_FILE, SYSTEM_ARK_STDLIB_PATH}, +#elif defined(KOALA_OHOS) + {EtsOptionType::ETS_BOOT_FILE, (std::string(OHOS_USER_LIBS) + "/" + "etsstdlib.abc").c_str() }, + +#elif defined(KOALA_LINUX) || defined(KOALA_MACOS) || defined(KOALA_WINDOWS) + {EtsOptionType::ETS_BOOT_FILE, (char*)strdup((std::string(thisVM->sdkPath) + "/ets/etsstdlib.abc").c_str())}, +#endif + }; + std::string all_files; + for (const std::string& path : files) { + etsVMOptions.push_back({EtsOptionType::ETS_BOOT_FILE, (char*)strdup(path.c_str())}); + if (all_files.size() > 0) all_files.append(":"); + all_files.append(path); + } + LOGI("Using ETSNAPI: classpath \"%" LOG_PUBLIC "s\" from %" LOG_PUBLIC "s", all_files.c_str(), appClassPath); + std::string all_files_aot; + for (const std::string& path : files_aot) { + etsVMOptions.push_back({EtsOptionType::ETS_AOT_FILE, (char*)strdup(path.c_str())}); + if (all_files_aot.size() > 0) all_files_aot.append(":"); + all_files_aot.append(path); + } + LOGI("ETSNAPI classpath (aot) \"%" LOG_PUBLIC "s\" from %" LOG_PUBLIC "s", all_files_aot.c_str(), appClassPath); + etsVMOptions.push_back({EtsOptionType::ETS_GC_TRIGGER_TYPE, "heap-trigger"}); + etsVMOptions.push_back({EtsOptionType::ETS_NATIVE_LIBRARY_PATH, (char*)strdup(std::string(appLibPath).c_str())}); + etsVMOptions.push_back({EtsOptionType::ETS_VERIFICATION_MODE, "on-the-fly"}); + etsVMOptions.push_back({EtsOptionType::ETS_JIT, nullptr}); + etsVMOptions.push_back({EtsOptionType::ETS_MOBILE_LOG, (void*)ArkMobileLog}); + etsVMOptions.push_back({EtsOptionType::ETS_AOT, nullptr}); + // etsVMOptions.push_back({EtsOptionType::ETS_LOG_LEVEL, "info"}); + pandaVMArgs.nOptions = etsVMOptions.size(); + pandaVMArgs.options = etsVMOptions.data(); + g_vmEntry.vmKind = vmKind; + + int32_t nVMs = 0; + typedef int (*createVM_t)(void** pVM, void** pEnv, void* vmInitArgs); + typedef int (*getVMs_t)(void** pVM, int32_t bufLen, int32_t* nVMs); + createVM_t createVM = (createVM_t)findSymbol(handle, "ETS_CreateVM"); + getVMs_t getVMs = (getVMs_t)findSymbol(handle, "ETS_GetCreatedVMs"); + result = getVMs ? getVMs(&vm, 1, &nVMs) : 0; + if (nVMs != 0) { + __EtsVM* vmInstance = (__EtsVM*)vm; + EtsEnv* pEnv = nullptr; + vmInstance->GetEnv(&pEnv, ETS_NAPI_VERSION_1_0); + env = static_cast(pEnv); + + } else { + result = createVM(&vm, &env, &pandaVMArgs); + } + } +#endif + + if (result != 0) { + LOGE("Error creating a VM of kind %" LOG_PUBLIC "d: %" LOG_PUBLIC "d\n", vmKind, result); + return result; + } + g_vmEntry.env = env; + g_vmEntry.foreignVMContext = *foreignVMContext; + return 0; +} + +struct AppInfo { + const char* className; + const char* createMethodName; + const char* createMethodSig; + const char* startMethodName; + const char* startMethodSig; + const char* enterMethodName; + const char* enterMethodSig; + const char* emitEventMethodName; + const char* emitEventMethodSig; + const char* restartWithMethodName; + const char* restartWithMethodSig; +}; + +#ifdef KOALA_JNI +const AppInfo javaAppInfo = { + "org/koalaui/arkoala/Application", + "createApplication", + "(Ljava/lang/String;Ljava/lang/String;)Lorg/koalaui/arkoala/Application;", + "start", + "()J", + "enter", + "(IIJ)Z", + "emitEvent", + "(IIII)Ljava/lang/String;", +}; +#endif + +#ifdef KOALA_ETS_NAPI +const AppInfo pandaAppInfo = { + "@ohos/arkui/Application/Application", + "createApplication", + "Lstd/core/String;Lstd/core/String;ZI:L@ohos/arkui/Application/Application;", + "start", + "J:J", + "enter", + "IIJ:Z", + "emitEvent", + "IIII:Lstd/core/String;", +}; +const AppInfo harnessAppInfo = { + "@koalaui/ets-harness/src/EtsHarnessApplication/EtsHarnessApplication", + "createApplication", + "Lstd/core/String;Lstd/core/String;ZI:L@koalaui/ets-harness/src/EtsHarnessApplication/EtsHarnessApplication;", + "start", + "J:J", + "enter", + "IIJ:Z", + "emitEvent", + "IIII:Lstd/core/String;", + "restartWith", + "Lstd/core/String;:V", + }; +#endif +#ifdef KOALA_ANI +const AppInfo harnessAniAppInfo = { + "L@koalaui/ets-harness/src/EtsHarnessApplication/EtsHarnessApplication;", + "createApplication", + "Lstd/core/String;Lstd/core/String;ZI:L@koalaui/ets-harness/src/EtsHarnessApplication/EtsHarnessApplication;", + "start", + "J:J", + "enter", + "IIJ:Z", + "emitEvent", + "IIII:Lstd/core/String;", + "restartWith", + "Lstd/core/String;:V", +}; +const AppInfo aniAppInfo = { + "L@ohos/arkui/Application/Application;", + "createApplication", + "Lstd/core/String;Lstd/core/String;ZI:L@ohos/arkui/Application/Application;", + "start", + "J:J", + "enter", + "IIJ:Z", + "emitEvent", + "IIII:Lstd/core/String;", +}; +#endif + +extern "C" DLL_EXPORT KNativePointer StartApplication(const char* appUrl, const char* appParams) { + const auto isTestEnv = std::string(appUrl) == "EtsHarness"; + const AppInfo* appInfo = + #ifdef KOALA_JNI + (g_vmEntry.vmKind == JAVA_VM_KIND) ? &javaAppInfo : + #endif + #if defined(KOALA_ETS_NAPI) + (g_vmEntry.vmKind == PANDA_VM_KIND) ? isTestEnv ? &harnessAppInfo : &pandaAppInfo : + #endif + #if defined(KOALA_ANI) + (g_vmEntry.vmKind == PANDA_ANI_VM_KIND) ? isTestEnv ? &harnessAniAppInfo : &aniAppInfo : + #endif + nullptr; + + if (!appInfo) { + LOGE("No appInfo provided for VM kind %" LOG_PUBLIC "d (recompile vmloader.cc with the missing flags)\n", g_vmEntry.vmKind); + return nullptr; + } + + LOGI("Starting application %" LOG_PUBLIC "s with params %" LOG_PUBLIC "s", appUrl, appParams); +#ifdef KOALA_JNI + if (g_vmEntry.vmKind == JAVA_VM_KIND) { + JNIEnv* jEnv = (JNIEnv*)(g_vmEntry.env); + jclass appClass = jEnv->FindClass(appInfo->className); + if (!appClass) { + LOGE("Cannot load main class %s\n", appInfo->className); + return nullptr; + } + jmethodID create = jEnv->GetStaticMethodID(appClass, appInfo->createMethodName, appInfo->createMethodSig); + if (!create) { + LOGE("Cannot find create method %s\n", appInfo->createMethodName); + return nullptr; + } + auto app = jEnv->NewGlobalRef(jEnv->CallStaticObjectMethod(appClass, create, jEnv->NewStringUTF(appUrl), jEnv->NewStringUTF(appParams))); + g_vmEntry.app = app; + auto start = jEnv->GetMethodID(appClass, appInfo->startMethodName, appInfo->startMethodSig); + if (!start) { + LOGE("Cannot find start method \"%s %s\"\n", appInfo->startMethodName, appInfo->startMethodSig); + return nullptr; + } + g_vmEntry.enter = (void*)(jEnv->GetMethodID(appClass, appInfo->enterMethodName, appInfo->enterMethodSig)); + if (!g_vmEntry.enter) { + LOGE("Cannot find enter method %s\n", appInfo->enterMethodName); + return nullptr; + } + g_vmEntry.emitEvent = (void*)(jEnv->GetMethodID(appClass, appInfo->emitEventMethodName, appInfo->emitEventMethodSig)); + if (!g_vmEntry.emitEvent) { + LOGE("Cannot find emitEvent method %s\n", appInfo->emitEventMethodName); + return nullptr; + } + return reinterpret_cast(jEnv->CallLongMethod( + app, start)); + } +#endif +#if defined(KOALA_ETS_NAPI) + if (g_vmEntry.vmKind == PANDA_VM_KIND) { + EtsEnv* etsEnv = (EtsEnv*)g_vmEntry.env; + ets_class appClass = etsEnv->FindClass(appInfo->className); + if (!appClass) { + LOGE("Cannot load main class %" LOG_PUBLIC "s\n", appInfo->className); + if (etsEnv->ErrorCheck()) { + etsEnv->ErrorDescribe(); + etsEnv->ErrorClear(); + } + return nullptr; + } + ets_method create = etsEnv->GetStaticp_method(appClass, appInfo->createMethodName, appInfo->createMethodSig); + if (!create) { + LOGE("Cannot find create method %" LOG_PUBLIC "s\n", appInfo->createMethodName); + if (etsEnv->ErrorCheck()) { + etsEnv->ErrorDescribe(); + etsEnv->ErrorClear(); + } + return nullptr; + } +#if defined (KOALA_OHOS_ARM64) + auto useNativeLog = true; +#else + auto useNativeLog = false; +#endif + auto app = etsEnv->NewGlobalRef(etsEnv->CallStaticObjectMethod( + appClass, create, + etsEnv->NewStringUTF(appUrl), etsEnv->NewStringUTF(appParams), + useNativeLog, + g_vmEntry.vmKind + )); + if (!app) { + LOGE("createApplication returned null"); + if (etsEnv->ErrorCheck()) { + etsEnv->ErrorDescribe(); + etsEnv->ErrorClear(); + return nullptr; + } + return nullptr; + } + g_vmEntry.app = (void*)app; + auto start = etsEnv->Getp_method(appClass, appInfo->startMethodName, appInfo->startMethodSig); + g_vmEntry.enter = (void*)(etsEnv->Getp_method(appClass, appInfo->enterMethodName, nullptr /*appInfo->enterMethodSig */)); + if (!g_vmEntry.enter) { + LOGE("Cannot find enter method %" LOG_PUBLIC "s", appInfo->enterMethodName); + if (etsEnv->ErrorCheck()) { + etsEnv->ErrorDescribe(); + etsEnv->ErrorClear(); + } + return nullptr; + } + if (etsEnv->ErrorCheck()) { + etsEnv->ErrorDescribe(); + etsEnv->ErrorClear(); + return nullptr; + } + g_vmEntry.emitEvent = (void*)(etsEnv->Getp_method(appClass, appInfo->emitEventMethodName, appInfo->emitEventMethodSig)); + if (!g_vmEntry.emitEvent) { + LOGE("Cannot find enter emitEvent %" LOG_PUBLIC "s", appInfo->emitEventMethodSig); + if (etsEnv->ErrorCheck()) { + etsEnv->ErrorDescribe(); + etsEnv->ErrorClear(); + } + return nullptr; + } + if (isTestEnv) { + g_vmEntry.restartWith = (void*)(etsEnv->Getp_method(appClass, appInfo->restartWithMethodName, appInfo->restartWithMethodSig)); + if (!g_vmEntry.restartWith) { + LOGE("Cannot find enter restartWith %" LOG_PUBLIC "s", appInfo->restartWithMethodSig); + if (etsEnv->ErrorCheck()) { + etsEnv->ErrorDescribe(); + etsEnv->ErrorClear(); + } + return nullptr; + } + } + // TODO: pass app entry point! + return reinterpret_cast(etsEnv->CallLongMethod((ets_object)(app), start, &g_vmEntry.foreignVMContext)); + } +#endif +#if defined(KOALA_ANI) + if (g_vmEntry.vmKind == PANDA_ANI_VM_KIND) { + auto *env = reinterpret_cast(g_vmEntry.env); + + ani_class appClass {}; + auto status = env->FindClass(appInfo->className, &appClass); + if (status != ANI_OK) { + LOGE("Cannot load main class %" LOG_PUBLIC "s\n", appInfo->className); + ResetErrorIfExists(env); + return nullptr; + } + ani_static_method create {}; + status = env->Class_FindStaticMethod(appClass, appInfo->createMethodName, appInfo->createMethodSig, &create); + if (status != ANI_OK) { + LOGE("Cannot find create method %" LOG_PUBLIC "s\n", appInfo->createMethodName); + ResetErrorIfExists(env); + return nullptr; + } + +#if defined (KOALA_OHOS_ARM64) + ani_boolean useNativeLog = ANI_TRUE; +#else + ani_boolean useNativeLog = ANI_FALSE; +#endif + ani_string appUrlString {}; + status = env->String_NewUTF8(appUrl, strlen(appUrl), &appUrlString); + if (status != ANI_OK) { + ResetErrorIfExists(env); + return nullptr; + } + ani_string appParamsString {}; + status = env->String_NewUTF8(appParams, strlen(appParams), &appParamsString); + if (status != ANI_OK) { + ResetErrorIfExists(env); + return nullptr; + } + + ani_ref appInstance {}; + status = env->Class_CallStaticMethod_Ref(appClass, create, &appInstance, appUrlString, appParamsString, + useNativeLog, static_cast(g_vmEntry.vmKind)); + if (status != ANI_OK) { + LOGE("createApplication returned null"); + ResetErrorIfExists(env); + return nullptr; + } + ani_ref app {}; + status = env->GlobalReference_Create(appInstance, &app); + if (status != ANI_OK) { + ResetErrorIfExists(env); + return nullptr; + } + g_vmEntry.app = (void*)app; + + ani_method start {}; + status = env->Class_FindMethod(appClass, appInfo->startMethodName, appInfo->startMethodSig, &start); + if (status != ANI_OK) { + ResetErrorIfExists(env); + return nullptr; + } + ani_method enter {}; + status = env->Class_FindMethod(appClass, appInfo->enterMethodName, nullptr, &enter); + if (status != ANI_OK) { + LOGE("Cannot find `enter` method %" LOG_PUBLIC "s", appInfo->enterMethodName); + ResetErrorIfExists(env); + return nullptr; + } + g_vmEntry.enter = reinterpret_cast(enter); + ani_method emitEvent {}; + status = env->Class_FindMethod(appClass, appInfo->emitEventMethodName, appInfo->emitEventMethodSig, &emitEvent); + if (status != ANI_OK) { + LOGE("Cannot find `emitEvent` method %" LOG_PUBLIC "s", appInfo->emitEventMethodSig); + ResetErrorIfExists(env); + return nullptr; + } + g_vmEntry.emitEvent = reinterpret_cast(emitEvent); + + if (isTestEnv) { + ani_method restartWith {}; + status = env->Class_FindMethod(appClass, appInfo->restartWithMethodName, appInfo->restartWithMethodSig, &restartWith); + if (status != ANI_OK) { + LOGE("Cannot find `restartWith` method %" LOG_PUBLIC "s", appInfo->restartWithMethodSig); + ResetErrorIfExists(env); + return nullptr; + } + g_vmEntry.restartWith = reinterpret_cast(restartWith); + } + + ani_long ptr = 0; + // TODO: pass app entry point! + status = env->Object_CallMethod_Long(static_cast(appInstance), start, &ptr, + reinterpret_cast(&g_vmEntry.foreignVMContext)); + if (status != ANI_OK) { + LOGE("Cannot start application"); + ResetErrorIfExists(env); + return nullptr; + } + return reinterpret_cast(ptr); + } +#endif + return nullptr; +} + +extern "C" DLL_EXPORT KBoolean RunApplication(const KInt arg0, const KInt arg1) { +#ifdef KOALA_JNI + if (g_vmEntry.vmKind == JAVA_VM_KIND) { + JNIEnv* jEnv = (JNIEnv*)(g_vmEntry.env); + auto result = jEnv->CallBooleanMethod( + (jobject)(g_vmEntry.app), + (jmethodID)(g_vmEntry.enter), + (jint)arg0, + (jint)arg1, + (int64_t)(intptr_t)(&g_vmEntry.foreignVMContext) + ); + if (jEnv->ExceptionCheck()) { + jEnv->ExceptionDescribe(); + jEnv->ExceptionClear(); + } + return result; + } +#endif +#if defined(KOALA_ETS_NAPI) + if (g_vmEntry.vmKind == PANDA_VM_KIND) { + EtsEnv* etsEnv = (EtsEnv*)(g_vmEntry.env); + if (!g_vmEntry.enter) { + LOGE("Cannot find enter method"); + return -1; + } + auto result = etsEnv->CallBooleanMethod( + (ets_object)(g_vmEntry.app), + (ets_method)(g_vmEntry.enter), + (ets_int)arg0, + (ets_int)arg1, + (int64_t)(intptr_t)(&g_vmEntry.foreignVMContext) + ); + if (etsEnv->ErrorCheck()) { + LOGE("Calling enter() method gave an error"); + etsEnv->ErrorDescribe(); + etsEnv->ErrorClear(); + } + return result; + } +#endif +#if defined(KOALA_ANI) + if (g_vmEntry.vmKind == PANDA_ANI_VM_KIND) { + ani_env* env = reinterpret_cast(g_vmEntry.env); + if (g_vmEntry.enter == nullptr) { + LOGE("Cannot find enter method"); + return -1; + } + ani_boolean result = ANI_FALSE; + auto status = env->Object_CallMethod_Boolean(reinterpret_cast(g_vmEntry.app), + reinterpret_cast(g_vmEntry.enter), &result, + static_cast(arg0), static_cast(arg1), + reinterpret_cast(&g_vmEntry.foreignVMContext)); + if (status != ANI_OK) { + ResetErrorIfExists(env); + return ANI_FALSE; + } + return result; + } +#endif + + return 1; +} + +extern "C" DLL_EXPORT const char* EmitEvent(const KInt type, const KInt target, const KInt arg0, const KInt arg1) { +#ifdef KOALA_JNI + if (g_vmEntry.vmKind == JAVA_VM_KIND) { + JNIEnv* jEnv = (JNIEnv*)(g_vmEntry.env); + if (!g_vmEntry.emitEvent) { + LOGE("Cannot find emitEvent method"); + return "-1"; + } + auto rv = (jstring)jEnv->CallObjectMethod( + (jobject)(g_vmEntry.app), + (jmethodID)(g_vmEntry.emitEvent), + (jint)type, + (jint)target, + (jint)arg0, + (jint)arg1 + ); + if (jEnv->ExceptionCheck()) { + jEnv->ExceptionDescribe(); + jEnv->ExceptionClear(); + } + const char *result = jEnv->GetStringUTFChars(rv, 0); + return result; + } +#endif + +#if defined(KOALA_ETS_NAPI) + if (g_vmEntry.vmKind == PANDA_VM_KIND) { + EtsEnv* etsEnv = (EtsEnv*)(g_vmEntry.env); + if (!g_vmEntry.emitEvent) { + LOGE("Cannot find emitEvent method"); + return "-1"; + } + auto rv = (ets_string)etsEnv->CallObjectMethod( + (ets_object)(g_vmEntry.app), + (ets_method)(g_vmEntry.emitEvent), + (ets_int)type, + (ets_int)target, + (ets_int)arg0, + (ets_int)arg1 + ); + if (etsEnv->ErrorCheck()) { + LOGE("Calling emitEvent() method gave an error"); + etsEnv->ErrorDescribe(); + etsEnv->ErrorClear(); + } + const char *result = etsEnv->GetStringUTFChars(rv, 0); + return result; + } +#endif +#if defined(KOALA_ANI) + if (g_vmEntry.vmKind == PANDA_ANI_VM_KIND) { + ani_env *env = reinterpret_cast(g_vmEntry.env); + if (g_vmEntry.emitEvent == nullptr) { + LOGE("Cannot find emitEvent method"); + return "-1"; + } + ani_ref result {}; + auto status = env->Object_CallMethod_Ref(reinterpret_cast(g_vmEntry.app), + reinterpret_cast(g_vmEntry.emitEvent), + &result, + static_cast(type), + static_cast(target), + static_cast(arg0), + static_cast(arg1)); + if (status != ANI_OK) { + LOGE("Calling emitEvent() method gave an error"); + ResetErrorIfExists(env); + return "-1"; + } + + auto str = static_cast(result); + ani_size sz = 0; + status = env->String_GetUTF8Size(str, &sz); + if (status != ANI_OK) { + ResetErrorIfExists(env); + return "-1"; + } + auto buffer = new char[sz + 1]; + ani_size writtenChars = 0; + status = env->String_GetUTF8(str, buffer, sz + 1, &writtenChars); + if (status != ANI_OK || writtenChars != sz) { + delete [] buffer; + ResetErrorIfExists(env); + return "-1"; + } + return buffer; + } +#endif + return "-1"; +} + +extern "C" DLL_EXPORT void RestartWith(const char* page) { +#ifdef KOALA_JNI + if (g_vmEntry.vmKind == JAVA_VM_KIND) { + JNIEnv* jEnv = (JNIEnv*)(g_vmEntry.env); + if (!g_vmEntry.restartWith) { + LOGE("Cannot find restartWith method"); + return; + } + jEnv->CallVoidMethod( + (jobject)(g_vmEntry.app), + (jmethodID)(g_vmEntry.restartWith), + jEnv->NewStringUTF(page) + ); + if (jEnv->ExceptionCheck()) { + jEnv->ExceptionDescribe(); + jEnv->ExceptionClear(); + } + } +#endif +#if defined(KOALA_ETS_NAPI) + if (g_vmEntry.vmKind == PANDA_VM_KIND) { + EtsEnv* etsEnv = (EtsEnv*)(g_vmEntry.env); + if (!g_vmEntry.restartWith) { + LOGE("Cannot find restartWith method"); + return; + } + etsEnv->CallVoidMethod( + (ets_object)(g_vmEntry.app), + (ets_method)(g_vmEntry.restartWith), + etsEnv->NewStringUTF(page) + ); + if (etsEnv->ErrorCheck()) { + LOGE("Calling restartWith() method gave an error"); + etsEnv->ErrorDescribe(); + etsEnv->ErrorClear(); + } + } +#endif +#if defined(KOALA_ANI) + if (g_vmEntry.vmKind == PANDA_ANI_VM_KIND) { + ani_env *env = reinterpret_cast(g_vmEntry.env); + if (!g_vmEntry.restartWith) { + LOGE("Cannot find restartWith method"); + return; + } + ani_string pageString {}; + auto status = env->String_NewUTF8(page, strlen(page), &pageString); + if (status != ANI_OK) { + ResetErrorIfExists(env); + return; + } + status = env->Object_CallMethod_Void(reinterpret_cast(g_vmEntry.app), + reinterpret_cast(g_vmEntry.restartWith), pageString); + if (status != ANI_OK) { + LOGE("Calling restartWith() method gave an error"); + ResetErrorIfExists(env); + } + } +#endif +} + +namespace fs = std::filesystem; + +bool ends_with(std::string str, std::string suffix) +{ + return str.size() >= suffix.size() && str.compare(str.size()-suffix.size(), suffix.size(), suffix) == 0; +} + +void traverseDir(const std::string& root, std::vector& paths, std::string suffix, const std::vector& fallbackPaths) { + #ifdef KOALA_OHOS_ARM32 + // selinux prohibits any access to "/system/framework" + if (root == "/system/framework") { + for (auto path: fallbackPaths) { + paths.push_back(root + "/" + path + suffix); + } + return; + } + #endif + + if (!fs::exists(root)) { + LOGE("Cannot open dir %" LOG_PUBLIC "s\n", root.c_str()); + return; + } + + #if defined(KOALA_OHOS) + suffix += ".so"; + #endif + + LOGI("Searching in %" LOG_PUBLIC "s\n", root.c_str()); + for (auto &file : fs::recursive_directory_iterator(root)) { + if (ends_with(file.path().string(), suffix) && fs::is_regular_file(file)) { + paths.push_back(file.path().string()); + } + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/wasm/convertors-wasm.h b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/wasm/convertors-wasm.h new file mode 100644 index 0000000000000000000000000000000000000000..43a66773813f5aff7a1ff75a924394648aa70197 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/cpp/wasm/convertors-wasm.h @@ -0,0 +1,827 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "koala-types.h" + +#include +#include +#define KOALA_INTEROP_EXPORT EMSCRIPTEN_KEEPALIVE extern "C" + +template +struct InteropTypeConverter { + using InteropType = T; + static T convertFrom(InteropType value) { return value; } + static InteropType convertTo(T value) { return value; } +}; + +template<> +struct InteropTypeConverter { + using InteropType = const uint8_t*; + static KStringPtr convertFrom(InteropType value) { + KStringPtr result; + if (value == nullptr) { + return KStringPtr(); + } else { + int len = (value[0] | (value[1] << 8) | (value[2] << 16) | (value[3] << 24)); + return KStringPtr((const char*)(value + 4), len, true); + } + } + static InteropType convertTo(KStringPtr value) = delete; +}; + +template +inline T getArgument(typename InteropTypeConverter::InteropType arg) { + return InteropTypeConverter::convertFrom(arg); +} + +template +inline typename InteropTypeConverter::InteropType makeResult(T value) { + return InteropTypeConverter::convertTo(value); +} + +// TODO: Rewrite all others to typed convertors. + +#define KOALA_INTEROP_0(name, Ret) \ +KOALA_INTEROP_EXPORT Ret name() { \ + KOALA_MAYBE_LOG(name) \ + return makeResult(impl_##name()); \ +} + +#define KOALA_INTEROP_1(name, Ret, P0) \ +KOALA_INTEROP_EXPORT Ret name(InteropTypeConverter::InteropType _p0) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + return makeResult(impl_##name(p0)); \ +} + +#define KOALA_INTEROP_2(name, Ret, P0, P1) \ +KOALA_INTEROP_EXPORT Ret name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + return makeResult(impl_##name(p0, p1)); \ +} + +#define KOALA_INTEROP_3(name, Ret, P0, P1, P2) \ +KOALA_INTEROP_EXPORT Ret name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + return makeResult(impl_##name(p0, p1, p2)); \ +} + +#define KOALA_INTEROP_4(name, Ret, P0, P1, P2, P3) \ +KOALA_INTEROP_EXPORT Ret name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + return makeResult(impl_##name(p0, p1, p2, p3)); \ +} + +#define KOALA_INTEROP_5(name, Ret, P0, P1, P2, P3, P4) \ +KOALA_INTEROP_EXPORT Ret name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + return makeResult(impl_##name(p0, p1, p2, p3, p4)); \ +} + +#define KOALA_INTEROP_6(name, Ret, P0, P1, P2, P3, P4, P5) \ +KOALA_INTEROP_EXPORT Ret name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + return makeResult(impl_##name(p0, p1, p2, p3, p4, p5)); \ +} + +#define KOALA_INTEROP_7(name, Ret, P0, P1, P2, P3, P4, P5, P6) \ +KOALA_INTEROP_EXPORT Ret name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + return makeResult(impl_##name(p0, p1, p2, p3, p4, p5, p6)); \ +} + +#define KOALA_INTEROP_8(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7) \ +KOALA_INTEROP_EXPORT Ret name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + return makeResult(impl_##name(p0, p1, p2, p3, p4, p5, p6, p7)); \ +} + +#define KOALA_INTEROP_9(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8) \ +KOALA_INTEROP_EXPORT Ret name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + return makeResult(impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8)); \ +} + +#define KOALA_INTEROP_10(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) \ +KOALA_INTEROP_EXPORT Ret name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + P9 p9 = getArgument(_p9); \ + return makeResult(impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)); \ +} + +#define KOALA_INTEROP_11(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) \ +KOALA_INTEROP_EXPORT Ret name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + P9 p9 = getArgument(_p9); \ + P10 p10 = getArgument(_p10); \ + return makeResult(impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10)); \ +} + +#define KOALA_INTEROP_12(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11) \ +KOALA_INTEROP_EXPORT Ret name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + P9 p9 = getArgument(_p9); \ + P10 p10 = getArgument(_p10); \ + P11 p11 = getArgument(_p11); \ + return makeResult(impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11)); \ +} + +#define KOALA_INTEROP_13(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12) \ +KOALA_INTEROP_EXPORT Ret name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11, \ + InteropTypeConverter::InteropType _p12 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + P9 p9 = getArgument(_p9); \ + P10 p10 = getArgument(_p10); \ + P11 p11 = getArgument(_p11); \ + P12 p12 = getArgument(_p12); \ + return makeResult(impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12)); \ +} + +#define KOALA_INTEROP_14(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13) \ +KOALA_INTEROP_EXPORT Ret name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11, \ + InteropTypeConverter::InteropType _p12, \ + InteropTypeConverter::InteropType _p13 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + P9 p9 = getArgument(_p9); \ + P10 p10 = getArgument(_p10); \ + P11 p11 = getArgument(_p11); \ + P12 p12 = getArgument(_p12); \ + P13 p13 = getArgument(_p13); \ + return makeResult(impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13)); \ +} + + + +#define KOALA_INTEROP_V0(name) \ +KOALA_INTEROP_EXPORT void name() { \ + KOALA_MAYBE_LOG(name) \ + impl_##name(); \ + return; \ +} + +#define KOALA_INTEROP_V1(name, P0) \ +KOALA_INTEROP_EXPORT void name(typename InteropTypeConverter::InteropType _p0) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + impl_##name(p0); \ + return; \ +} + +#define KOALA_INTEROP_V2(name, P0, P1) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + impl_##name(p0, p1); \ + return; \ +} + +#define KOALA_INTEROP_V3(name, P0, P1, P2) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + impl_##name(p0, p1, p2); \ + return; \ +} + +#define KOALA_INTEROP_V4(name, P0, P1, P2, P3) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2, \ + typename InteropTypeConverter::InteropType _p3 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + impl_##name(p0, p1, p2, p3); \ + return; \ +} + +#define KOALA_INTEROP_V5(name, P0, P1, P2, P3, P4) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2, \ + typename InteropTypeConverter::InteropType _p3, \ + typename InteropTypeConverter::InteropType _p4 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + impl_##name(p0, p1, p2, p3, p4); \ + return; \ +} + +#define KOALA_INTEROP_V6(name, P0, P1, P2, P3, P4, P5) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2, \ + typename InteropTypeConverter::InteropType _p3, \ + typename InteropTypeConverter::InteropType _p4, \ + typename InteropTypeConverter::InteropType _p5 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + impl_##name(p0, p1, p2, p3, p4, p5); \ + return; \ +} + +#define KOALA_INTEROP_V7(name, P0, P1, P2, P3, P4, P5, P6) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2, \ + typename InteropTypeConverter::InteropType _p3, \ + typename InteropTypeConverter::InteropType _p4, \ + typename InteropTypeConverter::InteropType _p5, \ + typename InteropTypeConverter::InteropType _p6 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6); \ + return; \ +} + +#define KOALA_INTEROP_V8(name, P0, P1, P2, P3, P4, P5, P6, P7) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2, \ + typename InteropTypeConverter::InteropType _p3, \ + typename InteropTypeConverter::InteropType _p4, \ + typename InteropTypeConverter::InteropType _p5, \ + typename InteropTypeConverter::InteropType _p6, \ + typename InteropTypeConverter::InteropType _p7 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7); \ + return; \ +} + +#define KOALA_INTEROP_V9(name, P0, P1, P2, P3, P4, P5, P6, P7, P8) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2, \ + typename InteropTypeConverter::InteropType _p3, \ + typename InteropTypeConverter::InteropType _p4, \ + typename InteropTypeConverter::InteropType _p5, \ + typename InteropTypeConverter::InteropType _p6, \ + typename InteropTypeConverter::InteropType _p7, \ + typename InteropTypeConverter::InteropType _p8 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8); \ + return; \ +} + +#define KOALA_INTEROP_V10(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2, \ + typename InteropTypeConverter::InteropType _p3, \ + typename InteropTypeConverter::InteropType _p4, \ + typename InteropTypeConverter::InteropType _p5, \ + typename InteropTypeConverter::InteropType _p6, \ + typename InteropTypeConverter::InteropType _p7, \ + typename InteropTypeConverter::InteropType _p8, \ + typename InteropTypeConverter::InteropType _p9 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + P9 p9 = getArgument(_p9); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9); \ + return; \ +} + +#define KOALA_INTEROP_V11(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2, \ + typename InteropTypeConverter::InteropType _p3, \ + typename InteropTypeConverter::InteropType _p4, \ + typename InteropTypeConverter::InteropType _p5, \ + typename InteropTypeConverter::InteropType _p6, \ + typename InteropTypeConverter::InteropType _p7, \ + typename InteropTypeConverter::InteropType _p8, \ + typename InteropTypeConverter::InteropType _p9, \ + typename InteropTypeConverter::InteropType _p10 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + P9 p9 = getArgument(_p9); \ + P10 p10 = getArgument(_p10); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); \ + return; \ +} + +#define KOALA_INTEROP_V12(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2, \ + typename InteropTypeConverter::InteropType _p3, \ + typename InteropTypeConverter::InteropType _p4, \ + typename InteropTypeConverter::InteropType _p5, \ + typename InteropTypeConverter::InteropType _p6, \ + typename InteropTypeConverter::InteropType _p7, \ + typename InteropTypeConverter::InteropType _p8, \ + typename InteropTypeConverter::InteropType _p9, \ + typename InteropTypeConverter::InteropType _p10, \ + typename InteropTypeConverter::InteropType _p11 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + P9 p9 = getArgument(_p9); \ + P10 p10 = getArgument(_p10); \ + P11 p11 = getArgument(_p11); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11); \ + return; \ +} + +#define KOALA_INTEROP_V13(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2, \ + typename InteropTypeConverter::InteropType _p3, \ + typename InteropTypeConverter::InteropType _p4, \ + typename InteropTypeConverter::InteropType _p5, \ + typename InteropTypeConverter::InteropType _p6, \ + typename InteropTypeConverter::InteropType _p7, \ + typename InteropTypeConverter::InteropType _p8, \ + typename InteropTypeConverter::InteropType _p9, \ + typename InteropTypeConverter::InteropType _p10, \ + typename InteropTypeConverter::InteropType _p11, \ + typename InteropTypeConverter::InteropType _p12 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + P9 p9 = getArgument(_p9); \ + P10 p10 = getArgument(_p10); \ + P11 p11 = getArgument(_p11); \ + P12 p12 = getArgument(_p12); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12); \ + return; \ +} + +#define KOALA_INTEROP_V14(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2, \ + typename InteropTypeConverter::InteropType _p3, \ + typename InteropTypeConverter::InteropType _p4, \ + typename InteropTypeConverter::InteropType _p5, \ + typename InteropTypeConverter::InteropType _p6, \ + typename InteropTypeConverter::InteropType _p7, \ + typename InteropTypeConverter::InteropType _p8, \ + typename InteropTypeConverter::InteropType _p9, \ + typename InteropTypeConverter::InteropType _p10, \ + typename InteropTypeConverter::InteropType _p11, \ + typename InteropTypeConverter::InteropType _p12, \ + typename InteropTypeConverter::InteropType _p13 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + P9 p9 = getArgument(_p9); \ + P10 p10 = getArgument(_p10); \ + P11 p11 = getArgument(_p11); \ + P12 p12 = getArgument(_p12); \ + P13 p13 = getArgument(_p13); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13); \ + return; \ +} + +#define KOALA_INTEROP_CTX_1(name, Ret, P0) \ +KOALA_INTEROP_EXPORT Ret name(InteropTypeConverter::InteropType _p0) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + return makeResult(impl_##name(nullptr, p0)); \ +} + +#define KOALA_INTEROP_CTX_2(name, Ret, P0, P1) \ +KOALA_INTEROP_EXPORT Ret name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + return makeResult(impl_##name(nullptr, p0, p1)); \ +} + +#define KOALA_INTEROP_CTX_3(name, Ret, P0, P1, P2) \ +KOALA_INTEROP_EXPORT Ret name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + return makeResult(impl_##name(nullptr, p0, p1, p2)); \ +} + +#define KOALA_INTEROP_CTX_4(name, Ret, P0, P1, P2, P3) \ +KOALA_INTEROP_EXPORT Ret name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + return makeResult(impl_##name(nullptr, p0, p1, p2, p3)); \ +} + +#define KOALA_INTEROP_CTX_V3(name, P0, P1, P2) \ +KOALA_INTEROP_EXPORT void name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + impl_##name(nullptr, p0, p1, p2); \ +} + +#define KOALA_INTEROP_CTX_V4(name, P0, P1, P2, P3) \ +KOALA_INTEROP_EXPORT void name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + impl_##name(nullptr, p0, p1, p2, p3); \ +} + +#define KOALA_INTEROP_DIRECT_0(name, Ret) \ + KOALA_INTEROP_0(name, Ret) +#define KOALA_INTEROP_DIRECT_1(name, Ret, P0) \ + KOALA_INTEROP_1(name, Ret, P0) +#define KOALA_INTEROP_DIRECT_2(name, Ret, P0, P1) \ + KOALA_INTEROP_2(name, Ret, P0, P1) +#define KOALA_INTEROP_DIRECT_3(name, Ret, P0, P1, P2) \ + KOALA_INTEROP_3(name, Ret, P0, P1, P2) +#define KOALA_INTEROP_DIRECT_4(name, Ret, P0, P1, P2, P3) \ + KOALA_INTEROP_4(name, Ret, P0, P1, P2, P3) +#define KOALA_INTEROP_DIRECT_5(name, Ret, P0, P1, P2, P3, P4) \ + KOALA_INTEROP_5(name, Ret, P0, P1, P2, P3, P4) +#define KOALA_INTEROP_DIRECT_6(name, Ret, P0, P1, P2, P3, P4, P5) \ + KOALA_INTEROP_6(name, Ret, P0, P1, P2, P3, P4, P5) +#define KOALA_INTEROP_DIRECT_7(name, Ret, P0, P1, P2, P3, P4, P5, P6) \ + KOALA_INTEROP_7(name, Ret, P0, P1, P2, P3, P4, P5, P6) +#define KOALA_INTEROP_DIRECT_8(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7) \ + KOALA_INTEROP_8(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7) +#define KOALA_INTEROP_DIRECT_9(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8) \ + KOALA_INTEROP_9(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8) +#define KOALA_INTEROP_DIRECT_10(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) \ + KOALA_INTEROP_10(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) +#define KOALA_INTEROP_DIRECT_11(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) \ + KOALA_INTEROP_11(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) +#define KOALA_INTEROP_DIRECT_V0(name) \ + KOALA_INTEROP_V0(name) +#define KOALA_INTEROP_DIRECT_V1(name, P0) \ + KOALA_INTEROP_V1(name, P0) +#define KOALA_INTEROP_DIRECT_V2(name, P0, P1) \ + KOALA_INTEROP_V2(name, P0, P1) +#define KOALA_INTEROP_DIRECT_V3(name, P0, P1, P2) \ + KOALA_INTEROP_V3(name, P0, P1, P2) +#define KOALA_INTEROP_DIRECT_V4(name, P0, P1, P2, P3) \ + KOALA_INTEROP_V4(name, P0, P1, P2, P3) +#define KOALA_INTEROP_DIRECT_V5(name, P0, P1, P2, P3, P4) \ + KOALA_INTEROP_V5(name, P0, P1, P2, P3, P4) +#define KOALA_INTEROP_DIRECT_V6(name, P0, P1, P2, P3, P4, P5) \ + KOALA_INTEROP_V6(name, P0, P1, P2, P3, P4, P5) +#define KOALA_INTEROP_DIRECT_V7(name, P0, P1, P2, P3, P4, P5, P6) \ + KOALA_INTEROP_V7(name, P0, P1, P2, P3, P4, P5, P6) +#define KOALA_INTEROP_DIRECT_V8(name, P0, P1, P2, P3, P4, P5, P6, P7) \ + KOALA_INTEROP_V8(name, P0, P1, P2, P3, P4, P5, P6, P7) +#define KOALA_INTEROP_DIRECT_V9(name, P0, P1, P2, P3, P4, P5, P6, P7, P8) \ + KOALA_INTEROP_V9(name, P0, P1, P2, P3, P4, P5, P6, P7, P8) +#define KOALA_INTEROP_DIRECT_V10(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) \ + KOALA_INTEROP_V10(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) +#define KOALA_INTEROP_DIRECT_V11(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) \ + KOALA_INTEROP_V11(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) + +#define KOALA_INTEROP_THROW(vmContext, object, ...) \ + do { \ + assert(false); /* TODO: implement*/ \ + return __VA_ARGS__; \ + } while (0) + +#define KOALA_INTEROP_THROW_STRING(vmContext, message, ...) \ + do { \ + assert(false); /* TODO: implement*/ \ + return __VA_ARGS__; \ + } while (0) diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/DeserializerBase.ts b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/DeserializerBase.ts new file mode 100644 index 0000000000000000000000000000000000000000..0e4c522a3e58974022e00e5beb7eeb7f9174f659 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/DeserializerBase.ts @@ -0,0 +1,235 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { CustomTextDecoder, float32, int32, int64 } from "@koalaui/common" +import { Tags, CallbackResource } from "./SerializerBase"; +import { pointer, KUint8ArrayPtr, KSerializerBuffer } from "./InteropTypes" +import { NativeBuffer } from "./NativeBuffer"; +import { ResourceHolder } from "../arkts/ResourceManager"; + +export class DeserializerBase { + private position = 0 + private readonly buffer: ArrayBuffer + private readonly length: int32 + private view: DataView + private static textDecoder = new CustomTextDecoder() + private static customDeserializers: CustomDeserializer | undefined = undefined + + static registerCustomDeserializer(deserializer: CustomDeserializer) { + let current = DeserializerBase.customDeserializers + if (current == undefined) { + DeserializerBase.customDeserializers = deserializer + } else { + while (current.next != undefined) { + current = current.next + } + current.next = deserializer + } + } + + constructor(buffer: ArrayBuffer|KSerializerBuffer|KUint8ArrayPtr, length: int32) { + if (typeof buffer != 'object') + throw new Error('Must be used only with ArrayBuffer') + if (buffer && ("buffer" in buffer)) { + buffer = buffer.buffer as ArrayBuffer + } + this.buffer = buffer as ArrayBuffer + this.length = length + this.view = new DataView(this.buffer) + } + + static get( + factory: (args: Uint8Array, length: int32) => T, + args: Uint8Array, length: int32): T { + + // TBD: Use cache + return factory(args, length); + } + + asBuffer(position?: int32, length?: int32): KSerializerBuffer { + return new Uint8Array(this.buffer, position, length) + } + + asArray(position?: int32, length?: int32): Uint8Array { + return new Uint8Array(this.buffer, position, length) + } + + currentPosition(): int32 { + return this.position + } + + resetCurrentPosition(): void { + this.position = 0 + } + + private checkCapacity(value: int32) { + if (value > this.length) { + throw new Error(`${value} is less than remaining buffer length`) + } + } + + readInt8(): int32 { + this.checkCapacity(1) + const value = this.view.getInt8(this.position) + this.position += 1 + return value + } + + readInt32(): int32 { + this.checkCapacity(4) + const value = this.view.getInt32(this.position, true) + this.position += 4 + return value + } + + readInt64(): int64 { + this.checkCapacity(8) + const value = this.view.getBigInt64(this.position, true) + this.position += 8 + return Number(value) + } + + readPointer(): pointer { + this.checkCapacity(8) + const value = this.view.getBigInt64(this.position, true) + this.position += 8 + return value + } + + readFloat32(): float32 { + this.checkCapacity(4) + const value = this.view.getFloat32(this.position, true) + this.position += 4 + return value + } + + readBoolean(): boolean { + this.checkCapacity(1) + const value = this.view.getInt8(this.position) + this.position += 1 + return value == 1 + } + + readFunction(): any { + // TODO: not exactly correct. + const id = this.readInt32() + return id + } + + readMaterialized(): object { + const ptr = this.readPointer() + return { ptr: ptr } + } + + readString(): string { + const length = this.readInt32() + this.checkCapacity(length) + // read without null-terminated byte + const value = DeserializerBase.textDecoder.decode(this.asArray(this.position, length - 1)); + this.position += length + return value + } + + readCustomObject(kind: string): any { + let current = DeserializerBase.customDeserializers + while (current) { + if (current.supports(kind)) { + return current.deserialize(this, kind) + } + current = current.next + } + // consume tag + const tag = this.readInt8() + return undefined + } + + readNumber(): int32 | undefined { + const tag = this.readInt8() + switch (tag) { + case Tags.UNDEFINED: + return undefined; + case Tags.INT32: + return this.readInt32() + case Tags.FLOAT32: + return this.readFloat32() + default: + throw new Error(`Unknown number tag: ${tag}`) + break + } + } + + readCallbackResource(): CallbackResource { + return { + resourceId: this.readInt32(), + hold: this.readPointer(), + release: this.readPointer(), + } + } + readObject():any { + const resource = this.readCallbackResource() + return ResourceHolder.instance().get(resource.resourceId) + } + + static lengthUnitFromInt(unit: int32): string { + let suffix: string + switch (unit) { + case 0: + suffix = "px" + break + case 1: + suffix = "vp" + break + case 3: + suffix = "%" + break + case 4: + suffix = "lpx" + break + default: + suffix = "" + } + return suffix + } + readBuffer(): NativeBuffer { + const resource = this.readCallbackResource() + const data = this.readPointer() + const length = this.readInt64() + + return NativeBuffer.wrap(data, length, resource.resourceId, resource.hold, resource.release) + } +} + +export abstract class CustomDeserializer { + protected constructor(protected supported: Array) { + } + + supports(kind: string): boolean { + return this.supported.includes(kind) + } + + abstract deserialize(serializer: DeserializerBase, kind: string): any + + next: CustomDeserializer | undefined = undefined +} + +class DateDeserializer extends CustomDeserializer { + constructor() { + super(["Date"]); + } + + deserialize(serializer: DeserializerBase, kind: string): any { + return new Date(serializer.readString()) + } +} +DeserializerBase.registerCustomDeserializer(new DateDeserializer()) diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/Finalizable.ts b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/Finalizable.ts new file mode 100644 index 0000000000000000000000000000000000000000..b130150ffe19e3a2cbce5bec549f480af945cfc7 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/Finalizable.ts @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Wrapper, nullptr } from "./Wrapper" +import { finalizerRegister, finalizerUnregister, Thunk } from "@koalaui/common" +import { InteropNativeModule } from "./InteropNativeModule" +import { pointer } from "./InteropTypes" + +export class NativeThunk implements Thunk { + finalizer: pointer + obj: pointer + name: string|undefined + + constructor(obj: pointer, finalizer: pointer, name?: string) { + this.finalizer = finalizer + this.obj = obj + this.name = name + } + + clean() { + if (this.obj != nullptr) { + this.destroyNative(this.obj, this.finalizer) + } + this.obj = nullptr + } + + destroyNative(ptr: pointer, finalizer: pointer): void { + InteropNativeModule._InvokeFinalizer(ptr, finalizer) + } +} + +/** + * Class with the custom finalizer, usually used to release a native peer. + * Do not use directly, only via subclasses. + */ +export class Finalizable extends Wrapper { + finalizer: pointer + cleaner?: NativeThunk = undefined + managed: boolean + constructor(ptr: pointer, finalizer: pointer, managed: boolean = true) { + super(ptr) + this.finalizer = finalizer + this.managed = managed + const handle = this.createHandle() + + if (this.managed) { + // TODO: reenable exception. + if (this.ptr == nullptr) return // throw new Error("Can't have nullptr ptr ${}") + if (this.finalizer == nullptr) throw new Error("Managed finalizer is 0") + + const thunk = this.makeNativeThunk(ptr, finalizer, handle) + finalizerRegister(this, thunk) + this.cleaner = thunk + } + } + + createHandle(): string | undefined { + return undefined + } + + makeNativeThunk(ptr: pointer, finalizer: pointer, handle: string | undefined): NativeThunk { + return new NativeThunk(ptr, finalizer, handle) + } + + close() { + if (this.ptr == nullptr) { + throw new Error(`Closing a closed object: ` + this.toString()) + } else if (this.cleaner == null) { + throw new Error(`No thunk assigned to ` + this.toString()) + } else { + finalizerUnregister(this) + this.cleaner.clean() + this.cleaner = undefined + this.ptr = nullptr + } + } + + release(): pointer { + finalizerUnregister(this) + if (this.cleaner) + this.cleaner.obj = nullptr + let result = this.ptr + this.ptr = nullptr + return result + } + + resetPeer(pointer: pointer) { + if (this.managed) throw new Error("Can only reset peer for an unmanaged object") + this.ptr = pointer + } + + use(body: (value: Finalizable) => R): R { + let result = body(this) + this.close() + return result + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/InteropNativeModule.ts b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/InteropNativeModule.ts new file mode 100644 index 0000000000000000000000000000000000000000..7aa61e70bc8b5ed4aaa6484e0e208a4d3ecd3550 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/InteropNativeModule.ts @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { int32, int64 } from "@koalaui/common"; +import { KPointer, KSerializerBuffer, KStringPtr, KUint8ArrayPtr } from "./InteropTypes"; +import { loadNativeModuleLibrary } from "./loadLibraries"; + +export class InteropNativeModule { + public static _SetCallbackDispatcher(dispatcher: (id: int32, args: Uint8Array, length: int32) => int32): void { throw "method not loaded" } + public static _CleanCallbackDispatcher(): void { throw "method not loaded" } + + public static _GetGroupedLog(index: int32): KPointer { throw "method not loaded" } + public static _StartGroupedLog(index: int32): void { throw "method not loaded" } + public static _StopGroupedLog(index: int32): void { throw "method not loaded" } + public static _AppendGroupedLog(index: int32, message: string): void { throw "method not loaded" } + public static _PrintGroupedLog(index: int32): void { throw "method not loaded" } + public static _GetStringFinalizer(): KPointer { throw "method not loaded" } + public static _IncrementNumber(value: number): number { throw "method not loaded" } + public static _InvokeFinalizer(ptr1: KPointer, ptr2: KPointer): void { throw "method not loaded" } + public static _GetPtrVectorElement(ptr1: KPointer, arg: int32): KPointer { throw "method not loaded" } + public static _StringLength(ptr1: KPointer): int32 { throw "method not loaded" } + public static _StringData(ptr1: KPointer, arr: KUint8ArrayPtr, i: int32): void { throw "method not loaded" } + public static _StringMake(str1: KStringPtr): KPointer { throw "method not loaded" } + public static _GetPtrVectorSize(ptr1: KPointer): int32 { throw "method not loaded" } + public static _ManagedStringWrite(str1: string, arr: Uint8Array, arg: int32): int32 { throw "method not loaded" } + public static _NativeLog(str1: string): void { throw "method not loaded" } + public static _Utf8ToString(data: KSerializerBuffer, offset: int32, length: int32): string { throw "method not loaded" } + public static _StdStringToString(cstring: KPointer): string { throw "method not loaded" } + public static _CheckCallbackEvent(buffer: KSerializerBuffer, bufferLength: int32): int32 { throw "method not loaded" } + public static _HoldCallbackResource(resourceId: int32): void { throw "method not loaded" } + public static _ReleaseCallbackResource(resourceId: int32): void { throw "method not loaded" } + public static _CallCallback(callbackKind: int32, args: KSerializerBuffer, argsSize: int32): void { throw "method not loaded" } + public static _CallCallbackSync(callbackKind: int32, args: KSerializerBuffer, argsSize: int32): void { throw "method not loaded" } + public static _CallCallbackResourceHolder(holder: KPointer, resourceId: int32): void { throw "method not loaded" } + public static _CallCallbackResourceReleaser(releaser: KPointer, resourceId: int32): void { throw "method not loaded" } + public static _MaterializeBuffer(data: KPointer, length: bigint, resourceId: int32, hold: KPointer, release: KPointer): ArrayBuffer { throw "method not loaded" } + public static _GetNativeBufferPointer(data: ArrayBuffer): KPointer { throw "method not loaded" } + + public static _LoadVirtualMachine(arg0: int32, arg1: string, arg2: string): int32 { throw "method not loaded" } + public static _RunApplication(arg0: int32, arg1: int32): number { throw "method not loaded" } + public static _StartApplication(appUrl: string, appParams: string): KPointer { throw "method not loaded" } + public static _EmitEvent(eventType: int32, target: int32, arg0: int32, arg1: int32): void { throw "method not loaded" } + public static _CallForeignVM(foreignContext: KPointer, kind: int32, args: KSerializerBuffer, argsSize: int32): int32 { throw "method not loaded" } + public static _SetForeignVMContext(context: KPointer): void { throw "method not loaded" } + public static _ReadByte(data: KPointer, index: int32, length: bigint): int32 { throw "method not loaded" } + public static _WriteByte(data: KPointer, index: int32, length: bigint, value: int32): void { throw "method not loaded" } +} + +export function loadInteropNativeModule() { + loadNativeModuleLibrary("InteropNativeModule", InteropNativeModule) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/InteropOps.ts b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/InteropOps.ts new file mode 100644 index 0000000000000000000000000000000000000000..43706f055b9693ad583ad1db286cb524e27682f9 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/InteropOps.ts @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { int32 } from "@koalaui/common" +import { withStringResult } from "./Platform" +import { KInt, KStringPtr, KUint8ArrayPtr, pointer } from "./InteropTypes" + +export type CallbackType = (args: Uint8Array, length: int32) => int32 + +class CallbackRecord { + constructor( + public readonly callback: CallbackType, + public readonly autoDisposable: boolean + ) { } +} + +class CallbackRegistry { + + static INSTANCE = new CallbackRegistry() + + private callbacks = new Map() + private id = 1024 + + constructor() { + this.callbacks.set(0, new CallbackRecord( + (args: Uint8Array, length: int32): int32 => { + console.log(`Callback 0 called with args = ${args} and length = ${length}`) + throw new Error(`Null callback called`) + }, false) + ) + } + + wrap(callback: CallbackType, autoDisposable: boolean): int32 { + const id = this.id++ + this.callbacks.set(id, new CallbackRecord(callback, autoDisposable)) + return id + } + + wrapSystem(id: number, callback: CallbackType, autoDisposable: boolean): int32 { + this.callbacks.set(id, new CallbackRecord(callback, autoDisposable)) + return id + } + + call(id: int32, args: Uint8Array, length: int32): int32 { + const record = this.callbacks.get(id) + if (!record) { + console.log(`Callback ${id} is not known`) + // throw new Error(`Disposed or unwrapped callback called (id = ${id})`) + return 0; // todo + } + if (record.autoDisposable) { + this.dispose(id) + } + return record.callback(args, length) + } + + dispose(id: int32) { + this.callbacks.delete(id) + } +} + +export function wrapCallback(callback: CallbackType, autoDisposable: boolean = true): int32 { + return CallbackRegistry.INSTANCE.wrap(callback, autoDisposable) +} + +export function wrapSystemCallback(id:number, callback: CallbackType): int32 { + return CallbackRegistry.INSTANCE.wrapSystem(id, callback, false) +} + +export function disposeCallback(id: int32) { + CallbackRegistry.INSTANCE.dispose(id) +} + +export function callCallback(id: int32, args: Uint8Array, length: int32): int32 { + return CallbackRegistry.INSTANCE.call(id, args, length) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/InteropTypes.ts b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/InteropTypes.ts new file mode 100644 index 0000000000000000000000000000000000000000..0aaa80bd75648b71c171e7a80491f48693c1e17c --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/InteropTypes.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { int32, int64, float32, float64 } from "@koalaui/common" + +export type KStringPtr = int32 | string | null +export type KStringArrayPtr = int32 | Uint8Array | null +export type KInt32ArrayPtr = int32 | Int32Array | null +export type KFloat32ArrayPtr = int32 | Float32Array | null +export type KUint8ArrayPtr = int32 | Uint8Array | null +export type KInt = int32 +export type KUInt = int32 +export type KLong = int64 +export type KFloat = float32 +export type KDouble = float64 +export type KBoolean = int32 +export type KPointer = number | bigint +export type pointer = KPointer +export type KNativePointer = KPointer +export type KInteropReturnBuffer = Uint8Array +export type KSerializerBuffer = KUint8ArrayPtr \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/MaterializedBase.ts b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/MaterializedBase.ts new file mode 100644 index 0000000000000000000000000000000000000000..51135fbaa7beee1e31f48d30b9eebc69c5fa45eb --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/MaterializedBase.ts @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Finalizable } from "./Finalizable" + +export interface MaterializedBase { + getPeer(): Finalizable | undefined +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/NativeBuffer.ts b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/NativeBuffer.ts new file mode 100644 index 0000000000000000000000000000000000000000..3bf74c58fd02e0ca39d7dac8c264cfa5130de3ae --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/NativeBuffer.ts @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { pointer } from './InteropTypes' +import { int32, int64 } from '@koalaui/common' +import { InteropNativeModule } from "./InteropNativeModule" + +// stub wrapper for KInteropBuffer +// export type NativeBuffer = ArrayBuffer + +export class NativeBuffer { + public data: pointer = 0 + public length: int64 = 0 + public resourceId: int32 = 0 + public hold: pointer = 0 + public release: pointer = 0 + + constructor(data: pointer, length: int64, resourceId: int32, hold: pointer, release: pointer) { + this.data = data + this.length = length + this.resourceId = resourceId + this.hold = hold + this.release = release + } + + public readByte(index: int64): int32 { + return InteropNativeModule._ReadByte(this.data, index, BigInt(this.length)) + } + + public writeByte(index: int64, value: int32): void { + InteropNativeModule._WriteByte(this.data, index, BigInt(this.length), value) + } + + static wrap(data: pointer, length: int64, resourceId: int32, hold: pointer, release: pointer): NativeBuffer { + return new NativeBuffer(data, length, resourceId, hold, release) + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/NativeString.ts b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/NativeString.ts new file mode 100644 index 0000000000000000000000000000000000000000..3e7affc5638f3d9da1a4ccbe044c0b8482630d80 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/NativeString.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Finalizable } from "./Finalizable" +import { InteropNativeModule } from "./InteropNativeModule" +import { pointer } from "./InteropTypes" + +export class NativeString extends Finalizable { + constructor(ptr: pointer) { + super(ptr, InteropNativeModule._GetStringFinalizer()) + } + static Make(value: string): NativeString { + return new NativeString(InteropNativeModule._StringMake(value)) + } + toString(): string { + return InteropNativeModule._StdStringToString(this.ptr) + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/Platform.ts b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/Platform.ts new file mode 100644 index 0000000000000000000000000000000000000000..5ff7d072d63fccafde387c3add3b113d09e6d728 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/Platform.ts @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { int32 } from "@koalaui/common" +import { isNullPtr, nullptr, Wrapper } from "./Wrapper" +import { decodeToString } from "#common/wrappers/arrays" +import { setCallbackRegistry } from "#common/wrappers/Callback" +import { KPointer } from "./InteropTypes" + +export abstract class NativeStringBase extends Wrapper { + constructor(ptr: KPointer) { + super(ptr) + } + + protected abstract bytesLength(): int32 + protected abstract getData(data: Uint8Array): void + + toString(): string { + let length = this.bytesLength() + let data = new Uint8Array(length) + this.getData(data) + return decodeToString(data) + } + + abstract close(): void +} + +export abstract class ArrayDecoder { + abstract getArraySize(blob: KPointer): int32 + abstract disposeArray(blob: KPointer): void + abstract getArrayElement(blob: KPointer, index: int32): T + + decode(blob: KPointer): Array { + const size = this.getArraySize(blob) + const result = new Array(size) + for (let index = 0; index < size; index++) { + result[index] = this.getArrayElement(blob, index) + } + this.disposeArray(blob) + return result + } +} + + +// TODO: the semicolons after methods in these interfaces are to +// workaround ArkTS compiler parser bug +export interface CallbackRegistry { + registerCallback(callback: any, obj: any): KPointer; +} + +export interface PlatformDefinedData { + nativeString(ptr: KPointer): NativeStringBase; + nativeStringArrayDecoder(): ArrayDecoder; + callbackRegistry(): CallbackRegistry | undefined; +} + +let platformData: PlatformDefinedData|undefined = undefined + +export function providePlatformDefinedData(platformDataParam: PlatformDefinedData) { + platformData = platformDataParam + let registry = platformDataParam.callbackRegistry() + if (registry) setCallbackRegistry(registry) +} + +export function withStringResult(ptr: KPointer): string|undefined { + if (isNullPtr(ptr)) return undefined + let managedString = platformData!.nativeString(ptr) + let result = managedString?.toString() + managedString?.close() + return result +} + +export function withStringArrayResult(ptr: KPointer): Array { + if (ptr == nullptr) return new Array() + let managedStringArray = platformData!.nativeStringArrayDecoder().decode(ptr) + return managedStringArray.map((nativeString:NativeStringBase) => nativeString.toString()) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/SerializerBase.ts b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/SerializerBase.ts new file mode 100644 index 0000000000000000000000000000000000000000..7c15552b9cba79b2c326e6e3cb8103e1a523e311 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/SerializerBase.ts @@ -0,0 +1,306 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { float32, int32, int64 } from "@koalaui/common" +import { pointer, KPointer, KSerializerBuffer } from "./InteropTypes" +import { wrapCallback } from "./InteropOps" +import { InteropNativeModule } from "./InteropNativeModule" +import { ResourceHolder, ResourceId } from "../arkts/ResourceManager" +import { MaterializedBase } from "./MaterializedBase" +import { nullptr } from "./Wrapper" +import { NativeBuffer } from "./NativeBuffer" + +// imports required interfaces (now generation is disabled) +// import { Resource } from "@arkoala/arkui" +/** + * Value representing possible JS runtime object type. + * Must be synced with "enum RuntimeType" in C++. + */ +export enum RuntimeType { + UNEXPECTED = -1, + NUMBER = 1, + STRING = 2, + OBJECT = 3, + BOOLEAN = 4, + UNDEFINED = 5, + BIGINT = 6, + FUNCTION = 7, + SYMBOL = 8, + MATERIALIZED = 9, +} + +/** + * Value representing object type in serialized data. + * Must be synced with "enum Tags" in C++. + */ +export enum Tags { + UNDEFINED = 101, + INT32 = 102, + FLOAT32 = 103, + STRING = 104, + LENGTH = 105, + RESOURCE = 106, + OBJECT = 107, +} + +export function runtimeType(value: any): int32 { + let type = typeof value + if (type == "number") return RuntimeType.NUMBER + if (type == "string") return RuntimeType.STRING + if (type == "undefined") return RuntimeType.UNDEFINED + if (type == "object") return RuntimeType.OBJECT + if (type == "boolean") return RuntimeType.BOOLEAN + if (type == "bigint") return RuntimeType.BIGINT + if (type == "function") return RuntimeType.FUNCTION + if (type == "symbol") return RuntimeType.SYMBOL + + throw new Error(`bug: ${value} is ${type}`) +} + +// Poor man's instanceof, fails on subclasses +export function isInstanceOf(className: string, value: object | undefined): boolean { + return value?.constructor.name === className +} + +export function registerCallback(value: object|undefined): int32 { + return wrapCallback((args: Uint8Array, length: int32) => { + // TBD: deserialize the callback arguments and call the callback + return 42 + }) +} + +export function toPeerPtr(value: object): KPointer { + if (value.hasOwnProperty("peer")) + return unsafeCast(value).getPeer()?.ptr ?? nullptr + else + throw new Error("Value is not a MaterializedBase instance") +} + +export interface CallbackResource { + resourceId: int32 + hold: pointer + release: pointer +} + +/* Serialization extension point */ +export abstract class CustomSerializer { + constructor(protected supported: Array) {} + supports(kind: string): boolean { return this.supported.includes(kind) } + abstract serialize(serializer: SerializerBase, value: any, kind: string): void + next: CustomSerializer | undefined = undefined +} + +export class SerializerBase { + private position = 0 + private buffer: ArrayBuffer + private view: DataView + + private static customSerializers: CustomSerializer | undefined = undefined + static registerCustomSerializer(serializer: CustomSerializer) { + if (SerializerBase.customSerializers == undefined) { + SerializerBase.customSerializers = serializer + } else { + let current = SerializerBase.customSerializers + while (current.next != undefined) { current = current.next } + current.next = serializer + } + } + constructor() { + this.buffer = new ArrayBuffer(96) + this.view = new DataView(this.buffer) + } + public release() { + this.releaseResources() + this.position = 0 + } + asBuffer(): KSerializerBuffer { + return new Uint8Array(this.buffer) + } + length(): int32 { + return this.position + } + getByte(offset: int32): int32 { + return this.view.getUint8(offset) as int32 + } + toArray(): Uint8Array { + return new Uint8Array(this.buffer.slice(0, this.currentPosition())) + } + currentPosition(): int32 { return this.position } + + private checkCapacity(value: int32) { + if (value < 1) { + throw new Error(`${value} is less than 1`) + } + let buffSize = this.buffer.byteLength + if (this.position > buffSize - value) { + const minSize = this.position + value + const resizedSize = Math.max(minSize, Math.round(3 * buffSize / 2)) + let resizedBuffer = new ArrayBuffer(resizedSize) + // TODO: can we grow without new? + // TODO: check the status of ArrayBuffer.transfer function implementation in STS + new Uint8Array(resizedBuffer).set(new Uint8Array(this.buffer)) + this.buffer = resizedBuffer + this.view = new DataView(resizedBuffer) + } + } + private heldResources: ResourceId[] = [] + holdAndWriteCallback(callback: object, hold: KPointer = 0, release: KPointer = 0, call: KPointer = 0, callSync: KPointer = 0): ResourceId { + const resourceId = ResourceHolder.instance().registerAndHold(callback) + this.heldResources.push(resourceId) + this.writeInt32(resourceId) + this.writePointer(hold) + this.writePointer(release) + this.writePointer(call) + this.writePointer(callSync) + return resourceId + } + holdAndWriteCallbackForPromiseVoid(hold: KPointer = 0, release: KPointer = 0, call: KPointer = 0, callSync = 0): [Promise, ResourceId] { + let resourceId: ResourceId = 0 + const promise = new Promise((resolve, reject) => { + const callback = (err: string[]|undefined) => { + if (err !== undefined) + reject(err) + else + resolve() + } + resourceId = this.holdAndWriteCallback(callback, hold, release, call, callSync) + }) + return [promise, resourceId] + } + holdAndWriteCallbackForPromise(hold: KPointer = 0, release: KPointer = 0, call: KPointer = 0): [Promise, ResourceId] { + let resourceId: ResourceId = 0 + const promise = new Promise((resolve, reject) => { + const callback = (value: T|undefined, err: string[]|undefined) => { + if (err !== undefined) + reject(err) + else + resolve(value!) + } + resourceId = this.holdAndWriteCallback(callback, hold, release, call) + }) + return [promise, resourceId] + } + writeCallbackResource(resource: CallbackResource) { + this.writeInt32(resource.resourceId) + this.writePointer(resource.hold) + this.writePointer(resource.release) + } + holdAndWriteObject(obj:any, hold: KPointer = 0, release: KPointer = 0): ResourceId { + const resourceId = ResourceHolder.instance().registerAndHold(obj) + this.heldResources.push(resourceId) + this.writeInt32(resourceId) + this.writePointer(hold) + this.writePointer(release) + return resourceId + } + private releaseResources() { + for (const resourceId of this.heldResources) + InteropNativeModule._ReleaseCallbackResource(resourceId) + // todo think about effective array clearing/pushing + this.heldResources = [] + } + writeCustomObject(kind: string, value: any) { + let current = SerializerBase.customSerializers + while (current) { + if (current.supports(kind)) { + current.serialize(this, value, kind) + return + } + current = current.next + } + console.log(`Unsupported custom serialization for ${kind}, write undefined`) + this.writeInt8(Tags.UNDEFINED) + } + writeNumber(value: number|undefined) { + this.checkCapacity(5) + if (value == undefined) { + this.view.setInt8(this.position, Tags.UNDEFINED) + this.position++ + return + } + if (value == Math.round(value)) { + this.view.setInt8(this.position, Tags.INT32) + this.view.setInt32(this.position + 1, value, true) + this.position += 5 + return + } + this.view.setInt8(this.position, Tags.FLOAT32) + this.view.setFloat32(this.position + 1, value, true) + this.position += 5 + } + writeInt8(value: int32) { + this.checkCapacity(1) + this.view.setInt8(this.position, value) + this.position += 1 + } + writeInt32(value: int32) { + this.checkCapacity(4) + this.view.setInt32(this.position, value, true) + this.position += 4 + } + writeInt64(value: int64) { + this.checkCapacity(8) + this.view.setBigInt64(this.position, BigInt(value), true) + this.position += 8 + } + writePointer(value: pointer) { + this.checkCapacity(8) + this.view.setBigInt64(this.position, BigInt(value ?? 0), true) + this.position += 8 + } + writeFloat32(value: float32) { + this.checkCapacity(4) + this.view.setFloat32(this.position, value, true) + this.position += 4 + } + writeBoolean(value: boolean|undefined) { + this.checkCapacity(1) + this.view.setInt8(this.position, value == undefined ? RuntimeType.UNDEFINED : +value) + this.position++ + } + writeFunction(value: object | undefined) { + this.writeInt32(registerCallback(value)) + } + writeString(value: string) { + this.checkCapacity(4 + value.length * 4) // length, data + let encodedLength = + InteropNativeModule._ManagedStringWrite(value, new Uint8Array(this.view.buffer, 0), this.position + 4) + this.view.setInt32(this.position, encodedLength, true) + this.position += encodedLength + 4 + } + writeBuffer(buffer: NativeBuffer) { + this.writeCallbackResource({ + resourceId: buffer.resourceId, + hold: buffer.hold, + release: buffer.release, + }) + this.writePointer(buffer.data) + this.writeInt64(buffer.length) + } +} + +class DateSerializer extends CustomSerializer { + constructor() { + super(["Date"]) + } + + serialize(serializer: SerializerBase, value: object, kind: string): void { + serializer.writeString((value as Date).toISOString()) + } +} +SerializerBase.registerCustomSerializer(new DateSerializer()) + +export function unsafeCast(value: unknown) { + return value as unknown as T +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/Wrapper.ts b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/Wrapper.ts new file mode 100644 index 0000000000000000000000000000000000000000..47da5d393a829537ec07e306933c50da80008800 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/Wrapper.ts @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ptrToString, nullptr, isSamePtr } from "#common/wrappers/Wrapper" +import { className } from "@koalaui/common" +import { KPointer } from "./InteropTypes" + +export { isNullPtr, nullptr, ptrToBits, bitsToPtr, isSamePtr, ptrToString } from "#common/wrappers/Wrapper" + +/** + * An object holding reference to the native pointer. + */ +export class Wrapper { + ptr: KPointer + constructor(ptr: KPointer) { + if (ptr == null) + throw new Error(`Init <${className(this)}> with null native peer`) + this.ptr = ptr + } + toString(): string { + return `[native object <${className(this)}> at ${ptrToString(this.ptr)}]` + } +} + +export function getPtr(value: Wrapper|undefined): KPointer { + return value?.ptr ?? nullptr +} + +export function ptrEqual(a: Wrapper|undefined, b: Wrapper|undefined): boolean { + if (a === b) return true + if (a == undefined || b == undefined) return false + return isSamePtr(a.ptr, b.ptr) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/arrays.ts b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/arrays.ts new file mode 100644 index 0000000000000000000000000000000000000000..f85319a27d772160266c7f42790a6a3e5d2ee4c3 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/arrays.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { int32 } from "@koalaui/common" + +export enum Access { + READ = 1, // 1 << 0, + WRITE = 2, // 1 << 1, + READWRITE = 3, // READ | WRITE +} +export function isRead(access: Access) { + return access & Access.READ +} +export function isWrite(access: Access) { + return access & Access.WRITE +} + +export type Exec = (pointer: P) => R +export type ExecWithLength = (pointer: P, length: int32) => R + +export type TypedArray = + Uint8Array + | Int8Array + | Uint16Array + | Int16Array + | Uint32Array + | Int32Array + | Float32Array + | Float64Array + +export type PtrArray = Uint32Array | BigUint64Array \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/buffer.ts b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/buffer.ts new file mode 100644 index 0000000000000000000000000000000000000000..bfd04c207e0f456dcf919c1abb14c7bb22241f7d --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/buffer.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { int32 } from "@koalaui/common" + +// todo can be removed if passing ArrayBuffer type through interop is possible +export class KBuffer { + private readonly _buffer: Uint8Array + public get buffer(): ArrayBuffer { + return this._buffer + } + public get length(): int32 { + return this._buffer.length + } + + constructor(length: int32) { + this._buffer = new Uint8Array(length) + } + + set(index: int32, value: int32): void { + this._buffer[index] = value + } + + get(index: int32): int32 { + return this._buffer[index] + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/index.ts b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..44281dead889a0489c2f6e0d4e0e4ebb099bff61 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/index.ts @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + withFloat32Array, + withFloat64Array, + withInt16Array, + withInt32Array, + withInt8Array, + withUint16Array, + withUint32Array, + withUint8Array, + wasmHeap as wasmHeapArrayBuffer +} from "#common/wrappers/arrays" + +export { registerCallback, setCallbackRegistry } from "#common/wrappers/Callback" + +export { Access, Exec } from "./arrays" +export { Finalizable, NativeThunk } from "./Finalizable" +export { nullable } from "./nullable" +export { getPtr, isNullPtr, nullptr, ptrEqual, Wrapper, ptrToBits, bitsToPtr } from "./Wrapper" + +export { + decodeToString, + encodeToData, + withString, + withStringArray, + withPtrArray, + fromPtrArray, + toPtrArray +} from "#common/wrappers/arrays" + +export const withFloatArray = withFloat32Array +export const withByteArray = withUint8Array +export const withIntArray = withInt32Array + +export const wasmHeap = wasmHeapArrayBuffer + +export { + withFloat32Array, + withFloat64Array, + withInt8Array, + withInt16Array, + withInt32Array, + withUint8Array, + withUint16Array, + withUint32Array, +} + +export * from "./Platform" +export * from "./InteropTypes" + +export * from "./InteropOps" +export * from "./NativeString" +export * from "./buffer" +export * from "../arkts/ResourceManager" +export * from "./NativeBuffer" +export { InteropNativeModule, loadInteropNativeModule } from "./InteropNativeModule" +export { SerializerBase, RuntimeType, Tags, runtimeType, CallbackResource, unsafeCast, isInstanceOf, toPeerPtr } from "./SerializerBase" +export { DeserializerBase } from "./DeserializerBase" +export { loadNativeModuleLibrary, loadNativeLibrary, registerNativeModuleLibraryName } from "./loadLibraries" +export * from "./MaterializedBase" diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/java/CallbackRecord.java b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/java/CallbackRecord.java new file mode 100644 index 0000000000000000000000000000000000000000..2292705a6c5707f76e068a8e26481f12eef2fb1d --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/java/CallbackRecord.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.koalaui.interop; + +class CallbackRecord { + public CallbackType callback; + public boolean autoDisposable; + + public CallbackRecord(CallbackType callback, boolean autoDisposable) { + this.callback = callback; + this.autoDisposable = autoDisposable; + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/java/CallbackRegistry.java b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/java/CallbackRegistry.java new file mode 100644 index 0000000000000000000000000000000000000000..1a98807d9c12f23bcf4c6d1857e0fe69adc72a1f --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/java/CallbackRegistry.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.koalaui.interop; + +import java.util.Arrays; +import java.util.HashMap; + +class CallbackRegistry { + + private static HashMap callbacks = new HashMap(); + private static Integer id = 0; + + static { + CallbackRegistry.callbacks.put(id, new CallbackRecord( + new CallbackType() { + @Override + public int apply(byte[] args, int length) { + System.out.printf("Callback 0 called with args = %s and length = %d\n", Arrays.toString(args), length); + throw new Error("Null callback called"); + } + }, false) + ); + CallbackRegistry.id++; + } + + private CallbackRegistry() { + + } + + public static Integer wrap(CallbackType callback) { + Integer id = CallbackRegistry.id++; + CallbackRegistry.callbacks.put(id, new CallbackRecord(callback, true)); + return id; + } + + public static Integer wrap(CallbackType callback, boolean autoDisposable) { + Integer id = CallbackRegistry.id++; + CallbackRegistry.callbacks.put(id, new CallbackRecord(callback, autoDisposable)); + return id; + } + + public static int call(Integer id, byte[] args, int length) { + if (!CallbackRegistry.callbacks.containsKey(id)) { + System.out.printf("Callback %d is not known\n", id); + throw new Error(String.format("Disposed or unwrapped callback called (id = %d)", id)); + } + CallbackRecord record = CallbackRegistry.callbacks.get(id); + if (record.autoDisposable) { + CallbackRegistry.dispose(id); + } + return record.callback.apply(args, length); + } + + public static void dispose(Integer id) { + CallbackRegistry.callbacks.remove(id); + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/java/CallbackTests.java b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/java/CallbackTests.java new file mode 100644 index 0000000000000000000000000000000000000000..a5aa880e41f0a83157838ae2de547304a43e5699 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/java/CallbackTests.java @@ -0,0 +1,181 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.koalaui.interop; + +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.IntBuffer; +import java.util.function.Function; + +import org.koalaui.arkoala.NativeModule; + +public class CallbackTests { + // Todo: where tests will be located? + + public class TestUtils { + // Todo: where test utils will be located? + public static void assertEquals(String name, T expected, T actual) { + if (!expected.equals(actual)) { + System.out.printf("TEST %s FAIL:\n EXPECTED \"%s\"\n ACTUAL \"%s\"\n", name, expected.toString(), actual.toString()); + } else { + System.out.printf("TEST %s PASS\n", name); + } + } + + public static void assertThrows(String name, Function fn) { + boolean caught = false; + try { + fn.apply(null); + } catch (Throwable e) { + caught = true; + } + if (!caught) { + System.out.printf("TEST %s FAIL:\n No exception thrown\n", name); + } else { + System.out.printf("TEST %s PASS\n", name); + } + } + } + + public static void checkCallback() { + Integer id1 = CallbackRegistry.wrap(new CallbackType() { + @Override + public int apply(byte[] args, int length) { + return 2024; + } + }); + Integer id2 = CallbackRegistry.wrap(new CallbackType() { + @Override + public int apply(byte[] args, int length) { + return 2025; + } + }); + + TestUtils.assertEquals("Call callback 1", 2024, CallbackRegistry.call(id1, new byte[] {}, 0)); + TestUtils.assertEquals("Call callback 2", 2025, CallbackRegistry.call(id2, new byte[] {}, 0)); + TestUtils.assertThrows("Call disposed callback 1", new Function() { + @Override + public Integer apply(Void v) { + return CallbackRegistry.call(id1, new byte[] { }, 0); + } + }); + TestUtils.assertThrows("Call callback 0", new Function() { + @Override + public Integer apply(Void v) { + return CallbackRegistry.call(0, new byte[] { 2, 4, 6, 8 }, 4); + } + }); + } + + public static void checkNativeCallback() { + Integer id1 = CallbackRegistry.wrap(new CallbackType() { + @Override + public int apply(byte[] args, int length) { + return 123456; + } + }); + TestUtils.assertEquals("NativeCallback without args", 123456, NativeModule._TestCallIntNoArgs(id1)); + TestUtils.assertThrows("NativeCallback without args called again", new Function() { + @Override + public Integer apply(Void v) { + return CallbackRegistry.call(id1, new byte[] { }, 0); + } + }); + TestUtils.assertThrows("NativeCallback without args called again from native", new Function() { + @Override + public Integer apply(Void v) { + return NativeModule._TestCallIntNoArgs(id1); + } + }); + + Integer id2 = CallbackRegistry.wrap(new CallbackType() { + @Override + public int apply(byte[] args, int length) { + ByteBuffer buffer = ByteBuffer.wrap(args); + buffer.order(ByteOrder.LITTLE_ENDIAN); + IntBuffer intBuffer = buffer.asIntBuffer(); + int sum = 0; + for (int i = 0; i < length / 4; i++) { + sum += intBuffer.get(i); + } + return sum; + } + }); + int[] arr2 = new int[] { 100, 200, 300, -1000 }; + TestUtils.assertEquals("NativeCallback Int32Array sum", -400, NativeModule._TestCallIntIntArraySum(id2, arr2, arr2.length)); + + Integer id3 = CallbackRegistry.wrap(new CallbackType() { + @Override + public int apply(byte[] args, int length) { + ByteBuffer buffer = ByteBuffer.wrap(args); + buffer.order(ByteOrder.LITTLE_ENDIAN); + IntBuffer intBuffer = buffer.asIntBuffer(); + for (int i = 1; i < length / 4; i++) { + intBuffer.put(i, intBuffer.get(i) + intBuffer.get(i - 1)); + } + return 0; + } + }); + int[] arr3 = new int[] { 100, 200, 300, -1000 }; + NativeModule._TestCallVoidIntArrayPrefixSum(id3, arr3, arr3.length); + TestUtils.assertEquals("NativeCallback Int32Array PrefixSum [0]", 100, arr3[0]); + TestUtils.assertEquals("NativeCallback Int32Array PrefixSum [1]", 300, arr3[1]); + TestUtils.assertEquals("NativeCallback Int32Array PrefixSum [2]", 600, arr3[2]); + TestUtils.assertEquals("NativeCallback Int32Array PrefixSum [3]", -400, arr3[3]); + + long start = System.currentTimeMillis(); + Integer id4 = CallbackRegistry.wrap(new CallbackType() { + @Override + public int apply(byte[] args, int length) { + ByteBuffer buffer = ByteBuffer.wrap(args); + buffer.order(ByteOrder.LITTLE_ENDIAN); + IntBuffer intBuffer = buffer.asIntBuffer(); + intBuffer.put(1, intBuffer.get(1) + 1); + if (intBuffer.get(0) + intBuffer.get(1) < intBuffer.get(2)) { + return NativeModule._TestCallIntRecursiveCallback(id3 + 1, args, args.length); + } + return 1; + } + }, false); + TestUtils.assertEquals("NativeCallback prepare recursive callback test", id4, id3 + 1); + int depth = 500; + int count = 100; + for (int i = 0; i < count; i++) { + int length = 12; + byte[] args = new byte[length]; + IntBuffer args32 = ByteBuffer.wrap(args).order(ByteOrder.LITTLE_ENDIAN).asIntBuffer(); + args32.put(2, depth); + NativeModule._TestCallIntRecursiveCallback(id4, args, args.length); + if (i == 0) { + TestUtils.assertEquals("NativeCallback Recursive [0]", (depth + 1) / 2, args32.get(0)); + TestUtils.assertEquals("NativeCallback Recursive [1]", depth / 2, args32.get(1)); + } + } + long passed = System.currentTimeMillis() - start; + System.out.println("recursive native callback: " + String.valueOf(passed) + "ms for " + depth * count + " callbacks, " + Math.round((double)passed / (depth * count) * 1000000) + "ms per 1M callbacks"); + + Integer id5 = CallbackRegistry.wrap(new CallbackType() { + @Override + public int apply(byte[] args, int length) { + int sum = 0; + for (int i = 0; i < length; i++) { + sum += args[i]; + } + return sum; + } + }, false); + NativeModule._TestCallIntMemory(id5, 1000); + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/java/CallbackType.java b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/java/CallbackType.java new file mode 100644 index 0000000000000000000000000000000000000000..952cd3d399a7fddc441ca5bef9d755ee3231a24b --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/java/CallbackType.java @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.koalaui.interop; + +public interface CallbackType { + public int apply(byte[] args, int length); +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/loadLibraries.ts b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/loadLibraries.ts new file mode 100644 index 0000000000000000000000000000000000000000..84a5068d32e054aae87bb02bddae20fe117975cb --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/loadLibraries.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const nativeModuleLibraries: Map = new Map() + +export function loadNativeLibrary(name: string): Record { + if ((globalThis as any).requireNapi) + return (globalThis as any).requireNapi(name, true) + else { + let suffixedName = name.endsWith(".node") ? name : `${name}.node` + try { suffixedName = eval(`require.resolve("${suffixedName}")`) } catch (_) {} + return eval(`let exports = {}; process.dlopen({ exports }, "${suffixedName}", 2); exports`) + } +} + +export function registerNativeModuleLibraryName(nativeModule: string, libraryName: string) { + nativeModuleLibraries.set(nativeModule, libraryName) +} + +export function loadNativeModuleLibrary(moduleName: string, module?: object) { + if (!module) + throw new Error(" argument is required and optional only for compatibility with ArkTS") + const library = loadNativeLibrary(nativeModuleLibraries.get(moduleName) ?? moduleName) + if (!library || !library[moduleName]) { + console.error(`Failed to load library for module ${moduleName}`) + return + } + Object.assign(module, library[moduleName]) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/nullable.ts b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/nullable.ts new file mode 100644 index 0000000000000000000000000000000000000000..1a1875e25662eecfade68bb221dccad907d45e36 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/interop/nullable.ts @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { isNullPtr } from "./Wrapper" +import { KPointer } from "./InteropTypes" + +export function nullable(value: KPointer, body: (arg: KPointer) => T | undefined): T | undefined { + if (isNullPtr(value)) { + return undefined + } else { + return body(value) + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/napi/wrappers/Callback.ts b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/napi/wrappers/Callback.ts new file mode 100644 index 0000000000000000000000000000000000000000..5af4ae26bf1ad7d2f0e3d71003d08e9aac3a5077 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/napi/wrappers/Callback.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { KPointer } from "../../interop/InteropTypes" +import { CallbackRegistry } from "../../interop/Platform" + +export function registerCallback(callback: any, obj: any = null): KPointer { + return theRegistry!.registerCallback(callback, obj) +} + +let theRegistry: CallbackRegistry|undefined = undefined + +export function setCallbackRegistry(registry: CallbackRegistry) { + theRegistry = registry +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/napi/wrappers/Wrapper.ts b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/napi/wrappers/Wrapper.ts new file mode 100644 index 0000000000000000000000000000000000000000..87fae78665863b017f80ea0801ed190b26b8b253 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/napi/wrappers/Wrapper.ts @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { int32 } from "@koalaui/common" +import { KPointer } from "../../interop/InteropTypes" + +export const nullptr = BigInt(0) + +export function isNullPtr(value: KPointer): boolean { + return value === nullptr +} + +export function ptrToString(ptr: KPointer) { + return `0x${ptr!.toString(16).padStart(8, "0")}` +} + +export function isSamePtr(a: KPointer, b: KPointer) { + return (a === b) +} + +// TODO rethink me +export function ptrToBits(ptr: KPointer): Uint32Array | null { + let result = new Uint32Array(2) + let ptrBigInt = ptr as bigint + result[0] = Number(ptrBigInt & BigInt(0xFFFFFFFF)) + result[1] = Number((ptrBigInt >> BigInt(32)) & BigInt(0xFFFFFFFF)) + return result +} + +export function bitsToPtr(array: Int32Array, offset: int32): KPointer { + let ptrBigInt: bigint = BigInt(array[offset + 1]) & BigInt(0xFFFFFFFF) + ptrBigInt = (ptrBigInt << BigInt(32)) | (BigInt(array[offset]) & BigInt(0xFFFFFFFF)) + return ptrBigInt +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/napi/wrappers/arrays.ts b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/napi/wrappers/arrays.ts new file mode 100644 index 0000000000000000000000000000000000000000..6995a51540b50bdf403bdb3d2a3f0c296254f458 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/napi/wrappers/arrays.ts @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { CustomTextDecoder, CustomTextEncoder } from "@koalaui/common" +import { Access, Exec, ExecWithLength, PtrArray, TypedArray } from "../../interop/arrays" +import { nullptr } from "./Wrapper" +import { Wrapper } from "../../interop/Wrapper" +import { KPointer, KStringArrayPtr } from "../../interop" + +const encoder = new CustomTextEncoder() +const decoder = new CustomTextDecoder() + +export function decodeToString(array: Uint8Array): string { + return decoder.decode(array) +} + +export function encodeToData(string: string): Uint8Array { + return encoder.encode(string, false) +} + +export function withString(data: string | undefined, exec: Exec): R { + return exec(data === undefined ? null : data) +} + +export function withStringArray(strings: Array | undefined, exec: Exec): R { + if (strings === undefined || strings.length === 0) { + return exec(null) + } + + let array = encoder.encodeArray(strings) + return exec(array) +} + +function withArray( + data: C | undefined, + exec: ExecWithLength +): R { + return exec(data ?? null, data?.length ?? 0) +} + +export function withPtrArray(data: BigUint64Array, access: Access, exec: ExecWithLength) { + return exec(data ?? null, data?.length ?? 0) // TODO rethink +} + +export function toPtrArray(data: Array | undefined): BigUint64Array { + if (data == undefined || data.length === 0) { + return new BigUint64Array(0) + } + const array = new BigUint64Array(data.length) + for (let i = 0; i < data.length; i++) { + let item = data[i] + array[i] = item != undefined ? item.ptr as bigint : nullptr + } + return array +} + +export function fromPtrArray(array: PtrArray, factory: (ptr: KPointer) => T) : Array { + if (array.length === 0) { + return new Array(0) + } + const result = new Array(array.length) + for (let i = 0; i < array.length; i++) { + let ptr = array[i] + if (ptr == nullptr) { + result[i] = undefined + } else { + result[i] = factory(ptr) + } + } + return result +} + +export function withUint8Array(data: Uint8Array | undefined, access: Access, exec: ExecWithLength) { + return withArray(data, exec) +} +export function withInt8Array(data: Int8Array | undefined, access: Access, exec: ExecWithLength) { + return withArray(data, exec) +} +export function withUint16Array(data: Uint16Array | undefined, access: Access, exec: ExecWithLength) { + return withArray(data, exec) +} +export function withInt16Array(data: Int16Array | undefined, access: Access, exec: ExecWithLength) { + return withArray(data, exec) +} +export function withUint32Array(data: Uint32Array | undefined, access: Access, exec: ExecWithLength) { + return withArray(data, exec) +} +export function withInt32Array(data: Int32Array | undefined, access: Access, exec: ExecWithLength) { + return withArray(data, exec) +} +export function withFloat32Array(data: Float32Array | undefined, access: Access, exec: ExecWithLength) { + return withArray(data, exec) +} +export function withFloat64Array(data: Float64Array | undefined, access: Access, exec: ExecWithLength) { + return withArray(data, exec) +} +export function wasmHeap(): ArrayBuffer { + throw new Error("Unused") +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/wasm/wrappers/Callback.ts b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/wasm/wrappers/Callback.ts new file mode 100644 index 0000000000000000000000000000000000000000..abc939bcaf4f8548a8eca0ee7e35fd7389a203a0 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/wasm/wrappers/Callback.ts @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { KPointer } from "../../interop/InteropTypes" +import { CallbackRegistry } from "../../interop/Platform" + +class CallbackInfo { + cb: any + recv: any + constructor(callback: any, obj: any = null) { + this.cb = callback + this.recv = obj + } +} + +const GLOBAL_SCOPE = new class CallbackScope { + static readonly CB_NULL = new CallbackInfo( + () => { throw new Error("attempted to call a callback at NULL") }, + null + ) + static readonly CB_UNDEFINED = new CallbackInfo( + () => { throw new Error("attempted to call an uninitialized callback") }, + null + ) + static readonly CB_NULL_ID = 0 + nextId: number + callbackMap: Map | null + + constructor() { + this.nextId = 1 + this.callbackMap = new Map() + this.callbackMap.set(CallbackScope.CB_NULL_ID, CallbackScope.CB_NULL) + } + + addCallback(cb: any, obj: any): number { + let id = this.nextId++ + this.callbackMap?.set(id, new CallbackInfo(cb, obj)) + return id + } + + getCallback(id: number): CallbackInfo { + return this.callbackMap?.get(id) || CallbackScope.CB_UNDEFINED + } + + deleteCallback(id: number): void { + if (id > CallbackScope.CB_NULL_ID) { + this.callbackMap?.delete(id) + } + } + + release(): void { + this.callbackMap = null + } +} + +function callCallback(callbackId: number): any { + let CallbackInfo = GLOBAL_SCOPE.getCallback(callbackId) + try { + let cb = CallbackInfo.cb + if (CallbackInfo.recv !== null) { + cb = cb.bind(CallbackInfo.recv) + } + return cb() + } catch (e) { + console.error(e) + } +} + +export function registerCallback(callback: any, obj: any = null): KPointer { + return GLOBAL_SCOPE.addCallback(callback, obj) +} + +function releaseCallback(callbackId: number): void { + return GLOBAL_SCOPE.deleteCallback(callbackId) +} + +declare namespace globalThis { + function callCallback(callbackId: number): any + function releaseCallback(callbackId: number): any +} + +globalThis.callCallback = callCallback +globalThis.releaseCallback = releaseCallback + +export function setCallbackRegistry(_ignoredRegistry: CallbackRegistry) { + // On WASM we don't need registry in current implementation. +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/wasm/wrappers/Wrapper.ts b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/wasm/wrappers/Wrapper.ts new file mode 100644 index 0000000000000000000000000000000000000000..8c0dc94f636766eeaad9573cfc07308e230ebd05 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/wasm/wrappers/Wrapper.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { int32 } from "@koalaui/common" +import { KPointer } from "../../interop/InteropTypes" + +export const nullptr: number = 0 + +export function isNullPtr(value: KPointer): boolean { + return (value == nullptr) +} + +export function ptrToString(ptr: KPointer) { + if (ptr === 0) return "0x0" + + const hex = (ptr as number).toString(16).padStart(8, "0") + return `0x${hex}` +} + +export function isSamePtr(a: KPointer, b: KPointer) { + return a === b +} + +export function ptrToBits(ptr: KPointer): Uint32Array { + let result = new Uint32Array(2) + result[0] = ptr as int32 + return result +} + +export function bitsToPtr(array: Int32Array, offset: int32): KPointer { + return array[offset] +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/wasm/wrappers/arrays.ts b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/wasm/wrappers/arrays.ts new file mode 100644 index 0000000000000000000000000000000000000000..cbb1f1e16ba312567b7c4bd7b905375bcb5f9cfa --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/src/wasm/wrappers/arrays.ts @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { CustomTextEncoder, CustomTextDecoder, int32 } from "@koalaui/common" + +import { KPointer } from "../../interop/InteropTypes" +import { Wrapper } from "../../interop/Wrapper" +import { Access, isRead, isWrite, Exec, TypedArray, ExecWithLength } from "../../interop/arrays" + +const encoder = new CustomTextEncoder() +const decoder = new CustomTextDecoder() + +export function decodeToString(array: Uint8Array): string { + return decoder.decode(array) +} + +export function encodeToData(string: string): Uint8Array { + return encoder.encode(string, false) +} + +type Heap = { readonly buffer: ArrayBuffer } + +// TODO actually memory allocation primitives are defined for a specific intance instance, +// refactor me +declare const _heaps: { + HEAP8(): Heap; + HEAP16(): Heap; + HEAP32(): Heap; + HEAPU8(): Heap; + HEAPU16(): Heap; + HEAPU32(): Heap; + HEAPF32(): Heap; + HEAPF64(): Heap; +} +declare function _malloc(size: number): number; +declare function _free(ptr: number): void; + +const nullptr: number = 0 + +// with string as array of utf8 data headed by length +export function withString(data: string | undefined, exec: Exec): R { + if (data === undefined) return exec(nullptr) + + let array = encoder.encode(data, true) + return withUint8Array(array, Access.READ, exec) +} + +export function withStringArray(strings: Array | undefined, exec: Exec): R { + if (strings === undefined || strings.length === 0) { + return exec(nullptr) + } + + let array = encoder.encodeArray(strings) + return withUint8Array(array, Access.READ, exec) +} + +function withArray( + data: C | undefined, + access: Access, + exec: ExecWithLength, + bytesPerElement: int32, + ctor: (ptr: number, length: number) => C +): R { + if (data === undefined || data.length === 0) { + return exec(nullptr, 0) + } + + let ptr = _malloc(data.length * bytesPerElement) + let wasmArray = ctor(ptr, data.length) + + if (isRead(access)) { + wasmArray.set(data) + } + + let result = exec(ptr, data.length) + + if (isWrite(access)) { + data.set(wasmArray) + } + + _free(ptr) + + return result +} + +export function withPtrArray(data: Uint32Array, access: Access, exec: ExecWithLength) { + return withArray(data as Uint32Array, access, exec, Uint32Array.BYTES_PER_ELEMENT, (ptr: number, length: number) => { + return new Uint32Array(_heaps.HEAPU8().buffer, ptr, length) + }) +} + +export function toPtrArray(data: Array | undefined): Uint32Array { + if (data === undefined || data.length === 0) { + return new Uint32Array(0) + } + const array = new Uint32Array(data.length) + for (let i = 0; i < data.length; i++) { + array[i] = data[i]?.ptr as number + } + return array +} + +export function fromPtrArray(array: Uint32Array, factory: (ptr: KPointer) => T) : Array { + const result = new Array(array.length) + for (let i = 0; i < array.length; i++) { + let v = array[i] + if (v == 0) { + result[i] = undefined + } else { + result[i] = factory(v) + } + } + return result +} + +export function withUint8Array(data: Uint8Array | undefined, access: Access, exec: ExecWithLength) { + return withArray(data, access, exec, Uint8Array.BYTES_PER_ELEMENT, (ptr: number, length: number) => { + return new Uint8Array(_heaps.HEAPU8().buffer, ptr, length) + }) +} +export function withInt8Array(data: Int8Array | undefined, access: Access, exec: ExecWithLength) { + return withArray(data, access, exec, Int8Array.BYTES_PER_ELEMENT, (ptr: number, length: number) => { + return new Int8Array(_heaps.HEAPU8().buffer, ptr, length) + }) +} +export function withUint16Array(data: Uint16Array | undefined, access: Access, exec: ExecWithLength) { + return withArray(data, access, exec, Uint16Array.BYTES_PER_ELEMENT, (ptr: number, length: number) => { + return new Uint16Array(_heaps.HEAPU8().buffer, ptr, length) + }) +} +export function withInt16Array(data: Int16Array | undefined, access: Access, exec: ExecWithLength) { + return withArray(data, access, exec, Int16Array.BYTES_PER_ELEMENT, (ptr: number, length: number) => { + return new Int16Array(_heaps.HEAPU8().buffer, ptr, length) + }) +} +export function withUint32Array(data: Uint32Array | undefined, access: Access, exec: ExecWithLength) { + return withArray(data, access, exec, Uint32Array.BYTES_PER_ELEMENT, (ptr: number, length: number) => { + return new Uint32Array(_heaps.HEAPU8().buffer, ptr, length) + }) +} +export function withInt32Array(data: Int32Array | undefined, access: Access, exec: ExecWithLength) { + return withArray(data, access, exec, Int32Array.BYTES_PER_ELEMENT, (ptr: number, length: number) => { + return new Int32Array(_heaps.HEAPU8().buffer, ptr, length) + }) +} +export function withFloat32Array(data: Float32Array | undefined, access: Access, exec: ExecWithLength) { + return withArray(data, access, exec, Float32Array.BYTES_PER_ELEMENT, (ptr: number, length: number) => { + return new Float32Array(_heaps.HEAPU8().buffer, ptr, length) + }) +} +export function withFloat64Array(data: Float64Array | undefined, access: Access, exec: ExecWithLength) { + return withArray(data, access, exec, Float64Array.BYTES_PER_ELEMENT, (ptr: number, length: number) => { + return new Float64Array(_heaps.HEAPU8().buffer, ptr, length) + }) +} + +export function wasmHeap(): ArrayBuffer { + return _heaps.HEAP32().buffer +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/interop/tsconfig.json b/frameworks/bridge/arkts_frontend/koala_mirror/interop/tsconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..20defe21ff0088065b1bfe0c4da0ec6ee5372591 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/interop/tsconfig.json @@ -0,0 +1,31 @@ +{ + "compilerOptions": { + "target": "es2017", + "lib": ["ESNext", "ESNext.WeakRef"], + "moduleResolution": "node", + "composite": true, + "incremental": true, + "declarationMap": true, + "sourceMap": true, + "declaration": true, + "noEmitOnError": true, + "strict": true, + "skipLibCheck": true, + "removeComments": false, + "outDir": "build/lib", + "module": "CommonJS", // TODO maybe migrate to ESM? + "rootDirs": ["src"], + "baseUrl": ".", + "types": ["node"], + "paths": { + "@koalaui/common": ["../incremental/common/src"], + "#common/wrappers/*": ["./src/napi/wrappers/*", "./src/wasm/wrappers/*"] + } + }, + "include": ["src/interop/**/*", "src/napi/**/*", "src/wasm/**/*", "src/arkts/ResourceManager.ts"], + "references": [ + { "path": "../incremental/compiler-plugin" }, + { "path": "../incremental/compat" }, + { "path": "../incremental/common" } + ] +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/package.json b/frameworks/bridge/arkts_frontend/koala_mirror/package.json new file mode 100644 index 0000000000000000000000000000000000000000..efdeda636cd45a057c5ff5c66cba7ca4f2451849 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/package.json @@ -0,0 +1,23 @@ +{ + "name": "root", + "private": true, + "//": "DO NOT ADD dependencies or devDependencies clauses to this level! Keep subfolders autonomous.", + "scripts": { + "prepare": "cd incremental && npm i && cd .. && cd interop && npm i && cd .. && cd arkoala-arkts && npm i && cd .. && cd ui2abc && npm i", + "compile": "npm run compile --prefix incremental && npm run compile --prefix interop", + "release": "npm run compile && node tools/release.mjs", + "ohos-sdk": "npm run ohos-sdk --prefix arkoala-arkts/arkui-common", + "ohos-sdk:full": "node ./tools/ohos-tools/ohos-sdk/cli.mjs download", + "ohos-sdk:prebuilt": "node tools/ohos-tools/ohos-sdk/cli.mjs prebuilt:download", + "ohos-sdk:patch": "npm run ohos-sdk:prebuilt && node tools/ohos-tools/ohos-sdk/oh-sdk-patch.mjs", + "ets:plugin:compile": "npm run compile --prefix arkoala-arkts/ets-plugin", + "compiler:plugin:compile": "npm run compile --prefix incremental/compiler-plugin", + "plugins:compile": "npm run compiler:plugin:compile && npm run ets:plugin:compile", + "plugins:patch": "npm run compile:patch --prefix arkoala/tools/arkoala-transformer", + "arkoala:plugin": "npm run plugins:compile && npm run plugins:patch", + "arkoala:har": "npm run all --prefix arkoala/har", + "arkoala:har-arm64": "npm run arkoala:har", + "arkoala:har-arm32": "npm run all-arm32 --prefix arkoala/har", + "arkoala:har-universal": "npm run all-universal --prefix arkoala/har" + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/annotate/.gitignore b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/annotate/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..7951405f85a569efbacc12fccfee529ef1866602 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/annotate/.gitignore @@ -0,0 +1 @@ +lib \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/annotate/package.json b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/annotate/package.json new file mode 100644 index 0000000000000000000000000000000000000000..30085730de9b3db5f38f4a8604a154948ca4cc62 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/annotate/package.json @@ -0,0 +1,18 @@ +{ + "name": "@koalaui/annotate", + "version": "1.5.13+devel", + "description": "", + "main": "lib/annotate.js", + "bin": "lib/annotate.js", + "scripts": { + "clean": "rimraf out lib", + "compile": "npx tsc -p ." + }, + "keywords": [], + "dependencies": { + "minimatch": "10.0.1" + }, + "devDependencies": { + "rimraf": "^6.0.1" + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/annotate/src/annotate.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/annotate/src/annotate.ts new file mode 100644 index 0000000000000000000000000000000000000000..88d2258de67d31b81b25cacd1cf25a382ca2d5c3 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/annotate/src/annotate.ts @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as fs from 'fs' +import * as path from 'path' +import { minimatch } from 'minimatch' + +class Config { + inputDir: string = "./src" + outputDir: string = "./ets" + include: string[] = [ "./src/**/*" ] + exclude: string[] = [] + fileExtension?: string +} + +const memoImport = "@koalaui/runtime/annotations" + +export function main(options: Config) { + console.log(options) + + const readdirSyncRecursive: (dir: string) => string[] = (dir: string) => + fs.readdirSync(dir).reduce((files: string[], file: string) => { + const name = path.join(dir, file) + return fs.lstatSync(name).isDirectory() ? [...files, ...readdirSyncRecursive(name)] : [...files, name] + }, []) + + + const files = readdirSyncRecursive(options.inputDir) + .map(it => path.relative(options.inputDir, it)) + + fs.mkdirSync(options.outputDir, { recursive: true }) + + const include = options.include.map(it => path.resolve(it)) + const exclude = options.exclude.map(it => path.resolve(it)) + + files.forEach(it => { + const inputFile = path.join(options.inputDir, it) + let outputFile = path.join(options.outputDir, it) + if (options.fileExtension) { + let { dir, name, ext } = path.parse(outputFile) + if (ext) { + outputFile = path.join(dir, name + options.fileExtension) + } + } + if (include.some(value => minimatch(path.resolve(inputFile), value)) + && !exclude.some(value => minimatch(path.resolve(inputFile), value)) + ) { + const text = fs.readFileSync(inputFile, 'utf8').toString() + const newText = convertMemo(text, memoImport) + if (fs.existsSync(outputFile)) { + // This is not to update already annotated files + if (newText == fs.readFileSync(outputFile, 'utf8').toString()) { + return + } + } + console.log(inputFile, " -> ", outputFile) + fs.mkdirSync(path.dirname(outputFile), { recursive: true }) + fs.writeFileSync(outputFile, newText, 'utf8') + } + }) +} + +function convertMemo(text: string, memoImport: string): string { + const result = text + .replaceAll(/\/\*\* @memo \*\//g, "@memo") + .replaceAll(/\/\*\* @memo:intrinsic \*\//g, "@memo_intrinsic") + .replaceAll(/\/\*\* @memo:stable \*\//g, "@memo_stable") + .replaceAll(/\/\*\* @memo:entry \*\//g, "@memo_entry") + .replaceAll(/\/\*\* @skip:memo \*\//g, "@memo_skip") + if (result == text) { + return result + } + return `import { memo, memo_intrinsic, memo_entry, memo_stable, memo_skip } from "${memoImport}"\n` + result +} + +if (process.argv.length == 3) { + const configPath = path.resolve(process.argv[2]) + const config = JSON.parse(fs.readFileSync(configPath, 'utf8')) + main({ ...(new Config()), ...config }) +} else { + main(new Config()) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/annotate/test/test.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/annotate/test/test.ts new file mode 100644 index 0000000000000000000000000000000000000000..abe6d446c15c03b5d0f7782c6e6eb7f241a29b82 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/annotate/test/test.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** @memo */ diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/annotate/tsconfig.json b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/annotate/tsconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..3de03062e66b16503a1ca8639501e3de5ecae3da --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/annotate/tsconfig.json @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + "target": "esnext", + "lib": ["esnext"], + "module": "CommonJS", + "moduleResolution": "node", + "sourceMap": true, + "noEmitOnError": true, + "strict": true, + "removeComments": false, + "outDir": "lib", + "rootDir": "src" + }, + "include": ["./src"] +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/docs/UI2ABC_WORKS.md b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/docs/UI2ABC_WORKS.md new file mode 100644 index 0000000000000000000000000000000000000000..dec6f5cba01a53b3c11617d2bd175425729bf1d2 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/docs/UI2ABC_WORKS.md @@ -0,0 +1,70 @@ +At least the following implementation steps are needed + +## General plugin API infrastructure + +### Large bodies of code + +We need to ensure we can pass through at least: + * incremental/runtime (v) + * arkoala-arkts/arkui/src/* -- the handwritten part of arkoala (v) + * arkoala-arkts/arkui-common/src/* -- the handwritten part of arkoala ( ) + * arkoala-arkts/arkui/src/generated/* -- the generated component classes (v) + * arkoala-arkts/arkui/src/sts/* -- the generated facades ( ) + +### Perfomance and memory approaches + + * keep node overproduction under control + * declaration cache (PR) + * update logics + * have fast-arktsc working with all three plugins (v) + * Compile against the d.ts surface of arkoala + +### The three plugin stack is capable of running in multi-file, multi-import scenario + + * In parallel work with the compiler people to ensure the proper scheme with "recheck" is moving (in progress: "rebind" + "recheck" works in small amount of cases, inserting imports in bound/checked stage plugin is non trivial) + * work on ui2abc and fast-arktsc tools to hide implementation details from users (v) + * The plugin configuration is per-module (v) + +## Memo plugin works + + * Ensure we can compile incremental runtime (as a large body of memo code) with and after memo rewrite (v) + * Ensure we can compile arkoala (in progress) + * Ensure the incremental runtime harness can run tests for ui2abc (v) + * Ensure we can run test on incremental runtime compiled by ui2abc ( ) + * Have the diagnostics issued where needed. ( ) + * First to console ( ) + * Then, after compiler issue is implemented thtrough the C API ( ) + * Functional completeness ( ) + +## UI plugin works + + * Ensure the ets-harness is capable of running tests for ui2abc ( ) + * Transfer ets-plugin functionality to ui-plugin, covering by executable tests in parallel in ets-harness ( ) + * directed by user + +## IDLize works + +### arkgen + + * Gnereare proper ETS facades with proper interfaces in proper packages ( ) + * Have the generator emit d.ts surfaces of arkoala layers + * Adapt enums, non-component interfaces, etc to be properly named and not expose users unneeded implementation details ( ) + * This is an iterative work in small steps ensuring runnability on every step. + +### arktsgen + + * keep maintaining the plugin author needs (v) + * keep following the @panda/sdk release cycle (v) + * work with DevOps to ensure the regular builds are really going (v) + +## User code and intergration work + + * Transition from the small demo working on prototype arkui.ts to correctly work through arkoala implementations ( ) + * Bring the user app to the desired shape + * This is an iterative work in small steps ensuring runnability on every step. (x) + * trivial can startup on the host + * trivial can run on a device/previewer + * trvial is running fine + * shopping can startup + * shopping is running fine + diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/fast-arktsc/.gitignore b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/fast-arktsc/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..7951405f85a569efbacc12fccfee529ef1866602 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/fast-arktsc/.gitignore @@ -0,0 +1 @@ +lib \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/fast-arktsc/package.json b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/fast-arktsc/package.json new file mode 100644 index 0000000000000000000000000000000000000000..c875a6006f3f3d2cc9daf1015432129c232e3273 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/fast-arktsc/package.json @@ -0,0 +1,24 @@ +{ + "name": "@koalaui/fast-arktsc", + "version": "1.5.15+devel", + "description": "", + "main": "lib/index.js", + "bin": "lib/index.js", + "scripts": { + "clean": "rimraf out lib", + "compile": "WEBPACK_NO_MINIMIZE=true webpack --config webpack.config.node.js" + }, + "keywords": [], + "dependencies": { + "commander": "^10.0.0", + "minimatch": "10.0.1" + }, + "devDependencies": { + "@types/node": "^18.0.0", + "typescript": "^4.9.5", + "webpack": "5.95.0", + "copy-webpack-plugin": "12.0.2", + "webpack-cli": "5.1.4", + "rimraf": "^6.0.1" + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/fast-arktsc/src/main.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/fast-arktsc/src/main.ts new file mode 100644 index 0000000000000000000000000000000000000000..b829db498e61adbded6f0ec5fcb0ffc0990dc4a6 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/fast-arktsc/src/main.ts @@ -0,0 +1,215 @@ +#!/usr/bin/env node + +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { program } from "commander" +import * as fs from "fs" +import * as path from "path" +import * as child_process from "child_process" +import { minimatch } from 'minimatch' +import { resolveConfig, section, log, relativeOrDot, getConfigFullDirname } from "./resolve-config" + +const readdirSyncRecursive: (dir: string) => string[] = (dir: string) => + fs.readdirSync(dir).reduce((files: string[], file: string) => { + const name = path.join(dir, file) + return fs.lstatSync(name).isDirectory() ? [...files, ...readdirSyncRecursive(name)] : [...files, name] + }, []) + +export const options = program + .option('--config ', 'Path to configuration file') + .option('--compiler ', 'Path to compiler') + .option('--link-name ', 'Path to final linked file', "all") + + .option('--file-option', 'When provided pass the source as --file rather than a free option') + .option('--restart-stages', 'Compilation with plugins and compiler restarting') + + .option('--output-dir ', 'Path to output dir (only used by AOT compilation)') + .option('--aot-libs ', 'Comma-separated AOT libraries to include') + .option('--only-aot ', 'AOT an .abc taking --aot-libs into account') + .option('--aot-target ', 'Compilation target for AOT') + + .parse() + .opts() + +if (options.onlyAot) + mainAot(path.resolve(options.onlyAot)) +else + main(options.config, options.linkName) + + + +function findMatching(base: string, include: string[], exclude: string[]): string[] { + return readdirSyncRecursive(base) + .map(it => path.resolve(it)) + .filter(it => include.some(value => minimatch(it, path.join(base, value), {matchBase: true}))) + .filter(it => !exclude.some(value => minimatch(it, path.join(base, value), {matchBase: true}))) +} + +function produceNinjafile( + compiler: string, + files: string[], + config: string, + linkPath: string, + baseUrl: string, + intermediateOutDirs: string[], +): string { + // We have no Panda SDK for macOS. + const tools_prefix = process.platform == "darwin" ? "echo " : "" + let result: string[] = [] + let all: string[][] = [] + let basename = path.basename(compiler) + let linker = compiler.replace(basename, 'arklink') + const stages = intermediateOutDirs.length + + for (var i = 0; i < stages; i++) { + all.push([]) + } + + let compilerPrefix = [...Array(stages).keys()].map((i) => ` +rule arkts_compiler_stage${i} + command = ${tools_prefix}${compiler} --ets-module --arktsconfig ${path.resolve(config)} ${options.fileOption ? "--file" : ""} $in --output $out ${options.restartStages ? `--restart-stages` : ``} ${stages > 1 ? `--stage ${i}` : ``} + description = "Compiling ARKTS ${stages > 1 ? `(stage ${i})` : ``} $in" +`).join('') + + let linker_prefix = ` +rule arkts_linker + command = ${tools_prefix}${linker} --output $out -- $in + description = "Linking ARKTS $out" +` + + files.forEach(it => { + for (var i = 0; i < stages; i++) { + let output = path.resolve(intermediateOutDirs[i], relativeOrDot(baseUrl, it)) + if (i + 1 == stages) { + output = `${path.dirname(output)}/${path.basename(output, path.extname(output))}.abc` + } + result.push( +` +build ${output}: arkts_compiler_stage${i} ${it} ${i > 0 ? `|| stage${i - 1}` : ``} +` + ) + all[i].push(output) + } + }) + + for (var i = 0; i < stages; i++) { + result.push(`build stage${i}: phony ${i > 0 ? `stage${i - 1} ` : ``}${all[i].join(' ')}\n`) + } + + result.push(`build ${linkPath}: arkts_linker ${all[stages - 1].join(' ')}\n`) + result.push(`build link: phony ${linkPath}\n`) + result.push(`build all: phony link\n`) + result.push("default all\n") + return compilerPrefix + linker_prefix + '\n' + result.join('') +} + +function main(configPath: string, linkName: string) { + const config = JSON.parse(fs.readFileSync(configPath, 'utf8')) + const baseDir = path.resolve(path.dirname(configPath)) + const include = (config.include as string[]).map(it => it.replace('\\.', '.')) + const exclude = config.exclude ? (config.exclude as string[]).map(it => it.replace('\\.', '.')) : [] + const outDir = path.resolve(getConfigFullDirname(), config.compilerOptions?.outDir ?? ".") + const baseUrl = path.resolve(getConfigFullDirname(), config.compilerOptions?.baseUrl ?? ".") + + fs.mkdirSync(outDir, { recursive: true }) + const [firstConfigPath, intermediateOutDirs] = resolveConfig(configPath, options.restartStages) + section() + const linkPath = path.resolve(process.cwd(), linkName) + log(`computed location of linked .abc: ${linkPath}`) + + const files = findMatching(baseDir, include, exclude) + if (files.length == 0) { + throw new Error(`No files matching include "${include.join(",")}" exclude "${exclude.join(",")}"`) + } + + let ninja = produceNinjafile(path.resolve(options.compiler), files, firstConfigPath, linkPath, baseUrl, intermediateOutDirs) + fs.writeFileSync(`${outDir}/build.ninja`, ninja) +} + + + +function archDir(): string { + const arch = process.arch + let sdkArch = ""; + switch (arch) { + case "x64": + sdkArch = "" + break + case "arm64": + sdkArch = "arm64" + break + default: throw new Error(`Unexpected arch: ${arch}`) + + } + const platform = process.platform + let sdkPlatform = "" + switch (platform) { + case "linux": sdkPlatform = "linux" + break + case "win32": sdkPlatform = "windows" + break + case "darwin": sdkPlatform = "macos" + break + default: throw new Error(`Unsupported platform ${platform}`) + } + const suffix = "host_tools" + return [sdkPlatform, sdkArch, suffix].filter(it => it != "").join("_") +} + +function mainAot(abc: string) { + let sdk = options.sdk ?? path.resolve(path.join(__dirname, '..', '..', 'panda', 'node_modules', '@panda', 'sdk')) + let aot = path.join(sdk, archDir(), 'bin', 'ark_aot') + let stdlib = path.resolve(path.join(sdk, "ets", "etsstdlib.abc")) + const aotLibs = abc.indexOf("etsstdlib") == -1 ? [stdlib] : [] + if (options.aotLibs) aotLibs.push(... options.aotLibs.split(",")) + let args: string[] = [] + if (process.platform == "darwin") { + // No tools on macOS, just echo + args.push(aot) + aot = "echo" + } + let dir = options.outputDir ?? path.dirname(abc) + let result = path.join(dir, path.basename(abc).replace('.abc', '.an')) + args.push(... options.aotTarget ? [`--compiler-cross-arch=${options.aotTarget}`] : []) + args.push(... [ + `--load-runtimes=ets`, + `--boot-panda-files=${aotLibs.map(it => path.resolve(it)).concat(abc).join(':')}`, + `--paoc-panda-files=${abc}`, + `--paoc-output=${result}` + ]) + console.log(`AOT compile ${abc} to ${result}...`) + console.log(`Launch ${aot} ${args.join(" ")}`) + const child = child_process.spawn(aot, args) + child.stdout.on('data', (data) => { + process.stdout.write(data); + }) + child.stderr.on('data', (data) => { + process.stderr.write(data); + }) + child.on('close', (code) => { + if (code != 0) + console.log(`Command ${aot} ${args.join(" ")} failed with return code ${code}`) + else + console.log(`Produced AOT file ${result}: ${Math.round(fs.statSync(result).size / 1024 / 1024)}M`) + process.exit(code!) + }) + child.on('exit', (code, signal) => { + if (signal) { + console.log(`Received signal: ${signal} from '${aot} ${args.join(' ')}'`) + process.exit(1) + } + }) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/fast-arktsc/src/resolve-config.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/fast-arktsc/src/resolve-config.ts new file mode 100644 index 0000000000000000000000000000000000000000..9a2620e0e48836a45fda8e0cb38dc265e9f8b187 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/fast-arktsc/src/resolve-config.ts @@ -0,0 +1,207 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as fs from "node:fs" +import * as path from "node:path" +import { options } from "./main" + +export const SPLITTER = "=".repeat(80) +export const BANNER = "[fast-arktsc]" +export const PLUGIN_DEPENDENCIES = "dependencies" +export const PLUGIN_NAME = "name" +export const LAST_STAGE = "_proceed_to_binary" + +export function relativeOrDot(from: string, to: string) { + const result = path.relative(from, to) + if (result == "") { + return "." + } + return result +} + +export function log(text: string) { + console.log(`${BANNER} ${text}`) +} + +export function error(text: string, exitCode: number = 1): never { + console.log(`${BANNER} ${text}`) + process.exit(exitCode) +} + +export function section() { + log(SPLITTER) +} + +export function getConfigFullPath() { + return path.resolve(process.cwd(), options.config) +} + +export function getConfigFullDirname() { + return path.dirname(getConfigFullPath()) +} + +function filterPathSectionToMap(from: string, name: string, object: any): Map { + return new Map( + Object.entries(object).map(([k, v]: [string, unknown]) => { + if (typeof v == "string") { + return [k, path.resolve(from, v)] + } + if (Array.isArray(v)) { + return [k, path.resolve(from, v[0])] + } + error(`unexpected value of ${name}.${k}: ${v}`) + }) + ) +} + +function getDependencyConfigs(from: string, dependencies: Map): Map { + return new Map( + Array.from(dependencies).map(([k, v]: [string, string]) => { + const location = path.resolve(from, v) + if (!fs.existsSync(location) || !fs.statSync(location).isFile()) { + error(`no config found at ${location} (for package ${k})`) + } + return [k, JSON.parse(fs.readFileSync(location, 'utf-8'))] + }) + ) +} + +function resolvePath(name: string, dependency?: string, config?: any) { + const plugins = config?.compilerOptions?.plugins + if (!plugins || !dependency) { + return undefined + } + const pluginsArray = Array.from(plugins) as any[] + for (var i = 0; i < pluginsArray.length; i++) { + if (`${pluginsArray[i].name}-${pluginsArray[i].stage}` == name) { + if (i == 0) { + return undefined + } + return path.resolve(path.dirname(dependency), config.compilerOptions.outDir ?? ".", `${pluginsArray[i - 1].name}-${pluginsArray[i - 1].stage}` ) + } + } + if (name == LAST_STAGE) { + return path.resolve(path.dirname(dependency), config.compilerOptions.outDir ?? ".", `${pluginsArray[pluginsArray.length - 1].name}-${pluginsArray[pluginsArray.length - 1].stage}` ) + } + return undefined +} + +function resolvePaths(name: string, paths: Map, dependencies: Map, dependencyConfigs: Map) { + return new Map( + Array.from(paths).map(([k, v]: [string, string]) => { + return [k, resolvePath(name, dependencies.get(k), dependencyConfigs.get(k)) ?? v] + }) + ) +} + +/** + * Checks that compilation with the given ui2abcconfig is possible and creates temporary arktsconfigs + * + * @param configPath path to ui2abc configuration file + * @returns path to first es2panda configuration file and intermediate build directories + */ +export function resolveConfig(configPath: string, restartStages: boolean): [string, string[]] { + section() + + const config = JSON.parse(fs.readFileSync(configPath, 'utf8')) + const compilerOptions = config.compilerOptions ?? { } + const configDirname = getConfigFullDirname() + const baseUrl = path.resolve(getConfigFullDirname(), compilerOptions?.baseUrl ?? ".") + const outDir = path.resolve(getConfigFullDirname(), compilerOptions?.outDir ?? ".") + const packageRoot = path.resolve(configDirname, baseUrl) + const paths = filterPathSectionToMap(packageRoot, "paths", compilerOptions.paths ?? { }) + const pluginNames = (compilerOptions.plugins ?? []).map((plugin: any) => `${plugin.name}-${plugin.stage}`) + const dependencies = filterPathSectionToMap(configDirname, PLUGIN_DEPENDENCIES, config[PLUGIN_DEPENDENCIES] ?? { }) + const dependencyConfigs = getDependencyConfigs(configDirname, dependencies) + + const stages = restartStages ? pluginNames.length + 1 : 1 // the last stage is a binary generation + log(`stages: ${stages}`) + + const computedPlugins = Array.from(compilerOptions.plugins ?? []).map((it: any, i) => { + if (!it.transform) { + error(`no transform specified for plugin ${i}`) + } + if (it.transform.startsWith(`.`)) { + return { + ...it, + transform: path.join(relativeOrDot(outDir, getConfigFullDirname()), it.transform), + } + } + return it + }) + + const outDirs = [] + + for (var i = 0; i < stages; i++) { + const name = i == pluginNames.length ? LAST_STAGE : pluginNames[i] + log(` stage #${i + 1}: ${name}`) + const resolvedPaths = resolvePaths(name, paths, dependencies, dependencyConfigs) + log(` paths:`) + for (const [k, v] of resolvedPaths) { + const res = relativeOrDot(packageRoot, v) + log(` ${k}: ${k.endsWith('*') && !res.endsWith('*') ? `${res}/*` : res}`) + } + + for (const [k, v] of resolvedPaths) { + if ((k.startsWith('@') || k.startsWith('#')) && !v.endsWith('*') && !fs.existsSync(path.join(v, "index.ts")) && !fs.existsSync(path.join(v, "index.ets"))) { + error(`File ${v}/index.[ts|ets] does not exists`) + } + } + + const newBaseUrl = i == 0 ? relativeOrDot(outDir, baseUrl) : `./${pluginNames[i - 1]}` + const pathsInConfig = Array.from(resolvedPaths).map(([k, v]) => { + if (!path.relative(baseUrl, v).startsWith('..')) { + const res = relativeOrDot(path.resolve(baseUrl), v) + return [k, [k.endsWith('*') && !res.endsWith('*') ? `${res}/*` : res]] + } + const res = relativeOrDot(path.resolve(outDir ?? `.`, newBaseUrl), v) + return [k, [k.endsWith('*') && !res.endsWith('*') ? `${res}/*` : res]] + }) + + const arktsconfig = { + compilerOptions: { + package: compilerOptions.package ?? `.`, + outDir: `.`, + baseUrl: newBaseUrl, + paths: Object.fromEntries(pathsInConfig), + plugins: i == 0 ? computedPlugins : [] // es2panda.js will only use check plugins from the first config + }, + include: config.include ? Array.from(config.include as string[]).map((it) => { + return path.join(path.relative(outDir ?? `.`, configDirname), it) + }) : [] + } + + if (config.exclude) { // compiler might crash is exclude section is [] + (arktsconfig as any).exclude = config.exclude ? Array.from(config.exclude as string[]).map((it) => { + return path.join(path.relative(outDir, configDirname), it) + }) : [] + } + + const emitPath = path.resolve(outDir ?? `.`, `arktsconfig-${name}.json`) + log(` config emitted to ${emitPath}`) + fs.mkdirSync(path.dirname(emitPath), { recursive: true }) + fs.writeFileSync(emitPath, JSON.stringify(arktsconfig, null, 2)) + + const intermediateOutDir = path.resolve(getConfigFullDirname(), outDir ?? `.`, name == LAST_STAGE ? `.` : name) + fs.mkdirSync(intermediateOutDir, { recursive: true }) + outDirs.push(intermediateOutDir) + } + + return [ + path.resolve(getConfigFullDirname(), outDir ?? `.`, `arktsconfig-${pluginNames.length == 0 ? LAST_STAGE : pluginNames[0]}.json`), + outDirs + ] +} + diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/fast-arktsc/tsconfig.json b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/fast-arktsc/tsconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..398f0fd91eae6b8d66b1e3612a78cb11ffd18a25 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/fast-arktsc/tsconfig.json @@ -0,0 +1,13 @@ +{ + "compilerOptions": { + "target": "es2017", + "module": "CommonJS", + "moduleResolution": "node", + "sourceMap": true, + "noEmitOnError": true, + "strict": true, + "removeComments": false, + "outDir": "lib", + "rootDir": "src" + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/fast-arktsc/webpack.config.node.js b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/fast-arktsc/webpack.config.node.js new file mode 100644 index 0000000000000000000000000000000000000000..7b21707cadacde9c62394e8ba637e89ca8f239cc --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/fast-arktsc/webpack.config.node.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const path = require("path") +var webpack = require("webpack"); + +const minimize = !process.env.WEBPACK_NO_MINIMIZE + +/** @returns {import("webpack").WebpackOptionsNormalized} */ +const makeConfig = ({ os, arch, tsconfig }) => ({ + target: "node", + entry: `./src/main.ts`, + output: { + filename: `index.js`, + path: path.resolve(__dirname, `lib`), + libraryTarget: "commonjs2", + }, + resolve: { + extensions: [".ts", ".node", "..."] + }, + plugins: [ + new webpack.BannerPlugin({ banner: "#!/usr/bin/env node", raw: true }) + ], + module: { + rules: [ + { + test: /\.ts$/, + loader: "ts-loader", + }, + ] + }, + + mode: minimize ? "production" : "development", + devtool: minimize ? false : "inline-source-map" +}) + +module.exports = env => { + const oses = { + 'win32': 'windows', + 'darwin': 'macos', + } + + const os = env.os || oses[process.platform] || process.platform + const arch = (env.arch || process.arch) + + const tsconfig = env.tsconfig || "" + + return makeConfig({os, arch, tsconfig}) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/.mocharc.json b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/.mocharc.json new file mode 100644 index 0000000000000000000000000000000000000000..62699a6cd93955182895f22cca7ca55823ac97d6 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/.mocharc.json @@ -0,0 +1,11 @@ +{ + "ui": "tdd", + "spec": "./test/arkts-api/**/*.test.ts", + "extension": [ + "ts" + ], + "require": [ + "../../incremental/test-utils/scripts/register" + ], + "timeout": 10000 +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/README.md b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/README.md new file mode 100644 index 0000000000000000000000000000000000000000..a6d77389ce1c9606785ec440b93ea6cd884bb4f2 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/README.md @@ -0,0 +1,36 @@ +## libarkts + +Wrapper library which provides tsc-like __ArkTS__ compiler API + +Implemented with koala interop technology + +### Prerequisites + +node >= 18 +meson >= 0.62 + +Having following .npmrc: https://gitee.com/openharmony-sig/arkcompiler_ets_frontend/wikis/npmrc + +``` +cd ~/arkcompiler_ets_frontend +npm i +cd ./ui2abc/libarkts/ +npm i +npm run compile +``` + +### Structure + +- ```compatible``` - __ArkTS__ / __typescript__ plugins +- ```input``` - code samples to be compiled with __ArkTS__ / __typescript__ +- ```native``` - node module wrapper for __es2panda.so__ +- ```src``` - plugin API sources +- ```test``` - plugin API tests + +### How to run +``` +npm run run +node build/api/es2panda.js --help +``` + +Runs __ArkTS__ compiler for __./input/main.sts__ invoking plugins specified in __arktsconfig.json__ diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/arktsconfig-direct.json b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/arktsconfig-direct.json new file mode 100644 index 0000000000000000000000000000000000000000..82bb4866ab97f6862237b51459264076bfd012fe --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/arktsconfig-direct.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "outDir": "./build/abc", + "baseUrl": ".", + "paths": { + "@koalaui/compat": [ "../../incremental/compat/src/arkts" ], + "#platform": [ "../../incremental/compat/src/arkts" ], + "@koalaui/common": [ "../../incremental/common/src" ], + "@koalaui/runtime": [ "../../incremental/runtime/ets" ], + "@koalaui/runtime/annotations": [ "../../incremental/runtime/annotations" ] + }, + "plugins": [ + { + "transform": "../memo-plugin", + "stage": "checked", + "name": "memo", + "manuallyDisableInsertingImport": true + } + ] + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/arktsconfig-memo.json b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/arktsconfig-memo.json new file mode 100644 index 0000000000000000000000000000000000000000..1bea2b105ca8f33deaf6fe75cd3dd0f0f1bc6bed --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/arktsconfig-memo.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "package0": "@koalaui/example", + "outDir": "./build/abc", + "baseUrl": ".", + "paths": { + "@koalaui/compat": [ "../../incremental/compat/src/arkts" ], + "#platform": [ "../../incremental/compat/src/arkts" ], + "@koalaui/common": [ "../../incremental/common/src" ], + "@koalaui/runtime": [ "../../incremental/runtime/ets" ], + "@koalaui/runtime/annotations": [ "../../incremental/runtime/annotations" ] + }, + "plugins": [ + { + "transform": "@koalaui/memo-plugin", + "stage": "checked", + "name": "memo" + } + ] + }, + "dependencies": { + "@koalaui/runtime": [ "../../incremental/runtime/ui2abcconfig.json" ] + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/arktsconfig.json b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/arktsconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..d1b9486cd97e0ff5ca8a7d536c37d7e84028cd5d --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/arktsconfig.json @@ -0,0 +1,43 @@ +{ + "compilerOptions": { + "package0": "@koalaui/example", + "outDir": "./build/abc", + "baseUrl": ".", + "paths": { + "@ohos.arkui": ["../../arkoala-arkts/arkui/src/ets-stubs"], + "@koalaui/compat": [ "../../incremental/compat/src/arkts" ], + "#platform": [ "../../incremental/compat/src/arkts" ], + "@koalaui/common": [ "../../incremental/common/src" ], + "@koalaui/interop": [ "../../interop/src/arkts" ], + "@koalaui/runtime": [ "../../incremental/runtime/ets" ], + "@koalaui/runtime/annotations": [ "../../incremental/runtime/annotations" ] + }, + "plugins": [ + { + "transform": "./lib/plugins/printer-plugin.js", + "stage": "parsed", + "name": "printer" + }, + { + "transform": "@koalaui/ui-plugins/parsed-stage-plugin", + "stage": "parsed", + "name": "ui" + }, + { + "transform": "@koalaui/ui-plugins/checked-stage-plugin", + "stage": "checked", + "name": "ui" + }, + { + "transform": "@koalaui/memo-plugin", + "stage": "checked", + "name": "memo" + } + ] + }, + "dependencies": { + "@koalaui/runtime": [ "../../incremental/runtime/ui2abcconfig.json" ], + "@ohos.arkui": ["../../arkoala-arkts/arkui/ui2abcconfig-pure-ets.json"] + }, + "include": ["./plugins/input/main.ets", "./plugins/input/library.ets"] +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/doc/IMPLEMENTATION_PATH.md b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/doc/IMPLEMENTATION_PATH.md new file mode 100644 index 0000000000000000000000000000000000000000..f3bebcac6392301d039544283c6af490f49da603 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/doc/IMPLEMENTATION_PATH.md @@ -0,0 +1,100 @@ +# Implementation steps for es2panda plugins + +## IDL based bindings generation + +* Negotiate and obtain structured IDL within @panda/sdk + * track IDL shape evolution + +* Have a (may be partial) generator of: + * bridge.cc, + * Es2PandaNativeModule.ts + * types.ts + * enums.ts + * C API debug printer stubs + ... + +* Have an infrastructure of regeneration into $SIG/ui2abc/libarkts on @panda/sdk updates + + +## Plugin invocations + +* Provide infrastructure to be able to invoke plugins at AFTER PARSER and AFTER CHECKER points + * Ensure we can go from PARSER to CHECKED + * Ensure we can go from CHECKED to BIN_GENERATED + * Ensure the annotations are preserved at the CHECKED phase + * Ensure we can go to BIN_GENERATED + * Ensure the abc produced are linkable and working within applications (trivial, shopping etc) + +## Compilation pipeline intergration + +* Integrate es2panda.ts into compilation pipeline instead of es2panda + * Teach arktsc script to be able to call es2panda call es2panda.ts interchangengly + * Ensure the jsdoc to annotations propagate correctly ( /** @memo */ becomes @memo where needed ) + +* Integrate es2panda.ts as the preprocessor before ets-tsc + * Ensure it can print out @annotations. + * Handle ETSGLOBAL transformation, so that it doesn't apply multiple times + +* Encapsulate all the preprocessors behind a single facade on the basis of arktsc script + * The assumed path of transition can be something like + * ets+memo+es2panda + * ets+memo+es2panda.ts + * es2panda.ts+ets+memo+es2panda.ts + * es2panda.ts + + * Provide controls to switch between configurations + +## C API completeness + +* Ensure binder interface is complete + * *there is API for "find declaration" for all the needed kinds of nodes (functions, methods, properties, types, variables etc) + * "find declaration" consistently works throught imports and exports +* The missing AstNodes are handled by requests +* The missing node methods are handled by requests + + +## Plugin migration + +### tsc partial switch off + +* Provide options for partial switch off of parts of memo and ets plugins +* Provide + +### Step by step MEMO plugin migration + +The memo plugin transition is easier because it is working in es2panda which is already the last in the pipeline + +* Provide @memo *call* rewrite in es2panda plugin + * Enchance the managed API where needed + * Adapt the relevant pieces of koala-transformer for es2panda + * Ensure the transformed abc is linkable against the @koalaui/runtime and @memo declarations + * demo-playground/ works against tsc-compiled runtime/ + * Reconcile jsdoc /** @memo */ vs @memo annotation + * Ensure the plugin is working in the general compilation pipeline + +* Provide the rest of the memo plugin with ad-hoc sequence of steps + * incremental runtime source code is transformable + * demo-playground/ works with es2panda transformed runtime + * test suite test cases work + +### Step by step ETS plugin migration + +The ets plugin transition is trickier because it is working in the beginnig of the pipeline + +* Have a prototype of the small plugin working at the PARSED stage + * struct to "class extends ArkStructBase" + * creation of Options interfaces + * "import { StructBase } from the support library + * Provide the StructBase version good for pure ArkTS + +* Have a prototype of plugin working on CHECKED stage + * Have ets hello world struct compiled + * Have it running on host and on devices + * Provide ets-tsc subsitute in the pipeline + +* Advance the plugin to the level of shopping/ application + * Advance runtime library where needed + * Move to complete language features use as originally designed + +* Advance the plugin to the level of photos/ application + diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/generator/options.json5 b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/generator/options.json5 new file mode 100644 index 0000000000000000000000000000000000000000..4e642e4d2213071ac146ecedab76154a272d4368 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/generator/options.json5 @@ -0,0 +1,239 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "irHack": [ + "AnnotationUsage", + "ETSFunctionType", + "ETSUnionType", + "ETSNullType", + "ETSUndefinedType", + ], + "ignore": { + "full": [ + "es2panda_Impl", + "es2panda_Config", + "es2panda_ExternalSource", + ], + "partial": [ + { + interface: "MethodDefinition", + methods: [ + "GetOverloadInfo", // return type is wrong + ] + }, + { + interface: "AnnotationDeclaration", + methods: [ + "PropertiesPtrConst" // interfaces create-to-param matching + ] + }, + { + interface: "NumberLiteral", + methods: [ + "SetInt", + "SetLong", + "SetDouble", + "SetFloat" + ] + }, + { + interface: "AnnotationUsage", + methods: [ + "PropertiesPtrConst" // interfaces create-to-param matching + ] + }, + { + interface: "TSInterfaceBody", + methods: [ + "BodyPtr" // interfaces create-to-param matching + ] + }, + { + interface: "Signature", + methods: [ + "ProtectionFlagConst" // u8 + ] + }, + { + interface: "ETSReExportDeclaration", + methods: [ + "Create", // sequence + "Update", // sequence + "GetUserPathsConst" // sequence + ] + }, + { + interface: "CharLiteral", + methods: [ + "Create1", // KShort, + "Update1", // KShort + "CharConst", // KShort + ] + }, + { + interface: "ForUpdateStatement", + methods: [ + "Update" // forbidden naming + ] + }, + { + interface: "CallExpression", + methods: [ + "Update" // differs from handwritten + ] + }, + { + interface: "TryStatement", + methods: [ + "AddFinalizerInsertion" // idl missing const + ] + }, + { + interface: "MemberExpression", + methods: [ + "SetExtensionAccessorType" // ETSFunction type ambiguity + ] + }, + ] + }, + nonNullable: [ + { + name: "ScriptFunction", + methods: [ + { + name: "SetIdent", + types: ["id"] + } + ] + }, + { + name: "ArrowFunctionExpression", + methods: [ + { + name: "FunctionConst", + types: ["returnType"] + } + ] + }, + { + name : "FunctionDeclaration", + methods: [ + { + name: "FunctionConst", + types: ["returnType"] + } + ] + }, + { + name: "CallExpression", + methods: [ + { + name: "CalleeConst", + types: ["returnType"] + } + ] + }, + { + name : "ExpressionStatement", + methods: [ + { + name: "GetExpressionConst", + types: ["returnType"] + } + ] + }, + { + name: "IfStatement", + methods: [ + { + name: "TestConst", + types: ["returnType"] + }, + { + name: "ConsequentConst", + types: ["returnType"] + } + ] + }, + { + name: "MemberExpression", + methods: [ + { + name: "ObjectConst", + types: ["returnType"] + }, + { + name: "PropertyConst", + types: ["returnType"] + } + ] + }, + { + name: "ETSParameterExpression", + methods: [ + { + name: "IdentConst", + types: ["returnType"] + } + ] + }, + { + name: "VariableDeclarator", + methods: [ + { + name: "IdConst", + types: ["returnType"] + } + ] + }, + { + name: "ClassElement", + methods: [ + { + name: "IdConst", + types: ["returnType"] + } + ] + }, + { + name: "MethodDefinition", + methods: [ + { + name: "FunctionConst", + types: ["returnType"] + }, + ] + }, + { + name: "ETSFunctionType", + methods: [ + { + name: "ReturnTypeConst", + types: ["returnType"] + } + ] + }, + { + name: "TSTypeAliasDeclaration", + methods: [ + { + name: "TypeAnnotationConst", + types: ["returnType"] + } + ] + }, + ], +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/native/meson.build b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/native/meson.build new file mode 100644 index 0000000000000000000000000000000000000000..6da74630c9a4266945e818fcc152e89dbc54d0e0 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/native/meson.build @@ -0,0 +1,62 @@ +project( + 'es2panda_interop', + 'cpp', + version: '1.0', + default_options: [ + 'cpp_std=c++17', + 'buildtype=debug', + ], +) + +sources = [ + './src/common.cc', + './src/bridges.cc', + './src/generated/bridges.cc', + get_option('interop_src_dir') / 'common-interop.cc', + get_option('interop_src_dir') / 'callback-resource.cc', + get_option('interop_src_dir') / 'interop-logging.cc', + get_option('interop_src_dir') / 'napi/convertors-napi.cc', +] + +cflags = [ + '-DKOALA_INTEROP_MODULE=NativeModule', + '-DINTEROP_LIBRARY_NAME=' + get_option('lib_name'), + '-DKOALA_USE_NODE_VM', + '-DKOALA_NAPI', +] + +if (target_machine.system() == 'windows') + cflags += ['-DKOALA_WINDOWS'] + if (meson.get_compiler('cpp').get_id() == 'msvc') + # apply node.exe symbol loading hook + sources += [ + get_option('interop_src_dir') / 'napi/win-dynamic-node.cc' + ] + endif +else + cflags += ['-DKOALA_LINUX'] +endif + +shared_library( + get_option('lib_name'), + sources, + override_options: [ + 'b_lundef=false', + ], + install: true, + name_prefix: '', + name_suffix: 'node', + include_directories: [ + './src/', + get_option('panda_sdk_dir') / 'ohos_arm64/include/tools/es2panda/public', + get_option('panda_sdk_dir') / 'ohos_arm64/include/tools/es2panda', + get_option('interop_src_dir'), + get_option('interop_src_dir') / 'types', + get_option('interop_src_dir') / 'napi', + get_option('node_modules_dir') / 'node-api-headers/include', + get_option('node_modules_dir') / 'node-addon-api', + ], + cpp_args: cflags, + link_args: [], + dependencies: [] +) diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/native/meson_options.txt b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/native/meson_options.txt new file mode 100644 index 0000000000000000000000000000000000000000..994cd4ce26073f8f3a5d2bfc352bceb6a4cee1e1 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/native/meson_options.txt @@ -0,0 +1,24 @@ +option( + 'node_modules_dir', + type : 'string', + value : '../../node_modules/', + description : 'path to node_modules' +) +option( + 'interop_src_dir', + type : 'string', + value : '../../../interop/src/cpp/', + description : 'path to koala interop cpp files' +) +option( + 'panda_sdk_dir', + type : 'string', + value : '../../../incremental/tools/panda/node_modules/@panda/sdk/', + description : 'path to panda sdk' +) +option( + 'lib_name', + type : 'string', + value : 'es2panda', + description : 'name of shared library' +) diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/native/src/bridges.cc b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/native/src/bridges.cc new file mode 100644 index 0000000000000000000000000000000000000000..375d31b2e8381e5f93e8e0e86ee41d70e879aee6 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/native/src/bridges.cc @@ -0,0 +1,333 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "common.h" + +KNativePointer impl_AstNodeRecheck(KNativePointer contextPtr, KNativePointer nodePtr) +{ + auto context = reinterpret_cast(contextPtr); + auto node = reinterpret_cast(nodePtr); + GetImpl()->AstNodeRecheck(context, node); + return nullptr; +} +KOALA_INTEROP_2(AstNodeRecheck, KNativePointer, KNativePointer, KNativePointer) + +KNativePointer impl_AstNodeRebind(KNativePointer contextPtr, KNativePointer nodePtr) +{ + auto context = reinterpret_cast(contextPtr); + auto node = reinterpret_cast(nodePtr); + GetImpl()->AstNodeRebind(context, node); + return nullptr; +} +KOALA_INTEROP_2(AstNodeRebind, KNativePointer, KNativePointer, KNativePointer) + +KNativePointer impl_AnnotationAllowedAnnotations(KNativePointer contextPtr, KNativePointer nodePtr, KNativePointer returnLen) +{ + auto context = reinterpret_cast(contextPtr); + auto node = reinterpret_cast(nodePtr); + std::size_t params_len = 0; + auto annotations = GetImpl()->AnnotationAllowedAnnotations(context, node, ¶ms_len); + return new std::vector(annotations, annotations + params_len); +} +KOALA_INTEROP_3(AnnotationAllowedAnnotations, KNativePointer, KNativePointer, KNativePointer, KNativePointer) + +KNativePointer impl_AnnotationAllowedAnnotationsConst(KNativePointer contextPtr, KNativePointer nodePtr, KNativePointer returnLen) +{ + auto context = reinterpret_cast(contextPtr); + auto node = reinterpret_cast(nodePtr); + std::size_t params_len = 0; + auto annotations = GetImpl()->AnnotationAllowedAnnotationsConst(context, node, ¶ms_len); + return new std::vector(annotations, annotations + params_len); +} +KOALA_INTEROP_3(AnnotationAllowedAnnotationsConst, KNativePointer, KNativePointer, KNativePointer, KNativePointer) + +/* +KNativePointer impl_AstNodeVariableConst(KNativePointer contextPtr, KNativePointer nodePtr) +{ + auto context = reinterpret_cast(contextPtr); + auto node = reinterpret_cast(nodePtr); + + return GetImpl()->AstNodeVariableConst(context, node); +} +KOALA_INTEROP_2(AstNodeVariableConst, KNativePointer, KNativePointer, KNativePointer) +*/ + +KNativePointer impl_VariableDeclaration(KNativePointer contextPtr, KNativePointer variablePtr) +{ + auto context = reinterpret_cast(contextPtr); + auto variable = reinterpret_cast(variablePtr); + + return GetImpl()->VariableDeclaration(context, variable); +} +KOALA_INTEROP_2(VariableDeclaration, KNativePointer, KNativePointer, KNativePointer) + +KNativePointer impl_DeclNode(KNativePointer contextPtr, KNativePointer declPtr) +{ + auto context = reinterpret_cast(contextPtr); + auto decl = reinterpret_cast(declPtr); + + return GetImpl()->DeclNode(context, decl); +} +KOALA_INTEROP_2(DeclNode, KNativePointer, KNativePointer, KNativePointer) + +/* +KNativePointer impl_AstNodeScopeConst(KNativePointer contextPtr, KNativePointer nodePtr) +{ + auto context = reinterpret_cast(contextPtr); + auto node = reinterpret_cast(nodePtr); + return GetImpl()->AstNodeScopeConst(context, node); +} +KOALA_INTEROP_2(AstNodeScopeConst, KNativePointer, KNativePointer, KNativePointer) +*/ +KNativePointer impl_ScopeSetParent(KNativePointer contextPtr, KNativePointer nodePtr, KNativePointer parentPtr) +{ + auto context = reinterpret_cast(contextPtr); + auto node = reinterpret_cast(nodePtr); + auto parent = reinterpret_cast(parentPtr); + GetImpl()->ScopeSetParent(context, node, parent); + return node; +} +KOALA_INTEROP_3(ScopeSetParent, KNativePointer, KNativePointer, KNativePointer, KNativePointer) + +/* +KNativePointer impl_CreateNumberLiteral(KNativePointer contextPtr, KDouble value) +{ + auto context = reinterpret_cast(contextPtr); + + return GetImpl()->CreateNumberLiteral(context, value); +} +KOALA_INTEROP_2(CreateNumberLiteral, KNativePointer, KNativePointer, KDouble) +*/ + +KNativePointer impl_ETSParserCreateExpression(KNativePointer contextPtr, KStringPtr& sourceCodePtr, KInt flagsT) +{ + auto context = reinterpret_cast(contextPtr); + auto flags = static_cast(flagsT); + + return GetImpl()->ETSParserCreateExpression(context, getStringCopy(sourceCodePtr), flags); +} +KOALA_INTEROP_3(ETSParserCreateExpression, KNativePointer, KNativePointer, KStringPtr, KInt) + +KBoolean impl_IsProgram(KNativePointer contextPtr, KNativePointer nodePtr) +{ + auto context = reinterpret_cast(contextPtr); + auto node = reinterpret_cast(nodePtr); + return GetImpl()->AstNodeIsProgramConst(context, node); +} +KOALA_INTEROP_2(IsProgram, KBoolean, KNativePointer, KNativePointer) + +KBoolean impl_IsBlockStatement(KNativePointer nodePtr) +{ + auto node = reinterpret_cast(nodePtr); + return GetImpl()->IsBlockStatement(node); +} +KOALA_INTEROP_1(IsBlockStatement, KBoolean, KNativePointer) + +KNativePointer impl_ProceedToState(KNativePointer contextPtr, KInt state) +{ + auto context = reinterpret_cast(contextPtr); + return GetImpl()->ProceedToState(context, intToState(state)); +} +KOALA_INTEROP_2(ProceedToState, KNativePointer, KNativePointer, KInt) + +KNativePointer impl_ContextProgram(KNativePointer contextPtr) +{ + auto context = reinterpret_cast(contextPtr); + return GetImpl()->ContextProgram(context); +} +KOALA_INTEROP_1(ContextProgram, KNativePointer, KNativePointer) + +KNativePointer impl_ProgramAst(KNativePointer contextPtr, KNativePointer programPtr) +{ + auto context = reinterpret_cast(programPtr); + auto program = reinterpret_cast(programPtr); + return GetImpl()->ProgramAst(context, program); +} +KOALA_INTEROP_2(ProgramAst, KNativePointer, KNativePointer, KNativePointer) + +KBoolean impl_IsIdentifier(KNativePointer nodePtr) +{ + auto node = reinterpret_cast(nodePtr); + return GetImpl()->IsIdentifier(node); +} +KOALA_INTEROP_1(IsIdentifier, KBoolean, KNativePointer) + +KNativePointer impl_CreateContextFromString(KNativePointer configPtr, KStringPtr& sourcePtr, KStringPtr& filenamePtr) +{ + auto config = reinterpret_cast(configPtr); + return GetImpl()->CreateContextFromString(config, sourcePtr.data(), filenamePtr.data()); +} +KOALA_INTEROP_3(CreateContextFromString, KNativePointer, KNativePointer, KStringPtr, KStringPtr) + +KNativePointer impl_CreateContextFromFile(KNativePointer configPtr, KStringPtr& filenamePtr) +{ + auto config = reinterpret_cast(configPtr); + return GetImpl()->CreateContextFromFile(config, getStringCopy(filenamePtr)); +} +KOALA_INTEROP_2(CreateContextFromFile, KNativePointer, KNativePointer, KStringPtr) + +KInt impl_ContextState(KNativePointer contextPtr) +{ + auto context = reinterpret_cast(contextPtr); + + return static_cast(GetImpl()->ContextState(context)); +} +KOALA_INTEROP_1(ContextState, KInt, KNativePointer) + +KNativePointer impl_ContextErrorMessage(KNativePointer contextPtr) +{ + auto context = reinterpret_cast(contextPtr); + + return new string(GetImpl()->ContextErrorMessage(context)); +} +KOALA_INTEROP_1(ContextErrorMessage, KNativePointer, KNativePointer) + +/* +KNativePointer impl_CallExpressionSignature(KNativePointer context, KNativePointer classInstance) +{ + const auto _context = reinterpret_cast(context); + const auto _classInstance = reinterpret_cast(classInstance); + const auto result = GetImpl()->CallExpressionSignature(_context, _classInstance); + return result; +} +KOALA_INTEROP_2(CallExpressionSignature, KNativePointer, KNativePointer, KNativePointer) +*/ +KNativePointer impl_SignatureFunction(KNativePointer context, KNativePointer classInstance) +{ + const auto _context = reinterpret_cast(context); + const auto _classInstance = reinterpret_cast(classInstance); + const auto result = GetImpl()->SignatureFunction(_context, _classInstance); + return result; +} +KOALA_INTEROP_2(SignatureFunction, KNativePointer, KNativePointer, KNativePointer) + +KNativePointer impl_DeclarationFromIdentifier(KNativePointer context, KNativePointer identifier) +{ + const auto _context = reinterpret_cast(context); + const auto _identifier = reinterpret_cast(identifier); + const auto result = GetImpl()->DeclarationFromIdentifier(_context, _identifier); + return result; +} +KOALA_INTEROP_2(DeclarationFromIdentifier, KNativePointer, KNativePointer, KNativePointer) + +static KNativePointer impl_ProgramExternalSources(KNativePointer contextPtr, KNativePointer instancePtr) +{ + auto context = reinterpret_cast(contextPtr); + auto&& instance = reinterpret_cast(instancePtr); + std::size_t source_len = 0; + auto external_sources = GetImpl()->ProgramExternalSources(context, instance, &source_len); + return new std::vector(external_sources, external_sources + source_len); +} +KOALA_INTEROP_2(ProgramExternalSources, KNativePointer, KNativePointer, KNativePointer); + +static KNativePointer impl_ExternalSourceName(KNativePointer instance) +{ + auto&& _instance_ = reinterpret_cast(instance); + auto&& _result_ = GetImpl()->ExternalSourceName(_instance_); + return new std::string(_result_); +} +KOALA_INTEROP_1(ExternalSourceName, KNativePointer, KNativePointer); + +static KNativePointer impl_ExternalSourcePrograms(KNativePointer instance) +{ + auto&& _instance_ = reinterpret_cast(instance); + std::size_t program_len = 0; + auto programs = GetImpl()->ExternalSourcePrograms(_instance_, &program_len); + return new std::vector(programs, programs + program_len); +} +KOALA_INTEROP_1(ExternalSourcePrograms, KNativePointer, KNativePointer); + +KBoolean impl_IsClassProperty(KNativePointer nodePtr) +{ + auto node = reinterpret_cast(nodePtr); + return GetImpl()->IsClassProperty(node); +} +KOALA_INTEROP_1(IsClassProperty, KBoolean, KNativePointer) + +KBoolean impl_IsETSUnionType(KNativePointer nodePtr) +{ + auto node = reinterpret_cast(nodePtr); + return GetImpl()->IsETSUnionType(node); +} +KOALA_INTEROP_1(IsETSUnionType, KBoolean, KNativePointer) + +KBoolean impl_IsETSFunctionType(KNativePointer nodePtr) +{ + auto node = reinterpret_cast(nodePtr); + return GetImpl()->IsETSFunctionType(node); +} +KOALA_INTEROP_1(IsETSFunctionType, KBoolean, KNativePointer) + +KNativePointer impl_ETSParserBuildImportDeclaration(KNativePointer context, KInt importKinds, KNativePointerArray specifiers, KUInt specifiersSequenceLength, KNativePointer source, KNativePointer program, KInt importFlag) +{ + const auto _context = reinterpret_cast(context); + const auto _kinds = static_cast(importKinds); + const auto _specifiers = reinterpret_cast(specifiers); + const auto _specifiersSequenceLength = static_cast(specifiersSequenceLength); + const auto _source = reinterpret_cast(source); + const auto _program = reinterpret_cast(program); + const auto _importFlag = static_cast(importFlag); + + return GetImpl()->ETSParserBuildImportDeclaration(_context, _kinds, _specifiers, _specifiersSequenceLength, _source, _program, _importFlag); +} +KOALA_INTEROP_7(ETSParserBuildImportDeclaration, KNativePointer, KNativePointer, KInt, KNativePointerArray, KUInt, KNativePointer, KNativePointer, KInt) + +void impl_InsertETSImportDeclarationAndParse(KNativePointer context, KNativePointer program, KNativePointer importDeclaration) +{ + const auto _context = reinterpret_cast(context); + const auto _program = reinterpret_cast(program); + const auto _import = reinterpret_cast(importDeclaration); + GetImpl()->InsertETSImportDeclarationAndParse(_context, _program, _import); +} +KOALA_INTEROP_V3(InsertETSImportDeclarationAndParse, KNativePointer, KNativePointer, KNativePointer) + +KNativePointer impl_ETSParserGetImportPathManager(KNativePointer contextPtr) +{ + auto context = reinterpret_cast(contextPtr); + return GetImpl()->ETSParserGetImportPathManager(context); +} +KOALA_INTEROP_1(ETSParserGetImportPathManager, KNativePointer, KNativePointer); + +KNativePointer impl_CreateSourcePosition(KNativePointer context, KInt index, KInt line) +{ + auto&& _context_ = reinterpret_cast(context); + return GetImpl()->CreateSourcePosition(_context_, index, line); +} +KOALA_INTEROP_3(CreateSourcePosition, KNativePointer, KNativePointer, KInt, KInt); + +KInt impl_SourcePositionIndex(KNativePointer context, KNativePointer instance) +{ + auto&& _context_ = reinterpret_cast(context); + auto&& _instance_ = reinterpret_cast(instance); + return GetImpl()->SourcePositionIndex(_context_, _instance_); +} +KOALA_INTEROP_2(SourcePositionIndex, KInt, KNativePointer, KNativePointer); + +KInt impl_SourcePositionLine(KNativePointer context, KNativePointer instance) +{ + auto&& _context_ = reinterpret_cast(context); + auto&& _instance_ = reinterpret_cast(instance); + return GetImpl()->SourcePositionLine(_context_, _instance_); +} +KOALA_INTEROP_2(SourcePositionLine, KInt, KNativePointer, KNativePointer); + +KNativePointer impl_CreateSourceRange(KNativePointer context, KNativePointer start, KNativePointer end) +{ + auto&& _context_ = reinterpret_cast(context); + auto&& _start_ = reinterpret_cast(start); + auto&& _end_ = reinterpret_cast(end); + return GetImpl()->CreateSourceRange(_context_, _start_, _end_); +} +KOALA_INTEROP_3(CreateSourceRange, KNativePointer, KNativePointer, KNativePointer, KNativePointer); diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/native/src/common.cc b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/native/src/common.cc new file mode 100644 index 0000000000000000000000000000000000000000..31ce9150eec6a56a552ef322d2dbe6a75b32c4f7 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/native/src/common.cc @@ -0,0 +1,231 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +using std::string, std::cout, std::endl, std::vector; + +static es2panda_Impl *impl = nullptr; + +#ifdef KOALA_WINDOWS + #include + #define PLUGIN_DIR "windows_host_tools" + #define LIB_PREFIX "" + #define LIB_SUFFIX ".dll" +#endif + +#ifdef KOALA_LINUX + #include + + #ifdef __x86_64__ + #define PLUGIN_DIR "linux_host_tools" + #else + #define PLUGIN_DIR "linux_arm64_host_tools" + #endif + + #define LIB_PREFIX "lib" + #define LIB_SUFFIX ".so" +#endif + +const char* DEFAULT_SDK_PATH = "../../../incremental/tools/panda/node_modules/@panda/sdk" ; +const char* NAME = LIB_PREFIX "es2panda-public" LIB_SUFFIX; + +void* FindLibrary() { + char* envValue = getenv("PANDA_SDK_PATH"); + if (!envValue) { + std::cout << "PANDA_SDK_PATH not specified, assuming " << DEFAULT_SDK_PATH << std::endl; + } + std::string prefix = envValue ? std::string(envValue) : DEFAULT_SDK_PATH; + std::string libraryName = prefix + ("/" PLUGIN_DIR "/lib/") + NAME; + return loadLibrary(libraryName); +} + +es2panda_Impl *GetImpl() { + if (impl) { + return impl; + } + auto library = FindLibrary(); + if (!library) { + throw std::runtime_error("No library (es2panda_lib.cc)"); + } + auto symbol = findSymbol(library, "es2panda_GetImpl"); + if (!symbol) { + throw std::runtime_error("No entry point"); + } + impl = reinterpret_cast(symbol)(ES2PANDA_LIB_VERSION); + return impl; +} + +es2panda_ContextState intToState(KInt state) +{ + return es2panda_ContextState(state); +} + +string getString(KStringPtr ptr) { + return ptr.data(); +} + +char* getStringCopy(KStringPtr& ptr) { + return strdup(ptr.c_str()); +} + +inline KUInt unpackUInt(const KByte* bytes) { + const KUInt BYTE_0 = 0; + const KUInt BYTE_1 = 1; + const KUInt BYTE_2 = 2; + const KUInt BYTE_3 = 3; + + const KUInt BYTE_1_SHIFT = 8; + const KUInt BYTE_2_SHIFT = 16; + const KUInt BYTE_3_SHIFT = 24; + return ( + bytes[BYTE_0] + | (bytes[BYTE_1] << BYTE_1_SHIFT) + | (bytes[BYTE_2] << BYTE_2_SHIFT) + | (bytes[BYTE_3] << BYTE_3_SHIFT) + ); +} + +KNativePointer impl_CreateConfig(KInt argc, KStringArray argvPtr) { + const std::size_t headerLen = 4; + + const char** argv = new const char*[argc]; + std::size_t position = headerLen; + std::size_t strLen; + for (std::size_t i = 0; i < static_cast(argc); ++i) { + strLen = unpackUInt(argvPtr + position); + position += headerLen; + argv[i] = strdup(std::string(reinterpret_cast(argvPtr + position), strLen).c_str()); + position += strLen; + } + return GetImpl()->CreateConfig(argc, argv); +} +KOALA_INTEROP_2(CreateConfig, KNativePointer, KInt, KStringArray) + +KNativePointer impl_DestroyConfig(KNativePointer configPtr) { + auto config = reinterpret_cast(configPtr); + GetImpl()->DestroyConfig(config); + return nullptr; +} +KOALA_INTEROP_1(DestroyConfig, KNativePointer, KNativePointer) + +KNativePointer impl_DestroyContext(KNativePointer contextPtr) { + auto context = reinterpret_cast(contextPtr); + GetImpl()->DestroyContext(context); + return nullptr; +} +KOALA_INTEROP_1(DestroyContext, KNativePointer, KNativePointer) + +KNativePointer impl_UpdateCallExpression( + KNativePointer contextPtr, + KNativePointer nodePtr, + KNativePointer calleePtr, + KNativePointerArray argumentsPtr, + KInt argumentsLen, + KNativePointer typeParamsPtr, + KBoolean optionalT, + KBoolean trailingCommaT +) { + auto node = reinterpret_cast(nodePtr); + auto context = reinterpret_cast(contextPtr); + auto callee = reinterpret_cast(calleePtr); + auto arguments = reinterpret_cast(argumentsPtr); + auto typeParams = reinterpret_cast(typeParamsPtr); + auto optional = static_cast(optionalT); + auto trailingComma = static_cast(trailingCommaT); + + auto nn = GetImpl()->CreateCallExpression( + context, callee, arguments, argumentsLen, typeParams, optional, trailingComma + ); + GetImpl()->AstNodeSetOriginalNode(context, nn, node); + return nn; +} +KOALA_INTEROP_8(UpdateCallExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KInt, KNativePointer, KBoolean, KBoolean) + +KInt impl_IdentifierIdentifierFlags(KNativePointer contextPtr, KNativePointer nodePtr) { + auto context = reinterpret_cast(contextPtr); + auto node = reinterpret_cast(nodePtr); + + return + (GetImpl()->IdentifierIsOptionalConst(context, node) ? (1 << 0) : 0) | + (GetImpl()->IdentifierIsReferenceConst(context, node) ? (1 << 1) : 0) | + (GetImpl()->IdentifierIsTdzConst(context, node) ? (1 << 2) : 0); +} +KOALA_INTEROP_2(IdentifierIdentifierFlags, KInt, KNativePointer, KNativePointer) + +/* +TODO: NOT FROM API (shouldn't be there) +----------------------------------------------------------------------------------------------------------------------------- +*/ + +es2panda_AstNode * cachedParentNode; +es2panda_Context * cachedContext; + +static void changeParent(es2panda_AstNode *child) +{ + GetImpl()->AstNodeSetParent(cachedContext, child, cachedParentNode); +} + +static void SetRightParent(es2panda_AstNode *node, void *arg) +{ + es2panda_Context *ctx = static_cast(arg); + cachedContext = ctx; + cachedParentNode = node; + + GetImpl()->AstNodeIterateConst(ctx, node, changeParent); +} + +KNativePointer impl_AstNodeUpdateAll(KNativePointer contextPtr, KNativePointer programPtr) { + auto context = reinterpret_cast(contextPtr); + auto program = reinterpret_cast(programPtr); + + GetImpl()->AstNodeForEach(program, SetRightParent, context); + return program; +} +KOALA_INTEROP_2(AstNodeUpdateAll, KNativePointer, KNativePointer, KNativePointer) + +KNativePointer impl_AstNodeUpdateChildren(KNativePointer contextPtr, KNativePointer nodePtr) { + auto context = reinterpret_cast(contextPtr); + auto node = reinterpret_cast(nodePtr); + cachedParentNode = node; + + GetImpl()->AstNodeIterateConst(context, node, changeParent); + return node; +} +KOALA_INTEROP_2(AstNodeUpdateChildren, KNativePointer, KNativePointer, KNativePointer) + +std::vector cachedChildren; + +static void visitChild(es2panda_AstNode *node) { + cachedChildren.emplace_back(node); +} + +KNativePointer impl_AstNodeChildren( + KNativePointer contextPtr, + KNativePointer nodePtr +) { + auto context = reinterpret_cast(contextPtr); + auto node = reinterpret_cast(nodePtr); + cachedContext = context; + cachedChildren.clear(); + + GetImpl()->AstNodeIterateConst(context, node, visitChild); + return new std::vector(cachedChildren); +} +KOALA_INTEROP_2(AstNodeChildren, KNativePointer, KNativePointer, KNativePointer) + +/* +----------------------------------------------------------------------------------------------------------------------------- +*/ diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/native/src/common.h b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/native/src/common.h new file mode 100644 index 0000000000000000000000000000000000000000..60d111e0b7b13a4d79450ae7618ecc2ec2f7ca92 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/native/src/common.h @@ -0,0 +1,39 @@ +#ifndef COMMON_H +#define COMMON_H + +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "dynamic-loader.h" +#include "es2panda_lib.h" +#include "common-interop.h" +#include "stdexcept" +#include +#include +#include + +using std::string, std::cout, std::endl, std::vector; + +es2panda_Impl *GetImpl(); + +string getString(KStringPtr ptr); + +char* getStringCopy(KStringPtr& ptr); + +inline KUInt unpackUInt(const KByte* bytes); + +es2panda_ContextState intToState(KInt state); + +#endif // COMMON_H \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/native/src/generated/bridges.cc b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/native/src/generated/bridges.cc new file mode 100644 index 0000000000000000000000000000000000000000..9ab88b8cb05d6c0f343064090c7bf9d5d8927748 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/native/src/generated/bridges.cc @@ -0,0 +1,12479 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +KNativePointer impl_NumberLiteralStrConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->NumberLiteralStrConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(NumberLiteralStrConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateNumberLiteral(KNativePointer context, KInt value) +{ + const auto _context = reinterpret_cast(context); + const auto _value = static_cast(value); + auto result = GetImpl()->CreateNumberLiteral(_context, _value); + return result; +} +KOALA_INTEROP_2(CreateNumberLiteral, KNativePointer, KNativePointer, KInt); + +KNativePointer impl_CreateNumberLiteral1(KNativePointer context, KLong value) +{ + const auto _context = reinterpret_cast(context); + const auto _value = static_cast(value); + auto result = GetImpl()->CreateNumberLiteral1(_context, _value); + return result; +} +KOALA_INTEROP_2(CreateNumberLiteral1, KNativePointer, KNativePointer, KLong); + +KNativePointer impl_CreateNumberLiteral2(KNativePointer context, KDouble value) +{ + const auto _context = reinterpret_cast(context); + const auto _value = static_cast(value); + auto result = GetImpl()->CreateNumberLiteral2(_context, _value); + return result; +} +KOALA_INTEROP_2(CreateNumberLiteral2, KNativePointer, KNativePointer, KDouble); + +KNativePointer impl_CreateNumberLiteral3(KNativePointer context, KFloat value) +{ + const auto _context = reinterpret_cast(context); + const auto _value = static_cast(value); + auto result = GetImpl()->CreateNumberLiteral3(_context, _value); + return result; +} +KOALA_INTEROP_2(CreateNumberLiteral3, KNativePointer, KNativePointer, KFloat); + +KNativePointer impl_UpdateNumberLiteral(KNativePointer context, KNativePointer original, KInt value) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _value = static_cast(value); + auto result = GetImpl()->UpdateNumberLiteral(_context, _original, _value); + return result; +} +KOALA_INTEROP_3(UpdateNumberLiteral, KNativePointer, KNativePointer, KNativePointer, KInt); + +KNativePointer impl_UpdateNumberLiteral1(KNativePointer context, KNativePointer original, KLong value) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _value = static_cast(value); + auto result = GetImpl()->UpdateNumberLiteral1(_context, _original, _value); + return result; +} +KOALA_INTEROP_3(UpdateNumberLiteral1, KNativePointer, KNativePointer, KNativePointer, KLong); + +KNativePointer impl_UpdateNumberLiteral2(KNativePointer context, KNativePointer original, KDouble value) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _value = static_cast(value); + auto result = GetImpl()->UpdateNumberLiteral2(_context, _original, _value); + return result; +} +KOALA_INTEROP_3(UpdateNumberLiteral2, KNativePointer, KNativePointer, KNativePointer, KDouble); + +KNativePointer impl_UpdateNumberLiteral3(KNativePointer context, KNativePointer original, KFloat value) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _value = static_cast(value); + auto result = GetImpl()->UpdateNumberLiteral3(_context, _original, _value); + return result; +} +KOALA_INTEROP_3(UpdateNumberLiteral3, KNativePointer, KNativePointer, KNativePointer, KFloat); + +KNativePointer impl_CreateLabelledStatement(KNativePointer context, KNativePointer ident, KNativePointer body) +{ + const auto _context = reinterpret_cast(context); + const auto _ident = reinterpret_cast(ident); + const auto _body = reinterpret_cast(body); + auto result = GetImpl()->CreateLabelledStatement(_context, _ident, _body); + return result; +} +KOALA_INTEROP_3(CreateLabelledStatement, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateLabelledStatement(KNativePointer context, KNativePointer original, KNativePointer ident, KNativePointer body) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _ident = reinterpret_cast(ident); + const auto _body = reinterpret_cast(body); + auto result = GetImpl()->UpdateLabelledStatement(_context, _original, _ident, _body); + return result; +} +KOALA_INTEROP_4(UpdateLabelledStatement, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_LabelledStatementBody(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->LabelledStatementBody(_context, _receiver); + return result; +} +KOALA_INTEROP_2(LabelledStatementBody, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_LabelledStatementBodyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->LabelledStatementBodyConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(LabelledStatementBodyConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_LabelledStatementIdentConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->LabelledStatementIdentConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(LabelledStatementIdentConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_LabelledStatementIdent(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->LabelledStatementIdent(_context, _receiver); + return result; +} +KOALA_INTEROP_2(LabelledStatementIdent, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_LabelledStatementGetReferencedStatementConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->LabelledStatementGetReferencedStatementConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(LabelledStatementGetReferencedStatementConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateThrowStatement(KNativePointer context, KNativePointer argument) +{ + const auto _context = reinterpret_cast(context); + const auto _argument = reinterpret_cast(argument); + auto result = GetImpl()->CreateThrowStatement(_context, _argument); + return result; +} +KOALA_INTEROP_2(CreateThrowStatement, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateThrowStatement(KNativePointer context, KNativePointer original, KNativePointer argument) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _argument = reinterpret_cast(argument); + auto result = GetImpl()->UpdateThrowStatement(_context, _original, _argument); + return result; +} +KOALA_INTEROP_3(UpdateThrowStatement, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ThrowStatementArgumentConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ThrowStatementArgumentConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ThrowStatementArgumentConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateClassProperty(KNativePointer context, KNativePointer key, KNativePointer value, KNativePointer typeAnnotation, KInt modifiers, KBoolean isComputed) +{ + const auto _context = reinterpret_cast(context); + const auto _key = reinterpret_cast(key); + const auto _value = reinterpret_cast(value); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + const auto _modifiers = static_cast(modifiers); + const auto _isComputed = static_cast(isComputed); + auto result = GetImpl()->CreateClassProperty(_context, _key, _value, _typeAnnotation, _modifiers, _isComputed); + return result; +} +KOALA_INTEROP_6(CreateClassProperty, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KInt, KBoolean); + +KNativePointer impl_UpdateClassProperty(KNativePointer context, KNativePointer original, KNativePointer key, KNativePointer value, KNativePointer typeAnnotation, KInt modifiers, KBoolean isComputed) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _key = reinterpret_cast(key); + const auto _value = reinterpret_cast(value); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + const auto _modifiers = static_cast(modifiers); + const auto _isComputed = static_cast(isComputed); + auto result = GetImpl()->UpdateClassProperty(_context, _original, _key, _value, _typeAnnotation, _modifiers, _isComputed); + return result; +} +KOALA_INTEROP_7(UpdateClassProperty, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KInt, KBoolean); + +KBoolean impl_ClassPropertyIsDefaultAccessModifierConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassPropertyIsDefaultAccessModifierConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassPropertyIsDefaultAccessModifierConst, KBoolean, KNativePointer, KNativePointer); + +void impl_ClassPropertySetDefaultAccessModifier(KNativePointer context, KNativePointer receiver, KBoolean isDefault) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _isDefault = static_cast(isDefault); + GetImpl()->ClassPropertySetDefaultAccessModifier(_context, _receiver, _isDefault); + return ; +} +KOALA_INTEROP_V3(ClassPropertySetDefaultAccessModifier, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_ClassPropertyTypeAnnotationConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassPropertyTypeAnnotationConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ClassPropertyTypeAnnotationConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_ClassPropertySetTypeAnnotation(KNativePointer context, KNativePointer receiver, KNativePointer typeAnnotation) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + GetImpl()->ClassPropertySetTypeAnnotation(_context, _receiver, _typeAnnotation); + return ; +} +KOALA_INTEROP_V3(ClassPropertySetTypeAnnotation, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_ClassPropertyNeedInitInStaticBlockConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassPropertyNeedInitInStaticBlockConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassPropertyNeedInitInStaticBlockConst, KBoolean, KNativePointer, KNativePointer); + +void impl_ClassPropertySetInitInStaticBlock(KNativePointer context, KNativePointer receiver, KBoolean needInitInStaticBlock) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _needInitInStaticBlock = static_cast(needInitInStaticBlock); + GetImpl()->ClassPropertySetInitInStaticBlock(_context, _receiver, _needInitInStaticBlock); + return ; +} +KOALA_INTEROP_V3(ClassPropertySetInitInStaticBlock, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_ClassPropertyAnnotations(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ClassPropertyAnnotations(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(ClassPropertyAnnotations, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassPropertyAnnotationsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ClassPropertyAnnotationsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(ClassPropertyAnnotationsConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_ClassPropertySetAnnotations(KNativePointer context, KNativePointer receiver, KNativePointerArray annotations, KUInt annotationsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _annotations = reinterpret_cast(annotations); + const auto _annotationsSequenceLength = static_cast(annotationsSequenceLength); + GetImpl()->ClassPropertySetAnnotations(_context, _receiver, _annotations, _annotationsSequenceLength); + return ; +} +KOALA_INTEROP_V4(ClassPropertySetAnnotations, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_CreateTSVoidKeyword(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateTSVoidKeyword(_context); + return result; +} +KOALA_INTEROP_1(CreateTSVoidKeyword, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSVoidKeyword(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateTSVoidKeyword(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateTSVoidKeyword, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateETSFunctionType(KNativePointer context, KNativePointer signature, KInt funcFlags) +{ + const auto _context = reinterpret_cast(context); + const auto _signature = reinterpret_cast(signature); + const auto _funcFlags = static_cast(funcFlags); + auto result = GetImpl()->CreateETSFunctionTypeIr(_context, _signature, _funcFlags); + return result; +} +KOALA_INTEROP_3(CreateETSFunctionType, KNativePointer, KNativePointer, KNativePointer, KInt); + +KNativePointer impl_UpdateETSFunctionType(KNativePointer context, KNativePointer original, KNativePointer signature, KInt funcFlags) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _signature = reinterpret_cast(signature); + const auto _funcFlags = static_cast(funcFlags); + auto result = GetImpl()->UpdateETSFunctionTypeIr(_context, _original, _signature, _funcFlags); + return result; +} +KOALA_INTEROP_4(UpdateETSFunctionType, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KInt); + +KNativePointer impl_ETSFunctionTypeTypeParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSFunctionTypeIrTypeParamsConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ETSFunctionTypeTypeParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSFunctionTypeTypeParams(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSFunctionTypeIrTypeParams(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSFunctionTypeTypeParams, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSFunctionTypeParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ETSFunctionTypeIrParamsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(ETSFunctionTypeParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSFunctionTypeReturnTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSFunctionTypeIrReturnTypeConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ETSFunctionTypeReturnTypeConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSFunctionTypeReturnType(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSFunctionTypeIrReturnType(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSFunctionTypeReturnType, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSFunctionTypeFunctionalInterface(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSFunctionTypeIrFunctionalInterface(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSFunctionTypeFunctionalInterface, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSFunctionTypeFunctionalInterfaceConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSFunctionTypeIrFunctionalInterfaceConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ETSFunctionTypeFunctionalInterfaceConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_ETSFunctionTypeSetFunctionalInterface(KNativePointer context, KNativePointer receiver, KNativePointer functionalInterface) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _functionalInterface = reinterpret_cast(functionalInterface); + GetImpl()->ETSFunctionTypeIrSetFunctionalInterface(_context, _receiver, _functionalInterface); + return ; +} +KOALA_INTEROP_V3(ETSFunctionTypeSetFunctionalInterface, KNativePointer, KNativePointer, KNativePointer); + +KInt impl_ETSFunctionTypeFlags(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSFunctionTypeIrFlags(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSFunctionTypeFlags, KInt, KNativePointer, KNativePointer); + +KBoolean impl_ETSFunctionTypeIsThrowingConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSFunctionTypeIrIsThrowingConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSFunctionTypeIsThrowingConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ETSFunctionTypeIsRethrowingConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSFunctionTypeIrIsRethrowingConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSFunctionTypeIsRethrowingConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ETSFunctionTypeIsExtensionFunctionConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSFunctionTypeIrIsExtensionFunctionConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSFunctionTypeIsExtensionFunctionConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSTypeOperator(KNativePointer context, KNativePointer type, KInt operatorType) +{ + const auto _context = reinterpret_cast(context); + const auto _type = reinterpret_cast(type); + const auto _operatorType = static_cast(operatorType); + auto result = GetImpl()->CreateTSTypeOperator(_context, _type, _operatorType); + return result; +} +KOALA_INTEROP_3(CreateTSTypeOperator, KNativePointer, KNativePointer, KNativePointer, KInt); + +KNativePointer impl_UpdateTSTypeOperator(KNativePointer context, KNativePointer original, KNativePointer type, KInt operatorType) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _type = reinterpret_cast(type); + const auto _operatorType = static_cast(operatorType); + auto result = GetImpl()->UpdateTSTypeOperator(_context, _original, _type, _operatorType); + return result; +} +KOALA_INTEROP_4(UpdateTSTypeOperator, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KInt); + +KNativePointer impl_TSTypeOperatorTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSTypeOperatorTypeConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSTypeOperatorTypeConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_TSTypeOperatorIsReadonlyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSTypeOperatorIsReadonlyConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSTypeOperatorIsReadonlyConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_TSTypeOperatorIsKeyofConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSTypeOperatorIsKeyofConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSTypeOperatorIsKeyofConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_TSTypeOperatorIsUniqueConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSTypeOperatorIsUniqueConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSTypeOperatorIsUniqueConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_CreateIfStatement(KNativePointer context, KNativePointer test, KNativePointer consequent, KNativePointer alternate) +{ + const auto _context = reinterpret_cast(context); + const auto _test = reinterpret_cast(test); + const auto _consequent = reinterpret_cast(consequent); + const auto _alternate = reinterpret_cast(alternate); + auto result = GetImpl()->CreateIfStatement(_context, _test, _consequent, _alternate); + return result; +} +KOALA_INTEROP_4(CreateIfStatement, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateIfStatement(KNativePointer context, KNativePointer original, KNativePointer test, KNativePointer consequent, KNativePointer alternate) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _test = reinterpret_cast(test); + const auto _consequent = reinterpret_cast(consequent); + const auto _alternate = reinterpret_cast(alternate); + auto result = GetImpl()->UpdateIfStatement(_context, _original, _test, _consequent, _alternate); + return result; +} +KOALA_INTEROP_5(UpdateIfStatement, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_IfStatementTestConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->IfStatementTestConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(IfStatementTestConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_IfStatementTest(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->IfStatementTest(_context, _receiver); + return result; +} +KOALA_INTEROP_2(IfStatementTest, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_IfStatementConsequentConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->IfStatementConsequentConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(IfStatementConsequentConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_IfStatementConsequent(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->IfStatementConsequent(_context, _receiver); + return result; +} +KOALA_INTEROP_2(IfStatementConsequent, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_IfStatementAlternate(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->IfStatementAlternate(_context, _receiver); + return result; +} +KOALA_INTEROP_2(IfStatementAlternate, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_IfStatementAlternateConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->IfStatementAlternateConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(IfStatementAlternateConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_IfStatementSetAlternate(KNativePointer context, KNativePointer receiver, KNativePointer alternate) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _alternate = reinterpret_cast(alternate); + GetImpl()->IfStatementSetAlternate(_context, _receiver, _alternate); + return ; +} +KOALA_INTEROP_V3(IfStatementSetAlternate, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSConstructorType(KNativePointer context, KNativePointer signature, KBoolean abstract) +{ + const auto _context = reinterpret_cast(context); + const auto _signature = reinterpret_cast(signature); + const auto _abstract = static_cast(abstract); + auto result = GetImpl()->CreateTSConstructorType(_context, _signature, _abstract); + return result; +} +KOALA_INTEROP_3(CreateTSConstructorType, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_UpdateTSConstructorType(KNativePointer context, KNativePointer original, KNativePointer signature, KBoolean abstract) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _signature = reinterpret_cast(signature); + const auto _abstract = static_cast(abstract); + auto result = GetImpl()->UpdateTSConstructorType(_context, _original, _signature, _abstract); + return result; +} +KOALA_INTEROP_4(UpdateTSConstructorType, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_TSConstructorTypeTypeParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSConstructorTypeTypeParamsConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSConstructorTypeTypeParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSConstructorTypeTypeParams(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSConstructorTypeTypeParams(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSConstructorTypeTypeParams, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSConstructorTypeParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSConstructorTypeParamsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSConstructorTypeParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSConstructorTypeReturnTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSConstructorTypeReturnTypeConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSConstructorTypeReturnTypeConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSConstructorTypeReturnType(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSConstructorTypeReturnType(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSConstructorTypeReturnType, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_TSConstructorTypeAbstractConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSConstructorTypeAbstractConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSConstructorTypeAbstractConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_CreateDecorator(KNativePointer context, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _expr = reinterpret_cast(expr); + auto result = GetImpl()->CreateDecorator(_context, _expr); + return result; +} +KOALA_INTEROP_2(CreateDecorator, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateDecorator(KNativePointer context, KNativePointer original, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _expr = reinterpret_cast(expr); + auto result = GetImpl()->UpdateDecorator(_context, _original, _expr); + return result; +} +KOALA_INTEROP_3(UpdateDecorator, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_DecoratorExprConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->DecoratorExprConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(DecoratorExprConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSEnumDeclaration(KNativePointer context, KNativePointer key, KNativePointerArray members, KUInt membersSequenceLength, KBoolean isConst, KBoolean isStatic, KBoolean isDeclare) +{ + const auto _context = reinterpret_cast(context); + const auto _key = reinterpret_cast(key); + const auto _members = reinterpret_cast(members); + const auto _membersSequenceLength = static_cast(membersSequenceLength); + const auto _isConst = static_cast(isConst); + const auto _isStatic = static_cast(isStatic); + const auto _isDeclare = static_cast(isDeclare); + auto result = GetImpl()->CreateTSEnumDeclaration(_context, _key, _members, _membersSequenceLength, _isConst, _isStatic, _isDeclare); + return result; +} +KOALA_INTEROP_7(CreateTSEnumDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KBoolean, KBoolean, KBoolean); + +KNativePointer impl_UpdateTSEnumDeclaration(KNativePointer context, KNativePointer original, KNativePointer key, KNativePointerArray members, KUInt membersSequenceLength, KBoolean isConst, KBoolean isStatic, KBoolean isDeclare) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _key = reinterpret_cast(key); + const auto _members = reinterpret_cast(members); + const auto _membersSequenceLength = static_cast(membersSequenceLength); + const auto _isConst = static_cast(isConst); + const auto _isStatic = static_cast(isStatic); + const auto _isDeclare = static_cast(isDeclare); + auto result = GetImpl()->UpdateTSEnumDeclaration(_context, _original, _key, _members, _membersSequenceLength, _isConst, _isStatic, _isDeclare); + return result; +} +KOALA_INTEROP_8(UpdateTSEnumDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KBoolean, KBoolean, KBoolean); + +KNativePointer impl_TSEnumDeclarationKeyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSEnumDeclarationKeyConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSEnumDeclarationKeyConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSEnumDeclarationKey(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSEnumDeclarationKey(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSEnumDeclarationKey, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSEnumDeclarationMembersConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSEnumDeclarationMembersConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSEnumDeclarationMembersConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSEnumDeclarationInternalNameConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSEnumDeclarationInternalNameConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(TSEnumDeclarationInternalNameConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_TSEnumDeclarationSetInternalName(KNativePointer context, KNativePointer receiver, KStringPtr& internalName) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _internalName = getStringCopy(internalName); + GetImpl()->TSEnumDeclarationSetInternalName(_context, _receiver, _internalName); + return ; +} +KOALA_INTEROP_V3(TSEnumDeclarationSetInternalName, KNativePointer, KNativePointer, KStringPtr); + +KNativePointer impl_TSEnumDeclarationBoxedClassConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSEnumDeclarationBoxedClassConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSEnumDeclarationBoxedClassConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_TSEnumDeclarationSetBoxedClass(KNativePointer context, KNativePointer receiver, KNativePointer wrapperClass) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _wrapperClass = reinterpret_cast(wrapperClass); + GetImpl()->TSEnumDeclarationSetBoxedClass(_context, _receiver, _wrapperClass); + return ; +} +KOALA_INTEROP_V3(TSEnumDeclarationSetBoxedClass, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_TSEnumDeclarationIsConstConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSEnumDeclarationIsConstConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSEnumDeclarationIsConstConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_TSEnumDeclarationDecoratorsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSEnumDeclarationDecoratorsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSEnumDeclarationDecoratorsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSNeverKeyword(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateTSNeverKeyword(_context); + return result; +} +KOALA_INTEROP_1(CreateTSNeverKeyword, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSNeverKeyword(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateTSNeverKeyword(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateTSNeverKeyword, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateImportDefaultSpecifier(KNativePointer context, KNativePointer local) +{ + const auto _context = reinterpret_cast(context); + const auto _local = reinterpret_cast(local); + auto result = GetImpl()->CreateImportDefaultSpecifier(_context, _local); + return result; +} +KOALA_INTEROP_2(CreateImportDefaultSpecifier, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateImportDefaultSpecifier(KNativePointer context, KNativePointer original, KNativePointer local) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _local = reinterpret_cast(local); + auto result = GetImpl()->UpdateImportDefaultSpecifier(_context, _original, _local); + return result; +} +KOALA_INTEROP_3(UpdateImportDefaultSpecifier, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ImportDefaultSpecifierLocalConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ImportDefaultSpecifierLocalConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ImportDefaultSpecifierLocalConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ImportDefaultSpecifierLocal(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ImportDefaultSpecifierLocal(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ImportDefaultSpecifierLocal, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateObjectExpression(KNativePointer context, KInt nodeType, KNativePointerArray properties, KUInt propertiesSequenceLength, KBoolean trailingComma) +{ + const auto _context = reinterpret_cast(context); + const auto _nodeType = static_cast(nodeType); + const auto _properties = reinterpret_cast(properties); + const auto _propertiesSequenceLength = static_cast(propertiesSequenceLength); + const auto _trailingComma = static_cast(trailingComma); + auto result = GetImpl()->CreateObjectExpression(_context, _nodeType, _properties, _propertiesSequenceLength, _trailingComma); + return result; +} +KOALA_INTEROP_5(CreateObjectExpression, KNativePointer, KNativePointer, KInt, KNativePointerArray, KUInt, KBoolean); + +KNativePointer impl_UpdateObjectExpression(KNativePointer context, KNativePointer original, KInt nodeType, KNativePointerArray properties, KUInt propertiesSequenceLength, KBoolean trailingComma) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _nodeType = static_cast(nodeType); + const auto _properties = reinterpret_cast(properties); + const auto _propertiesSequenceLength = static_cast(propertiesSequenceLength); + const auto _trailingComma = static_cast(trailingComma); + auto result = GetImpl()->UpdateObjectExpression(_context, _original, _nodeType, _properties, _propertiesSequenceLength, _trailingComma); + return result; +} +KOALA_INTEROP_6(UpdateObjectExpression, KNativePointer, KNativePointer, KNativePointer, KInt, KNativePointerArray, KUInt, KBoolean); + +KNativePointer impl_ObjectExpressionPropertiesConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ObjectExpressionPropertiesConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(ObjectExpressionPropertiesConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_ObjectExpressionIsDeclarationConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ObjectExpressionIsDeclarationConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ObjectExpressionIsDeclarationConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ObjectExpressionIsOptionalConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ObjectExpressionIsOptionalConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ObjectExpressionIsOptionalConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_ObjectExpressionDecoratorsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ObjectExpressionDecoratorsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(ObjectExpressionDecoratorsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ObjectExpressionValidateExpression(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ObjectExpressionValidateExpression(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ObjectExpressionValidateExpression, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_ObjectExpressionConvertibleToObjectPattern(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ObjectExpressionConvertibleToObjectPattern(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ObjectExpressionConvertibleToObjectPattern, KBoolean, KNativePointer, KNativePointer); + +void impl_ObjectExpressionSetDeclaration(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->ObjectExpressionSetDeclaration(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(ObjectExpressionSetDeclaration, KNativePointer, KNativePointer); + +void impl_ObjectExpressionSetOptional(KNativePointer context, KNativePointer receiver, KBoolean optional_arg) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _optional_arg = static_cast(optional_arg); + GetImpl()->ObjectExpressionSetOptional(_context, _receiver, _optional_arg); + return ; +} +KOALA_INTEROP_V3(ObjectExpressionSetOptional, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_ObjectExpressionTypeAnnotationConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ObjectExpressionTypeAnnotationConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ObjectExpressionTypeAnnotationConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_ObjectExpressionSetTsTypeAnnotation(KNativePointer context, KNativePointer receiver, KNativePointer typeAnnotation) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + GetImpl()->ObjectExpressionSetTsTypeAnnotation(_context, _receiver, _typeAnnotation); + return ; +} +KOALA_INTEROP_V3(ObjectExpressionSetTsTypeAnnotation, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateImportSpecifier(KNativePointer context, KNativePointer imported, KNativePointer local) +{ + const auto _context = reinterpret_cast(context); + const auto _imported = reinterpret_cast(imported); + const auto _local = reinterpret_cast(local); + auto result = GetImpl()->CreateImportSpecifier(_context, _imported, _local); + return result; +} +KOALA_INTEROP_3(CreateImportSpecifier, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateImportSpecifier(KNativePointer context, KNativePointer original, KNativePointer imported, KNativePointer local) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _imported = reinterpret_cast(imported); + const auto _local = reinterpret_cast(local); + auto result = GetImpl()->UpdateImportSpecifier(_context, _original, _imported, _local); + return result; +} +KOALA_INTEROP_4(UpdateImportSpecifier, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ImportSpecifierImported(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ImportSpecifierImported(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ImportSpecifierImported, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ImportSpecifierImportedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ImportSpecifierImportedConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ImportSpecifierImportedConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ImportSpecifierLocal(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ImportSpecifierLocal(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ImportSpecifierLocal, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ImportSpecifierLocalConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ImportSpecifierLocalConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ImportSpecifierLocalConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_ImportSpecifierIsRemovableConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ImportSpecifierIsRemovableConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ImportSpecifierIsRemovableConst, KBoolean, KNativePointer, KNativePointer); + +void impl_ImportSpecifierSetRemovable(KNativePointer context, KNativePointer receiver, KBoolean isRemovable) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _isRemovable = static_cast(isRemovable); + GetImpl()->ImportSpecifierSetRemovable(_context, _receiver, _isRemovable); + return ; +} +KOALA_INTEROP_V3(ImportSpecifierSetRemovable, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_CreateConditionalExpression(KNativePointer context, KNativePointer test, KNativePointer consequent, KNativePointer alternate) +{ + const auto _context = reinterpret_cast(context); + const auto _test = reinterpret_cast(test); + const auto _consequent = reinterpret_cast(consequent); + const auto _alternate = reinterpret_cast(alternate); + auto result = GetImpl()->CreateConditionalExpression(_context, _test, _consequent, _alternate); + return result; +} +KOALA_INTEROP_4(CreateConditionalExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateConditionalExpression(KNativePointer context, KNativePointer original, KNativePointer test, KNativePointer consequent, KNativePointer alternate) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _test = reinterpret_cast(test); + const auto _consequent = reinterpret_cast(consequent); + const auto _alternate = reinterpret_cast(alternate); + auto result = GetImpl()->UpdateConditionalExpression(_context, _original, _test, _consequent, _alternate); + return result; +} +KOALA_INTEROP_5(UpdateConditionalExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ConditionalExpressionTestConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ConditionalExpressionTestConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ConditionalExpressionTestConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ConditionalExpressionTest(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ConditionalExpressionTest(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ConditionalExpressionTest, KNativePointer, KNativePointer, KNativePointer); + +void impl_ConditionalExpressionSetTest(KNativePointer context, KNativePointer receiver, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _expr = reinterpret_cast(expr); + GetImpl()->ConditionalExpressionSetTest(_context, _receiver, _expr); + return ; +} +KOALA_INTEROP_V3(ConditionalExpressionSetTest, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ConditionalExpressionConsequentConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ConditionalExpressionConsequentConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ConditionalExpressionConsequentConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ConditionalExpressionConsequent(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ConditionalExpressionConsequent(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ConditionalExpressionConsequent, KNativePointer, KNativePointer, KNativePointer); + +void impl_ConditionalExpressionSetConsequent(KNativePointer context, KNativePointer receiver, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _expr = reinterpret_cast(expr); + GetImpl()->ConditionalExpressionSetConsequent(_context, _receiver, _expr); + return ; +} +KOALA_INTEROP_V3(ConditionalExpressionSetConsequent, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ConditionalExpressionAlternateConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ConditionalExpressionAlternateConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ConditionalExpressionAlternateConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ConditionalExpressionAlternate(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ConditionalExpressionAlternate(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ConditionalExpressionAlternate, KNativePointer, KNativePointer, KNativePointer); + +void impl_ConditionalExpressionSetAlternate(KNativePointer context, KNativePointer receiver, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _expr = reinterpret_cast(expr); + GetImpl()->ConditionalExpressionSetAlternate(_context, _receiver, _expr); + return ; +} +KOALA_INTEROP_V3(ConditionalExpressionSetAlternate, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateCallExpression(KNativePointer context, KNativePointer callee, KNativePointerArray _arguments, KUInt _argumentsSequenceLength, KNativePointer typeParams, KBoolean optional_arg, KBoolean trailingComma) +{ + const auto _context = reinterpret_cast(context); + const auto _callee = reinterpret_cast(callee); + const auto __arguments = reinterpret_cast(_arguments); + const auto __argumentsSequenceLength = static_cast(_argumentsSequenceLength); + const auto _typeParams = reinterpret_cast(typeParams); + const auto _optional_arg = static_cast(optional_arg); + const auto _trailingComma = static_cast(trailingComma); + auto result = GetImpl()->CreateCallExpression(_context, _callee, __arguments, __argumentsSequenceLength, _typeParams, _optional_arg, _trailingComma); + return result; +} +KOALA_INTEROP_7(CreateCallExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KNativePointer, KBoolean, KBoolean); + +KNativePointer impl_CreateCallExpression1(KNativePointer context, KNativePointer other) +{ + const auto _context = reinterpret_cast(context); + const auto _other = reinterpret_cast(other); + auto result = GetImpl()->CreateCallExpression1(_context, _other); + return result; +} +KOALA_INTEROP_2(CreateCallExpression1, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateCallExpression1(KNativePointer context, KNativePointer original, KNativePointer other) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _other = reinterpret_cast(other); + auto result = GetImpl()->UpdateCallExpression1(_context, _original, _other); + return result; +} +KOALA_INTEROP_3(UpdateCallExpression1, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CallExpressionCalleeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->CallExpressionCalleeConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(CallExpressionCalleeConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CallExpressionCallee(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->CallExpressionCallee(_context, _receiver); + return result; +} +KOALA_INTEROP_2(CallExpressionCallee, KNativePointer, KNativePointer, KNativePointer); + +void impl_CallExpressionSetCallee(KNativePointer context, KNativePointer receiver, KNativePointer callee) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _callee = reinterpret_cast(callee); + GetImpl()->CallExpressionSetCallee(_context, _receiver, _callee); + return ; +} +KOALA_INTEROP_V3(CallExpressionSetCallee, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CallExpressionTypeParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->CallExpressionTypeParamsConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(CallExpressionTypeParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CallExpressionTypeParams(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->CallExpressionTypeParams(_context, _receiver); + return result; +} +KOALA_INTEROP_2(CallExpressionTypeParams, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CallExpressionArgumentsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->CallExpressionArgumentsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(CallExpressionArgumentsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CallExpressionArguments(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->CallExpressionArguments(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(CallExpressionArguments, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_CallExpressionHasTrailingCommaConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->CallExpressionHasTrailingCommaConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(CallExpressionHasTrailingCommaConst, KBoolean, KNativePointer, KNativePointer); + +void impl_CallExpressionSetTypeParams(KNativePointer context, KNativePointer receiver, KNativePointer typeParams) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _typeParams = reinterpret_cast(typeParams); + GetImpl()->CallExpressionSetTypeParams(_context, _receiver, _typeParams); + return ; +} +KOALA_INTEROP_V3(CallExpressionSetTypeParams, KNativePointer, KNativePointer, KNativePointer); + +void impl_CallExpressionSetTrailingBlock(KNativePointer context, KNativePointer receiver, KNativePointer block) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _block = reinterpret_cast(block); + GetImpl()->CallExpressionSetTrailingBlock(_context, _receiver, _block); + return ; +} +KOALA_INTEROP_V3(CallExpressionSetTrailingBlock, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_CallExpressionIsExtensionAccessorCall(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->CallExpressionIsExtensionAccessorCall(_context, _receiver); + return result; +} +KOALA_INTEROP_2(CallExpressionIsExtensionAccessorCall, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_CallExpressionTrailingBlockConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->CallExpressionTrailingBlockConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(CallExpressionTrailingBlockConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_CallExpressionSetIsTrailingBlockInNewLine(KNativePointer context, KNativePointer receiver, KBoolean isNewLine) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _isNewLine = static_cast(isNewLine); + GetImpl()->CallExpressionSetIsTrailingBlockInNewLine(_context, _receiver, _isNewLine); + return ; +} +KOALA_INTEROP_V3(CallExpressionSetIsTrailingBlockInNewLine, KNativePointer, KNativePointer, KBoolean); + +KBoolean impl_CallExpressionIsTrailingBlockInNewLineConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->CallExpressionIsTrailingBlockInNewLineConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(CallExpressionIsTrailingBlockInNewLineConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_CallExpressionIsETSConstructorCallConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->CallExpressionIsETSConstructorCallConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(CallExpressionIsETSConstructorCallConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_CreateBigIntLiteral(KNativePointer context, KStringPtr& src) +{ + const auto _context = reinterpret_cast(context); + const auto _src = getStringCopy(src); + auto result = GetImpl()->CreateBigIntLiteral(_context, _src); + return result; +} +KOALA_INTEROP_2(CreateBigIntLiteral, KNativePointer, KNativePointer, KStringPtr); + +KNativePointer impl_UpdateBigIntLiteral(KNativePointer context, KNativePointer original, KStringPtr& src) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _src = getStringCopy(src); + auto result = GetImpl()->UpdateBigIntLiteral(_context, _original, _src); + return result; +} +KOALA_INTEROP_3(UpdateBigIntLiteral, KNativePointer, KNativePointer, KNativePointer, KStringPtr); + +KNativePointer impl_BigIntLiteralStrConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->BigIntLiteralStrConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(BigIntLiteralStrConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassElementId(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassElementId(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassElementId, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassElementIdConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassElementIdConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ClassElementIdConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassElementKey(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassElementKey(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassElementKey, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassElementKeyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassElementKeyConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ClassElementKeyConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassElementValue(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassElementValue(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassElementValue, KNativePointer, KNativePointer, KNativePointer); + +void impl_ClassElementSetValue(KNativePointer context, KNativePointer receiver, KNativePointer value) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _value = reinterpret_cast(value); + GetImpl()->ClassElementSetValue(_context, _receiver, _value); + return ; +} +KOALA_INTEROP_V3(ClassElementSetValue, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassElementValueConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassElementValueConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ClassElementValueConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassElementOriginEnumMemberConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassElementOriginEnumMemberConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ClassElementOriginEnumMemberConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_ClassElementSetOrigEnumMember(KNativePointer context, KNativePointer receiver, KNativePointer enumMember) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _enumMember = reinterpret_cast(enumMember); + GetImpl()->ClassElementSetOrigEnumMember(_context, _receiver, _enumMember); + return ; +} +KOALA_INTEROP_V3(ClassElementSetOrigEnumMember, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_ClassElementIsPrivateElementConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassElementIsPrivateElementConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassElementIsPrivateElementConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_ClassElementDecoratorsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ClassElementDecoratorsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(ClassElementDecoratorsConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_ClassElementIsComputedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassElementIsComputedConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassElementIsComputedConst, KBoolean, KNativePointer, KNativePointer); + +void impl_ClassElementAddDecorator(KNativePointer context, KNativePointer receiver, KNativePointer decorator) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _decorator = reinterpret_cast(decorator); + GetImpl()->ClassElementAddDecorator(_context, _receiver, _decorator); + return ; +} +KOALA_INTEROP_V3(ClassElementAddDecorator, KNativePointer, KNativePointer, KNativePointer); + +KInt impl_ClassElementToPrivateFieldKindConst(KNativePointer context, KNativePointer receiver, KBoolean isStatic) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _isStatic = static_cast(isStatic); + auto result = GetImpl()->ClassElementToPrivateFieldKindConst(_context, _receiver, _isStatic); + return result; +} +KOALA_INTEROP_3(ClassElementToPrivateFieldKindConst, KInt, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_CreateTSImportType(KNativePointer context, KNativePointer param, KNativePointer typeParams, KNativePointer qualifier, KBoolean isTypeof) +{ + const auto _context = reinterpret_cast(context); + const auto _param = reinterpret_cast(param); + const auto _typeParams = reinterpret_cast(typeParams); + const auto _qualifier = reinterpret_cast(qualifier); + const auto _isTypeof = static_cast(isTypeof); + auto result = GetImpl()->CreateTSImportType(_context, _param, _typeParams, _qualifier, _isTypeof); + return result; +} +KOALA_INTEROP_5(CreateTSImportType, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_UpdateTSImportType(KNativePointer context, KNativePointer original, KNativePointer param, KNativePointer typeParams, KNativePointer qualifier, KBoolean isTypeof) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _param = reinterpret_cast(param); + const auto _typeParams = reinterpret_cast(typeParams); + const auto _qualifier = reinterpret_cast(qualifier); + const auto _isTypeof = static_cast(isTypeof); + auto result = GetImpl()->UpdateTSImportType(_context, _original, _param, _typeParams, _qualifier, _isTypeof); + return result; +} +KOALA_INTEROP_6(UpdateTSImportType, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_TSImportTypeParamConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSImportTypeParamConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSImportTypeParamConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSImportTypeTypeParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSImportTypeTypeParamsConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSImportTypeTypeParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSImportTypeQualifierConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSImportTypeQualifierConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSImportTypeQualifierConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_TSImportTypeIsTypeofConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSImportTypeIsTypeofConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSImportTypeIsTypeofConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTaggedTemplateExpression(KNativePointer context, KNativePointer tag, KNativePointer quasi, KNativePointer typeParams) +{ + const auto _context = reinterpret_cast(context); + const auto _tag = reinterpret_cast(tag); + const auto _quasi = reinterpret_cast(quasi); + const auto _typeParams = reinterpret_cast(typeParams); + auto result = GetImpl()->CreateTaggedTemplateExpression(_context, _tag, _quasi, _typeParams); + return result; +} +KOALA_INTEROP_4(CreateTaggedTemplateExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTaggedTemplateExpression(KNativePointer context, KNativePointer original, KNativePointer tag, KNativePointer quasi, KNativePointer typeParams) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _tag = reinterpret_cast(tag); + const auto _quasi = reinterpret_cast(quasi); + const auto _typeParams = reinterpret_cast(typeParams); + auto result = GetImpl()->UpdateTaggedTemplateExpression(_context, _original, _tag, _quasi, _typeParams); + return result; +} +KOALA_INTEROP_5(UpdateTaggedTemplateExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TaggedTemplateExpressionTagConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TaggedTemplateExpressionTagConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TaggedTemplateExpressionTagConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TaggedTemplateExpressionQuasiConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TaggedTemplateExpressionQuasiConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TaggedTemplateExpressionQuasiConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TaggedTemplateExpressionTypeParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TaggedTemplateExpressionTypeParamsConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TaggedTemplateExpressionTypeParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateFunctionDeclaration(KNativePointer context, KNativePointer func, KNativePointerArray annotations, KUInt annotationsSequenceLength, KBoolean isAnonymous) +{ + const auto _context = reinterpret_cast(context); + const auto _func = reinterpret_cast(func); + const auto _annotations = reinterpret_cast(annotations); + const auto _annotationsSequenceLength = static_cast(annotationsSequenceLength); + const auto _isAnonymous = static_cast(isAnonymous); + auto result = GetImpl()->CreateFunctionDeclaration(_context, _func, _annotations, _annotationsSequenceLength, _isAnonymous); + return result; +} +KOALA_INTEROP_5(CreateFunctionDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KBoolean); + +KNativePointer impl_UpdateFunctionDeclaration(KNativePointer context, KNativePointer original, KNativePointer func, KNativePointerArray annotations, KUInt annotationsSequenceLength, KBoolean isAnonymous) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _func = reinterpret_cast(func); + const auto _annotations = reinterpret_cast(annotations); + const auto _annotationsSequenceLength = static_cast(annotationsSequenceLength); + const auto _isAnonymous = static_cast(isAnonymous); + auto result = GetImpl()->UpdateFunctionDeclaration(_context, _original, _func, _annotations, _annotationsSequenceLength, _isAnonymous); + return result; +} +KOALA_INTEROP_6(UpdateFunctionDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KBoolean); + +KNativePointer impl_CreateFunctionDeclaration1(KNativePointer context, KNativePointer func, KBoolean isAnonymous) +{ + const auto _context = reinterpret_cast(context); + const auto _func = reinterpret_cast(func); + const auto _isAnonymous = static_cast(isAnonymous); + auto result = GetImpl()->CreateFunctionDeclaration1(_context, _func, _isAnonymous); + return result; +} +KOALA_INTEROP_3(CreateFunctionDeclaration1, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_UpdateFunctionDeclaration1(KNativePointer context, KNativePointer original, KNativePointer func, KBoolean isAnonymous) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _func = reinterpret_cast(func); + const auto _isAnonymous = static_cast(isAnonymous); + auto result = GetImpl()->UpdateFunctionDeclaration1(_context, _original, _func, _isAnonymous); + return result; +} +KOALA_INTEROP_4(UpdateFunctionDeclaration1, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_FunctionDeclarationFunction(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->FunctionDeclarationFunction(_context, _receiver); + return result; +} +KOALA_INTEROP_2(FunctionDeclarationFunction, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_FunctionDeclarationIsAnonymousConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->FunctionDeclarationIsAnonymousConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(FunctionDeclarationIsAnonymousConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_FunctionDeclarationFunctionConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->FunctionDeclarationFunctionConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(FunctionDeclarationFunctionConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_FunctionDeclarationAnnotations(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->FunctionDeclarationAnnotations(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(FunctionDeclarationAnnotations, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_FunctionDeclarationAnnotationsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->FunctionDeclarationAnnotationsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(FunctionDeclarationAnnotationsConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_FunctionDeclarationSetAnnotations(KNativePointer context, KNativePointer receiver, KNativePointerArray annotations, KUInt annotationsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _annotations = reinterpret_cast(annotations); + const auto _annotationsSequenceLength = static_cast(annotationsSequenceLength); + GetImpl()->FunctionDeclarationSetAnnotations(_context, _receiver, _annotations, _annotationsSequenceLength); + return ; +} +KOALA_INTEROP_V4(FunctionDeclarationSetAnnotations, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_CreateETSTypeReference(KNativePointer context, KNativePointer part) +{ + const auto _context = reinterpret_cast(context); + const auto _part = reinterpret_cast(part); + auto result = GetImpl()->CreateETSTypeReference(_context, _part); + return result; +} +KOALA_INTEROP_2(CreateETSTypeReference, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateETSTypeReference(KNativePointer context, KNativePointer original, KNativePointer part) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _part = reinterpret_cast(part); + auto result = GetImpl()->UpdateETSTypeReference(_context, _original, _part); + return result; +} +KOALA_INTEROP_3(UpdateETSTypeReference, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSTypeReferencePart(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSTypeReferencePart(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSTypeReferencePart, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSTypeReferencePartConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSTypeReferencePartConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ETSTypeReferencePartConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSTypeReferenceBaseNameConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSTypeReferenceBaseNameConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ETSTypeReferenceBaseNameConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSTypeReference(KNativePointer context, KNativePointer typeName, KNativePointer typeParams) +{ + const auto _context = reinterpret_cast(context); + const auto _typeName = reinterpret_cast(typeName); + const auto _typeParams = reinterpret_cast(typeParams); + auto result = GetImpl()->CreateTSTypeReference(_context, _typeName, _typeParams); + return result; +} +KOALA_INTEROP_3(CreateTSTypeReference, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSTypeReference(KNativePointer context, KNativePointer original, KNativePointer typeName, KNativePointer typeParams) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _typeName = reinterpret_cast(typeName); + const auto _typeParams = reinterpret_cast(typeParams); + auto result = GetImpl()->UpdateTSTypeReference(_context, _original, _typeName, _typeParams); + return result; +} +KOALA_INTEROP_4(UpdateTSTypeReference, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSTypeReferenceTypeParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSTypeReferenceTypeParamsConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSTypeReferenceTypeParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSTypeReferenceTypeNameConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSTypeReferenceTypeNameConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSTypeReferenceTypeNameConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSTypeReferenceBaseNameConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSTypeReferenceBaseNameConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSTypeReferenceBaseNameConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateNamedType(KNativePointer context, KNativePointer name) +{ + const auto _context = reinterpret_cast(context); + const auto _name = reinterpret_cast(name); + auto result = GetImpl()->CreateNamedType(_context, _name); + return result; +} +KOALA_INTEROP_2(CreateNamedType, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateNamedType(KNativePointer context, KNativePointer original, KNativePointer name) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _name = reinterpret_cast(name); + auto result = GetImpl()->UpdateNamedType(_context, _original, _name); + return result; +} +KOALA_INTEROP_3(UpdateNamedType, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_NamedTypeNameConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->NamedTypeNameConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(NamedTypeNameConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_NamedTypeTypeParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->NamedTypeTypeParamsConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(NamedTypeTypeParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_NamedTypeIsNullableConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->NamedTypeIsNullableConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(NamedTypeIsNullableConst, KBoolean, KNativePointer, KNativePointer); + +void impl_NamedTypeSetNullable(KNativePointer context, KNativePointer receiver, KBoolean nullable) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _nullable = static_cast(nullable); + GetImpl()->NamedTypeSetNullable(_context, _receiver, _nullable); + return ; +} +KOALA_INTEROP_V3(NamedTypeSetNullable, KNativePointer, KNativePointer, KBoolean); + +void impl_NamedTypeSetNext(KNativePointer context, KNativePointer receiver, KNativePointer next) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _next = reinterpret_cast(next); + GetImpl()->NamedTypeSetNext(_context, _receiver, _next); + return ; +} +KOALA_INTEROP_V3(NamedTypeSetNext, KNativePointer, KNativePointer, KNativePointer); + +void impl_NamedTypeSetTypeParams(KNativePointer context, KNativePointer receiver, KNativePointer typeParams) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _typeParams = reinterpret_cast(typeParams); + GetImpl()->NamedTypeSetTypeParams(_context, _receiver, _typeParams); + return ; +} +KOALA_INTEROP_V3(NamedTypeSetTypeParams, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSFunctionType(KNativePointer context, KNativePointer signature) +{ + const auto _context = reinterpret_cast(context); + const auto _signature = reinterpret_cast(signature); + auto result = GetImpl()->CreateTSFunctionType(_context, _signature); + return result; +} +KOALA_INTEROP_2(CreateTSFunctionType, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSFunctionType(KNativePointer context, KNativePointer original, KNativePointer signature) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _signature = reinterpret_cast(signature); + auto result = GetImpl()->UpdateTSFunctionType(_context, _original, _signature); + return result; +} +KOALA_INTEROP_3(UpdateTSFunctionType, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSFunctionTypeTypeParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSFunctionTypeTypeParamsConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSFunctionTypeTypeParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSFunctionTypeTypeParams(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSFunctionTypeTypeParams(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSFunctionTypeTypeParams, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSFunctionTypeParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSFunctionTypeParamsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSFunctionTypeParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSFunctionTypeReturnTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSFunctionTypeReturnTypeConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSFunctionTypeReturnTypeConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSFunctionTypeReturnType(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSFunctionTypeReturnType(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSFunctionTypeReturnType, KNativePointer, KNativePointer, KNativePointer); + +void impl_TSFunctionTypeSetNullable(KNativePointer context, KNativePointer receiver, KBoolean nullable) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _nullable = static_cast(nullable); + GetImpl()->TSFunctionTypeSetNullable(_context, _receiver, _nullable); + return ; +} +KOALA_INTEROP_V3(TSFunctionTypeSetNullable, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_CreateTemplateElement(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateTemplateElement(_context); + return result; +} +KOALA_INTEROP_1(CreateTemplateElement, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTemplateElement(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateTemplateElement(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateTemplateElement, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTemplateElement1(KNativePointer context, KStringPtr& raw, KStringPtr& cooked) +{ + const auto _context = reinterpret_cast(context); + const auto _raw = getStringCopy(raw); + const auto _cooked = getStringCopy(cooked); + auto result = GetImpl()->CreateTemplateElement1(_context, _raw, _cooked); + return result; +} +KOALA_INTEROP_3(CreateTemplateElement1, KNativePointer, KNativePointer, KStringPtr, KStringPtr); + +KNativePointer impl_UpdateTemplateElement1(KNativePointer context, KNativePointer original, KStringPtr& raw, KStringPtr& cooked) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _raw = getStringCopy(raw); + const auto _cooked = getStringCopy(cooked); + auto result = GetImpl()->UpdateTemplateElement1(_context, _original, _raw, _cooked); + return result; +} +KOALA_INTEROP_4(UpdateTemplateElement1, KNativePointer, KNativePointer, KNativePointer, KStringPtr, KStringPtr); + +KNativePointer impl_TemplateElementRawConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TemplateElementRawConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(TemplateElementRawConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TemplateElementCookedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TemplateElementCookedConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(TemplateElementCookedConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSInterfaceDeclaration(KNativePointer context, KNativePointerArray _extends, KUInt _extendsSequenceLength, KNativePointer id, KNativePointer typeParams, KNativePointer body, KBoolean isStatic, KBoolean isExternal) +{ + const auto _context = reinterpret_cast(context); + const auto __extends = reinterpret_cast(_extends); + const auto __extendsSequenceLength = static_cast(_extendsSequenceLength); + const auto _id = reinterpret_cast(id); + const auto _typeParams = reinterpret_cast(typeParams); + const auto _body = reinterpret_cast(body); + const auto _isStatic = static_cast(isStatic); + const auto _isExternal = static_cast(isExternal); + auto result = GetImpl()->CreateTSInterfaceDeclaration(_context, __extends, __extendsSequenceLength, _id, _typeParams, _body, _isStatic, _isExternal); + return result; +} +KOALA_INTEROP_8(CreateTSInterfaceDeclaration, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KNativePointer, KNativePointer, KNativePointer, KBoolean, KBoolean); + +KNativePointer impl_UpdateTSInterfaceDeclaration(KNativePointer context, KNativePointer original, KNativePointerArray _extends, KUInt _extendsSequenceLength, KNativePointer id, KNativePointer typeParams, KNativePointer body, KBoolean isStatic, KBoolean isExternal) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto __extends = reinterpret_cast(_extends); + const auto __extendsSequenceLength = static_cast(_extendsSequenceLength); + const auto _id = reinterpret_cast(id); + const auto _typeParams = reinterpret_cast(typeParams); + const auto _body = reinterpret_cast(body); + const auto _isStatic = static_cast(isStatic); + const auto _isExternal = static_cast(isExternal); + auto result = GetImpl()->UpdateTSInterfaceDeclaration(_context, _original, __extends, __extendsSequenceLength, _id, _typeParams, _body, _isStatic, _isExternal); + return result; +} +KOALA_INTEROP_9(UpdateTSInterfaceDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KNativePointer, KNativePointer, KNativePointer, KBoolean, KBoolean); + +KNativePointer impl_TSInterfaceDeclarationBody(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSInterfaceDeclarationBody(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSInterfaceDeclarationBody, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSInterfaceDeclarationBodyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSInterfaceDeclarationBodyConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSInterfaceDeclarationBodyConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSInterfaceDeclarationId(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSInterfaceDeclarationId(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSInterfaceDeclarationId, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSInterfaceDeclarationIdConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSInterfaceDeclarationIdConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSInterfaceDeclarationIdConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSInterfaceDeclarationInternalNameConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSInterfaceDeclarationInternalNameConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(TSInterfaceDeclarationInternalNameConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_TSInterfaceDeclarationSetInternalName(KNativePointer context, KNativePointer receiver, KStringPtr& internalName) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _internalName = getStringCopy(internalName); + GetImpl()->TSInterfaceDeclarationSetInternalName(_context, _receiver, _internalName); + return ; +} +KOALA_INTEROP_V3(TSInterfaceDeclarationSetInternalName, KNativePointer, KNativePointer, KStringPtr); + +KBoolean impl_TSInterfaceDeclarationIsStaticConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSInterfaceDeclarationIsStaticConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSInterfaceDeclarationIsStaticConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_TSInterfaceDeclarationIsFromExternalConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSInterfaceDeclarationIsFromExternalConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSInterfaceDeclarationIsFromExternalConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_TSInterfaceDeclarationTypeParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSInterfaceDeclarationTypeParamsConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSInterfaceDeclarationTypeParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSInterfaceDeclarationTypeParams(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSInterfaceDeclarationTypeParams(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSInterfaceDeclarationTypeParams, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSInterfaceDeclarationExtends(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSInterfaceDeclarationExtends(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSInterfaceDeclarationExtends, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSInterfaceDeclarationExtendsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSInterfaceDeclarationExtendsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSInterfaceDeclarationExtendsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSInterfaceDeclarationDecoratorsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSInterfaceDeclarationDecoratorsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSInterfaceDeclarationDecoratorsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSInterfaceDeclarationGetAnonClass(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSInterfaceDeclarationGetAnonClass(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSInterfaceDeclarationGetAnonClass, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSInterfaceDeclarationGetAnonClassConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSInterfaceDeclarationGetAnonClassConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSInterfaceDeclarationGetAnonClassConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_TSInterfaceDeclarationSetAnonClass(KNativePointer context, KNativePointer receiver, KNativePointer anonClass) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _anonClass = reinterpret_cast(anonClass); + GetImpl()->TSInterfaceDeclarationSetAnonClass(_context, _receiver, _anonClass); + return ; +} +KOALA_INTEROP_V3(TSInterfaceDeclarationSetAnonClass, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSInterfaceDeclarationAnnotations(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSInterfaceDeclarationAnnotations(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSInterfaceDeclarationAnnotations, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSInterfaceDeclarationAnnotationsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSInterfaceDeclarationAnnotationsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSInterfaceDeclarationAnnotationsConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_TSInterfaceDeclarationSetAnnotations(KNativePointer context, KNativePointer receiver, KNativePointerArray annotations, KUInt annotationsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _annotations = reinterpret_cast(annotations); + const auto _annotationsSequenceLength = static_cast(annotationsSequenceLength); + GetImpl()->TSInterfaceDeclarationSetAnnotations(_context, _receiver, _annotations, _annotationsSequenceLength); + return ; +} +KOALA_INTEROP_V4(TSInterfaceDeclarationSetAnnotations, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_CreateVariableDeclaration(KNativePointer context, KInt kind, KNativePointerArray declarators, KUInt declaratorsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _kind = static_cast(kind); + const auto _declarators = reinterpret_cast(declarators); + const auto _declaratorsSequenceLength = static_cast(declaratorsSequenceLength); + auto result = GetImpl()->CreateVariableDeclaration(_context, _kind, _declarators, _declaratorsSequenceLength); + return result; +} +KOALA_INTEROP_4(CreateVariableDeclaration, KNativePointer, KNativePointer, KInt, KNativePointerArray, KUInt); + +KNativePointer impl_UpdateVariableDeclaration(KNativePointer context, KNativePointer original, KInt kind, KNativePointerArray declarators, KUInt declaratorsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _kind = static_cast(kind); + const auto _declarators = reinterpret_cast(declarators); + const auto _declaratorsSequenceLength = static_cast(declaratorsSequenceLength); + auto result = GetImpl()->UpdateVariableDeclaration(_context, _original, _kind, _declarators, _declaratorsSequenceLength); + return result; +} +KOALA_INTEROP_5(UpdateVariableDeclaration, KNativePointer, KNativePointer, KNativePointer, KInt, KNativePointerArray, KUInt); + +KNativePointer impl_VariableDeclarationDeclaratorsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->VariableDeclarationDeclaratorsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(VariableDeclarationDeclaratorsConst, KNativePointer, KNativePointer, KNativePointer); + +KInt impl_VariableDeclarationKindConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->VariableDeclarationKindConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(VariableDeclarationKindConst, KInt, KNativePointer, KNativePointer); + +KNativePointer impl_VariableDeclarationDecoratorsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->VariableDeclarationDecoratorsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(VariableDeclarationDecoratorsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_VariableDeclarationGetDeclaratorByNameConst(KNativePointer context, KNativePointer receiver, KStringPtr& name) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _name = getStringCopy(name); + auto result = GetImpl()->VariableDeclarationGetDeclaratorByNameConst(_context, _receiver, _name); + return (void*)result; +} +KOALA_INTEROP_3(VariableDeclarationGetDeclaratorByNameConst, KNativePointer, KNativePointer, KNativePointer, KStringPtr); + +KNativePointer impl_VariableDeclarationAnnotations(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->VariableDeclarationAnnotations(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(VariableDeclarationAnnotations, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_VariableDeclarationAnnotationsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->VariableDeclarationAnnotationsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(VariableDeclarationAnnotationsConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_VariableDeclarationSetAnnotations(KNativePointer context, KNativePointer receiver, KNativePointerArray annotations, KUInt annotationsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _annotations = reinterpret_cast(annotations); + const auto _annotationsSequenceLength = static_cast(annotationsSequenceLength); + GetImpl()->VariableDeclarationSetAnnotations(_context, _receiver, _annotations, _annotationsSequenceLength); + return ; +} +KOALA_INTEROP_V4(VariableDeclarationSetAnnotations, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_CreateUndefinedLiteral(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateUndefinedLiteral(_context); + return result; +} +KOALA_INTEROP_1(CreateUndefinedLiteral, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateUndefinedLiteral(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateUndefinedLiteral(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateUndefinedLiteral, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateMemberExpression(KNativePointer context, KNativePointer object_arg, KNativePointer property, KInt kind, KBoolean computed, KBoolean optional_arg) +{ + const auto _context = reinterpret_cast(context); + const auto _object_arg = reinterpret_cast(object_arg); + const auto _property = reinterpret_cast(property); + const auto _kind = static_cast(kind); + const auto _computed = static_cast(computed); + const auto _optional_arg = static_cast(optional_arg); + auto result = GetImpl()->CreateMemberExpression(_context, _object_arg, _property, _kind, _computed, _optional_arg); + return result; +} +KOALA_INTEROP_6(CreateMemberExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KInt, KBoolean, KBoolean); + +KNativePointer impl_UpdateMemberExpression(KNativePointer context, KNativePointer original, KNativePointer object_arg, KNativePointer property, KInt kind, KBoolean computed, KBoolean optional_arg) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _object_arg = reinterpret_cast(object_arg); + const auto _property = reinterpret_cast(property); + const auto _kind = static_cast(kind); + const auto _computed = static_cast(computed); + const auto _optional_arg = static_cast(optional_arg); + auto result = GetImpl()->UpdateMemberExpression(_context, _original, _object_arg, _property, _kind, _computed, _optional_arg); + return result; +} +KOALA_INTEROP_7(UpdateMemberExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KInt, KBoolean, KBoolean); + +KNativePointer impl_MemberExpressionObject(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->MemberExpressionObject(_context, _receiver); + return result; +} +KOALA_INTEROP_2(MemberExpressionObject, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_MemberExpressionObjectConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->MemberExpressionObjectConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(MemberExpressionObjectConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_MemberExpressionSetObject(KNativePointer context, KNativePointer receiver, KNativePointer object_arg) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _object_arg = reinterpret_cast(object_arg); + GetImpl()->MemberExpressionSetObject(_context, _receiver, _object_arg); + return ; +} +KOALA_INTEROP_V3(MemberExpressionSetObject, KNativePointer, KNativePointer, KNativePointer); + +void impl_MemberExpressionSetProperty(KNativePointer context, KNativePointer receiver, KNativePointer prop) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _prop = reinterpret_cast(prop); + GetImpl()->MemberExpressionSetProperty(_context, _receiver, _prop); + return ; +} +KOALA_INTEROP_V3(MemberExpressionSetProperty, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_MemberExpressionProperty(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->MemberExpressionProperty(_context, _receiver); + return result; +} +KOALA_INTEROP_2(MemberExpressionProperty, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_MemberExpressionPropertyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->MemberExpressionPropertyConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(MemberExpressionPropertyConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_MemberExpressionIsComputedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->MemberExpressionIsComputedConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(MemberExpressionIsComputedConst, KBoolean, KNativePointer, KNativePointer); + +KInt impl_MemberExpressionKindConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->MemberExpressionKindConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(MemberExpressionKindConst, KInt, KNativePointer, KNativePointer); + +void impl_MemberExpressionAddMemberKind(KNativePointer context, KNativePointer receiver, KInt kind) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _kind = static_cast(kind); + GetImpl()->MemberExpressionAddMemberKind(_context, _receiver, _kind); + return ; +} +KOALA_INTEROP_V3(MemberExpressionAddMemberKind, KNativePointer, KNativePointer, KInt); + +KBoolean impl_MemberExpressionHasMemberKindConst(KNativePointer context, KNativePointer receiver, KInt kind) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _kind = static_cast(kind); + auto result = GetImpl()->MemberExpressionHasMemberKindConst(_context, _receiver, _kind); + return result; +} +KOALA_INTEROP_3(MemberExpressionHasMemberKindConst, KBoolean, KNativePointer, KNativePointer, KInt); + +void impl_MemberExpressionRemoveMemberKind(KNativePointer context, KNativePointer receiver, KInt kind) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _kind = static_cast(kind); + GetImpl()->MemberExpressionRemoveMemberKind(_context, _receiver, _kind); + return ; +} +KOALA_INTEROP_V3(MemberExpressionRemoveMemberKind, KNativePointer, KNativePointer, KInt); + +KNativePointer impl_MemberExpressionExtensionAccessorTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->MemberExpressionExtensionAccessorTypeConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(MemberExpressionExtensionAccessorTypeConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_MemberExpressionIsIgnoreBoxConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->MemberExpressionIsIgnoreBoxConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(MemberExpressionIsIgnoreBoxConst, KBoolean, KNativePointer, KNativePointer); + +void impl_MemberExpressionSetIgnoreBox(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->MemberExpressionSetIgnoreBox(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(MemberExpressionSetIgnoreBox, KNativePointer, KNativePointer); + +KBoolean impl_MemberExpressionIsPrivateReferenceConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->MemberExpressionIsPrivateReferenceConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(MemberExpressionIsPrivateReferenceConst, KBoolean, KNativePointer, KNativePointer); + +void impl_MemberExpressionCompileToRegConst(KNativePointer context, KNativePointer receiver, KNativePointer pg, KNativePointer objReg) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _pg = reinterpret_cast(pg); + const auto _objReg = reinterpret_cast(objReg); + GetImpl()->MemberExpressionCompileToRegConst(_context, _receiver, _pg, _objReg); + return ; +} +KOALA_INTEROP_V4(MemberExpressionCompileToRegConst, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +void impl_MemberExpressionCompileToRegsConst(KNativePointer context, KNativePointer receiver, KNativePointer pg, KNativePointer object_arg, KNativePointer property) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _pg = reinterpret_cast(pg); + const auto _object_arg = reinterpret_cast(object_arg); + const auto _property = reinterpret_cast(property); + GetImpl()->MemberExpressionCompileToRegsConst(_context, _receiver, _pg, _object_arg, _property); + return ; +} +KOALA_INTEROP_V5(MemberExpressionCompileToRegsConst, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSClassImplements(KNativePointer context, KNativePointer expression, KNativePointer typeParameters) +{ + const auto _context = reinterpret_cast(context); + const auto _expression = reinterpret_cast(expression); + const auto _typeParameters = reinterpret_cast(typeParameters); + auto result = GetImpl()->CreateTSClassImplements(_context, _expression, _typeParameters); + return result; +} +KOALA_INTEROP_3(CreateTSClassImplements, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSClassImplements(KNativePointer context, KNativePointer original, KNativePointer expression, KNativePointer typeParameters) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _expression = reinterpret_cast(expression); + const auto _typeParameters = reinterpret_cast(typeParameters); + auto result = GetImpl()->UpdateTSClassImplements(_context, _original, _expression, _typeParameters); + return result; +} +KOALA_INTEROP_4(UpdateTSClassImplements, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSClassImplements1(KNativePointer context, KNativePointer expression) +{ + const auto _context = reinterpret_cast(context); + const auto _expression = reinterpret_cast(expression); + auto result = GetImpl()->CreateTSClassImplements1(_context, _expression); + return result; +} +KOALA_INTEROP_2(CreateTSClassImplements1, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSClassImplements1(KNativePointer context, KNativePointer original, KNativePointer expression) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _expression = reinterpret_cast(expression); + auto result = GetImpl()->UpdateTSClassImplements1(_context, _original, _expression); + return result; +} +KOALA_INTEROP_3(UpdateTSClassImplements1, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSClassImplementsExpr(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSClassImplementsExpr(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSClassImplementsExpr, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSClassImplementsExprConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSClassImplementsExprConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSClassImplementsExprConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSClassImplementsTypeParametersConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSClassImplementsTypeParametersConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSClassImplementsTypeParametersConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSObjectKeyword(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateTSObjectKeyword(_context); + return result; +} +KOALA_INTEROP_1(CreateTSObjectKeyword, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSObjectKeyword(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateTSObjectKeyword(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateTSObjectKeyword, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateETSUnionType(KNativePointer context, KNativePointerArray types, KUInt typesSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _types = reinterpret_cast(types); + const auto _typesSequenceLength = static_cast(typesSequenceLength); + auto result = GetImpl()->CreateETSUnionTypeIr(_context, _types, _typesSequenceLength); + return result; +} +KOALA_INTEROP_3(CreateETSUnionType, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_UpdateETSUnionType(KNativePointer context, KNativePointer original, KNativePointerArray types, KUInt typesSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _types = reinterpret_cast(types); + const auto _typesSequenceLength = static_cast(typesSequenceLength); + auto result = GetImpl()->UpdateETSUnionTypeIr(_context, _original, _types, _typesSequenceLength); + return result; +} +KOALA_INTEROP_4(UpdateETSUnionType, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_ETSUnionTypeTypesConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ETSUnionTypeIrTypesConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(ETSUnionTypeTypesConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateETSKeyofType(KNativePointer context, KNativePointer type) +{ + const auto _context = reinterpret_cast(context); + const auto _type = reinterpret_cast(type); + auto result = GetImpl()->CreateETSKeyofType(_context, _type); + return result; +} +KOALA_INTEROP_2(CreateETSKeyofType, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateETSKeyofType(KNativePointer context, KNativePointer original, KNativePointer type) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _type = reinterpret_cast(type); + auto result = GetImpl()->UpdateETSKeyofType(_context, _original, _type); + return result; +} +KOALA_INTEROP_3(UpdateETSKeyofType, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSKeyofTypeGetTypeRefConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSKeyofTypeGetTypeRefConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ETSKeyofTypeGetTypeRefConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSPropertySignature(KNativePointer context, KNativePointer key, KNativePointer typeAnnotation, KBoolean computed, KBoolean optional_arg, KBoolean readonly_arg) +{ + const auto _context = reinterpret_cast(context); + const auto _key = reinterpret_cast(key); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + const auto _computed = static_cast(computed); + const auto _optional_arg = static_cast(optional_arg); + const auto _readonly_arg = static_cast(readonly_arg); + auto result = GetImpl()->CreateTSPropertySignature(_context, _key, _typeAnnotation, _computed, _optional_arg, _readonly_arg); + return result; +} +KOALA_INTEROP_6(CreateTSPropertySignature, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean, KBoolean, KBoolean); + +KNativePointer impl_UpdateTSPropertySignature(KNativePointer context, KNativePointer original, KNativePointer key, KNativePointer typeAnnotation, KBoolean computed, KBoolean optional_arg, KBoolean readonly_arg) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _key = reinterpret_cast(key); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + const auto _computed = static_cast(computed); + const auto _optional_arg = static_cast(optional_arg); + const auto _readonly_arg = static_cast(readonly_arg); + auto result = GetImpl()->UpdateTSPropertySignature(_context, _original, _key, _typeAnnotation, _computed, _optional_arg, _readonly_arg); + return result; +} +KOALA_INTEROP_7(UpdateTSPropertySignature, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean, KBoolean, KBoolean); + +KNativePointer impl_TSPropertySignatureKeyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSPropertySignatureKeyConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSPropertySignatureKeyConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSPropertySignatureKey(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSPropertySignatureKey(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSPropertySignatureKey, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_TSPropertySignatureComputedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSPropertySignatureComputedConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSPropertySignatureComputedConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_TSPropertySignatureOptionalConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSPropertySignatureOptionalConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSPropertySignatureOptionalConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_TSPropertySignatureReadonlyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSPropertySignatureReadonlyConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSPropertySignatureReadonlyConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_TSPropertySignatureTypeAnnotationConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSPropertySignatureTypeAnnotationConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSPropertySignatureTypeAnnotationConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_TSPropertySignatureSetTsTypeAnnotation(KNativePointer context, KNativePointer receiver, KNativePointer typeAnnotation) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + GetImpl()->TSPropertySignatureSetTsTypeAnnotation(_context, _receiver, _typeAnnotation); + return ; +} +KOALA_INTEROP_V3(TSPropertySignatureSetTsTypeAnnotation, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSConditionalType(KNativePointer context, KNativePointer checkType, KNativePointer extendsType, KNativePointer trueType, KNativePointer falseType) +{ + const auto _context = reinterpret_cast(context); + const auto _checkType = reinterpret_cast(checkType); + const auto _extendsType = reinterpret_cast(extendsType); + const auto _trueType = reinterpret_cast(trueType); + const auto _falseType = reinterpret_cast(falseType); + auto result = GetImpl()->CreateTSConditionalType(_context, _checkType, _extendsType, _trueType, _falseType); + return result; +} +KOALA_INTEROP_5(CreateTSConditionalType, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSConditionalType(KNativePointer context, KNativePointer original, KNativePointer checkType, KNativePointer extendsType, KNativePointer trueType, KNativePointer falseType) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _checkType = reinterpret_cast(checkType); + const auto _extendsType = reinterpret_cast(extendsType); + const auto _trueType = reinterpret_cast(trueType); + const auto _falseType = reinterpret_cast(falseType); + auto result = GetImpl()->UpdateTSConditionalType(_context, _original, _checkType, _extendsType, _trueType, _falseType); + return result; +} +KOALA_INTEROP_6(UpdateTSConditionalType, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSConditionalTypeCheckTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSConditionalTypeCheckTypeConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSConditionalTypeCheckTypeConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSConditionalTypeExtendsTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSConditionalTypeExtendsTypeConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSConditionalTypeExtendsTypeConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSConditionalTypeTrueTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSConditionalTypeTrueTypeConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSConditionalTypeTrueTypeConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSConditionalTypeFalseTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSConditionalTypeFalseTypeConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSConditionalTypeFalseTypeConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSLiteralType(KNativePointer context, KNativePointer literal) +{ + const auto _context = reinterpret_cast(context); + const auto _literal = reinterpret_cast(literal); + auto result = GetImpl()->CreateTSLiteralType(_context, _literal); + return result; +} +KOALA_INTEROP_2(CreateTSLiteralType, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSLiteralType(KNativePointer context, KNativePointer original, KNativePointer literal) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _literal = reinterpret_cast(literal); + auto result = GetImpl()->UpdateTSLiteralType(_context, _original, _literal); + return result; +} +KOALA_INTEROP_3(UpdateTSLiteralType, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSLiteralTypeLiteralConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSLiteralTypeLiteralConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSLiteralTypeLiteralConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSTypeAliasDeclaration(KNativePointer context, KNativePointer id, KNativePointer typeParams, KNativePointer typeAnnotation) +{ + const auto _context = reinterpret_cast(context); + const auto _id = reinterpret_cast(id); + const auto _typeParams = reinterpret_cast(typeParams); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + auto result = GetImpl()->CreateTSTypeAliasDeclaration(_context, _id, _typeParams, _typeAnnotation); + return result; +} +KOALA_INTEROP_4(CreateTSTypeAliasDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSTypeAliasDeclaration(KNativePointer context, KNativePointer original, KNativePointer id, KNativePointer typeParams, KNativePointer typeAnnotation) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _id = reinterpret_cast(id); + const auto _typeParams = reinterpret_cast(typeParams); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + auto result = GetImpl()->UpdateTSTypeAliasDeclaration(_context, _original, _id, _typeParams, _typeAnnotation); + return result; +} +KOALA_INTEROP_5(UpdateTSTypeAliasDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSTypeAliasDeclaration1(KNativePointer context, KNativePointer id) +{ + const auto _context = reinterpret_cast(context); + const auto _id = reinterpret_cast(id); + auto result = GetImpl()->CreateTSTypeAliasDeclaration1(_context, _id); + return result; +} +KOALA_INTEROP_2(CreateTSTypeAliasDeclaration1, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSTypeAliasDeclaration1(KNativePointer context, KNativePointer original, KNativePointer id) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _id = reinterpret_cast(id); + auto result = GetImpl()->UpdateTSTypeAliasDeclaration1(_context, _original, _id); + return result; +} +KOALA_INTEROP_3(UpdateTSTypeAliasDeclaration1, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSTypeAliasDeclarationId(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSTypeAliasDeclarationId(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSTypeAliasDeclarationId, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSTypeAliasDeclarationIdConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSTypeAliasDeclarationIdConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSTypeAliasDeclarationIdConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSTypeAliasDeclarationTypeParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSTypeAliasDeclarationTypeParamsConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSTypeAliasDeclarationTypeParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSTypeAliasDeclarationDecoratorsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSTypeAliasDeclarationDecoratorsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSTypeAliasDeclarationDecoratorsConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_TSTypeAliasDeclarationSetTypeParameters(KNativePointer context, KNativePointer receiver, KNativePointer typeParams) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _typeParams = reinterpret_cast(typeParams); + GetImpl()->TSTypeAliasDeclarationSetTypeParameters(_context, _receiver, _typeParams); + return ; +} +KOALA_INTEROP_V3(TSTypeAliasDeclarationSetTypeParameters, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSTypeAliasDeclarationAnnotations(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSTypeAliasDeclarationAnnotations(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSTypeAliasDeclarationAnnotations, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSTypeAliasDeclarationAnnotationsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSTypeAliasDeclarationAnnotationsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSTypeAliasDeclarationAnnotationsConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_TSTypeAliasDeclarationSetAnnotations(KNativePointer context, KNativePointer receiver, KNativePointerArray annotations, KUInt annotationsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _annotations = reinterpret_cast(annotations); + const auto _annotationsSequenceLength = static_cast(annotationsSequenceLength); + GetImpl()->TSTypeAliasDeclarationSetAnnotations(_context, _receiver, _annotations, _annotationsSequenceLength); + return ; +} +KOALA_INTEROP_V4(TSTypeAliasDeclarationSetAnnotations, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_TSTypeAliasDeclarationTypeAnnotationConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSTypeAliasDeclarationTypeAnnotationConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSTypeAliasDeclarationTypeAnnotationConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_TSTypeAliasDeclarationSetTsTypeAnnotation(KNativePointer context, KNativePointer receiver, KNativePointer typeAnnotation) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + GetImpl()->TSTypeAliasDeclarationSetTsTypeAnnotation(_context, _receiver, _typeAnnotation); + return ; +} +KOALA_INTEROP_V3(TSTypeAliasDeclarationSetTsTypeAnnotation, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateDebuggerStatement(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateDebuggerStatement(_context); + return result; +} +KOALA_INTEROP_1(CreateDebuggerStatement, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateDebuggerStatement(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateDebuggerStatement(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateDebuggerStatement, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateReturnStatement(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateReturnStatement(_context); + return result; +} +KOALA_INTEROP_1(CreateReturnStatement, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateReturnStatement(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateReturnStatement(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateReturnStatement, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateReturnStatement1(KNativePointer context, KNativePointer argument) +{ + const auto _context = reinterpret_cast(context); + const auto _argument = reinterpret_cast(argument); + auto result = GetImpl()->CreateReturnStatement1(_context, _argument); + return result; +} +KOALA_INTEROP_2(CreateReturnStatement1, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateReturnStatement1(KNativePointer context, KNativePointer original, KNativePointer argument) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _argument = reinterpret_cast(argument); + auto result = GetImpl()->UpdateReturnStatement1(_context, _original, _argument); + return result; +} +KOALA_INTEROP_3(UpdateReturnStatement1, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ReturnStatementArgument(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ReturnStatementArgument(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ReturnStatementArgument, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ReturnStatementArgumentConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ReturnStatementArgumentConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ReturnStatementArgumentConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_ReturnStatementSetArgument(KNativePointer context, KNativePointer receiver, KNativePointer arg) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _arg = reinterpret_cast(arg); + GetImpl()->ReturnStatementSetArgument(_context, _receiver, _arg); + return ; +} +KOALA_INTEROP_V3(ReturnStatementSetArgument, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_ReturnStatementIsAsyncImplReturnConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ReturnStatementIsAsyncImplReturnConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ReturnStatementIsAsyncImplReturnConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_CreateExportDefaultDeclaration(KNativePointer context, KNativePointer decl, KBoolean exportEquals) +{ + const auto _context = reinterpret_cast(context); + const auto _decl = reinterpret_cast(decl); + const auto _exportEquals = static_cast(exportEquals); + auto result = GetImpl()->CreateExportDefaultDeclaration(_context, _decl, _exportEquals); + return result; +} +KOALA_INTEROP_3(CreateExportDefaultDeclaration, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_UpdateExportDefaultDeclaration(KNativePointer context, KNativePointer original, KNativePointer decl, KBoolean exportEquals) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _decl = reinterpret_cast(decl); + const auto _exportEquals = static_cast(exportEquals); + auto result = GetImpl()->UpdateExportDefaultDeclaration(_context, _original, _decl, _exportEquals); + return result; +} +KOALA_INTEROP_4(UpdateExportDefaultDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_ExportDefaultDeclarationDecl(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ExportDefaultDeclarationDecl(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ExportDefaultDeclarationDecl, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ExportDefaultDeclarationDeclConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ExportDefaultDeclarationDeclConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ExportDefaultDeclarationDeclConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_ExportDefaultDeclarationIsExportEqualsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ExportDefaultDeclarationIsExportEqualsConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ExportDefaultDeclarationIsExportEqualsConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_CreateScriptFunction(KNativePointer context, KNativePointer databody, KNativePointer datasignature, KInt datafuncFlags, KInt dataflags) +{ + const auto _context = reinterpret_cast(context); + const auto _databody = reinterpret_cast(databody); + const auto _datasignature = reinterpret_cast(datasignature); + const auto _datafuncFlags = static_cast(datafuncFlags); + const auto _dataflags = static_cast(dataflags); + auto result = GetImpl()->CreateScriptFunction(_context, _databody, _datasignature, _datafuncFlags, _dataflags); + return result; +} +KOALA_INTEROP_5(CreateScriptFunction, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KInt, KInt); + +KNativePointer impl_UpdateScriptFunction(KNativePointer context, KNativePointer original, KNativePointer databody, KNativePointer datasignature, KInt datafuncFlags, KInt dataflags) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _databody = reinterpret_cast(databody); + const auto _datasignature = reinterpret_cast(datasignature); + const auto _datafuncFlags = static_cast(datafuncFlags); + const auto _dataflags = static_cast(dataflags); + auto result = GetImpl()->UpdateScriptFunction(_context, _original, _databody, _datasignature, _datafuncFlags, _dataflags); + return result; +} +KOALA_INTEROP_6(UpdateScriptFunction, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KInt, KInt); + +KNativePointer impl_ScriptFunctionIdConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionIdConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ScriptFunctionIdConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ScriptFunctionId(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionId(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionId, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ScriptFunctionParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ScriptFunctionParamsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(ScriptFunctionParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ScriptFunctionParams(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ScriptFunctionParams(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(ScriptFunctionParams, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ScriptFunctionReturnStatementsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ScriptFunctionReturnStatementsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(ScriptFunctionReturnStatementsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ScriptFunctionReturnStatements(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ScriptFunctionReturnStatements(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(ScriptFunctionReturnStatements, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ScriptFunctionTypeParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionTypeParamsConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ScriptFunctionTypeParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ScriptFunctionTypeParams(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionTypeParams(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionTypeParams, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ScriptFunctionBodyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionBodyConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ScriptFunctionBodyConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ScriptFunctionBody(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionBody(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionBody, KNativePointer, KNativePointer, KNativePointer); + +void impl_ScriptFunctionAddReturnStatement(KNativePointer context, KNativePointer receiver, KNativePointer returnStatement) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _returnStatement = reinterpret_cast(returnStatement); + GetImpl()->ScriptFunctionAddReturnStatement(_context, _receiver, _returnStatement); + return ; +} +KOALA_INTEROP_V3(ScriptFunctionAddReturnStatement, KNativePointer, KNativePointer, KNativePointer); + +void impl_ScriptFunctionSetBody(KNativePointer context, KNativePointer receiver, KNativePointer body) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _body = reinterpret_cast(body); + GetImpl()->ScriptFunctionSetBody(_context, _receiver, _body); + return ; +} +KOALA_INTEROP_V3(ScriptFunctionSetBody, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ScriptFunctionReturnTypeAnnotationConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionReturnTypeAnnotationConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ScriptFunctionReturnTypeAnnotationConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ScriptFunctionReturnTypeAnnotation(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionReturnTypeAnnotation(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionReturnTypeAnnotation, KNativePointer, KNativePointer, KNativePointer); + +void impl_ScriptFunctionSetReturnTypeAnnotation(KNativePointer context, KNativePointer receiver, KNativePointer node) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _node = reinterpret_cast(node); + GetImpl()->ScriptFunctionSetReturnTypeAnnotation(_context, _receiver, _node); + return ; +} +KOALA_INTEROP_V3(ScriptFunctionSetReturnTypeAnnotation, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionIsEntryPointConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionIsEntryPointConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionIsEntryPointConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionIsGeneratorConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionIsGeneratorConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionIsGeneratorConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionIsAsyncFuncConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionIsAsyncFuncConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionIsAsyncFuncConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionIsAsyncImplFuncConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionIsAsyncImplFuncConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionIsAsyncImplFuncConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionIsArrowConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionIsArrowConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionIsArrowConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionIsOverloadConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionIsOverloadConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionIsOverloadConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionIsExternalOverloadConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionIsExternalOverloadConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionIsExternalOverloadConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionIsConstructorConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionIsConstructorConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionIsConstructorConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionIsGetterConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionIsGetterConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionIsGetterConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionIsSetterConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionIsSetterConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionIsSetterConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionIsExtensionAccessorConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionIsExtensionAccessorConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionIsExtensionAccessorConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionIsMethodConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionIsMethodConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionIsMethodConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionIsProxyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionIsProxyConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionIsProxyConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionIsStaticBlockConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionIsStaticBlockConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionIsStaticBlockConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionIsEnumConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionIsEnumConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionIsEnumConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionIsHiddenConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionIsHiddenConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionIsHiddenConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionIsExternalConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionIsExternalConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionIsExternalConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionIsImplicitSuperCallNeededConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionIsImplicitSuperCallNeededConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionIsImplicitSuperCallNeededConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionHasBodyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionHasBodyConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionHasBodyConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionHasRestParameterConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionHasRestParameterConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionHasRestParameterConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionHasReturnStatementConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionHasReturnStatementConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionHasReturnStatementConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionHasThrowStatementConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionHasThrowStatementConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionHasThrowStatementConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionIsThrowingConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionIsThrowingConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionIsThrowingConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionIsRethrowingConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionIsRethrowingConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionIsRethrowingConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionIsDynamicConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionIsDynamicConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionIsDynamicConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionIsExtensionMethodConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionIsExtensionMethodConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionIsExtensionMethodConst, KBoolean, KNativePointer, KNativePointer); + +KInt impl_ScriptFunctionFlagsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionFlagsConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionFlagsConst, KInt, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionHasReceiverConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionHasReceiverConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionHasReceiverConst, KBoolean, KNativePointer, KNativePointer); + +void impl_ScriptFunctionSetIdent(KNativePointer context, KNativePointer receiver, KNativePointer id) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _id = reinterpret_cast(id); + GetImpl()->ScriptFunctionSetIdent(_context, _receiver, _id); + return ; +} +KOALA_INTEROP_V3(ScriptFunctionSetIdent, KNativePointer, KNativePointer, KNativePointer); + +void impl_ScriptFunctionAddFlag(KNativePointer context, KNativePointer receiver, KInt flags) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _flags = static_cast(flags); + GetImpl()->ScriptFunctionAddFlag(_context, _receiver, _flags); + return ; +} +KOALA_INTEROP_V3(ScriptFunctionAddFlag, KNativePointer, KNativePointer, KInt); + +void impl_ScriptFunctionClearFlag(KNativePointer context, KNativePointer receiver, KInt flags) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _flags = static_cast(flags); + GetImpl()->ScriptFunctionClearFlag(_context, _receiver, _flags); + return ; +} +KOALA_INTEROP_V3(ScriptFunctionClearFlag, KNativePointer, KNativePointer, KInt); + +void impl_ScriptFunctionAddModifier(KNativePointer context, KNativePointer receiver, KInt flags) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _flags = static_cast(flags); + GetImpl()->ScriptFunctionAddModifier(_context, _receiver, _flags); + return ; +} +KOALA_INTEROP_V3(ScriptFunctionAddModifier, KNativePointer, KNativePointer, KInt); + +KUInt impl_ScriptFunctionFormalParamsLengthConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionFormalParamsLengthConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionFormalParamsLengthConst, KUInt, KNativePointer, KNativePointer); + +KNativePointer impl_ScriptFunctionAnnotations(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ScriptFunctionAnnotations(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(ScriptFunctionAnnotations, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ScriptFunctionAnnotationsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ScriptFunctionAnnotationsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(ScriptFunctionAnnotationsConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_ScriptFunctionSetAnnotations(KNativePointer context, KNativePointer receiver, KNativePointerArray annotations, KUInt annotationsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _annotations = reinterpret_cast(annotations); + const auto _annotationsSequenceLength = static_cast(annotationsSequenceLength); + GetImpl()->ScriptFunctionSetAnnotations(_context, _receiver, _annotations, _annotationsSequenceLength); + return ; +} +KOALA_INTEROP_V4(ScriptFunctionSetAnnotations, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_CreateClassDefinition(KNativePointer context, KNativePointer ident, KNativePointer typeParams, KNativePointer superTypeParams, KNativePointerArray _implements, KUInt _implementsSequenceLength, KNativePointer ctor, KNativePointer superClass, KNativePointerArray body, KUInt bodySequenceLength, KInt modifiers, KInt flags) +{ + const auto _context = reinterpret_cast(context); + const auto _ident = reinterpret_cast(ident); + const auto _typeParams = reinterpret_cast(typeParams); + const auto _superTypeParams = reinterpret_cast(superTypeParams); + const auto __implements = reinterpret_cast(_implements); + const auto __implementsSequenceLength = static_cast(_implementsSequenceLength); + const auto _ctor = reinterpret_cast(ctor); + const auto _superClass = reinterpret_cast(superClass); + const auto _body = reinterpret_cast(body); + const auto _bodySequenceLength = static_cast(bodySequenceLength); + const auto _modifiers = static_cast(modifiers); + const auto _flags = static_cast(flags); + auto result = GetImpl()->CreateClassDefinition(_context, _ident, _typeParams, _superTypeParams, __implements, __implementsSequenceLength, _ctor, _superClass, _body, _bodySequenceLength, _modifiers, _flags); + return result; +} +KOALA_INTEROP_12(CreateClassDefinition, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KInt, KInt); + +KNativePointer impl_UpdateClassDefinition(KNativePointer context, KNativePointer original, KNativePointer ident, KNativePointer typeParams, KNativePointer superTypeParams, KNativePointerArray _implements, KUInt _implementsSequenceLength, KNativePointer ctor, KNativePointer superClass, KNativePointerArray body, KUInt bodySequenceLength, KInt modifiers, KInt flags) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _ident = reinterpret_cast(ident); + const auto _typeParams = reinterpret_cast(typeParams); + const auto _superTypeParams = reinterpret_cast(superTypeParams); + const auto __implements = reinterpret_cast(_implements); + const auto __implementsSequenceLength = static_cast(_implementsSequenceLength); + const auto _ctor = reinterpret_cast(ctor); + const auto _superClass = reinterpret_cast(superClass); + const auto _body = reinterpret_cast(body); + const auto _bodySequenceLength = static_cast(bodySequenceLength); + const auto _modifiers = static_cast(modifiers); + const auto _flags = static_cast(flags); + auto result = GetImpl()->UpdateClassDefinition(_context, _original, _ident, _typeParams, _superTypeParams, __implements, __implementsSequenceLength, _ctor, _superClass, _body, _bodySequenceLength, _modifiers, _flags); + return result; +} +KOALA_INTEROP_13(UpdateClassDefinition, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KInt, KInt); + +KNativePointer impl_CreateClassDefinition1(KNativePointer context, KNativePointer ident, KNativePointerArray body, KUInt bodySequenceLength, KInt modifiers, KInt flags) +{ + const auto _context = reinterpret_cast(context); + const auto _ident = reinterpret_cast(ident); + const auto _body = reinterpret_cast(body); + const auto _bodySequenceLength = static_cast(bodySequenceLength); + const auto _modifiers = static_cast(modifiers); + const auto _flags = static_cast(flags); + auto result = GetImpl()->CreateClassDefinition1(_context, _ident, _body, _bodySequenceLength, _modifiers, _flags); + return result; +} +KOALA_INTEROP_6(CreateClassDefinition1, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KInt, KInt); + +KNativePointer impl_UpdateClassDefinition1(KNativePointer context, KNativePointer original, KNativePointer ident, KNativePointerArray body, KUInt bodySequenceLength, KInt modifiers, KInt flags) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _ident = reinterpret_cast(ident); + const auto _body = reinterpret_cast(body); + const auto _bodySequenceLength = static_cast(bodySequenceLength); + const auto _modifiers = static_cast(modifiers); + const auto _flags = static_cast(flags); + auto result = GetImpl()->UpdateClassDefinition1(_context, _original, _ident, _body, _bodySequenceLength, _modifiers, _flags); + return result; +} +KOALA_INTEROP_7(UpdateClassDefinition1, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KInt, KInt); + +KNativePointer impl_CreateClassDefinition2(KNativePointer context, KNativePointer ident, KInt modifiers, KInt flags) +{ + const auto _context = reinterpret_cast(context); + const auto _ident = reinterpret_cast(ident); + const auto _modifiers = static_cast(modifiers); + const auto _flags = static_cast(flags); + auto result = GetImpl()->CreateClassDefinition2(_context, _ident, _modifiers, _flags); + return result; +} +KOALA_INTEROP_4(CreateClassDefinition2, KNativePointer, KNativePointer, KNativePointer, KInt, KInt); + +KNativePointer impl_UpdateClassDefinition2(KNativePointer context, KNativePointer original, KNativePointer ident, KInt modifiers, KInt flags) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _ident = reinterpret_cast(ident); + const auto _modifiers = static_cast(modifiers); + const auto _flags = static_cast(flags); + auto result = GetImpl()->UpdateClassDefinition2(_context, _original, _ident, _modifiers, _flags); + return result; +} +KOALA_INTEROP_5(UpdateClassDefinition2, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KInt, KInt); + +KNativePointer impl_ClassDefinitionIdentConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionIdentConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ClassDefinitionIdentConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassDefinitionIdent(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionIdent(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionIdent, KNativePointer, KNativePointer, KNativePointer); + +void impl_ClassDefinitionSetIdent(KNativePointer context, KNativePointer receiver, KNativePointer ident) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _ident = reinterpret_cast(ident); + GetImpl()->ClassDefinitionSetIdent(_context, _receiver, _ident); + return ; +} +KOALA_INTEROP_V3(ClassDefinitionSetIdent, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassDefinitionInternalNameConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionInternalNameConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(ClassDefinitionInternalNameConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_ClassDefinitionSetInternalName(KNativePointer context, KNativePointer receiver, KStringPtr& internalName) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _internalName = getStringCopy(internalName); + GetImpl()->ClassDefinitionSetInternalName(_context, _receiver, _internalName); + return ; +} +KOALA_INTEROP_V3(ClassDefinitionSetInternalName, KNativePointer, KNativePointer, KStringPtr); + +KNativePointer impl_ClassDefinitionSuper(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionSuper(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionSuper, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassDefinitionSuperConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionSuperConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ClassDefinitionSuperConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_ClassDefinitionSetSuper(KNativePointer context, KNativePointer receiver, KNativePointer superClass) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _superClass = reinterpret_cast(superClass); + GetImpl()->ClassDefinitionSetSuper(_context, _receiver, _superClass); + return ; +} +KOALA_INTEROP_V3(ClassDefinitionSetSuper, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_ClassDefinitionIsGlobalConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionIsGlobalConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionIsGlobalConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ClassDefinitionIsLocalConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionIsLocalConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionIsLocalConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ClassDefinitionIsExternConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionIsExternConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionIsExternConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ClassDefinitionIsFromExternalConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionIsFromExternalConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionIsFromExternalConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ClassDefinitionIsInnerConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionIsInnerConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionIsInnerConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ClassDefinitionIsGlobalInitializedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionIsGlobalInitializedConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionIsGlobalInitializedConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ClassDefinitionIsClassDefinitionCheckedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionIsClassDefinitionCheckedConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionIsClassDefinitionCheckedConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ClassDefinitionIsAnonymousConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionIsAnonymousConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionIsAnonymousConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ClassDefinitionIsIntEnumTransformedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionIsIntEnumTransformedConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionIsIntEnumTransformedConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ClassDefinitionIsStringEnumTransformedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionIsStringEnumTransformedConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionIsStringEnumTransformedConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ClassDefinitionIsEnumTransformedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionIsEnumTransformedConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionIsEnumTransformedConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ClassDefinitionIsNamespaceTransformedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionIsNamespaceTransformedConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionIsNamespaceTransformedConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ClassDefinitionIsFromStructConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionIsFromStructConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionIsFromStructConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ClassDefinitionIsModuleConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionIsModuleConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionIsModuleConst, KBoolean, KNativePointer, KNativePointer); + +void impl_ClassDefinitionSetGlobalInitialized(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->ClassDefinitionSetGlobalInitialized(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(ClassDefinitionSetGlobalInitialized, KNativePointer, KNativePointer); + +void impl_ClassDefinitionSetInnerModifier(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->ClassDefinitionSetInnerModifier(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(ClassDefinitionSetInnerModifier, KNativePointer, KNativePointer); + +void impl_ClassDefinitionSetClassDefinitionChecked(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->ClassDefinitionSetClassDefinitionChecked(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(ClassDefinitionSetClassDefinitionChecked, KNativePointer, KNativePointer); + +void impl_ClassDefinitionSetAnonymousModifier(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->ClassDefinitionSetAnonymousModifier(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(ClassDefinitionSetAnonymousModifier, KNativePointer, KNativePointer); + +void impl_ClassDefinitionSetNamespaceTransformed(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->ClassDefinitionSetNamespaceTransformed(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(ClassDefinitionSetNamespaceTransformed, KNativePointer, KNativePointer); + +void impl_ClassDefinitionSetFromStructModifier(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->ClassDefinitionSetFromStructModifier(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(ClassDefinitionSetFromStructModifier, KNativePointer, KNativePointer); + +KInt impl_ClassDefinitionModifiersConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionModifiersConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionModifiersConst, KInt, KNativePointer, KNativePointer); + +void impl_ClassDefinitionSetModifiers(KNativePointer context, KNativePointer receiver, KInt modifiers) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _modifiers = static_cast(modifiers); + GetImpl()->ClassDefinitionSetModifiers(_context, _receiver, _modifiers); + return ; +} +KOALA_INTEROP_V3(ClassDefinitionSetModifiers, KNativePointer, KNativePointer, KInt); + +void impl_ClassDefinitionAddProperties(KNativePointer context, KNativePointer receiver, KNativePointerArray body, KUInt bodySequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _body = reinterpret_cast(body); + const auto _bodySequenceLength = static_cast(bodySequenceLength); + GetImpl()->ClassDefinitionAddProperties(_context, _receiver, _body, _bodySequenceLength); + return ; +} +KOALA_INTEROP_V4(ClassDefinitionAddProperties, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_ClassDefinitionBody(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ClassDefinitionBody(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(ClassDefinitionBody, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassDefinitionBodyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ClassDefinitionBodyConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(ClassDefinitionBodyConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassDefinitionCtor(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionCtor(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionCtor, KNativePointer, KNativePointer, KNativePointer); + +void impl_ClassDefinitionSetCtor(KNativePointer context, KNativePointer receiver, KNativePointer ctor) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _ctor = reinterpret_cast(ctor); + GetImpl()->ClassDefinitionSetCtor(_context, _receiver, _ctor); + return ; +} +KOALA_INTEROP_V3(ClassDefinitionSetCtor, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassDefinitionImplements(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ClassDefinitionImplements(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(ClassDefinitionImplements, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassDefinitionImplementsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ClassDefinitionImplementsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(ClassDefinitionImplementsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassDefinitionTypeParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionTypeParamsConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ClassDefinitionTypeParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassDefinitionTypeParams(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionTypeParams(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionTypeParams, KNativePointer, KNativePointer, KNativePointer); + +void impl_ClassDefinitionSetTypeParams(KNativePointer context, KNativePointer receiver, KNativePointer typeParams) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _typeParams = reinterpret_cast(typeParams); + GetImpl()->ClassDefinitionSetTypeParams(_context, _receiver, _typeParams); + return ; +} +KOALA_INTEROP_V3(ClassDefinitionSetTypeParams, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassDefinitionSuperTypeParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionSuperTypeParamsConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ClassDefinitionSuperTypeParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassDefinitionSuperTypeParams(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionSuperTypeParams(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionSuperTypeParams, KNativePointer, KNativePointer, KNativePointer); + +KInt impl_ClassDefinitionLocalTypeCounter(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionLocalTypeCounter(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionLocalTypeCounter, KInt, KNativePointer, KNativePointer); + +KInt impl_ClassDefinitionLocalIndexConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionLocalIndexConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionLocalIndexConst, KInt, KNativePointer, KNativePointer); + +KNativePointer impl_ClassDefinitionLocalPrefixConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionLocalPrefixConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(ClassDefinitionLocalPrefixConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_ClassDefinitionSetOrigEnumDecl(KNativePointer context, KNativePointer receiver, KNativePointer enumDecl) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _enumDecl = reinterpret_cast(enumDecl); + GetImpl()->ClassDefinitionSetOrigEnumDecl(_context, _receiver, _enumDecl); + return ; +} +KOALA_INTEROP_V3(ClassDefinitionSetOrigEnumDecl, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassDefinitionOrigEnumDeclConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionOrigEnumDeclConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ClassDefinitionOrigEnumDeclConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassDefinitionGetAnonClass(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionGetAnonClass(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionGetAnonClass, KNativePointer, KNativePointer, KNativePointer); + +void impl_ClassDefinitionSetAnonClass(KNativePointer context, KNativePointer receiver, KNativePointer anonClass) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _anonClass = reinterpret_cast(anonClass); + GetImpl()->ClassDefinitionSetAnonClass(_context, _receiver, _anonClass); + return ; +} +KOALA_INTEROP_V3(ClassDefinitionSetAnonClass, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassDefinitionCtorConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionCtorConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ClassDefinitionCtorConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_ClassDefinitionHasPrivateMethodConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionHasPrivateMethodConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionHasPrivateMethodConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ClassDefinitionHasNativeMethodConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionHasNativeMethodConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionHasNativeMethodConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ClassDefinitionHasComputedInstanceFieldConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionHasComputedInstanceFieldConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionHasComputedInstanceFieldConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ClassDefinitionHasMatchingPrivateKeyConst(KNativePointer context, KNativePointer receiver, KStringPtr& name) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _name = getStringCopy(name); + auto result = GetImpl()->ClassDefinitionHasMatchingPrivateKeyConst(_context, _receiver, _name); + return result; +} +KOALA_INTEROP_3(ClassDefinitionHasMatchingPrivateKeyConst, KBoolean, KNativePointer, KNativePointer, KStringPtr); + +void impl_ClassDefinitionAddToExportedClasses(KNativePointer context, KNativePointer receiver, KNativePointer cls) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _cls = reinterpret_cast(cls); + GetImpl()->ClassDefinitionAddToExportedClasses(_context, _receiver, _cls); + return ; +} +KOALA_INTEROP_V3(ClassDefinitionAddToExportedClasses, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassDefinitionAnnotations(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ClassDefinitionAnnotations(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(ClassDefinitionAnnotations, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassDefinitionAnnotationsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ClassDefinitionAnnotationsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(ClassDefinitionAnnotationsConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_ClassDefinitionSetAnnotations(KNativePointer context, KNativePointer receiver, KNativePointerArray annotations, KUInt annotationsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _annotations = reinterpret_cast(annotations); + const auto _annotationsSequenceLength = static_cast(annotationsSequenceLength); + GetImpl()->ClassDefinitionSetAnnotations(_context, _receiver, _annotations, _annotationsSequenceLength); + return ; +} +KOALA_INTEROP_V4(ClassDefinitionSetAnnotations, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_CreateArrayExpression(KNativePointer context, KNativePointerArray elements, KUInt elementsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _elements = reinterpret_cast(elements); + const auto _elementsSequenceLength = static_cast(elementsSequenceLength); + auto result = GetImpl()->CreateArrayExpression(_context, _elements, _elementsSequenceLength); + return result; +} +KOALA_INTEROP_3(CreateArrayExpression, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_UpdateArrayExpression(KNativePointer context, KNativePointer original, KNativePointerArray elements, KUInt elementsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _elements = reinterpret_cast(elements); + const auto _elementsSequenceLength = static_cast(elementsSequenceLength); + auto result = GetImpl()->UpdateArrayExpression(_context, _original, _elements, _elementsSequenceLength); + return result; +} +KOALA_INTEROP_4(UpdateArrayExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_CreateArrayExpression1(KNativePointer context, KInt nodeType, KNativePointerArray elements, KUInt elementsSequenceLength, KBoolean trailingComma) +{ + const auto _context = reinterpret_cast(context); + const auto _nodeType = static_cast(nodeType); + const auto _elements = reinterpret_cast(elements); + const auto _elementsSequenceLength = static_cast(elementsSequenceLength); + const auto _trailingComma = static_cast(trailingComma); + auto result = GetImpl()->CreateArrayExpression1(_context, _nodeType, _elements, _elementsSequenceLength, _trailingComma); + return result; +} +KOALA_INTEROP_5(CreateArrayExpression1, KNativePointer, KNativePointer, KInt, KNativePointerArray, KUInt, KBoolean); + +KNativePointer impl_UpdateArrayExpression1(KNativePointer context, KNativePointer original, KInt nodeType, KNativePointerArray elements, KUInt elementsSequenceLength, KBoolean trailingComma) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _nodeType = static_cast(nodeType); + const auto _elements = reinterpret_cast(elements); + const auto _elementsSequenceLength = static_cast(elementsSequenceLength); + const auto _trailingComma = static_cast(trailingComma); + auto result = GetImpl()->UpdateArrayExpression1(_context, _original, _nodeType, _elements, _elementsSequenceLength, _trailingComma); + return result; +} +KOALA_INTEROP_6(UpdateArrayExpression1, KNativePointer, KNativePointer, KNativePointer, KInt, KNativePointerArray, KUInt, KBoolean); + +KNativePointer impl_ArrayExpressionGetElementNodeAtIdxConst(KNativePointer context, KNativePointer receiver, KUInt idx) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _idx = static_cast(idx); + auto result = GetImpl()->ArrayExpressionGetElementNodeAtIdxConst(_context, _receiver, _idx); + return (void*)result; +} +KOALA_INTEROP_3(ArrayExpressionGetElementNodeAtIdxConst, KNativePointer, KNativePointer, KNativePointer, KUInt); + +KNativePointer impl_ArrayExpressionElementsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ArrayExpressionElementsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(ArrayExpressionElementsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ArrayExpressionElements(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ArrayExpressionElements(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(ArrayExpressionElements, KNativePointer, KNativePointer, KNativePointer); + +void impl_ArrayExpressionSetElements(KNativePointer context, KNativePointer receiver, KNativePointerArray elements, KUInt elementsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _elements = reinterpret_cast(elements); + const auto _elementsSequenceLength = static_cast(elementsSequenceLength); + GetImpl()->ArrayExpressionSetElements(_context, _receiver, _elements, _elementsSequenceLength); + return ; +} +KOALA_INTEROP_V4(ArrayExpressionSetElements, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KBoolean impl_ArrayExpressionIsDeclarationConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ArrayExpressionIsDeclarationConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ArrayExpressionIsDeclarationConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ArrayExpressionIsOptionalConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ArrayExpressionIsOptionalConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ArrayExpressionIsOptionalConst, KBoolean, KNativePointer, KNativePointer); + +void impl_ArrayExpressionSetDeclaration(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->ArrayExpressionSetDeclaration(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(ArrayExpressionSetDeclaration, KNativePointer, KNativePointer); + +void impl_ArrayExpressionSetOptional(KNativePointer context, KNativePointer receiver, KBoolean optional_arg) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _optional_arg = static_cast(optional_arg); + GetImpl()->ArrayExpressionSetOptional(_context, _receiver, _optional_arg); + return ; +} +KOALA_INTEROP_V3(ArrayExpressionSetOptional, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_ArrayExpressionDecoratorsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ArrayExpressionDecoratorsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(ArrayExpressionDecoratorsConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_ArrayExpressionClearPreferredType(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->ArrayExpressionClearPreferredType(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(ArrayExpressionClearPreferredType, KNativePointer, KNativePointer); + +KBoolean impl_ArrayExpressionConvertibleToArrayPattern(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ArrayExpressionConvertibleToArrayPattern(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ArrayExpressionConvertibleToArrayPattern, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_ArrayExpressionValidateExpression(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ArrayExpressionValidateExpression(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ArrayExpressionValidateExpression, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_ArrayExpressionTrySetPreferredTypeForNestedArrayExprConst(KNativePointer context, KNativePointer receiver, KNativePointer nestedArrayExpr, KUInt idx) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _nestedArrayExpr = reinterpret_cast(nestedArrayExpr); + const auto _idx = static_cast(idx); + auto result = GetImpl()->ArrayExpressionTrySetPreferredTypeForNestedArrayExprConst(_context, _receiver, _nestedArrayExpr, _idx); + return result; +} +KOALA_INTEROP_4(ArrayExpressionTrySetPreferredTypeForNestedArrayExprConst, KBoolean, KNativePointer, KNativePointer, KNativePointer, KUInt); + +KNativePointer impl_ArrayExpressionTypeAnnotationConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ArrayExpressionTypeAnnotationConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ArrayExpressionTypeAnnotationConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_ArrayExpressionSetTsTypeAnnotation(KNativePointer context, KNativePointer receiver, KNativePointer typeAnnotation) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + GetImpl()->ArrayExpressionSetTsTypeAnnotation(_context, _receiver, _typeAnnotation); + return ; +} +KOALA_INTEROP_V3(ArrayExpressionSetTsTypeAnnotation, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSInterfaceBody(KNativePointer context, KNativePointerArray body, KUInt bodySequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _body = reinterpret_cast(body); + const auto _bodySequenceLength = static_cast(bodySequenceLength); + auto result = GetImpl()->CreateTSInterfaceBody(_context, _body, _bodySequenceLength); + return result; +} +KOALA_INTEROP_3(CreateTSInterfaceBody, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_UpdateTSInterfaceBody(KNativePointer context, KNativePointer original, KNativePointerArray body, KUInt bodySequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _body = reinterpret_cast(body); + const auto _bodySequenceLength = static_cast(bodySequenceLength); + auto result = GetImpl()->UpdateTSInterfaceBody(_context, _original, _body, _bodySequenceLength); + return result; +} +KOALA_INTEROP_4(UpdateTSInterfaceBody, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_TSInterfaceBodyBody(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSInterfaceBodyBody(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSInterfaceBodyBody, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSInterfaceBodyBodyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSInterfaceBodyBodyConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSInterfaceBodyBodyConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSTypeQuery(KNativePointer context, KNativePointer exprName) +{ + const auto _context = reinterpret_cast(context); + const auto _exprName = reinterpret_cast(exprName); + auto result = GetImpl()->CreateTSTypeQuery(_context, _exprName); + return result; +} +KOALA_INTEROP_2(CreateTSTypeQuery, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSTypeQuery(KNativePointer context, KNativePointer original, KNativePointer exprName) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _exprName = reinterpret_cast(exprName); + auto result = GetImpl()->UpdateTSTypeQuery(_context, _original, _exprName); + return result; +} +KOALA_INTEROP_3(UpdateTSTypeQuery, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSTypeQueryExprNameConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSTypeQueryExprNameConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSTypeQueryExprNameConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSBigintKeyword(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateTSBigintKeyword(_context); + return result; +} +KOALA_INTEROP_1(CreateTSBigintKeyword, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSBigintKeyword(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateTSBigintKeyword(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateTSBigintKeyword, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateProperty(KNativePointer context, KNativePointer key, KNativePointer value) +{ + const auto _context = reinterpret_cast(context); + const auto _key = reinterpret_cast(key); + const auto _value = reinterpret_cast(value); + auto result = GetImpl()->CreateProperty(_context, _key, _value); + return result; +} +KOALA_INTEROP_3(CreateProperty, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateProperty(KNativePointer context, KNativePointer original, KNativePointer key, KNativePointer value) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _key = reinterpret_cast(key); + const auto _value = reinterpret_cast(value); + auto result = GetImpl()->UpdateProperty(_context, _original, _key, _value); + return result; +} +KOALA_INTEROP_4(UpdateProperty, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateProperty1(KNativePointer context, KInt kind, KNativePointer key, KNativePointer value, KBoolean isMethod, KBoolean isComputed) +{ + const auto _context = reinterpret_cast(context); + const auto _kind = static_cast(kind); + const auto _key = reinterpret_cast(key); + const auto _value = reinterpret_cast(value); + const auto _isMethod = static_cast(isMethod); + const auto _isComputed = static_cast(isComputed); + auto result = GetImpl()->CreateProperty1(_context, _kind, _key, _value, _isMethod, _isComputed); + return result; +} +KOALA_INTEROP_6(CreateProperty1, KNativePointer, KNativePointer, KInt, KNativePointer, KNativePointer, KBoolean, KBoolean); + +KNativePointer impl_UpdateProperty1(KNativePointer context, KNativePointer original, KInt kind, KNativePointer key, KNativePointer value, KBoolean isMethod, KBoolean isComputed) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _kind = static_cast(kind); + const auto _key = reinterpret_cast(key); + const auto _value = reinterpret_cast(value); + const auto _isMethod = static_cast(isMethod); + const auto _isComputed = static_cast(isComputed); + auto result = GetImpl()->UpdateProperty1(_context, _original, _kind, _key, _value, _isMethod, _isComputed); + return result; +} +KOALA_INTEROP_7(UpdateProperty1, KNativePointer, KNativePointer, KNativePointer, KInt, KNativePointer, KNativePointer, KBoolean, KBoolean); + +KNativePointer impl_PropertyKey(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->PropertyKey(_context, _receiver); + return result; +} +KOALA_INTEROP_2(PropertyKey, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_PropertyKeyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->PropertyKeyConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(PropertyKeyConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_PropertyValueConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->PropertyValueConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(PropertyValueConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_PropertyValue(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->PropertyValue(_context, _receiver); + return result; +} +KOALA_INTEROP_2(PropertyValue, KNativePointer, KNativePointer, KNativePointer); + +KInt impl_PropertyKindConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->PropertyKindConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(PropertyKindConst, KInt, KNativePointer, KNativePointer); + +KBoolean impl_PropertyIsMethodConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->PropertyIsMethodConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(PropertyIsMethodConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_PropertyIsShorthandConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->PropertyIsShorthandConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(PropertyIsShorthandConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_PropertyIsComputedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->PropertyIsComputedConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(PropertyIsComputedConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_PropertyIsAccessorConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->PropertyIsAccessorConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(PropertyIsAccessorConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_PropertyIsAccessorKind(KNativePointer context, KNativePointer receiver, KInt kind) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _kind = static_cast(kind); + auto result = GetImpl()->PropertyIsAccessorKind(_context, _receiver, _kind); + return result; +} +KOALA_INTEROP_3(PropertyIsAccessorKind, KBoolean, KNativePointer, KNativePointer, KInt); + +KBoolean impl_PropertyConvertibleToPatternProperty(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->PropertyConvertibleToPatternProperty(_context, _receiver); + return result; +} +KOALA_INTEROP_2(PropertyConvertibleToPatternProperty, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_PropertyValidateExpression(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->PropertyValidateExpression(_context, _receiver); + return result; +} +KOALA_INTEROP_2(PropertyValidateExpression, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateVariableDeclarator(KNativePointer context, KInt flag, KNativePointer ident) +{ + const auto _context = reinterpret_cast(context); + const auto _flag = static_cast(flag); + const auto _ident = reinterpret_cast(ident); + auto result = GetImpl()->CreateVariableDeclarator(_context, _flag, _ident); + return result; +} +KOALA_INTEROP_3(CreateVariableDeclarator, KNativePointer, KNativePointer, KInt, KNativePointer); + +KNativePointer impl_UpdateVariableDeclarator(KNativePointer context, KNativePointer original, KInt flag, KNativePointer ident) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _flag = static_cast(flag); + const auto _ident = reinterpret_cast(ident); + auto result = GetImpl()->UpdateVariableDeclarator(_context, _original, _flag, _ident); + return result; +} +KOALA_INTEROP_4(UpdateVariableDeclarator, KNativePointer, KNativePointer, KNativePointer, KInt, KNativePointer); + +KNativePointer impl_CreateVariableDeclarator1(KNativePointer context, KInt flag, KNativePointer ident, KNativePointer init) +{ + const auto _context = reinterpret_cast(context); + const auto _flag = static_cast(flag); + const auto _ident = reinterpret_cast(ident); + const auto _init = reinterpret_cast(init); + auto result = GetImpl()->CreateVariableDeclarator1(_context, _flag, _ident, _init); + return result; +} +KOALA_INTEROP_4(CreateVariableDeclarator1, KNativePointer, KNativePointer, KInt, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateVariableDeclarator1(KNativePointer context, KNativePointer original, KInt flag, KNativePointer ident, KNativePointer init) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _flag = static_cast(flag); + const auto _ident = reinterpret_cast(ident); + const auto _init = reinterpret_cast(init); + auto result = GetImpl()->UpdateVariableDeclarator1(_context, _original, _flag, _ident, _init); + return result; +} +KOALA_INTEROP_5(UpdateVariableDeclarator1, KNativePointer, KNativePointer, KNativePointer, KInt, KNativePointer, KNativePointer); + +KNativePointer impl_VariableDeclaratorInit(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->VariableDeclaratorInit(_context, _receiver); + return result; +} +KOALA_INTEROP_2(VariableDeclaratorInit, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_VariableDeclaratorInitConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->VariableDeclaratorInitConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(VariableDeclaratorInitConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_VariableDeclaratorSetInit(KNativePointer context, KNativePointer receiver, KNativePointer init) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _init = reinterpret_cast(init); + GetImpl()->VariableDeclaratorSetInit(_context, _receiver, _init); + return ; +} +KOALA_INTEROP_V3(VariableDeclaratorSetInit, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_VariableDeclaratorId(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->VariableDeclaratorId(_context, _receiver); + return result; +} +KOALA_INTEROP_2(VariableDeclaratorId, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_VariableDeclaratorIdConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->VariableDeclaratorIdConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(VariableDeclaratorIdConst, KNativePointer, KNativePointer, KNativePointer); + +KInt impl_VariableDeclaratorFlag(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->VariableDeclaratorFlag(_context, _receiver); + return result; +} +KOALA_INTEROP_2(VariableDeclaratorFlag, KInt, KNativePointer, KNativePointer); + +KNativePointer impl_CreateStringLiteral(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateStringLiteral(_context); + return result; +} +KOALA_INTEROP_1(CreateStringLiteral, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateStringLiteral(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateStringLiteral(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateStringLiteral, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateStringLiteral1(KNativePointer context, KStringPtr& str) +{ + const auto _context = reinterpret_cast(context); + const auto _str = getStringCopy(str); + auto result = GetImpl()->CreateStringLiteral1(_context, _str); + return result; +} +KOALA_INTEROP_2(CreateStringLiteral1, KNativePointer, KNativePointer, KStringPtr); + +KNativePointer impl_UpdateStringLiteral1(KNativePointer context, KNativePointer original, KStringPtr& str) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _str = getStringCopy(str); + auto result = GetImpl()->UpdateStringLiteral1(_context, _original, _str); + return result; +} +KOALA_INTEROP_3(UpdateStringLiteral1, KNativePointer, KNativePointer, KNativePointer, KStringPtr); + +KNativePointer impl_StringLiteralStrConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->StringLiteralStrConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(StringLiteralStrConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSTypeAssertion(KNativePointer context, KNativePointer typeAnnotation, KNativePointer expression) +{ + const auto _context = reinterpret_cast(context); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + const auto _expression = reinterpret_cast(expression); + auto result = GetImpl()->CreateTSTypeAssertion(_context, _typeAnnotation, _expression); + return result; +} +KOALA_INTEROP_3(CreateTSTypeAssertion, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSTypeAssertion(KNativePointer context, KNativePointer original, KNativePointer typeAnnotation, KNativePointer expression) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + const auto _expression = reinterpret_cast(expression); + auto result = GetImpl()->UpdateTSTypeAssertion(_context, _original, _typeAnnotation, _expression); + return result; +} +KOALA_INTEROP_4(UpdateTSTypeAssertion, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSTypeAssertionGetExpressionConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSTypeAssertionGetExpressionConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSTypeAssertionGetExpressionConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSTypeAssertionTypeAnnotationConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSTypeAssertionTypeAnnotationConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSTypeAssertionTypeAnnotationConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_TSTypeAssertionSetTsTypeAnnotation(KNativePointer context, KNativePointer receiver, KNativePointer typeAnnotation) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + GetImpl()->TSTypeAssertionSetTsTypeAnnotation(_context, _receiver, _typeAnnotation); + return ; +} +KOALA_INTEROP_V3(TSTypeAssertionSetTsTypeAnnotation, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSExternalModuleReference(KNativePointer context, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _expr = reinterpret_cast(expr); + auto result = GetImpl()->CreateTSExternalModuleReference(_context, _expr); + return result; +} +KOALA_INTEROP_2(CreateTSExternalModuleReference, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSExternalModuleReference(KNativePointer context, KNativePointer original, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _expr = reinterpret_cast(expr); + auto result = GetImpl()->UpdateTSExternalModuleReference(_context, _original, _expr); + return result; +} +KOALA_INTEROP_3(UpdateTSExternalModuleReference, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSExternalModuleReferenceExprConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSExternalModuleReferenceExprConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSExternalModuleReferenceExprConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSUndefinedKeyword(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateTSUndefinedKeyword(_context); + return result; +} +KOALA_INTEROP_1(CreateTSUndefinedKeyword, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSUndefinedKeyword(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateTSUndefinedKeyword(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateTSUndefinedKeyword, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateETSTuple(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateETSTuple(_context); + return result; +} +KOALA_INTEROP_1(CreateETSTuple, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateETSTuple(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateETSTuple(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateETSTuple, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateETSTuple1(KNativePointer context, KUInt size) +{ + const auto _context = reinterpret_cast(context); + const auto _size = static_cast(size); + auto result = GetImpl()->CreateETSTuple1(_context, _size); + return result; +} +KOALA_INTEROP_2(CreateETSTuple1, KNativePointer, KNativePointer, KUInt); + +KNativePointer impl_UpdateETSTuple1(KNativePointer context, KNativePointer original, KUInt size) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _size = static_cast(size); + auto result = GetImpl()->UpdateETSTuple1(_context, _original, _size); + return result; +} +KOALA_INTEROP_3(UpdateETSTuple1, KNativePointer, KNativePointer, KNativePointer, KUInt); + +KNativePointer impl_CreateETSTuple2(KNativePointer context, KNativePointerArray typeList, KUInt typeListSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _typeList = reinterpret_cast(typeList); + const auto _typeListSequenceLength = static_cast(typeListSequenceLength); + auto result = GetImpl()->CreateETSTuple2(_context, _typeList, _typeListSequenceLength); + return result; +} +KOALA_INTEROP_3(CreateETSTuple2, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_UpdateETSTuple2(KNativePointer context, KNativePointer original, KNativePointerArray typeList, KUInt typeListSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _typeList = reinterpret_cast(typeList); + const auto _typeListSequenceLength = static_cast(typeListSequenceLength); + auto result = GetImpl()->UpdateETSTuple2(_context, _original, _typeList, _typeListSequenceLength); + return result; +} +KOALA_INTEROP_4(UpdateETSTuple2, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KUInt impl_ETSTupleGetTupleSizeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSTupleGetTupleSizeConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSTupleGetTupleSizeConst, KUInt, KNativePointer, KNativePointer); + +KNativePointer impl_ETSTupleGetTupleTypeAnnotationsList(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ETSTupleGetTupleTypeAnnotationsList(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(ETSTupleGetTupleTypeAnnotationsList, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSTupleGetTupleTypeAnnotationsListConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ETSTupleGetTupleTypeAnnotationsListConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(ETSTupleGetTupleTypeAnnotationsListConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_ETSTupleSetTypeAnnotationsList(KNativePointer context, KNativePointer receiver, KNativePointerArray typeNodeList, KUInt typeNodeListSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _typeNodeList = reinterpret_cast(typeNodeList); + const auto _typeNodeListSequenceLength = static_cast(typeNodeListSequenceLength); + GetImpl()->ETSTupleSetTypeAnnotationsList(_context, _receiver, _typeNodeList, _typeNodeListSequenceLength); + return ; +} +KOALA_INTEROP_V4(ETSTupleSetTypeAnnotationsList, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_CreateETSStringLiteralType(KNativePointer context, KStringPtr& value) +{ + const auto _context = reinterpret_cast(context); + const auto _value = getStringCopy(value); + auto result = GetImpl()->CreateETSStringLiteralType(_context, _value); + return result; +} +KOALA_INTEROP_2(CreateETSStringLiteralType, KNativePointer, KNativePointer, KStringPtr); + +KNativePointer impl_UpdateETSStringLiteralType(KNativePointer context, KNativePointer original, KStringPtr& value) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _value = getStringCopy(value); + auto result = GetImpl()->UpdateETSStringLiteralType(_context, _original, _value); + return result; +} +KOALA_INTEROP_3(UpdateETSStringLiteralType, KNativePointer, KNativePointer, KNativePointer, KStringPtr); + +KNativePointer impl_CreateTryStatement(KNativePointer context, KNativePointer block, KNativePointerArray catchClauses, KUInt catchClausesSequenceLength, KNativePointer finalizer, KNativePointerArray finalizerInsertionsLabelPair, KUInt finalizerInsertionsLabelPairSequenceLength, KNativePointerArray finalizerInsertionsStatement, KUInt finalizerInsertionsStatementSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _block = reinterpret_cast(block); + const auto _catchClauses = reinterpret_cast(catchClauses); + const auto _catchClausesSequenceLength = static_cast(catchClausesSequenceLength); + const auto _finalizer = reinterpret_cast(finalizer); + const auto _finalizerInsertionsLabelPair = reinterpret_cast(finalizerInsertionsLabelPair); + const auto _finalizerInsertionsLabelPairSequenceLength = static_cast(finalizerInsertionsLabelPairSequenceLength); + const auto _finalizerInsertionsStatement = reinterpret_cast(finalizerInsertionsStatement); + const auto _finalizerInsertionsStatementSequenceLength = static_cast(finalizerInsertionsStatementSequenceLength); + auto result = GetImpl()->CreateTryStatement(_context, _block, _catchClauses, _catchClausesSequenceLength, _finalizer, _finalizerInsertionsLabelPair, _finalizerInsertionsLabelPairSequenceLength, _finalizerInsertionsStatement, _finalizerInsertionsStatementSequenceLength); + return result; +} +KOALA_INTEROP_9(CreateTryStatement, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KNativePointer, KNativePointerArray, KUInt, KNativePointerArray, KUInt); + +KNativePointer impl_UpdateTryStatement(KNativePointer context, KNativePointer original, KNativePointer block, KNativePointerArray catchClauses, KUInt catchClausesSequenceLength, KNativePointer finalizer, KNativePointerArray finalizerInsertionsLabelPair, KUInt finalizerInsertionsLabelPairSequenceLength, KNativePointerArray finalizerInsertionsStatement, KUInt finalizerInsertionsStatementSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _block = reinterpret_cast(block); + const auto _catchClauses = reinterpret_cast(catchClauses); + const auto _catchClausesSequenceLength = static_cast(catchClausesSequenceLength); + const auto _finalizer = reinterpret_cast(finalizer); + const auto _finalizerInsertionsLabelPair = reinterpret_cast(finalizerInsertionsLabelPair); + const auto _finalizerInsertionsLabelPairSequenceLength = static_cast(finalizerInsertionsLabelPairSequenceLength); + const auto _finalizerInsertionsStatement = reinterpret_cast(finalizerInsertionsStatement); + const auto _finalizerInsertionsStatementSequenceLength = static_cast(finalizerInsertionsStatementSequenceLength); + auto result = GetImpl()->UpdateTryStatement(_context, _original, _block, _catchClauses, _catchClausesSequenceLength, _finalizer, _finalizerInsertionsLabelPair, _finalizerInsertionsLabelPairSequenceLength, _finalizerInsertionsStatement, _finalizerInsertionsStatementSequenceLength); + return result; +} +KOALA_INTEROP_10(UpdateTryStatement, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KNativePointer, KNativePointerArray, KUInt, KNativePointerArray, KUInt); + +KNativePointer impl_CreateTryStatement1(KNativePointer context, KNativePointer other) +{ + const auto _context = reinterpret_cast(context); + const auto _other = reinterpret_cast(other); + auto result = GetImpl()->CreateTryStatement1(_context, _other); + return result; +} +KOALA_INTEROP_2(CreateTryStatement1, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTryStatement1(KNativePointer context, KNativePointer original, KNativePointer other) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _other = reinterpret_cast(other); + auto result = GetImpl()->UpdateTryStatement1(_context, _original, _other); + return result; +} +KOALA_INTEROP_3(UpdateTryStatement1, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TryStatementFinallyBlockConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TryStatementFinallyBlockConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TryStatementFinallyBlockConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TryStatementBlockConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TryStatementBlockConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TryStatementBlockConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_TryStatementHasFinalizerConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TryStatementHasFinalizerConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TryStatementHasFinalizerConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_TryStatementHasDefaultCatchClauseConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TryStatementHasDefaultCatchClauseConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TryStatementHasDefaultCatchClauseConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_TryStatementCatchClausesConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TryStatementCatchClausesConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TryStatementCatchClausesConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_TryStatementFinallyCanCompleteNormallyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TryStatementFinallyCanCompleteNormallyConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TryStatementFinallyCanCompleteNormallyConst, KBoolean, KNativePointer, KNativePointer); + +void impl_TryStatementSetFinallyCanCompleteNormally(KNativePointer context, KNativePointer receiver, KBoolean finallyCanCompleteNormally) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _finallyCanCompleteNormally = static_cast(finallyCanCompleteNormally); + GetImpl()->TryStatementSetFinallyCanCompleteNormally(_context, _receiver, _finallyCanCompleteNormally); + return ; +} +KOALA_INTEROP_V3(TryStatementSetFinallyCanCompleteNormally, KNativePointer, KNativePointer, KBoolean); + +KBoolean impl_AstNodeIsProgramConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsProgramConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsProgramConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsStatementConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsStatementConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsStatementConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsExpressionConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsExpressionConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsExpressionConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsTypedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsTypedConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsTypedConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_AstNodeAsTyped(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeAsTyped(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeAsTyped, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AstNodeAsTypedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeAsTypedConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(AstNodeAsTypedConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsBrokenStatementConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsBrokenStatementConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsBrokenStatementConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_AstNodeAsExpression(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeAsExpression(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeAsExpression, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AstNodeAsExpressionConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeAsExpressionConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(AstNodeAsExpressionConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AstNodeAsStatement(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeAsStatement(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeAsStatement, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AstNodeAsStatementConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeAsStatementConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(AstNodeAsStatementConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_AstNodeSetRange(KNativePointer context, KNativePointer receiver, KNativePointer loc) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _loc = reinterpret_cast(loc); + GetImpl()->AstNodeSetRange(_context, _receiver, _loc); + return ; +} +KOALA_INTEROP_V3(AstNodeSetRange, KNativePointer, KNativePointer, KNativePointer); + +void impl_AstNodeSetStart(KNativePointer context, KNativePointer receiver, KNativePointer start) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _start = reinterpret_cast(start); + GetImpl()->AstNodeSetStart(_context, _receiver, _start); + return ; +} +KOALA_INTEROP_V3(AstNodeSetStart, KNativePointer, KNativePointer, KNativePointer); + +void impl_AstNodeSetEnd(KNativePointer context, KNativePointer receiver, KNativePointer end) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _end = reinterpret_cast(end); + GetImpl()->AstNodeSetEnd(_context, _receiver, _end); + return ; +} +KOALA_INTEROP_V3(AstNodeSetEnd, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AstNodeStartConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeStartConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(AstNodeStartConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AstNodeEndConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeEndConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(AstNodeEndConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AstNodeRangeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeRangeConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(AstNodeRangeConst, KNativePointer, KNativePointer, KNativePointer); + +KInt impl_AstNodeTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeTypeConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeTypeConst, KInt, KNativePointer, KNativePointer); + +KNativePointer impl_AstNodeParent(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeParent(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeParent, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AstNodeParentConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeParentConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(AstNodeParentConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_AstNodeSetParent(KNativePointer context, KNativePointer receiver, KNativePointer parent) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _parent = reinterpret_cast(parent); + GetImpl()->AstNodeSetParent(_context, _receiver, _parent); + return ; +} +KOALA_INTEROP_V3(AstNodeSetParent, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AstNodeDecoratorsPtrConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->AstNodeDecoratorsPtrConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(AstNodeDecoratorsPtrConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_AstNodeAddDecorators(KNativePointer context, KNativePointer receiver, KNativePointerArray decorators, KUInt decoratorsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _decorators = reinterpret_cast(decorators); + const auto _decoratorsSequenceLength = static_cast(decoratorsSequenceLength); + GetImpl()->AstNodeAddDecorators(_context, _receiver, _decorators, _decoratorsSequenceLength); + return ; +} +KOALA_INTEROP_V4(AstNodeAddDecorators, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KBoolean impl_AstNodeCanHaveDecoratorConst(KNativePointer context, KNativePointer receiver, KBoolean inTs) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _inTs = static_cast(inTs); + auto result = GetImpl()->AstNodeCanHaveDecoratorConst(_context, _receiver, _inTs); + return result; +} +KOALA_INTEROP_3(AstNodeCanHaveDecoratorConst, KBoolean, KNativePointer, KNativePointer, KBoolean); + +KBoolean impl_AstNodeIsReadonlyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsReadonlyConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsReadonlyConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsReadonlyTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsReadonlyTypeConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsReadonlyTypeConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsOptionalDeclarationConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsOptionalDeclarationConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsOptionalDeclarationConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsDefiniteConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsDefiniteConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsDefiniteConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsConstructorConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsConstructorConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsConstructorConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsOverrideConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsOverrideConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsOverrideConst, KBoolean, KNativePointer, KNativePointer); + +void impl_AstNodeSetOverride(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->AstNodeSetOverride(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(AstNodeSetOverride, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsAsyncConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsAsyncConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsAsyncConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsSynchronizedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsSynchronizedConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsSynchronizedConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsNativeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsNativeConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsNativeConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsConstConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsConstConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsConstConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsStaticConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsStaticConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsStaticConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsFinalConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsFinalConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsFinalConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsAbstractConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsAbstractConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsAbstractConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsPublicConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsPublicConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsPublicConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsProtectedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsProtectedConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsProtectedConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsPrivateConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsPrivateConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsPrivateConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsInternalConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsInternalConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsInternalConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsExportedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsExportedConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsExportedConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsDefaultExportedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsDefaultExportedConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsDefaultExportedConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsExportedTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsExportedTypeConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsExportedTypeConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsDeclareConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsDeclareConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsDeclareConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsInConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsInConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsInConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsOutConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsOutConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsOutConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsSetterConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsSetterConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsSetterConst, KBoolean, KNativePointer, KNativePointer); + +void impl_AstNodeAddModifier(KNativePointer context, KNativePointer receiver, KInt flags) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _flags = static_cast(flags); + GetImpl()->AstNodeAddModifier(_context, _receiver, _flags); + return ; +} +KOALA_INTEROP_V3(AstNodeAddModifier, KNativePointer, KNativePointer, KInt); + +void impl_AstNodeClearModifier(KNativePointer context, KNativePointer receiver, KInt flags) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _flags = static_cast(flags); + GetImpl()->AstNodeClearModifier(_context, _receiver, _flags); + return ; +} +KOALA_INTEROP_V3(AstNodeClearModifier, KNativePointer, KNativePointer, KInt); + +KInt impl_AstNodeModifiers(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeModifiers(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeModifiers, KInt, KNativePointer, KNativePointer); + +KInt impl_AstNodeModifiersConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeModifiersConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeModifiersConst, KInt, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeHasExportAliasConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeHasExportAliasConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeHasExportAliasConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_AstNodeAsClassElement(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeAsClassElement(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeAsClassElement, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AstNodeAsClassElementConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeAsClassElementConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(AstNodeAsClassElementConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsScopeBearerConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsScopeBearerConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsScopeBearerConst, KBoolean, KNativePointer, KNativePointer); + +void impl_AstNodeClearScope(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->AstNodeClearScope(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(AstNodeClearScope, KNativePointer, KNativePointer); + +KNativePointer impl_AstNodeGetTopStatement(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeGetTopStatement(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeGetTopStatement, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AstNodeGetTopStatementConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeGetTopStatementConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(AstNodeGetTopStatementConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AstNodeClone(KNativePointer context, KNativePointer receiver, KNativePointer parent) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _parent = reinterpret_cast(parent); + auto result = GetImpl()->AstNodeClone(_context, _receiver, _parent); + return result; +} +KOALA_INTEROP_3(AstNodeClone, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AstNodeDumpJSONConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeDumpJSONConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(AstNodeDumpJSONConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AstNodeDumpEtsSrcConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeDumpEtsSrcConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(AstNodeDumpEtsSrcConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_AstNodeDumpConst(KNativePointer context, KNativePointer receiver, KNativePointer dumper) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _dumper = reinterpret_cast(dumper); + GetImpl()->AstNodeDumpConst(_context, _receiver, _dumper); + return ; +} +KOALA_INTEROP_V3(AstNodeDumpConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_AstNodeDumpConst1(KNativePointer context, KNativePointer receiver, KNativePointer dumper) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _dumper = reinterpret_cast(dumper); + GetImpl()->AstNodeDumpConst1(_context, _receiver, _dumper); + return ; +} +KOALA_INTEROP_V3(AstNodeDumpConst1, KNativePointer, KNativePointer, KNativePointer); + +void impl_AstNodeCompileConst(KNativePointer context, KNativePointer receiver, KNativePointer pg) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _pg = reinterpret_cast(pg); + GetImpl()->AstNodeCompileConst(_context, _receiver, _pg); + return ; +} +KOALA_INTEROP_V3(AstNodeCompileConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_AstNodeCompileConst1(KNativePointer context, KNativePointer receiver, KNativePointer etsg) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _etsg = reinterpret_cast(etsg); + GetImpl()->AstNodeCompileConst1(_context, _receiver, _etsg); + return ; +} +KOALA_INTEROP_V3(AstNodeCompileConst1, KNativePointer, KNativePointer, KNativePointer); + +void impl_AstNodeSetTransformedNode(KNativePointer context, KNativePointer receiver, KStringPtr& transformationName, KNativePointer transformedNode) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _transformationName = getStringCopy(transformationName); + const auto _transformedNode = reinterpret_cast(transformedNode); + GetImpl()->AstNodeSetTransformedNode(_context, _receiver, _transformationName, _transformedNode); + return ; +} +KOALA_INTEROP_V4(AstNodeSetTransformedNode, KNativePointer, KNativePointer, KStringPtr, KNativePointer); + +void impl_AstNodeAccept(KNativePointer context, KNativePointer receiver, KNativePointer v) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _v = reinterpret_cast(v); + GetImpl()->AstNodeAccept(_context, _receiver, _v); + return ; +} +KOALA_INTEROP_V3(AstNodeAccept, KNativePointer, KNativePointer, KNativePointer); + +void impl_AstNodeSetOriginalNode(KNativePointer context, KNativePointer receiver, KNativePointer originalNode) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _originalNode = reinterpret_cast(originalNode); + GetImpl()->AstNodeSetOriginalNode(_context, _receiver, _originalNode); + return ; +} +KOALA_INTEROP_V3(AstNodeSetOriginalNode, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AstNodeOriginalNodeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeOriginalNodeConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(AstNodeOriginalNodeConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_AstNodeCleanUp(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->AstNodeCleanUp(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(AstNodeCleanUp, KNativePointer, KNativePointer); + +KNativePointer impl_AstNodeShallowClone(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeShallowClone(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeShallowClone, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateUnaryExpression(KNativePointer context, KNativePointer argument, KInt unaryOperator) +{ + const auto _context = reinterpret_cast(context); + const auto _argument = reinterpret_cast(argument); + const auto _unaryOperator = static_cast(unaryOperator); + auto result = GetImpl()->CreateUnaryExpression(_context, _argument, _unaryOperator); + return result; +} +KOALA_INTEROP_3(CreateUnaryExpression, KNativePointer, KNativePointer, KNativePointer, KInt); + +KNativePointer impl_UpdateUnaryExpression(KNativePointer context, KNativePointer original, KNativePointer argument, KInt unaryOperator) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _argument = reinterpret_cast(argument); + const auto _unaryOperator = static_cast(unaryOperator); + auto result = GetImpl()->UpdateUnaryExpression(_context, _original, _argument, _unaryOperator); + return result; +} +KOALA_INTEROP_4(UpdateUnaryExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KInt); + +KInt impl_UnaryExpressionOperatorTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->UnaryExpressionOperatorTypeConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(UnaryExpressionOperatorTypeConst, KInt, KNativePointer, KNativePointer); + +KNativePointer impl_UnaryExpressionArgument(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->UnaryExpressionArgument(_context, _receiver); + return result; +} +KOALA_INTEROP_2(UnaryExpressionArgument, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UnaryExpressionArgumentConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->UnaryExpressionArgumentConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(UnaryExpressionArgumentConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateForInStatement(KNativePointer context, KNativePointer left, KNativePointer right, KNativePointer body) +{ + const auto _context = reinterpret_cast(context); + const auto _left = reinterpret_cast(left); + const auto _right = reinterpret_cast(right); + const auto _body = reinterpret_cast(body); + auto result = GetImpl()->CreateForInStatement(_context, _left, _right, _body); + return result; +} +KOALA_INTEROP_4(CreateForInStatement, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateForInStatement(KNativePointer context, KNativePointer original, KNativePointer left, KNativePointer right, KNativePointer body) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _left = reinterpret_cast(left); + const auto _right = reinterpret_cast(right); + const auto _body = reinterpret_cast(body); + auto result = GetImpl()->UpdateForInStatement(_context, _original, _left, _right, _body); + return result; +} +KOALA_INTEROP_5(UpdateForInStatement, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ForInStatementLeft(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ForInStatementLeft(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ForInStatementLeft, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ForInStatementLeftConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ForInStatementLeftConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ForInStatementLeftConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ForInStatementRight(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ForInStatementRight(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ForInStatementRight, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ForInStatementRightConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ForInStatementRightConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ForInStatementRightConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ForInStatementBody(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ForInStatementBody(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ForInStatementBody, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ForInStatementBodyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ForInStatementBodyConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ForInStatementBodyConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateThisExpression(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateThisExpression(_context); + return result; +} +KOALA_INTEROP_1(CreateThisExpression, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateThisExpression(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateThisExpression(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateThisExpression, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSMethodSignature(KNativePointer context, KNativePointer key, KNativePointer signature, KBoolean computed, KBoolean optional_arg) +{ + const auto _context = reinterpret_cast(context); + const auto _key = reinterpret_cast(key); + const auto _signature = reinterpret_cast(signature); + const auto _computed = static_cast(computed); + const auto _optional_arg = static_cast(optional_arg); + auto result = GetImpl()->CreateTSMethodSignature(_context, _key, _signature, _computed, _optional_arg); + return result; +} +KOALA_INTEROP_5(CreateTSMethodSignature, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean, KBoolean); + +KNativePointer impl_UpdateTSMethodSignature(KNativePointer context, KNativePointer original, KNativePointer key, KNativePointer signature, KBoolean computed, KBoolean optional_arg) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _key = reinterpret_cast(key); + const auto _signature = reinterpret_cast(signature); + const auto _computed = static_cast(computed); + const auto _optional_arg = static_cast(optional_arg); + auto result = GetImpl()->UpdateTSMethodSignature(_context, _original, _key, _signature, _computed, _optional_arg); + return result; +} +KOALA_INTEROP_6(UpdateTSMethodSignature, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean, KBoolean); + +KNativePointer impl_TSMethodSignatureKeyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSMethodSignatureKeyConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSMethodSignatureKeyConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSMethodSignatureKey(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSMethodSignatureKey(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSMethodSignatureKey, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSMethodSignatureTypeParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSMethodSignatureTypeParamsConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSMethodSignatureTypeParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSMethodSignatureTypeParams(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSMethodSignatureTypeParams(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSMethodSignatureTypeParams, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSMethodSignatureParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSMethodSignatureParamsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSMethodSignatureParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSMethodSignatureReturnTypeAnnotationConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSMethodSignatureReturnTypeAnnotationConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSMethodSignatureReturnTypeAnnotationConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSMethodSignatureReturnTypeAnnotation(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSMethodSignatureReturnTypeAnnotation(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSMethodSignatureReturnTypeAnnotation, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_TSMethodSignatureComputedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSMethodSignatureComputedConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSMethodSignatureComputedConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_TSMethodSignatureOptionalConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSMethodSignatureOptionalConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSMethodSignatureOptionalConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_CreateBinaryExpression(KNativePointer context, KNativePointer left, KNativePointer right, KInt operatorType) +{ + const auto _context = reinterpret_cast(context); + const auto _left = reinterpret_cast(left); + const auto _right = reinterpret_cast(right); + const auto _operatorType = static_cast(operatorType); + auto result = GetImpl()->CreateBinaryExpression(_context, _left, _right, _operatorType); + return result; +} +KOALA_INTEROP_4(CreateBinaryExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KInt); + +KNativePointer impl_UpdateBinaryExpression(KNativePointer context, KNativePointer original, KNativePointer left, KNativePointer right, KInt operatorType) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _left = reinterpret_cast(left); + const auto _right = reinterpret_cast(right); + const auto _operatorType = static_cast(operatorType); + auto result = GetImpl()->UpdateBinaryExpression(_context, _original, _left, _right, _operatorType); + return result; +} +KOALA_INTEROP_5(UpdateBinaryExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KInt); + +KNativePointer impl_BinaryExpressionLeftConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->BinaryExpressionLeftConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(BinaryExpressionLeftConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_BinaryExpressionLeft(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->BinaryExpressionLeft(_context, _receiver); + return result; +} +KOALA_INTEROP_2(BinaryExpressionLeft, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_BinaryExpressionRightConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->BinaryExpressionRightConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(BinaryExpressionRightConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_BinaryExpressionRight(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->BinaryExpressionRight(_context, _receiver); + return result; +} +KOALA_INTEROP_2(BinaryExpressionRight, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_BinaryExpressionResultConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->BinaryExpressionResultConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(BinaryExpressionResultConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_BinaryExpressionResult(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->BinaryExpressionResult(_context, _receiver); + return result; +} +KOALA_INTEROP_2(BinaryExpressionResult, KNativePointer, KNativePointer, KNativePointer); + +KInt impl_BinaryExpressionOperatorTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->BinaryExpressionOperatorTypeConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(BinaryExpressionOperatorTypeConst, KInt, KNativePointer, KNativePointer); + +KBoolean impl_BinaryExpressionIsLogicalConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->BinaryExpressionIsLogicalConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(BinaryExpressionIsLogicalConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_BinaryExpressionIsLogicalExtendedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->BinaryExpressionIsLogicalExtendedConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(BinaryExpressionIsLogicalExtendedConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_BinaryExpressionIsBitwiseConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->BinaryExpressionIsBitwiseConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(BinaryExpressionIsBitwiseConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_BinaryExpressionIsArithmeticConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->BinaryExpressionIsArithmeticConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(BinaryExpressionIsArithmeticConst, KBoolean, KNativePointer, KNativePointer); + +void impl_BinaryExpressionSetLeft(KNativePointer context, KNativePointer receiver, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _expr = reinterpret_cast(expr); + GetImpl()->BinaryExpressionSetLeft(_context, _receiver, _expr); + return ; +} +KOALA_INTEROP_V3(BinaryExpressionSetLeft, KNativePointer, KNativePointer, KNativePointer); + +void impl_BinaryExpressionSetRight(KNativePointer context, KNativePointer receiver, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _expr = reinterpret_cast(expr); + GetImpl()->BinaryExpressionSetRight(_context, _receiver, _expr); + return ; +} +KOALA_INTEROP_V3(BinaryExpressionSetRight, KNativePointer, KNativePointer, KNativePointer); + +void impl_BinaryExpressionSetResult(KNativePointer context, KNativePointer receiver, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _expr = reinterpret_cast(expr); + GetImpl()->BinaryExpressionSetResult(_context, _receiver, _expr); + return ; +} +KOALA_INTEROP_V3(BinaryExpressionSetResult, KNativePointer, KNativePointer, KNativePointer); + +void impl_BinaryExpressionSetOperator(KNativePointer context, KNativePointer receiver, KInt operatorType) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _operatorType = static_cast(operatorType); + GetImpl()->BinaryExpressionSetOperator(_context, _receiver, _operatorType); + return ; +} +KOALA_INTEROP_V3(BinaryExpressionSetOperator, KNativePointer, KNativePointer, KInt); + +void impl_BinaryExpressionCompileOperandsConst(KNativePointer context, KNativePointer receiver, KNativePointer etsg, KNativePointer lhs) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _etsg = reinterpret_cast(etsg); + const auto _lhs = reinterpret_cast(lhs); + GetImpl()->BinaryExpressionCompileOperandsConst(_context, _receiver, _etsg, _lhs); + return ; +} +KOALA_INTEROP_V4(BinaryExpressionCompileOperandsConst, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateSuperExpression(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateSuperExpression(_context); + return result; +} +KOALA_INTEROP_1(CreateSuperExpression, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateSuperExpression(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateSuperExpression(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateSuperExpression, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateAssertStatement(KNativePointer context, KNativePointer test, KNativePointer second) +{ + const auto _context = reinterpret_cast(context); + const auto _test = reinterpret_cast(test); + const auto _second = reinterpret_cast(second); + auto result = GetImpl()->CreateAssertStatement(_context, _test, _second); + return result; +} +KOALA_INTEROP_3(CreateAssertStatement, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateAssertStatement(KNativePointer context, KNativePointer original, KNativePointer test, KNativePointer second) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _test = reinterpret_cast(test); + const auto _second = reinterpret_cast(second); + auto result = GetImpl()->UpdateAssertStatement(_context, _original, _test, _second); + return result; +} +KOALA_INTEROP_4(UpdateAssertStatement, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AssertStatementTestConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AssertStatementTestConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(AssertStatementTestConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AssertStatementTest(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AssertStatementTest(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AssertStatementTest, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AssertStatementSecondConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AssertStatementSecondConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(AssertStatementSecondConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSStringKeyword(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateTSStringKeyword(_context); + return result; +} +KOALA_INTEROP_1(CreateTSStringKeyword, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSStringKeyword(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateTSStringKeyword(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateTSStringKeyword, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateAssignmentExpression(KNativePointer context, KNativePointer left, KNativePointer right, KInt assignmentOperator) +{ + const auto _context = reinterpret_cast(context); + const auto _left = reinterpret_cast(left); + const auto _right = reinterpret_cast(right); + const auto _assignmentOperator = static_cast(assignmentOperator); + auto result = GetImpl()->CreateAssignmentExpression(_context, _left, _right, _assignmentOperator); + return result; +} +KOALA_INTEROP_4(CreateAssignmentExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KInt); + +KNativePointer impl_UpdateAssignmentExpression(KNativePointer context, KNativePointer original, KNativePointer left, KNativePointer right, KInt assignmentOperator) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _left = reinterpret_cast(left); + const auto _right = reinterpret_cast(right); + const auto _assignmentOperator = static_cast(assignmentOperator); + auto result = GetImpl()->UpdateAssignmentExpression(_context, _original, _left, _right, _assignmentOperator); + return result; +} +KOALA_INTEROP_5(UpdateAssignmentExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KInt); + +KNativePointer impl_CreateAssignmentExpression1(KNativePointer context, KInt type, KNativePointer left, KNativePointer right, KInt assignmentOperator) +{ + const auto _context = reinterpret_cast(context); + const auto _type = static_cast(type); + const auto _left = reinterpret_cast(left); + const auto _right = reinterpret_cast(right); + const auto _assignmentOperator = static_cast(assignmentOperator); + auto result = GetImpl()->CreateAssignmentExpression1(_context, _type, _left, _right, _assignmentOperator); + return result; +} +KOALA_INTEROP_5(CreateAssignmentExpression1, KNativePointer, KNativePointer, KInt, KNativePointer, KNativePointer, KInt); + +KNativePointer impl_UpdateAssignmentExpression1(KNativePointer context, KNativePointer original, KInt type, KNativePointer left, KNativePointer right, KInt assignmentOperator) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _type = static_cast(type); + const auto _left = reinterpret_cast(left); + const auto _right = reinterpret_cast(right); + const auto _assignmentOperator = static_cast(assignmentOperator); + auto result = GetImpl()->UpdateAssignmentExpression1(_context, _original, _type, _left, _right, _assignmentOperator); + return result; +} +KOALA_INTEROP_6(UpdateAssignmentExpression1, KNativePointer, KNativePointer, KNativePointer, KInt, KNativePointer, KNativePointer, KInt); + +KNativePointer impl_AssignmentExpressionLeftConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AssignmentExpressionLeftConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(AssignmentExpressionLeftConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AssignmentExpressionLeft(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AssignmentExpressionLeft(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AssignmentExpressionLeft, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AssignmentExpressionRight(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AssignmentExpressionRight(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AssignmentExpressionRight, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AssignmentExpressionRightConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AssignmentExpressionRightConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(AssignmentExpressionRightConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_AssignmentExpressionSetRight(KNativePointer context, KNativePointer receiver, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _expr = reinterpret_cast(expr); + GetImpl()->AssignmentExpressionSetRight(_context, _receiver, _expr); + return ; +} +KOALA_INTEROP_V3(AssignmentExpressionSetRight, KNativePointer, KNativePointer, KNativePointer); + +void impl_AssignmentExpressionSetLeft(KNativePointer context, KNativePointer receiver, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _expr = reinterpret_cast(expr); + GetImpl()->AssignmentExpressionSetLeft(_context, _receiver, _expr); + return ; +} +KOALA_INTEROP_V3(AssignmentExpressionSetLeft, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AssignmentExpressionResultConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AssignmentExpressionResultConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(AssignmentExpressionResultConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AssignmentExpressionResult(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AssignmentExpressionResult(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AssignmentExpressionResult, KNativePointer, KNativePointer, KNativePointer); + +KInt impl_AssignmentExpressionOperatorTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AssignmentExpressionOperatorTypeConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AssignmentExpressionOperatorTypeConst, KInt, KNativePointer, KNativePointer); + +KInt impl_AssignmentExpressionSetOperatorType(KNativePointer context, KNativePointer receiver, KInt tokenType) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _tokenType = static_cast(tokenType); + auto result = GetImpl()->AssignmentExpressionSetOperatorType(_context, _receiver, _tokenType); + return result; +} +KOALA_INTEROP_3(AssignmentExpressionSetOperatorType, KInt, KNativePointer, KNativePointer, KInt); + +void impl_AssignmentExpressionSetResult(KNativePointer context, KNativePointer receiver, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _expr = reinterpret_cast(expr); + GetImpl()->AssignmentExpressionSetResult(_context, _receiver, _expr); + return ; +} +KOALA_INTEROP_V3(AssignmentExpressionSetResult, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_AssignmentExpressionIsLogicalExtendedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AssignmentExpressionIsLogicalExtendedConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AssignmentExpressionIsLogicalExtendedConst, KBoolean, KNativePointer, KNativePointer); + +void impl_AssignmentExpressionSetIgnoreConstAssign(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->AssignmentExpressionSetIgnoreConstAssign(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(AssignmentExpressionSetIgnoreConstAssign, KNativePointer, KNativePointer); + +KBoolean impl_AssignmentExpressionIsIgnoreConstAssignConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AssignmentExpressionIsIgnoreConstAssignConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AssignmentExpressionIsIgnoreConstAssignConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AssignmentExpressionConvertibleToAssignmentPatternLeft(KNativePointer context, KNativePointer receiver, KBoolean mustBePattern) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _mustBePattern = static_cast(mustBePattern); + auto result = GetImpl()->AssignmentExpressionConvertibleToAssignmentPatternLeft(_context, _receiver, _mustBePattern); + return result; +} +KOALA_INTEROP_3(AssignmentExpressionConvertibleToAssignmentPatternLeft, KBoolean, KNativePointer, KNativePointer, KBoolean); + +KBoolean impl_AssignmentExpressionConvertibleToAssignmentPatternRight(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AssignmentExpressionConvertibleToAssignmentPatternRight(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AssignmentExpressionConvertibleToAssignmentPatternRight, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AssignmentExpressionConvertibleToAssignmentPattern(KNativePointer context, KNativePointer receiver, KBoolean mustBePattern) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _mustBePattern = static_cast(mustBePattern); + auto result = GetImpl()->AssignmentExpressionConvertibleToAssignmentPattern(_context, _receiver, _mustBePattern); + return result; +} +KOALA_INTEROP_3(AssignmentExpressionConvertibleToAssignmentPattern, KBoolean, KNativePointer, KNativePointer, KBoolean); + +void impl_AssignmentExpressionCompilePatternConst(KNativePointer context, KNativePointer receiver, KNativePointer pg) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _pg = reinterpret_cast(pg); + GetImpl()->AssignmentExpressionCompilePatternConst(_context, _receiver, _pg); + return ; +} +KOALA_INTEROP_V3(AssignmentExpressionCompilePatternConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateExpressionStatement(KNativePointer context, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _expr = reinterpret_cast(expr); + auto result = GetImpl()->CreateExpressionStatement(_context, _expr); + return result; +} +KOALA_INTEROP_2(CreateExpressionStatement, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateExpressionStatement(KNativePointer context, KNativePointer original, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _expr = reinterpret_cast(expr); + auto result = GetImpl()->UpdateExpressionStatement(_context, _original, _expr); + return result; +} +KOALA_INTEROP_3(UpdateExpressionStatement, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ExpressionStatementGetExpressionConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ExpressionStatementGetExpressionConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ExpressionStatementGetExpressionConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ExpressionStatementGetExpression(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ExpressionStatementGetExpression(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ExpressionStatementGetExpression, KNativePointer, KNativePointer, KNativePointer); + +void impl_ExpressionStatementSetExpression(KNativePointer context, KNativePointer receiver, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _expr = reinterpret_cast(expr); + GetImpl()->ExpressionStatementSetExpression(_context, _receiver, _expr); + return ; +} +KOALA_INTEROP_V3(ExpressionStatementSetExpression, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSModuleIdent(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSModuleIdent(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSModuleIdent, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSModuleIdentConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSModuleIdentConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ETSModuleIdentConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_ETSModuleIsETSScriptConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSModuleIsETSScriptConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSModuleIsETSScriptConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ETSModuleIsNamespaceConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSModuleIsNamespaceConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSModuleIsNamespaceConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ETSModuleIsNamespaceChainLastNodeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSModuleIsNamespaceChainLastNodeConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSModuleIsNamespaceChainLastNodeConst, KBoolean, KNativePointer, KNativePointer); + +void impl_ETSModuleSetNamespaceChainLastNode(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->ETSModuleSetNamespaceChainLastNode(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(ETSModuleSetNamespaceChainLastNode, KNativePointer, KNativePointer); + +KNativePointer impl_ETSModuleAnnotations(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ETSModuleAnnotations(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(ETSModuleAnnotations, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSModuleAnnotationsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ETSModuleAnnotationsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(ETSModuleAnnotationsConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_ETSModuleSetAnnotations(KNativePointer context, KNativePointer receiver, KNativePointerArray annotations, KUInt annotationsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _annotations = reinterpret_cast(annotations); + const auto _annotationsSequenceLength = static_cast(annotationsSequenceLength); + GetImpl()->ETSModuleSetAnnotations(_context, _receiver, _annotations, _annotationsSequenceLength); + return ; +} +KOALA_INTEROP_V4(ETSModuleSetAnnotations, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_CreateMetaProperty(KNativePointer context, KInt kind) +{ + const auto _context = reinterpret_cast(context); + const auto _kind = static_cast(kind); + auto result = GetImpl()->CreateMetaProperty(_context, _kind); + return result; +} +KOALA_INTEROP_2(CreateMetaProperty, KNativePointer, KNativePointer, KInt); + +KNativePointer impl_UpdateMetaProperty(KNativePointer context, KNativePointer original, KInt kind) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _kind = static_cast(kind); + auto result = GetImpl()->UpdateMetaProperty(_context, _original, _kind); + return result; +} +KOALA_INTEROP_3(UpdateMetaProperty, KNativePointer, KNativePointer, KNativePointer, KInt); + +KInt impl_MetaPropertyKindConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->MetaPropertyKindConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(MetaPropertyKindConst, KInt, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSArrayType(KNativePointer context, KNativePointer elementType) +{ + const auto _context = reinterpret_cast(context); + const auto _elementType = reinterpret_cast(elementType); + auto result = GetImpl()->CreateTSArrayType(_context, _elementType); + return result; +} +KOALA_INTEROP_2(CreateTSArrayType, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSArrayType(KNativePointer context, KNativePointer original, KNativePointer elementType) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _elementType = reinterpret_cast(elementType); + auto result = GetImpl()->UpdateTSArrayType(_context, _original, _elementType); + return result; +} +KOALA_INTEROP_3(UpdateTSArrayType, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSArrayTypeElementTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSArrayTypeElementTypeConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSArrayTypeElementTypeConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSSignatureDeclaration(KNativePointer context, KInt kind, KNativePointer signature) +{ + const auto _context = reinterpret_cast(context); + const auto _kind = static_cast(kind); + const auto _signature = reinterpret_cast(signature); + auto result = GetImpl()->CreateTSSignatureDeclaration(_context, _kind, _signature); + return result; +} +KOALA_INTEROP_3(CreateTSSignatureDeclaration, KNativePointer, KNativePointer, KInt, KNativePointer); + +KNativePointer impl_UpdateTSSignatureDeclaration(KNativePointer context, KNativePointer original, KInt kind, KNativePointer signature) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _kind = static_cast(kind); + const auto _signature = reinterpret_cast(signature); + auto result = GetImpl()->UpdateTSSignatureDeclaration(_context, _original, _kind, _signature); + return result; +} +KOALA_INTEROP_4(UpdateTSSignatureDeclaration, KNativePointer, KNativePointer, KNativePointer, KInt, KNativePointer); + +KNativePointer impl_TSSignatureDeclarationTypeParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSSignatureDeclarationTypeParamsConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSSignatureDeclarationTypeParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSSignatureDeclarationTypeParams(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSSignatureDeclarationTypeParams(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSSignatureDeclarationTypeParams, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSSignatureDeclarationParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSSignatureDeclarationParamsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSSignatureDeclarationParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSSignatureDeclarationReturnTypeAnnotationConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSSignatureDeclarationReturnTypeAnnotationConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSSignatureDeclarationReturnTypeAnnotationConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSSignatureDeclarationReturnTypeAnnotation(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSSignatureDeclarationReturnTypeAnnotation(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSSignatureDeclarationReturnTypeAnnotation, KNativePointer, KNativePointer, KNativePointer); + +KInt impl_TSSignatureDeclarationKindConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSSignatureDeclarationKindConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSSignatureDeclarationKindConst, KInt, KNativePointer, KNativePointer); + +KNativePointer impl_CreateExportAllDeclaration(KNativePointer context, KNativePointer source, KNativePointer exported) +{ + const auto _context = reinterpret_cast(context); + const auto _source = reinterpret_cast(source); + const auto _exported = reinterpret_cast(exported); + auto result = GetImpl()->CreateExportAllDeclaration(_context, _source, _exported); + return result; +} +KOALA_INTEROP_3(CreateExportAllDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateExportAllDeclaration(KNativePointer context, KNativePointer original, KNativePointer source, KNativePointer exported) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _source = reinterpret_cast(source); + const auto _exported = reinterpret_cast(exported); + auto result = GetImpl()->UpdateExportAllDeclaration(_context, _original, _source, _exported); + return result; +} +KOALA_INTEROP_4(UpdateExportAllDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ExportAllDeclarationSourceConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ExportAllDeclarationSourceConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ExportAllDeclarationSourceConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ExportAllDeclarationExportedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ExportAllDeclarationExportedConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ExportAllDeclarationExportedConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateExportSpecifier(KNativePointer context, KNativePointer local, KNativePointer exported) +{ + const auto _context = reinterpret_cast(context); + const auto _local = reinterpret_cast(local); + const auto _exported = reinterpret_cast(exported); + auto result = GetImpl()->CreateExportSpecifier(_context, _local, _exported); + return result; +} +KOALA_INTEROP_3(CreateExportSpecifier, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateExportSpecifier(KNativePointer context, KNativePointer original, KNativePointer local, KNativePointer exported) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _local = reinterpret_cast(local); + const auto _exported = reinterpret_cast(exported); + auto result = GetImpl()->UpdateExportSpecifier(_context, _original, _local, _exported); + return result; +} +KOALA_INTEROP_4(UpdateExportSpecifier, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ExportSpecifierLocalConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ExportSpecifierLocalConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ExportSpecifierLocalConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ExportSpecifierExportedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ExportSpecifierExportedConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ExportSpecifierExportedConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSTupleType(KNativePointer context, KNativePointerArray elementTypes, KUInt elementTypesSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _elementTypes = reinterpret_cast(elementTypes); + const auto _elementTypesSequenceLength = static_cast(elementTypesSequenceLength); + auto result = GetImpl()->CreateTSTupleType(_context, _elementTypes, _elementTypesSequenceLength); + return result; +} +KOALA_INTEROP_3(CreateTSTupleType, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_UpdateTSTupleType(KNativePointer context, KNativePointer original, KNativePointerArray elementTypes, KUInt elementTypesSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _elementTypes = reinterpret_cast(elementTypes); + const auto _elementTypesSequenceLength = static_cast(elementTypesSequenceLength); + auto result = GetImpl()->UpdateTSTupleType(_context, _original, _elementTypes, _elementTypesSequenceLength); + return result; +} +KOALA_INTEROP_4(UpdateTSTupleType, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_TSTupleTypeElementTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSTupleTypeElementTypeConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSTupleTypeElementTypeConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateFunctionExpression(KNativePointer context, KNativePointer func) +{ + const auto _context = reinterpret_cast(context); + const auto _func = reinterpret_cast(func); + auto result = GetImpl()->CreateFunctionExpression(_context, _func); + return result; +} +KOALA_INTEROP_2(CreateFunctionExpression, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateFunctionExpression(KNativePointer context, KNativePointer original, KNativePointer func) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _func = reinterpret_cast(func); + auto result = GetImpl()->UpdateFunctionExpression(_context, _original, _func); + return result; +} +KOALA_INTEROP_3(UpdateFunctionExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateFunctionExpression1(KNativePointer context, KNativePointer namedExpr, KNativePointer func) +{ + const auto _context = reinterpret_cast(context); + const auto _namedExpr = reinterpret_cast(namedExpr); + const auto _func = reinterpret_cast(func); + auto result = GetImpl()->CreateFunctionExpression1(_context, _namedExpr, _func); + return result; +} +KOALA_INTEROP_3(CreateFunctionExpression1, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateFunctionExpression1(KNativePointer context, KNativePointer original, KNativePointer namedExpr, KNativePointer func) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _namedExpr = reinterpret_cast(namedExpr); + const auto _func = reinterpret_cast(func); + auto result = GetImpl()->UpdateFunctionExpression1(_context, _original, _namedExpr, _func); + return result; +} +KOALA_INTEROP_4(UpdateFunctionExpression1, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_FunctionExpressionFunctionConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->FunctionExpressionFunctionConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(FunctionExpressionFunctionConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_FunctionExpressionFunction(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->FunctionExpressionFunction(_context, _receiver); + return result; +} +KOALA_INTEROP_2(FunctionExpressionFunction, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_FunctionExpressionIsAnonymousConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->FunctionExpressionIsAnonymousConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(FunctionExpressionIsAnonymousConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_FunctionExpressionId(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->FunctionExpressionId(_context, _receiver); + return result; +} +KOALA_INTEROP_2(FunctionExpressionId, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSIndexSignature(KNativePointer context, KNativePointer param, KNativePointer typeAnnotation, KBoolean readonly_arg) +{ + const auto _context = reinterpret_cast(context); + const auto _param = reinterpret_cast(param); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + const auto _readonly_arg = static_cast(readonly_arg); + auto result = GetImpl()->CreateTSIndexSignature(_context, _param, _typeAnnotation, _readonly_arg); + return result; +} +KOALA_INTEROP_4(CreateTSIndexSignature, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_UpdateTSIndexSignature(KNativePointer context, KNativePointer original, KNativePointer param, KNativePointer typeAnnotation, KBoolean readonly_arg) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _param = reinterpret_cast(param); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + const auto _readonly_arg = static_cast(readonly_arg); + auto result = GetImpl()->UpdateTSIndexSignature(_context, _original, _param, _typeAnnotation, _readonly_arg); + return result; +} +KOALA_INTEROP_5(UpdateTSIndexSignature, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_TSIndexSignatureParamConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSIndexSignatureParamConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSIndexSignatureParamConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSIndexSignatureTypeAnnotationConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSIndexSignatureTypeAnnotationConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSIndexSignatureTypeAnnotationConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_TSIndexSignatureReadonlyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSIndexSignatureReadonlyConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSIndexSignatureReadonlyConst, KBoolean, KNativePointer, KNativePointer); + +KInt impl_TSIndexSignatureKindConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSIndexSignatureKindConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSIndexSignatureKindConst, KInt, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSModuleDeclaration(KNativePointer context, KNativePointer name, KNativePointer body, KBoolean declare, KBoolean _global) +{ + const auto _context = reinterpret_cast(context); + const auto _name = reinterpret_cast(name); + const auto _body = reinterpret_cast(body); + const auto _declare = static_cast(declare); + const auto __global = static_cast(_global); + auto result = GetImpl()->CreateTSModuleDeclaration(_context, _name, _body, _declare, __global); + return result; +} +KOALA_INTEROP_5(CreateTSModuleDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean, KBoolean); + +KNativePointer impl_UpdateTSModuleDeclaration(KNativePointer context, KNativePointer original, KNativePointer name, KNativePointer body, KBoolean declare, KBoolean _global) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _name = reinterpret_cast(name); + const auto _body = reinterpret_cast(body); + const auto _declare = static_cast(declare); + const auto __global = static_cast(_global); + auto result = GetImpl()->UpdateTSModuleDeclaration(_context, _original, _name, _body, _declare, __global); + return result; +} +KOALA_INTEROP_6(UpdateTSModuleDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean, KBoolean); + +KNativePointer impl_TSModuleDeclarationNameConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSModuleDeclarationNameConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSModuleDeclarationNameConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSModuleDeclarationBodyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSModuleDeclarationBodyConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSModuleDeclarationBodyConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_TSModuleDeclarationGlobalConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSModuleDeclarationGlobalConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSModuleDeclarationGlobalConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_TSModuleDeclarationIsExternalOrAmbientConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSModuleDeclarationIsExternalOrAmbientConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSModuleDeclarationIsExternalOrAmbientConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_CreateImportDeclaration(KNativePointer context, KNativePointer source, KNativePointerArray specifiers, KUInt specifiersSequenceLength, KInt importKinds) +{ + const auto _context = reinterpret_cast(context); + const auto _source = reinterpret_cast(source); + const auto _specifiers = reinterpret_cast(specifiers); + const auto _specifiersSequenceLength = static_cast(specifiersSequenceLength); + const auto _importKinds = static_cast(importKinds); + auto result = GetImpl()->CreateImportDeclaration(_context, _source, _specifiers, _specifiersSequenceLength, _importKinds); + return result; +} +KOALA_INTEROP_5(CreateImportDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KInt); + +KNativePointer impl_UpdateImportDeclaration(KNativePointer context, KNativePointer original, KNativePointer source, KNativePointerArray specifiers, KUInt specifiersSequenceLength, KInt importKinds) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _source = reinterpret_cast(source); + const auto _specifiers = reinterpret_cast(specifiers); + const auto _specifiersSequenceLength = static_cast(specifiersSequenceLength); + const auto _importKinds = static_cast(importKinds); + auto result = GetImpl()->UpdateImportDeclaration(_context, _original, _source, _specifiers, _specifiersSequenceLength, _importKinds); + return result; +} +KOALA_INTEROP_6(UpdateImportDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KInt); + +KNativePointer impl_ImportDeclarationSourceConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ImportDeclarationSourceConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ImportDeclarationSourceConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ImportDeclarationSource(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ImportDeclarationSource(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ImportDeclarationSource, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ImportDeclarationSpecifiersConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ImportDeclarationSpecifiersConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(ImportDeclarationSpecifiersConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ImportDeclarationSpecifiers(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ImportDeclarationSpecifiers(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(ImportDeclarationSpecifiers, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_ImportDeclarationIsTypeKindConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ImportDeclarationIsTypeKindConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ImportDeclarationIsTypeKindConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSParenthesizedType(KNativePointer context, KNativePointer type) +{ + const auto _context = reinterpret_cast(context); + const auto _type = reinterpret_cast(type); + auto result = GetImpl()->CreateTSParenthesizedType(_context, _type); + return result; +} +KOALA_INTEROP_2(CreateTSParenthesizedType, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSParenthesizedType(KNativePointer context, KNativePointer original, KNativePointer type) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _type = reinterpret_cast(type); + auto result = GetImpl()->UpdateTSParenthesizedType(_context, _original, _type); + return result; +} +KOALA_INTEROP_3(UpdateTSParenthesizedType, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSParenthesizedTypeTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSParenthesizedTypeTypeConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSParenthesizedTypeTypeConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateCharLiteral(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateCharLiteral(_context); + return result; +} +KOALA_INTEROP_1(CreateCharLiteral, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateCharLiteral(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateCharLiteral(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateCharLiteral, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateETSPackageDeclaration(KNativePointer context, KNativePointer name) +{ + const auto _context = reinterpret_cast(context); + const auto _name = reinterpret_cast(name); + auto result = GetImpl()->CreateETSPackageDeclaration(_context, _name); + return result; +} +KOALA_INTEROP_2(CreateETSPackageDeclaration, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateETSPackageDeclaration(KNativePointer context, KNativePointer original, KNativePointer name) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _name = reinterpret_cast(name); + auto result = GetImpl()->UpdateETSPackageDeclaration(_context, _original, _name); + return result; +} +KOALA_INTEROP_3(UpdateETSPackageDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateETSImportDeclaration(KNativePointer context, KNativePointer importPath, KNativePointerArray specifiers, KUInt specifiersSequenceLength, KInt importKinds) +{ + const auto _context = reinterpret_cast(context); + const auto _importPath = reinterpret_cast(importPath); + const auto _specifiers = reinterpret_cast(specifiers); + const auto _specifiersSequenceLength = static_cast(specifiersSequenceLength); + const auto _importKinds = static_cast(importKinds); + auto result = GetImpl()->CreateETSImportDeclaration(_context, _importPath, _specifiers, _specifiersSequenceLength, _importKinds); + return result; +} +KOALA_INTEROP_5(CreateETSImportDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KInt); + +KNativePointer impl_UpdateETSImportDeclaration(KNativePointer context, KNativePointer original, KNativePointer importPath, KNativePointerArray specifiers, KUInt specifiersSequenceLength, KInt importKinds) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _importPath = reinterpret_cast(importPath); + const auto _specifiers = reinterpret_cast(specifiers); + const auto _specifiersSequenceLength = static_cast(specifiersSequenceLength); + const auto _importKinds = static_cast(importKinds); + auto result = GetImpl()->UpdateETSImportDeclaration(_context, _original, _importPath, _specifiers, _specifiersSequenceLength, _importKinds); + return result; +} +KOALA_INTEROP_6(UpdateETSImportDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KInt); + +void impl_ETSImportDeclarationSetImportMetadata(KNativePointer context, KNativePointer receiver, KInt importFlags, KInt lang, KStringPtr& resolvedSource, KStringPtr& declPath, KStringPtr& ohmUrl) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _importFlags = static_cast(importFlags); + const auto _lang = static_cast(lang); + const auto _resolvedSource = getStringCopy(resolvedSource); + const auto _declPath = getStringCopy(declPath); + const auto _ohmUrl = getStringCopy(ohmUrl); + GetImpl()->ETSImportDeclarationSetImportMetadata(_context, _receiver, _importFlags, _lang, _resolvedSource, _declPath, _ohmUrl); + return ; +} +KOALA_INTEROP_V7(ETSImportDeclarationSetImportMetadata, KNativePointer, KNativePointer, KInt, KInt, KStringPtr, KStringPtr, KStringPtr); + +KNativePointer impl_ETSImportDeclarationDeclPathConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSImportDeclarationDeclPathConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(ETSImportDeclarationDeclPathConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSImportDeclarationOhmUrlConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSImportDeclarationOhmUrlConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(ETSImportDeclarationOhmUrlConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_ETSImportDeclarationIsValidConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSImportDeclarationIsValidConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSImportDeclarationIsValidConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ETSImportDeclarationIsPureDynamicConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSImportDeclarationIsPureDynamicConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSImportDeclarationIsPureDynamicConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_ETSImportDeclarationAssemblerName(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSImportDeclarationAssemblerName(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(ETSImportDeclarationAssemblerName, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSImportDeclarationAssemblerNameConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSImportDeclarationAssemblerNameConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(ETSImportDeclarationAssemblerNameConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSImportDeclarationResolvedSourceConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSImportDeclarationResolvedSourceConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(ETSImportDeclarationResolvedSourceConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateETSStructDeclaration(KNativePointer context, KNativePointer def) +{ + const auto _context = reinterpret_cast(context); + const auto _def = reinterpret_cast(def); + auto result = GetImpl()->CreateETSStructDeclaration(_context, _def); + return result; +} +KOALA_INTEROP_2(CreateETSStructDeclaration, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateETSStructDeclaration(KNativePointer context, KNativePointer original, KNativePointer def) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _def = reinterpret_cast(def); + auto result = GetImpl()->UpdateETSStructDeclaration(_context, _original, _def); + return result; +} +KOALA_INTEROP_3(UpdateETSStructDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSModuleBlock(KNativePointer context, KNativePointerArray statements, KUInt statementsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _statements = reinterpret_cast(statements); + const auto _statementsSequenceLength = static_cast(statementsSequenceLength); + auto result = GetImpl()->CreateTSModuleBlock(_context, _statements, _statementsSequenceLength); + return result; +} +KOALA_INTEROP_3(CreateTSModuleBlock, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_UpdateTSModuleBlock(KNativePointer context, KNativePointer original, KNativePointerArray statements, KUInt statementsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _statements = reinterpret_cast(statements); + const auto _statementsSequenceLength = static_cast(statementsSequenceLength); + auto result = GetImpl()->UpdateTSModuleBlock(_context, _original, _statements, _statementsSequenceLength); + return result; +} +KOALA_INTEROP_4(UpdateTSModuleBlock, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_TSModuleBlockStatementsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSModuleBlockStatementsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSModuleBlockStatementsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateETSNewArrayInstanceExpression(KNativePointer context, KNativePointer typeReference, KNativePointer dimension) +{ + const auto _context = reinterpret_cast(context); + const auto _typeReference = reinterpret_cast(typeReference); + const auto _dimension = reinterpret_cast(dimension); + auto result = GetImpl()->CreateETSNewArrayInstanceExpression(_context, _typeReference, _dimension); + return result; +} +KOALA_INTEROP_3(CreateETSNewArrayInstanceExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateETSNewArrayInstanceExpression(KNativePointer context, KNativePointer original, KNativePointer typeReference, KNativePointer dimension) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _typeReference = reinterpret_cast(typeReference); + const auto _dimension = reinterpret_cast(dimension); + auto result = GetImpl()->UpdateETSNewArrayInstanceExpression(_context, _original, _typeReference, _dimension); + return result; +} +KOALA_INTEROP_4(UpdateETSNewArrayInstanceExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSNewArrayInstanceExpressionTypeReference(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSNewArrayInstanceExpressionTypeReference(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSNewArrayInstanceExpressionTypeReference, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSNewArrayInstanceExpressionTypeReferenceConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSNewArrayInstanceExpressionTypeReferenceConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ETSNewArrayInstanceExpressionTypeReferenceConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSNewArrayInstanceExpressionDimension(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSNewArrayInstanceExpressionDimension(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSNewArrayInstanceExpressionDimension, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSNewArrayInstanceExpressionDimensionConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSNewArrayInstanceExpressionDimensionConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ETSNewArrayInstanceExpressionDimensionConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_ETSNewArrayInstanceExpressionSetDimension(KNativePointer context, KNativePointer receiver, KNativePointer dimension) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _dimension = reinterpret_cast(dimension); + GetImpl()->ETSNewArrayInstanceExpressionSetDimension(_context, _receiver, _dimension); + return ; +} +KOALA_INTEROP_V3(ETSNewArrayInstanceExpressionSetDimension, KNativePointer, KNativePointer, KNativePointer); + +void impl_ETSNewArrayInstanceExpressionClearPreferredType(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->ETSNewArrayInstanceExpressionClearPreferredType(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(ETSNewArrayInstanceExpressionClearPreferredType, KNativePointer, KNativePointer); + +KNativePointer impl_CreateAnnotationDeclaration(KNativePointer context, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _expr = reinterpret_cast(expr); + auto result = GetImpl()->CreateAnnotationDeclaration(_context, _expr); + return result; +} +KOALA_INTEROP_2(CreateAnnotationDeclaration, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateAnnotationDeclaration(KNativePointer context, KNativePointer original, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _expr = reinterpret_cast(expr); + auto result = GetImpl()->UpdateAnnotationDeclaration(_context, _original, _expr); + return result; +} +KOALA_INTEROP_3(UpdateAnnotationDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateAnnotationDeclaration1(KNativePointer context, KNativePointer expr, KNativePointerArray properties, KUInt propertiesSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _expr = reinterpret_cast(expr); + const auto _properties = reinterpret_cast(properties); + const auto _propertiesSequenceLength = static_cast(propertiesSequenceLength); + auto result = GetImpl()->CreateAnnotationDeclaration1(_context, _expr, _properties, _propertiesSequenceLength); + return result; +} +KOALA_INTEROP_4(CreateAnnotationDeclaration1, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_UpdateAnnotationDeclaration1(KNativePointer context, KNativePointer original, KNativePointer expr, KNativePointerArray properties, KUInt propertiesSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _expr = reinterpret_cast(expr); + const auto _properties = reinterpret_cast(properties); + const auto _propertiesSequenceLength = static_cast(propertiesSequenceLength); + auto result = GetImpl()->UpdateAnnotationDeclaration1(_context, _original, _expr, _properties, _propertiesSequenceLength); + return result; +} +KOALA_INTEROP_5(UpdateAnnotationDeclaration1, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_AnnotationDeclarationInternalNameConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AnnotationDeclarationInternalNameConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(AnnotationDeclarationInternalNameConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_AnnotationDeclarationSetInternalName(KNativePointer context, KNativePointer receiver, KStringPtr& internalName) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _internalName = getStringCopy(internalName); + GetImpl()->AnnotationDeclarationSetInternalName(_context, _receiver, _internalName); + return ; +} +KOALA_INTEROP_V3(AnnotationDeclarationSetInternalName, KNativePointer, KNativePointer, KStringPtr); + +KNativePointer impl_AnnotationDeclarationExprConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AnnotationDeclarationExprConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(AnnotationDeclarationExprConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AnnotationDeclarationExpr(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AnnotationDeclarationExpr(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AnnotationDeclarationExpr, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AnnotationDeclarationProperties(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->AnnotationDeclarationProperties(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(AnnotationDeclarationProperties, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AnnotationDeclarationPropertiesConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->AnnotationDeclarationPropertiesConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(AnnotationDeclarationPropertiesConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_AnnotationDeclarationAddProperties(KNativePointer context, KNativePointer receiver, KNativePointerArray properties, KUInt propertiesSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _properties = reinterpret_cast(properties); + const auto _propertiesSequenceLength = static_cast(propertiesSequenceLength); + GetImpl()->AnnotationDeclarationAddProperties(_context, _receiver, _properties, _propertiesSequenceLength); + return ; +} +KOALA_INTEROP_V4(AnnotationDeclarationAddProperties, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KBoolean impl_AnnotationDeclarationIsSourceRetentionConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AnnotationDeclarationIsSourceRetentionConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AnnotationDeclarationIsSourceRetentionConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AnnotationDeclarationIsBytecodeRetentionConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AnnotationDeclarationIsBytecodeRetentionConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AnnotationDeclarationIsBytecodeRetentionConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AnnotationDeclarationIsRuntimeRetentionConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AnnotationDeclarationIsRuntimeRetentionConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AnnotationDeclarationIsRuntimeRetentionConst, KBoolean, KNativePointer, KNativePointer); + +void impl_AnnotationDeclarationSetSourceRetention(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->AnnotationDeclarationSetSourceRetention(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(AnnotationDeclarationSetSourceRetention, KNativePointer, KNativePointer); + +void impl_AnnotationDeclarationSetBytecodeRetention(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->AnnotationDeclarationSetBytecodeRetention(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(AnnotationDeclarationSetBytecodeRetention, KNativePointer, KNativePointer); + +void impl_AnnotationDeclarationSetRuntimeRetention(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->AnnotationDeclarationSetRuntimeRetention(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(AnnotationDeclarationSetRuntimeRetention, KNativePointer, KNativePointer); + +KNativePointer impl_AnnotationDeclarationGetBaseNameConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AnnotationDeclarationGetBaseNameConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(AnnotationDeclarationGetBaseNameConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AnnotationDeclarationAnnotations(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->AnnotationDeclarationAnnotations(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(AnnotationDeclarationAnnotations, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AnnotationDeclarationAnnotationsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->AnnotationDeclarationAnnotationsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(AnnotationDeclarationAnnotationsConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_AnnotationDeclarationSetAnnotations(KNativePointer context, KNativePointer receiver, KNativePointerArray annotations, KUInt annotationsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _annotations = reinterpret_cast(annotations); + const auto _annotationsSequenceLength = static_cast(annotationsSequenceLength); + GetImpl()->AnnotationDeclarationSetAnnotations(_context, _receiver, _annotations, _annotationsSequenceLength); + return ; +} +KOALA_INTEROP_V4(AnnotationDeclarationSetAnnotations, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_CreateAnnotationUsage(KNativePointer context, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _expr = reinterpret_cast(expr); + auto result = GetImpl()->CreateAnnotationUsageIr(_context, _expr); + return result; +} +KOALA_INTEROP_2(CreateAnnotationUsage, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateAnnotationUsage(KNativePointer context, KNativePointer original, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _expr = reinterpret_cast(expr); + auto result = GetImpl()->UpdateAnnotationUsageIr(_context, _original, _expr); + return result; +} +KOALA_INTEROP_3(UpdateAnnotationUsage, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateAnnotationUsage1(KNativePointer context, KNativePointer expr, KNativePointerArray properties, KUInt propertiesSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _expr = reinterpret_cast(expr); + const auto _properties = reinterpret_cast(properties); + const auto _propertiesSequenceLength = static_cast(propertiesSequenceLength); + auto result = GetImpl()->CreateAnnotationUsageIr1(_context, _expr, _properties, _propertiesSequenceLength); + return result; +} +KOALA_INTEROP_4(CreateAnnotationUsage1, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_UpdateAnnotationUsage1(KNativePointer context, KNativePointer original, KNativePointer expr, KNativePointerArray properties, KUInt propertiesSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _expr = reinterpret_cast(expr); + const auto _properties = reinterpret_cast(properties); + const auto _propertiesSequenceLength = static_cast(propertiesSequenceLength); + auto result = GetImpl()->UpdateAnnotationUsageIr1(_context, _original, _expr, _properties, _propertiesSequenceLength); + return result; +} +KOALA_INTEROP_5(UpdateAnnotationUsage1, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_AnnotationUsageExpr(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AnnotationUsageIrExpr(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AnnotationUsageExpr, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AnnotationUsageProperties(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->AnnotationUsageIrProperties(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(AnnotationUsageProperties, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AnnotationUsagePropertiesConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->AnnotationUsageIrPropertiesConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(AnnotationUsagePropertiesConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_AnnotationUsageAddProperty(KNativePointer context, KNativePointer receiver, KNativePointer property) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _property = reinterpret_cast(property); + GetImpl()->AnnotationUsageIrAddProperty(_context, _receiver, _property); + return ; +} +KOALA_INTEROP_V3(AnnotationUsageAddProperty, KNativePointer, KNativePointer, KNativePointer); + +void impl_AnnotationUsageSetProperties(KNativePointer context, KNativePointer receiver, KNativePointerArray properties, KUInt propertiesSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _properties = reinterpret_cast(properties); + const auto _propertiesSequenceLength = static_cast(propertiesSequenceLength); + GetImpl()->AnnotationUsageIrSetProperties(_context, _receiver, _properties, _propertiesSequenceLength); + return ; +} +KOALA_INTEROP_V4(AnnotationUsageSetProperties, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_AnnotationUsageGetBaseNameConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AnnotationUsageIrGetBaseNameConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(AnnotationUsageGetBaseNameConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateEmptyStatement(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateEmptyStatement(_context); + return result; +} +KOALA_INTEROP_1(CreateEmptyStatement, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateEmptyStatement(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateEmptyStatement(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateEmptyStatement, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateWhileStatement(KNativePointer context, KNativePointer test, KNativePointer body) +{ + const auto _context = reinterpret_cast(context); + const auto _test = reinterpret_cast(test); + const auto _body = reinterpret_cast(body); + auto result = GetImpl()->CreateWhileStatement(_context, _test, _body); + return result; +} +KOALA_INTEROP_3(CreateWhileStatement, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateWhileStatement(KNativePointer context, KNativePointer original, KNativePointer test, KNativePointer body) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _test = reinterpret_cast(test); + const auto _body = reinterpret_cast(body); + auto result = GetImpl()->UpdateWhileStatement(_context, _original, _test, _body); + return result; +} +KOALA_INTEROP_4(UpdateWhileStatement, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_WhileStatementTestConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->WhileStatementTestConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(WhileStatementTestConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_WhileStatementTest(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->WhileStatementTest(_context, _receiver); + return result; +} +KOALA_INTEROP_2(WhileStatementTest, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_WhileStatementBodyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->WhileStatementBodyConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(WhileStatementBodyConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_WhileStatementBody(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->WhileStatementBody(_context, _receiver); + return result; +} +KOALA_INTEROP_2(WhileStatementBody, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateFunctionSignature(KNativePointer context, KNativePointer typeParams, KNativePointerArray params, KUInt paramsSequenceLength, KNativePointer returnTypeAnnotation, KBoolean hasReceiver) +{ + const auto _context = reinterpret_cast(context); + const auto _typeParams = reinterpret_cast(typeParams); + const auto _params = reinterpret_cast(params); + const auto _paramsSequenceLength = static_cast(paramsSequenceLength); + const auto _returnTypeAnnotation = reinterpret_cast(returnTypeAnnotation); + const auto _hasReceiver = static_cast(hasReceiver); + auto result = GetImpl()->CreateFunctionSignature(_context, _typeParams, _params, _paramsSequenceLength, _returnTypeAnnotation, _hasReceiver); + return result; +} +KOALA_INTEROP_6(CreateFunctionSignature, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KNativePointer, KBoolean); + +KNativePointer impl_FunctionSignatureParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->FunctionSignatureParamsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(FunctionSignatureParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_FunctionSignatureParams(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->FunctionSignatureParams(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(FunctionSignatureParams, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_FunctionSignatureTypeParams(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->FunctionSignatureTypeParams(_context, _receiver); + return result; +} +KOALA_INTEROP_2(FunctionSignatureTypeParams, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_FunctionSignatureTypeParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->FunctionSignatureTypeParamsConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(FunctionSignatureTypeParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_FunctionSignatureReturnType(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->FunctionSignatureReturnType(_context, _receiver); + return result; +} +KOALA_INTEROP_2(FunctionSignatureReturnType, KNativePointer, KNativePointer, KNativePointer); + +void impl_FunctionSignatureSetReturnType(KNativePointer context, KNativePointer receiver, KNativePointer type) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _type = reinterpret_cast(type); + GetImpl()->FunctionSignatureSetReturnType(_context, _receiver, _type); + return ; +} +KOALA_INTEROP_V3(FunctionSignatureSetReturnType, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_FunctionSignatureReturnTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->FunctionSignatureReturnTypeConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(FunctionSignatureReturnTypeConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_FunctionSignatureClone(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->FunctionSignatureClone(_context, _receiver); + return result; +} +KOALA_INTEROP_2(FunctionSignatureClone, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_FunctionSignatureHasReceiverConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->FunctionSignatureHasReceiverConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(FunctionSignatureHasReceiverConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_CreateChainExpression(KNativePointer context, KNativePointer expression) +{ + const auto _context = reinterpret_cast(context); + const auto _expression = reinterpret_cast(expression); + auto result = GetImpl()->CreateChainExpression(_context, _expression); + return result; +} +KOALA_INTEROP_2(CreateChainExpression, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateChainExpression(KNativePointer context, KNativePointer original, KNativePointer expression) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _expression = reinterpret_cast(expression); + auto result = GetImpl()->UpdateChainExpression(_context, _original, _expression); + return result; +} +KOALA_INTEROP_3(UpdateChainExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ChainExpressionGetExpressionConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ChainExpressionGetExpressionConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ChainExpressionGetExpressionConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ChainExpressionGetExpression(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ChainExpressionGetExpression(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ChainExpressionGetExpression, KNativePointer, KNativePointer, KNativePointer); + +void impl_ChainExpressionCompileToRegConst(KNativePointer context, KNativePointer receiver, KNativePointer pg, KNativePointer objReg) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _pg = reinterpret_cast(pg); + const auto _objReg = reinterpret_cast(objReg); + GetImpl()->ChainExpressionCompileToRegConst(_context, _receiver, _pg, _objReg); + return ; +} +KOALA_INTEROP_V4(ChainExpressionCompileToRegConst, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSIntersectionType(KNativePointer context, KNativePointerArray types, KUInt typesSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _types = reinterpret_cast(types); + const auto _typesSequenceLength = static_cast(typesSequenceLength); + auto result = GetImpl()->CreateTSIntersectionType(_context, _types, _typesSequenceLength); + return result; +} +KOALA_INTEROP_3(CreateTSIntersectionType, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_UpdateTSIntersectionType(KNativePointer context, KNativePointer original, KNativePointerArray types, KUInt typesSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _types = reinterpret_cast(types); + const auto _typesSequenceLength = static_cast(typesSequenceLength); + auto result = GetImpl()->UpdateTSIntersectionType(_context, _original, _types, _typesSequenceLength); + return result; +} +KOALA_INTEROP_4(UpdateTSIntersectionType, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_TSIntersectionTypeTypesConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSIntersectionTypeTypesConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSIntersectionTypeTypesConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateUpdateExpression(KNativePointer context, KNativePointer argument, KInt updateOperator, KBoolean isPrefix) +{ + const auto _context = reinterpret_cast(context); + const auto _argument = reinterpret_cast(argument); + const auto _updateOperator = static_cast(updateOperator); + const auto _isPrefix = static_cast(isPrefix); + auto result = GetImpl()->CreateUpdateExpression(_context, _argument, _updateOperator, _isPrefix); + return result; +} +KOALA_INTEROP_4(CreateUpdateExpression, KNativePointer, KNativePointer, KNativePointer, KInt, KBoolean); + +KNativePointer impl_UpdateUpdateExpression(KNativePointer context, KNativePointer original, KNativePointer argument, KInt updateOperator, KBoolean isPrefix) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _argument = reinterpret_cast(argument); + const auto _updateOperator = static_cast(updateOperator); + const auto _isPrefix = static_cast(isPrefix); + auto result = GetImpl()->UpdateUpdateExpression(_context, _original, _argument, _updateOperator, _isPrefix); + return result; +} +KOALA_INTEROP_5(UpdateUpdateExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KInt, KBoolean); + +KInt impl_UpdateExpressionOperatorTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->UpdateExpressionOperatorTypeConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(UpdateExpressionOperatorTypeConst, KInt, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateExpressionArgument(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->UpdateExpressionArgument(_context, _receiver); + return result; +} +KOALA_INTEROP_2(UpdateExpressionArgument, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateExpressionArgumentConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->UpdateExpressionArgumentConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(UpdateExpressionArgumentConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_UpdateExpressionIsPrefixConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->UpdateExpressionIsPrefixConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(UpdateExpressionIsPrefixConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_CreateBlockExpression(KNativePointer context, KNativePointerArray statements, KUInt statementsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _statements = reinterpret_cast(statements); + const auto _statementsSequenceLength = static_cast(statementsSequenceLength); + auto result = GetImpl()->CreateBlockExpression(_context, _statements, _statementsSequenceLength); + return result; +} +KOALA_INTEROP_3(CreateBlockExpression, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_UpdateBlockExpression(KNativePointer context, KNativePointer original, KNativePointerArray statements, KUInt statementsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _statements = reinterpret_cast(statements); + const auto _statementsSequenceLength = static_cast(statementsSequenceLength); + auto result = GetImpl()->UpdateBlockExpression(_context, _original, _statements, _statementsSequenceLength); + return result; +} +KOALA_INTEROP_4(UpdateBlockExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_BlockExpressionStatementsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->BlockExpressionStatementsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(BlockExpressionStatementsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_BlockExpressionStatements(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->BlockExpressionStatements(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(BlockExpressionStatements, KNativePointer, KNativePointer, KNativePointer); + +void impl_BlockExpressionAddStatements(KNativePointer context, KNativePointer receiver, KNativePointerArray statements, KUInt statementsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _statements = reinterpret_cast(statements); + const auto _statementsSequenceLength = static_cast(statementsSequenceLength); + GetImpl()->BlockExpressionAddStatements(_context, _receiver, _statements, _statementsSequenceLength); + return ; +} +KOALA_INTEROP_V4(BlockExpressionAddStatements, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +void impl_BlockExpressionAddStatement(KNativePointer context, KNativePointer receiver, KNativePointer statement) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _statement = reinterpret_cast(statement); + GetImpl()->BlockExpressionAddStatement(_context, _receiver, _statement); + return ; +} +KOALA_INTEROP_V3(BlockExpressionAddStatement, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSTypeLiteral(KNativePointer context, KNativePointerArray members, KUInt membersSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _members = reinterpret_cast(members); + const auto _membersSequenceLength = static_cast(membersSequenceLength); + auto result = GetImpl()->CreateTSTypeLiteral(_context, _members, _membersSequenceLength); + return result; +} +KOALA_INTEROP_3(CreateTSTypeLiteral, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_UpdateTSTypeLiteral(KNativePointer context, KNativePointer original, KNativePointerArray members, KUInt membersSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _members = reinterpret_cast(members); + const auto _membersSequenceLength = static_cast(membersSequenceLength); + auto result = GetImpl()->UpdateTSTypeLiteral(_context, _original, _members, _membersSequenceLength); + return result; +} +KOALA_INTEROP_4(UpdateTSTypeLiteral, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_TSTypeLiteralMembersConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSTypeLiteralMembersConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSTypeLiteralMembersConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSTypeParameter(KNativePointer context, KNativePointer name, KNativePointer constraint, KNativePointer defaultType) +{ + const auto _context = reinterpret_cast(context); + const auto _name = reinterpret_cast(name); + const auto _constraint = reinterpret_cast(constraint); + const auto _defaultType = reinterpret_cast(defaultType); + auto result = GetImpl()->CreateTSTypeParameter(_context, _name, _constraint, _defaultType); + return result; +} +KOALA_INTEROP_4(CreateTSTypeParameter, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSTypeParameter(KNativePointer context, KNativePointer original, KNativePointer name, KNativePointer constraint, KNativePointer defaultType) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _name = reinterpret_cast(name); + const auto _constraint = reinterpret_cast(constraint); + const auto _defaultType = reinterpret_cast(defaultType); + auto result = GetImpl()->UpdateTSTypeParameter(_context, _original, _name, _constraint, _defaultType); + return result; +} +KOALA_INTEROP_5(UpdateTSTypeParameter, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSTypeParameter1(KNativePointer context, KNativePointer name, KNativePointer constraint, KNativePointer defaultType, KInt flags) +{ + const auto _context = reinterpret_cast(context); + const auto _name = reinterpret_cast(name); + const auto _constraint = reinterpret_cast(constraint); + const auto _defaultType = reinterpret_cast(defaultType); + const auto _flags = static_cast(flags); + auto result = GetImpl()->CreateTSTypeParameter1(_context, _name, _constraint, _defaultType, _flags); + return result; +} +KOALA_INTEROP_5(CreateTSTypeParameter1, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KInt); + +KNativePointer impl_UpdateTSTypeParameter1(KNativePointer context, KNativePointer original, KNativePointer name, KNativePointer constraint, KNativePointer defaultType, KInt flags) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _name = reinterpret_cast(name); + const auto _constraint = reinterpret_cast(constraint); + const auto _defaultType = reinterpret_cast(defaultType); + const auto _flags = static_cast(flags); + auto result = GetImpl()->UpdateTSTypeParameter1(_context, _original, _name, _constraint, _defaultType, _flags); + return result; +} +KOALA_INTEROP_6(UpdateTSTypeParameter1, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KInt); + +KNativePointer impl_TSTypeParameterNameConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSTypeParameterNameConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSTypeParameterNameConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSTypeParameterName(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSTypeParameterName(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSTypeParameterName, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSTypeParameterConstraint(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSTypeParameterConstraint(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSTypeParameterConstraint, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSTypeParameterConstraintConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSTypeParameterConstraintConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSTypeParameterConstraintConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_TSTypeParameterSetConstraint(KNativePointer context, KNativePointer receiver, KNativePointer constraint) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _constraint = reinterpret_cast(constraint); + GetImpl()->TSTypeParameterSetConstraint(_context, _receiver, _constraint); + return ; +} +KOALA_INTEROP_V3(TSTypeParameterSetConstraint, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSTypeParameterDefaultTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSTypeParameterDefaultTypeConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSTypeParameterDefaultTypeConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_TSTypeParameterSetDefaultType(KNativePointer context, KNativePointer receiver, KNativePointer defaultType) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _defaultType = reinterpret_cast(defaultType); + GetImpl()->TSTypeParameterSetDefaultType(_context, _receiver, _defaultType); + return ; +} +KOALA_INTEROP_V3(TSTypeParameterSetDefaultType, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSTypeParameterAnnotations(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSTypeParameterAnnotations(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSTypeParameterAnnotations, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSTypeParameterAnnotationsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSTypeParameterAnnotationsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSTypeParameterAnnotationsConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_TSTypeParameterSetAnnotations(KNativePointer context, KNativePointer receiver, KNativePointerArray annotations, KUInt annotationsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _annotations = reinterpret_cast(annotations); + const auto _annotationsSequenceLength = static_cast(annotationsSequenceLength); + GetImpl()->TSTypeParameterSetAnnotations(_context, _receiver, _annotations, _annotationsSequenceLength); + return ; +} +KOALA_INTEROP_V4(TSTypeParameterSetAnnotations, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_CreateTSBooleanKeyword(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateTSBooleanKeyword(_context); + return result; +} +KOALA_INTEROP_1(CreateTSBooleanKeyword, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSBooleanKeyword(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateTSBooleanKeyword(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateTSBooleanKeyword, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateSpreadElement(KNativePointer context, KInt nodeType, KNativePointer argument) +{ + const auto _context = reinterpret_cast(context); + const auto _nodeType = static_cast(nodeType); + const auto _argument = reinterpret_cast(argument); + auto result = GetImpl()->CreateSpreadElement(_context, _nodeType, _argument); + return result; +} +KOALA_INTEROP_3(CreateSpreadElement, KNativePointer, KNativePointer, KInt, KNativePointer); + +KNativePointer impl_UpdateSpreadElement(KNativePointer context, KNativePointer original, KInt nodeType, KNativePointer argument) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _nodeType = static_cast(nodeType); + const auto _argument = reinterpret_cast(argument); + auto result = GetImpl()->UpdateSpreadElement(_context, _original, _nodeType, _argument); + return result; +} +KOALA_INTEROP_4(UpdateSpreadElement, KNativePointer, KNativePointer, KNativePointer, KInt, KNativePointer); + +KNativePointer impl_SpreadElementArgumentConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->SpreadElementArgumentConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(SpreadElementArgumentConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_SpreadElementArgument(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->SpreadElementArgument(_context, _receiver); + return result; +} +KOALA_INTEROP_2(SpreadElementArgument, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_SpreadElementIsOptionalConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->SpreadElementIsOptionalConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(SpreadElementIsOptionalConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_SpreadElementDecoratorsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->SpreadElementDecoratorsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(SpreadElementDecoratorsConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_SpreadElementSetOptional(KNativePointer context, KNativePointer receiver, KBoolean optional_arg) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _optional_arg = static_cast(optional_arg); + GetImpl()->SpreadElementSetOptional(_context, _receiver, _optional_arg); + return ; +} +KOALA_INTEROP_V3(SpreadElementSetOptional, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_SpreadElementValidateExpression(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->SpreadElementValidateExpression(_context, _receiver); + return result; +} +KOALA_INTEROP_2(SpreadElementValidateExpression, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_SpreadElementConvertibleToRest(KNativePointer context, KNativePointer receiver, KBoolean isDeclaration, KBoolean allowPattern) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _isDeclaration = static_cast(isDeclaration); + const auto _allowPattern = static_cast(allowPattern); + auto result = GetImpl()->SpreadElementConvertibleToRest(_context, _receiver, _isDeclaration, _allowPattern); + return result; +} +KOALA_INTEROP_4(SpreadElementConvertibleToRest, KBoolean, KNativePointer, KNativePointer, KBoolean, KBoolean); + +KNativePointer impl_SpreadElementTypeAnnotationConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->SpreadElementTypeAnnotationConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(SpreadElementTypeAnnotationConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_SpreadElementSetTsTypeAnnotation(KNativePointer context, KNativePointer receiver, KNativePointer typeAnnotation) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + GetImpl()->SpreadElementSetTsTypeAnnotation(_context, _receiver, _typeAnnotation); + return ; +} +KOALA_INTEROP_V3(SpreadElementSetTsTypeAnnotation, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSTypePredicate(KNativePointer context, KNativePointer parameterName, KNativePointer typeAnnotation, KBoolean asserts) +{ + const auto _context = reinterpret_cast(context); + const auto _parameterName = reinterpret_cast(parameterName); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + const auto _asserts = static_cast(asserts); + auto result = GetImpl()->CreateTSTypePredicate(_context, _parameterName, _typeAnnotation, _asserts); + return result; +} +KOALA_INTEROP_4(CreateTSTypePredicate, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_UpdateTSTypePredicate(KNativePointer context, KNativePointer original, KNativePointer parameterName, KNativePointer typeAnnotation, KBoolean asserts) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _parameterName = reinterpret_cast(parameterName); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + const auto _asserts = static_cast(asserts); + auto result = GetImpl()->UpdateTSTypePredicate(_context, _original, _parameterName, _typeAnnotation, _asserts); + return result; +} +KOALA_INTEROP_5(UpdateTSTypePredicate, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_TSTypePredicateParameterNameConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSTypePredicateParameterNameConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSTypePredicateParameterNameConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSTypePredicateTypeAnnotationConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSTypePredicateTypeAnnotationConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSTypePredicateTypeAnnotationConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_TSTypePredicateAssertsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSTypePredicateAssertsConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSTypePredicateAssertsConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_CreateImportNamespaceSpecifier(KNativePointer context, KNativePointer local) +{ + const auto _context = reinterpret_cast(context); + const auto _local = reinterpret_cast(local); + auto result = GetImpl()->CreateImportNamespaceSpecifier(_context, _local); + return result; +} +KOALA_INTEROP_2(CreateImportNamespaceSpecifier, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateImportNamespaceSpecifier(KNativePointer context, KNativePointer original, KNativePointer local) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _local = reinterpret_cast(local); + auto result = GetImpl()->UpdateImportNamespaceSpecifier(_context, _original, _local); + return result; +} +KOALA_INTEROP_3(UpdateImportNamespaceSpecifier, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ImportNamespaceSpecifierLocal(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ImportNamespaceSpecifierLocal(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ImportNamespaceSpecifierLocal, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ImportNamespaceSpecifierLocalConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ImportNamespaceSpecifierLocalConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ImportNamespaceSpecifierLocalConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateExportNamedDeclaration(KNativePointer context, KNativePointer source, KNativePointerArray specifiers, KUInt specifiersSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _source = reinterpret_cast(source); + const auto _specifiers = reinterpret_cast(specifiers); + const auto _specifiersSequenceLength = static_cast(specifiersSequenceLength); + auto result = GetImpl()->CreateExportNamedDeclaration(_context, _source, _specifiers, _specifiersSequenceLength); + return result; +} +KOALA_INTEROP_4(CreateExportNamedDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_UpdateExportNamedDeclaration(KNativePointer context, KNativePointer original, KNativePointer source, KNativePointerArray specifiers, KUInt specifiersSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _source = reinterpret_cast(source); + const auto _specifiers = reinterpret_cast(specifiers); + const auto _specifiersSequenceLength = static_cast(specifiersSequenceLength); + auto result = GetImpl()->UpdateExportNamedDeclaration(_context, _original, _source, _specifiers, _specifiersSequenceLength); + return result; +} +KOALA_INTEROP_5(UpdateExportNamedDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_CreateExportNamedDeclaration1(KNativePointer context, KNativePointer decl, KNativePointerArray specifiers, KUInt specifiersSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _decl = reinterpret_cast(decl); + const auto _specifiers = reinterpret_cast(specifiers); + const auto _specifiersSequenceLength = static_cast(specifiersSequenceLength); + auto result = GetImpl()->CreateExportNamedDeclaration1(_context, _decl, _specifiers, _specifiersSequenceLength); + return result; +} +KOALA_INTEROP_4(CreateExportNamedDeclaration1, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_UpdateExportNamedDeclaration1(KNativePointer context, KNativePointer original, KNativePointer decl, KNativePointerArray specifiers, KUInt specifiersSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _decl = reinterpret_cast(decl); + const auto _specifiers = reinterpret_cast(specifiers); + const auto _specifiersSequenceLength = static_cast(specifiersSequenceLength); + auto result = GetImpl()->UpdateExportNamedDeclaration1(_context, _original, _decl, _specifiers, _specifiersSequenceLength); + return result; +} +KOALA_INTEROP_5(UpdateExportNamedDeclaration1, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_CreateExportNamedDeclaration2(KNativePointer context, KNativePointer decl) +{ + const auto _context = reinterpret_cast(context); + const auto _decl = reinterpret_cast(decl); + auto result = GetImpl()->CreateExportNamedDeclaration2(_context, _decl); + return result; +} +KOALA_INTEROP_2(CreateExportNamedDeclaration2, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateExportNamedDeclaration2(KNativePointer context, KNativePointer original, KNativePointer decl) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _decl = reinterpret_cast(decl); + auto result = GetImpl()->UpdateExportNamedDeclaration2(_context, _original, _decl); + return result; +} +KOALA_INTEROP_3(UpdateExportNamedDeclaration2, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ExportNamedDeclarationDeclConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ExportNamedDeclarationDeclConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ExportNamedDeclarationDeclConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ExportNamedDeclarationSourceConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ExportNamedDeclarationSourceConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ExportNamedDeclarationSourceConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ExportNamedDeclarationSpecifiersConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ExportNamedDeclarationSpecifiersConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(ExportNamedDeclarationSpecifiersConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateETSParameterExpression(KNativePointer context, KNativePointer identOrSpread, KBoolean isOptional) +{ + const auto _context = reinterpret_cast(context); + const auto _identOrSpread = reinterpret_cast(identOrSpread); + const auto _isOptional = static_cast(isOptional); + auto result = GetImpl()->CreateETSParameterExpression(_context, _identOrSpread, _isOptional); + return result; +} +KOALA_INTEROP_3(CreateETSParameterExpression, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_UpdateETSParameterExpression(KNativePointer context, KNativePointer original, KNativePointer identOrSpread, KBoolean isOptional) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _identOrSpread = reinterpret_cast(identOrSpread); + const auto _isOptional = static_cast(isOptional); + auto result = GetImpl()->UpdateETSParameterExpression(_context, _original, _identOrSpread, _isOptional); + return result; +} +KOALA_INTEROP_4(UpdateETSParameterExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_CreateETSParameterExpression1(KNativePointer context, KNativePointer identOrSpread, KNativePointer initializer) +{ + const auto _context = reinterpret_cast(context); + const auto _identOrSpread = reinterpret_cast(identOrSpread); + const auto _initializer = reinterpret_cast(initializer); + auto result = GetImpl()->CreateETSParameterExpression1(_context, _identOrSpread, _initializer); + return result; +} +KOALA_INTEROP_3(CreateETSParameterExpression1, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateETSParameterExpression1(KNativePointer context, KNativePointer original, KNativePointer identOrSpread, KNativePointer initializer) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _identOrSpread = reinterpret_cast(identOrSpread); + const auto _initializer = reinterpret_cast(initializer); + auto result = GetImpl()->UpdateETSParameterExpression1(_context, _original, _identOrSpread, _initializer); + return result; +} +KOALA_INTEROP_4(UpdateETSParameterExpression1, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSParameterExpressionNameConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSParameterExpressionNameConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(ETSParameterExpressionNameConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSParameterExpressionIdentConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSParameterExpressionIdentConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ETSParameterExpressionIdentConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSParameterExpressionIdent(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSParameterExpressionIdent(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSParameterExpressionIdent, KNativePointer, KNativePointer, KNativePointer); + +void impl_ETSParameterExpressionSetIdent(KNativePointer context, KNativePointer receiver, KNativePointer ident) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _ident = reinterpret_cast(ident); + GetImpl()->ETSParameterExpressionSetIdent(_context, _receiver, _ident); + return ; +} +KOALA_INTEROP_V3(ETSParameterExpressionSetIdent, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSParameterExpressionRestParameterConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSParameterExpressionRestParameterConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ETSParameterExpressionRestParameterConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSParameterExpressionRestParameter(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSParameterExpressionRestParameter(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSParameterExpressionRestParameter, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSParameterExpressionInitializerConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSParameterExpressionInitializerConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ETSParameterExpressionInitializerConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSParameterExpressionInitializer(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSParameterExpressionInitializer(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSParameterExpressionInitializer, KNativePointer, KNativePointer, KNativePointer); + +void impl_ETSParameterExpressionSetLexerSaved(KNativePointer context, KNativePointer receiver, KStringPtr& s) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _s = getStringCopy(s); + GetImpl()->ETSParameterExpressionSetLexerSaved(_context, _receiver, _s); + return ; +} +KOALA_INTEROP_V3(ETSParameterExpressionSetLexerSaved, KNativePointer, KNativePointer, KStringPtr); + +KNativePointer impl_ETSParameterExpressionLexerSavedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSParameterExpressionLexerSavedConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(ETSParameterExpressionLexerSavedConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSParameterExpressionTypeAnnotationConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSParameterExpressionTypeAnnotationConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ETSParameterExpressionTypeAnnotationConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSParameterExpressionTypeAnnotation(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSParameterExpressionTypeAnnotation(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSParameterExpressionTypeAnnotation, KNativePointer, KNativePointer, KNativePointer); + +void impl_ETSParameterExpressionSetTypeAnnotation(KNativePointer context, KNativePointer receiver, KNativePointer typeNode) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _typeNode = reinterpret_cast(typeNode); + GetImpl()->ETSParameterExpressionSetTypeAnnotation(_context, _receiver, _typeNode); + return ; +} +KOALA_INTEROP_V3(ETSParameterExpressionSetTypeAnnotation, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_ETSParameterExpressionIsOptionalConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSParameterExpressionIsOptionalConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSParameterExpressionIsOptionalConst, KBoolean, KNativePointer, KNativePointer); + +void impl_ETSParameterExpressionSetOptional(KNativePointer context, KNativePointer receiver, KBoolean value) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _value = static_cast(value); + GetImpl()->ETSParameterExpressionSetOptional(_context, _receiver, _value); + return ; +} +KOALA_INTEROP_V3(ETSParameterExpressionSetOptional, KNativePointer, KNativePointer, KBoolean); + +void impl_ETSParameterExpressionSetInitializer(KNativePointer context, KNativePointer receiver, KNativePointer initExpr) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _initExpr = reinterpret_cast(initExpr); + GetImpl()->ETSParameterExpressionSetInitializer(_context, _receiver, _initExpr); + return ; +} +KOALA_INTEROP_V3(ETSParameterExpressionSetInitializer, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_ETSParameterExpressionIsRestParameterConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSParameterExpressionIsRestParameterConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSParameterExpressionIsRestParameterConst, KBoolean, KNativePointer, KNativePointer); + +KUInt impl_ETSParameterExpressionGetRequiredParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSParameterExpressionGetRequiredParamsConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSParameterExpressionGetRequiredParamsConst, KUInt, KNativePointer, KNativePointer); + +void impl_ETSParameterExpressionSetRequiredParams(KNativePointer context, KNativePointer receiver, KUInt value) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _value = static_cast(value); + GetImpl()->ETSParameterExpressionSetRequiredParams(_context, _receiver, _value); + return ; +} +KOALA_INTEROP_V3(ETSParameterExpressionSetRequiredParams, KNativePointer, KNativePointer, KUInt); + +KNativePointer impl_ETSParameterExpressionAnnotations(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ETSParameterExpressionAnnotations(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(ETSParameterExpressionAnnotations, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSParameterExpressionAnnotationsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ETSParameterExpressionAnnotationsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(ETSParameterExpressionAnnotationsConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_ETSParameterExpressionSetAnnotations(KNativePointer context, KNativePointer receiver, KNativePointerArray annotations, KUInt annotationsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _annotations = reinterpret_cast(annotations); + const auto _annotationsSequenceLength = static_cast(annotationsSequenceLength); + GetImpl()->ETSParameterExpressionSetAnnotations(_context, _receiver, _annotations, _annotationsSequenceLength); + return ; +} +KOALA_INTEROP_V4(ETSParameterExpressionSetAnnotations, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_CreateTSTypeParameterInstantiation(KNativePointer context, KNativePointerArray params, KUInt paramsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _params = reinterpret_cast(params); + const auto _paramsSequenceLength = static_cast(paramsSequenceLength); + auto result = GetImpl()->CreateTSTypeParameterInstantiation(_context, _params, _paramsSequenceLength); + return result; +} +KOALA_INTEROP_3(CreateTSTypeParameterInstantiation, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_UpdateTSTypeParameterInstantiation(KNativePointer context, KNativePointer original, KNativePointerArray params, KUInt paramsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _params = reinterpret_cast(params); + const auto _paramsSequenceLength = static_cast(paramsSequenceLength); + auto result = GetImpl()->UpdateTSTypeParameterInstantiation(_context, _original, _params, _paramsSequenceLength); + return result; +} +KOALA_INTEROP_4(UpdateTSTypeParameterInstantiation, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_TSTypeParameterInstantiationParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSTypeParameterInstantiationParamsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSTypeParameterInstantiationParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateNullLiteral(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateNullLiteral(_context); + return result; +} +KOALA_INTEROP_1(CreateNullLiteral, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateNullLiteral(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateNullLiteral(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateNullLiteral, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSInferType(KNativePointer context, KNativePointer typeParam) +{ + const auto _context = reinterpret_cast(context); + const auto _typeParam = reinterpret_cast(typeParam); + auto result = GetImpl()->CreateTSInferType(_context, _typeParam); + return result; +} +KOALA_INTEROP_2(CreateTSInferType, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSInferType(KNativePointer context, KNativePointer original, KNativePointer typeParam) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _typeParam = reinterpret_cast(typeParam); + auto result = GetImpl()->UpdateTSInferType(_context, _original, _typeParam); + return result; +} +KOALA_INTEROP_3(UpdateTSInferType, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSInferTypeTypeParamConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSInferTypeTypeParamConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSInferTypeTypeParamConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateSwitchCaseStatement(KNativePointer context, KNativePointer test, KNativePointerArray consequent, KUInt consequentSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _test = reinterpret_cast(test); + const auto _consequent = reinterpret_cast(consequent); + const auto _consequentSequenceLength = static_cast(consequentSequenceLength); + auto result = GetImpl()->CreateSwitchCaseStatement(_context, _test, _consequent, _consequentSequenceLength); + return result; +} +KOALA_INTEROP_4(CreateSwitchCaseStatement, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_UpdateSwitchCaseStatement(KNativePointer context, KNativePointer original, KNativePointer test, KNativePointerArray consequent, KUInt consequentSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _test = reinterpret_cast(test); + const auto _consequent = reinterpret_cast(consequent); + const auto _consequentSequenceLength = static_cast(consequentSequenceLength); + auto result = GetImpl()->UpdateSwitchCaseStatement(_context, _original, _test, _consequent, _consequentSequenceLength); + return result; +} +KOALA_INTEROP_5(UpdateSwitchCaseStatement, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_SwitchCaseStatementTest(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->SwitchCaseStatementTest(_context, _receiver); + return result; +} +KOALA_INTEROP_2(SwitchCaseStatementTest, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_SwitchCaseStatementTestConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->SwitchCaseStatementTestConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(SwitchCaseStatementTestConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_SwitchCaseStatementSetTest(KNativePointer context, KNativePointer receiver, KNativePointer test) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _test = reinterpret_cast(test); + GetImpl()->SwitchCaseStatementSetTest(_context, _receiver, _test); + return ; +} +KOALA_INTEROP_V3(SwitchCaseStatementSetTest, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_SwitchCaseStatementConsequentConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->SwitchCaseStatementConsequentConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(SwitchCaseStatementConsequentConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateYieldExpression(KNativePointer context, KNativePointer argument, KBoolean isDelegate) +{ + const auto _context = reinterpret_cast(context); + const auto _argument = reinterpret_cast(argument); + const auto _isDelegate = static_cast(isDelegate); + auto result = GetImpl()->CreateYieldExpression(_context, _argument, _isDelegate); + return result; +} +KOALA_INTEROP_3(CreateYieldExpression, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_UpdateYieldExpression(KNativePointer context, KNativePointer original, KNativePointer argument, KBoolean isDelegate) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _argument = reinterpret_cast(argument); + const auto _isDelegate = static_cast(isDelegate); + auto result = GetImpl()->UpdateYieldExpression(_context, _original, _argument, _isDelegate); + return result; +} +KOALA_INTEROP_4(UpdateYieldExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KBoolean impl_YieldExpressionHasDelegateConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->YieldExpressionHasDelegateConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(YieldExpressionHasDelegateConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_YieldExpressionArgumentConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->YieldExpressionArgumentConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(YieldExpressionArgumentConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSImportEqualsDeclaration(KNativePointer context, KNativePointer id, KNativePointer moduleReference, KBoolean isExport) +{ + const auto _context = reinterpret_cast(context); + const auto _id = reinterpret_cast(id); + const auto _moduleReference = reinterpret_cast(moduleReference); + const auto _isExport = static_cast(isExport); + auto result = GetImpl()->CreateTSImportEqualsDeclaration(_context, _id, _moduleReference, _isExport); + return result; +} +KOALA_INTEROP_4(CreateTSImportEqualsDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_UpdateTSImportEqualsDeclaration(KNativePointer context, KNativePointer original, KNativePointer id, KNativePointer moduleReference, KBoolean isExport) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _id = reinterpret_cast(id); + const auto _moduleReference = reinterpret_cast(moduleReference); + const auto _isExport = static_cast(isExport); + auto result = GetImpl()->UpdateTSImportEqualsDeclaration(_context, _original, _id, _moduleReference, _isExport); + return result; +} +KOALA_INTEROP_5(UpdateTSImportEqualsDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_TSImportEqualsDeclarationIdConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSImportEqualsDeclarationIdConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSImportEqualsDeclarationIdConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSImportEqualsDeclarationModuleReferenceConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSImportEqualsDeclarationModuleReferenceConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSImportEqualsDeclarationModuleReferenceConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_TSImportEqualsDeclarationIsExportConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSImportEqualsDeclarationIsExportConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSImportEqualsDeclarationIsExportConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_CreateBooleanLiteral(KNativePointer context, KBoolean value) +{ + const auto _context = reinterpret_cast(context); + const auto _value = static_cast(value); + auto result = GetImpl()->CreateBooleanLiteral(_context, _value); + return result; +} +KOALA_INTEROP_2(CreateBooleanLiteral, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_UpdateBooleanLiteral(KNativePointer context, KNativePointer original, KBoolean value) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _value = static_cast(value); + auto result = GetImpl()->UpdateBooleanLiteral(_context, _original, _value); + return result; +} +KOALA_INTEROP_3(UpdateBooleanLiteral, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KBoolean impl_BooleanLiteralValueConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->BooleanLiteralValueConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(BooleanLiteralValueConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSNumberKeyword(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateTSNumberKeyword(_context); + return result; +} +KOALA_INTEROP_1(CreateTSNumberKeyword, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSNumberKeyword(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateTSNumberKeyword(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateTSNumberKeyword, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateClassStaticBlock(KNativePointer context, KNativePointer value) +{ + const auto _context = reinterpret_cast(context); + const auto _value = reinterpret_cast(value); + auto result = GetImpl()->CreateClassStaticBlock(_context, _value); + return result; +} +KOALA_INTEROP_2(CreateClassStaticBlock, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateClassStaticBlock(KNativePointer context, KNativePointer original, KNativePointer value) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _value = reinterpret_cast(value); + auto result = GetImpl()->UpdateClassStaticBlock(_context, _original, _value); + return result; +} +KOALA_INTEROP_3(UpdateClassStaticBlock, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassStaticBlockFunction(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassStaticBlockFunction(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassStaticBlockFunction, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassStaticBlockFunctionConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassStaticBlockFunctionConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ClassStaticBlockFunctionConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassStaticBlockNameConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassStaticBlockNameConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(ClassStaticBlockNameConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSNonNullExpression(KNativePointer context, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _expr = reinterpret_cast(expr); + auto result = GetImpl()->CreateTSNonNullExpression(_context, _expr); + return result; +} +KOALA_INTEROP_2(CreateTSNonNullExpression, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSNonNullExpression(KNativePointer context, KNativePointer original, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _expr = reinterpret_cast(expr); + auto result = GetImpl()->UpdateTSNonNullExpression(_context, _original, _expr); + return result; +} +KOALA_INTEROP_3(UpdateTSNonNullExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSNonNullExpressionExprConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSNonNullExpressionExprConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSNonNullExpressionExprConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSNonNullExpressionExpr(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSNonNullExpressionExpr(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSNonNullExpressionExpr, KNativePointer, KNativePointer, KNativePointer); + +void impl_TSNonNullExpressionSetExpr(KNativePointer context, KNativePointer receiver, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _expr = reinterpret_cast(expr); + GetImpl()->TSNonNullExpressionSetExpr(_context, _receiver, _expr); + return ; +} +KOALA_INTEROP_V3(TSNonNullExpressionSetExpr, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreatePrefixAssertionExpression(KNativePointer context, KNativePointer expr, KNativePointer type) +{ + const auto _context = reinterpret_cast(context); + const auto _expr = reinterpret_cast(expr); + const auto _type = reinterpret_cast(type); + auto result = GetImpl()->CreatePrefixAssertionExpression(_context, _expr, _type); + return result; +} +KOALA_INTEROP_3(CreatePrefixAssertionExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdatePrefixAssertionExpression(KNativePointer context, KNativePointer original, KNativePointer expr, KNativePointer type) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _expr = reinterpret_cast(expr); + const auto _type = reinterpret_cast(type); + auto result = GetImpl()->UpdatePrefixAssertionExpression(_context, _original, _expr, _type); + return result; +} +KOALA_INTEROP_4(UpdatePrefixAssertionExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_PrefixAssertionExpressionExprConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->PrefixAssertionExpressionExprConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(PrefixAssertionExpressionExprConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_PrefixAssertionExpressionTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->PrefixAssertionExpressionTypeConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(PrefixAssertionExpressionTypeConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateClassExpression(KNativePointer context, KNativePointer def) +{ + const auto _context = reinterpret_cast(context); + const auto _def = reinterpret_cast(def); + auto result = GetImpl()->CreateClassExpression(_context, _def); + return result; +} +KOALA_INTEROP_2(CreateClassExpression, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateClassExpression(KNativePointer context, KNativePointer original, KNativePointer def) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _def = reinterpret_cast(def); + auto result = GetImpl()->UpdateClassExpression(_context, _original, _def); + return result; +} +KOALA_INTEROP_3(UpdateClassExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassExpressionDefinitionConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassExpressionDefinitionConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ClassExpressionDefinitionConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateForOfStatement(KNativePointer context, KNativePointer left, KNativePointer right, KNativePointer body, KBoolean isAwait) +{ + const auto _context = reinterpret_cast(context); + const auto _left = reinterpret_cast(left); + const auto _right = reinterpret_cast(right); + const auto _body = reinterpret_cast(body); + const auto _isAwait = static_cast(isAwait); + auto result = GetImpl()->CreateForOfStatement(_context, _left, _right, _body, _isAwait); + return result; +} +KOALA_INTEROP_5(CreateForOfStatement, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_UpdateForOfStatement(KNativePointer context, KNativePointer original, KNativePointer left, KNativePointer right, KNativePointer body, KBoolean isAwait) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _left = reinterpret_cast(left); + const auto _right = reinterpret_cast(right); + const auto _body = reinterpret_cast(body); + const auto _isAwait = static_cast(isAwait); + auto result = GetImpl()->UpdateForOfStatement(_context, _original, _left, _right, _body, _isAwait); + return result; +} +KOALA_INTEROP_6(UpdateForOfStatement, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_ForOfStatementLeft(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ForOfStatementLeft(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ForOfStatementLeft, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ForOfStatementLeftConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ForOfStatementLeftConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ForOfStatementLeftConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ForOfStatementRight(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ForOfStatementRight(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ForOfStatementRight, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ForOfStatementRightConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ForOfStatementRightConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ForOfStatementRightConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ForOfStatementBody(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ForOfStatementBody(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ForOfStatementBody, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ForOfStatementBodyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ForOfStatementBodyConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ForOfStatementBodyConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_ForOfStatementIsAwaitConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ForOfStatementIsAwaitConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ForOfStatementIsAwaitConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTemplateLiteral(KNativePointer context, KNativePointerArray quasis, KUInt quasisSequenceLength, KNativePointerArray expressions, KUInt expressionsSequenceLength, KStringPtr& multilineString) +{ + const auto _context = reinterpret_cast(context); + const auto _quasis = reinterpret_cast(quasis); + const auto _quasisSequenceLength = static_cast(quasisSequenceLength); + const auto _expressions = reinterpret_cast(expressions); + const auto _expressionsSequenceLength = static_cast(expressionsSequenceLength); + const auto _multilineString = getStringCopy(multilineString); + auto result = GetImpl()->CreateTemplateLiteral(_context, _quasis, _quasisSequenceLength, _expressions, _expressionsSequenceLength, _multilineString); + return result; +} +KOALA_INTEROP_6(CreateTemplateLiteral, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KNativePointerArray, KUInt, KStringPtr); + +KNativePointer impl_UpdateTemplateLiteral(KNativePointer context, KNativePointer original, KNativePointerArray quasis, KUInt quasisSequenceLength, KNativePointerArray expressions, KUInt expressionsSequenceLength, KStringPtr& multilineString) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _quasis = reinterpret_cast(quasis); + const auto _quasisSequenceLength = static_cast(quasisSequenceLength); + const auto _expressions = reinterpret_cast(expressions); + const auto _expressionsSequenceLength = static_cast(expressionsSequenceLength); + const auto _multilineString = getStringCopy(multilineString); + auto result = GetImpl()->UpdateTemplateLiteral(_context, _original, _quasis, _quasisSequenceLength, _expressions, _expressionsSequenceLength, _multilineString); + return result; +} +KOALA_INTEROP_7(UpdateTemplateLiteral, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KNativePointerArray, KUInt, KStringPtr); + +KNativePointer impl_TemplateLiteralQuasisConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TemplateLiteralQuasisConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TemplateLiteralQuasisConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TemplateLiteralExpressionsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TemplateLiteralExpressionsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TemplateLiteralExpressionsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TemplateLiteralGetMultilineStringConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TemplateLiteralGetMultilineStringConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(TemplateLiteralGetMultilineStringConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSUnionType(KNativePointer context, KNativePointerArray types, KUInt typesSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _types = reinterpret_cast(types); + const auto _typesSequenceLength = static_cast(typesSequenceLength); + auto result = GetImpl()->CreateTSUnionType(_context, _types, _typesSequenceLength); + return result; +} +KOALA_INTEROP_3(CreateTSUnionType, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_UpdateTSUnionType(KNativePointer context, KNativePointer original, KNativePointerArray types, KUInt typesSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _types = reinterpret_cast(types); + const auto _typesSequenceLength = static_cast(typesSequenceLength); + auto result = GetImpl()->UpdateTSUnionType(_context, _original, _types, _typesSequenceLength); + return result; +} +KOALA_INTEROP_4(UpdateTSUnionType, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_TSUnionTypeTypesConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSUnionTypeTypesConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSUnionTypeTypesConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSUnknownKeyword(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateTSUnknownKeyword(_context); + return result; +} +KOALA_INTEROP_1(CreateTSUnknownKeyword, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSUnknownKeyword(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateTSUnknownKeyword(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateTSUnknownKeyword, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateIdentifier(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateIdentifier(_context); + return result; +} +KOALA_INTEROP_1(CreateIdentifier, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateIdentifier(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateIdentifier(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateIdentifier, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateIdentifier1(KNativePointer context, KStringPtr& name) +{ + const auto _context = reinterpret_cast(context); + const auto _name = getStringCopy(name); + auto result = GetImpl()->CreateIdentifier1(_context, _name); + return result; +} +KOALA_INTEROP_2(CreateIdentifier1, KNativePointer, KNativePointer, KStringPtr); + +KNativePointer impl_UpdateIdentifier1(KNativePointer context, KNativePointer original, KStringPtr& name) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _name = getStringCopy(name); + auto result = GetImpl()->UpdateIdentifier1(_context, _original, _name); + return result; +} +KOALA_INTEROP_3(UpdateIdentifier1, KNativePointer, KNativePointer, KNativePointer, KStringPtr); + +KNativePointer impl_CreateIdentifier2(KNativePointer context, KStringPtr& name, KNativePointer typeAnnotation) +{ + const auto _context = reinterpret_cast(context); + const auto _name = getStringCopy(name); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + auto result = GetImpl()->CreateIdentifier2(_context, _name, _typeAnnotation); + return result; +} +KOALA_INTEROP_3(CreateIdentifier2, KNativePointer, KNativePointer, KStringPtr, KNativePointer); + +KNativePointer impl_UpdateIdentifier2(KNativePointer context, KNativePointer original, KStringPtr& name, KNativePointer typeAnnotation) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _name = getStringCopy(name); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + auto result = GetImpl()->UpdateIdentifier2(_context, _original, _name, _typeAnnotation); + return result; +} +KOALA_INTEROP_4(UpdateIdentifier2, KNativePointer, KNativePointer, KNativePointer, KStringPtr, KNativePointer); + +KNativePointer impl_IdentifierNameConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->IdentifierNameConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(IdentifierNameConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_IdentifierName(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->IdentifierName(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(IdentifierName, KNativePointer, KNativePointer, KNativePointer); + +void impl_IdentifierSetName(KNativePointer context, KNativePointer receiver, KStringPtr& newName) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _newName = getStringCopy(newName); + GetImpl()->IdentifierSetName(_context, _receiver, _newName); + return ; +} +KOALA_INTEROP_V3(IdentifierSetName, KNativePointer, KNativePointer, KStringPtr); + +KNativePointer impl_IdentifierDecoratorsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->IdentifierDecoratorsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(IdentifierDecoratorsConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_IdentifierIsErrorPlaceHolderConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->IdentifierIsErrorPlaceHolderConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(IdentifierIsErrorPlaceHolderConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_IdentifierIsOptionalConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->IdentifierIsOptionalConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(IdentifierIsOptionalConst, KBoolean, KNativePointer, KNativePointer); + +void impl_IdentifierSetOptional(KNativePointer context, KNativePointer receiver, KBoolean optional_arg) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _optional_arg = static_cast(optional_arg); + GetImpl()->IdentifierSetOptional(_context, _receiver, _optional_arg); + return ; +} +KOALA_INTEROP_V3(IdentifierSetOptional, KNativePointer, KNativePointer, KBoolean); + +KBoolean impl_IdentifierIsReferenceConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->IdentifierIsReferenceConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(IdentifierIsReferenceConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_IdentifierIsTdzConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->IdentifierIsTdzConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(IdentifierIsTdzConst, KBoolean, KNativePointer, KNativePointer); + +void impl_IdentifierSetTdz(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->IdentifierSetTdz(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(IdentifierSetTdz, KNativePointer, KNativePointer); + +void impl_IdentifierSetAccessor(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->IdentifierSetAccessor(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(IdentifierSetAccessor, KNativePointer, KNativePointer); + +KBoolean impl_IdentifierIsAccessorConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->IdentifierIsAccessorConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(IdentifierIsAccessorConst, KBoolean, KNativePointer, KNativePointer); + +void impl_IdentifierSetMutator(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->IdentifierSetMutator(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(IdentifierSetMutator, KNativePointer, KNativePointer); + +KBoolean impl_IdentifierIsMutatorConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->IdentifierIsMutatorConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(IdentifierIsMutatorConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_IdentifierIsReceiverConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->IdentifierIsReceiverConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(IdentifierIsReceiverConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_IdentifierIsPrivateIdentConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->IdentifierIsPrivateIdentConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(IdentifierIsPrivateIdentConst, KBoolean, KNativePointer, KNativePointer); + +void impl_IdentifierSetPrivate(KNativePointer context, KNativePointer receiver, KBoolean isPrivate) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _isPrivate = static_cast(isPrivate); + GetImpl()->IdentifierSetPrivate(_context, _receiver, _isPrivate); + return ; +} +KOALA_INTEROP_V3(IdentifierSetPrivate, KNativePointer, KNativePointer, KBoolean); + +KBoolean impl_IdentifierIsIgnoreBoxConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->IdentifierIsIgnoreBoxConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(IdentifierIsIgnoreBoxConst, KBoolean, KNativePointer, KNativePointer); + +void impl_IdentifierSetIgnoreBox(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->IdentifierSetIgnoreBox(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(IdentifierSetIgnoreBox, KNativePointer, KNativePointer); + +KBoolean impl_IdentifierIsAnnotationDeclConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->IdentifierIsAnnotationDeclConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(IdentifierIsAnnotationDeclConst, KBoolean, KNativePointer, KNativePointer); + +void impl_IdentifierSetAnnotationDecl(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->IdentifierSetAnnotationDecl(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(IdentifierSetAnnotationDecl, KNativePointer, KNativePointer); + +KBoolean impl_IdentifierIsAnnotationUsageConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->IdentifierIsAnnotationUsageConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(IdentifierIsAnnotationUsageConst, KBoolean, KNativePointer, KNativePointer); + +void impl_IdentifierSetAnnotationUsage(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->IdentifierSetAnnotationUsage(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(IdentifierSetAnnotationUsage, KNativePointer, KNativePointer); + +KNativePointer impl_IdentifierCloneReference(KNativePointer context, KNativePointer receiver, KNativePointer parent) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _parent = reinterpret_cast(parent); + auto result = GetImpl()->IdentifierCloneReference(_context, _receiver, _parent); + return result; +} +KOALA_INTEROP_3(IdentifierCloneReference, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_IdentifierValidateExpression(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->IdentifierValidateExpression(_context, _receiver); + return result; +} +KOALA_INTEROP_2(IdentifierValidateExpression, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_IdentifierTypeAnnotationConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->IdentifierTypeAnnotationConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(IdentifierTypeAnnotationConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_IdentifierSetTsTypeAnnotation(KNativePointer context, KNativePointer receiver, KNativePointer typeAnnotation) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + GetImpl()->IdentifierSetTsTypeAnnotation(_context, _receiver, _typeAnnotation); + return ; +} +KOALA_INTEROP_V3(IdentifierSetTsTypeAnnotation, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateOpaqueTypeNode1(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateOpaqueTypeNode1(_context); + return result; +} +KOALA_INTEROP_1(CreateOpaqueTypeNode1, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateOpaqueTypeNode1(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateOpaqueTypeNode1(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateOpaqueTypeNode1, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateBlockStatement(KNativePointer context, KNativePointerArray statementList, KUInt statementListSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _statementList = reinterpret_cast(statementList); + const auto _statementListSequenceLength = static_cast(statementListSequenceLength); + auto result = GetImpl()->CreateBlockStatement(_context, _statementList, _statementListSequenceLength); + return result; +} +KOALA_INTEROP_3(CreateBlockStatement, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_UpdateBlockStatement(KNativePointer context, KNativePointer original, KNativePointerArray statementList, KUInt statementListSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _statementList = reinterpret_cast(statementList); + const auto _statementListSequenceLength = static_cast(statementListSequenceLength); + auto result = GetImpl()->UpdateBlockStatement(_context, _original, _statementList, _statementListSequenceLength); + return result; +} +KOALA_INTEROP_4(UpdateBlockStatement, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_BlockStatementStatementsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->BlockStatementStatementsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(BlockStatementStatementsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_BlockStatementStatements(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->BlockStatementStatements(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(BlockStatementStatements, KNativePointer, KNativePointer, KNativePointer); + +void impl_BlockStatementSetStatements(KNativePointer context, KNativePointer receiver, KNativePointerArray statementList, KUInt statementListSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _statementList = reinterpret_cast(statementList); + const auto _statementListSequenceLength = static_cast(statementListSequenceLength); + GetImpl()->BlockStatementSetStatements(_context, _receiver, _statementList, _statementListSequenceLength); + return ; +} +KOALA_INTEROP_V4(BlockStatementSetStatements, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +void impl_BlockStatementAddStatement(KNativePointer context, KNativePointer receiver, KNativePointer stmt) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _stmt = reinterpret_cast(stmt); + GetImpl()->BlockStatementAddStatement(_context, _receiver, _stmt); + return ; +} +KOALA_INTEROP_V3(BlockStatementAddStatement, KNativePointer, KNativePointer, KNativePointer); + +void impl_BlockStatementAddStatements(KNativePointer context, KNativePointer receiver, KNativePointerArray stmts, KUInt stmtsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _stmts = reinterpret_cast(stmts); + const auto _stmtsSequenceLength = static_cast(stmtsSequenceLength); + GetImpl()->BlockStatementAddStatements(_context, _receiver, _stmts, _stmtsSequenceLength); + return ; +} +KOALA_INTEROP_V4(BlockStatementAddStatements, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +void impl_BlockStatementAddTrailingBlock(KNativePointer context, KNativePointer receiver, KNativePointer stmt, KNativePointer trailingBlock) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _stmt = reinterpret_cast(stmt); + const auto _trailingBlock = reinterpret_cast(trailingBlock); + GetImpl()->BlockStatementAddTrailingBlock(_context, _receiver, _stmt, _trailingBlock); + return ; +} +KOALA_INTEROP_V4(BlockStatementAddTrailingBlock, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateDirectEvalExpression(KNativePointer context, KNativePointer callee, KNativePointerArray _arguments, KUInt _argumentsSequenceLength, KNativePointer typeParams, KBoolean optional_arg, KUInt parserStatus) +{ + const auto _context = reinterpret_cast(context); + const auto _callee = reinterpret_cast(callee); + const auto __arguments = reinterpret_cast(_arguments); + const auto __argumentsSequenceLength = static_cast(_argumentsSequenceLength); + const auto _typeParams = reinterpret_cast(typeParams); + const auto _optional_arg = static_cast(optional_arg); + const auto _parserStatus = static_cast(parserStatus); + auto result = GetImpl()->CreateDirectEvalExpression(_context, _callee, __arguments, __argumentsSequenceLength, _typeParams, _optional_arg, _parserStatus); + return result; +} +KOALA_INTEROP_7(CreateDirectEvalExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KNativePointer, KBoolean, KUInt); + +KNativePointer impl_UpdateDirectEvalExpression(KNativePointer context, KNativePointer original, KNativePointer callee, KNativePointerArray _arguments, KUInt _argumentsSequenceLength, KNativePointer typeParams, KBoolean optional_arg, KUInt parserStatus) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _callee = reinterpret_cast(callee); + const auto __arguments = reinterpret_cast(_arguments); + const auto __argumentsSequenceLength = static_cast(_argumentsSequenceLength); + const auto _typeParams = reinterpret_cast(typeParams); + const auto _optional_arg = static_cast(optional_arg); + const auto _parserStatus = static_cast(parserStatus); + auto result = GetImpl()->UpdateDirectEvalExpression(_context, _original, _callee, __arguments, __argumentsSequenceLength, _typeParams, _optional_arg, _parserStatus); + return result; +} +KOALA_INTEROP_8(UpdateDirectEvalExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KNativePointer, KBoolean, KUInt); + +KNativePointer impl_CreateTSTypeParameterDeclaration(KNativePointer context, KNativePointerArray params, KUInt paramsSequenceLength, KUInt requiredParams) +{ + const auto _context = reinterpret_cast(context); + const auto _params = reinterpret_cast(params); + const auto _paramsSequenceLength = static_cast(paramsSequenceLength); + const auto _requiredParams = static_cast(requiredParams); + auto result = GetImpl()->CreateTSTypeParameterDeclaration(_context, _params, _paramsSequenceLength, _requiredParams); + return result; +} +KOALA_INTEROP_4(CreateTSTypeParameterDeclaration, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KUInt); + +KNativePointer impl_UpdateTSTypeParameterDeclaration(KNativePointer context, KNativePointer original, KNativePointerArray params, KUInt paramsSequenceLength, KUInt requiredParams) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _params = reinterpret_cast(params); + const auto _paramsSequenceLength = static_cast(paramsSequenceLength); + const auto _requiredParams = static_cast(requiredParams); + auto result = GetImpl()->UpdateTSTypeParameterDeclaration(_context, _original, _params, _paramsSequenceLength, _requiredParams); + return result; +} +KOALA_INTEROP_5(UpdateTSTypeParameterDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KUInt); + +KNativePointer impl_TSTypeParameterDeclarationParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSTypeParameterDeclarationParamsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSTypeParameterDeclarationParamsConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_TSTypeParameterDeclarationAddParam(KNativePointer context, KNativePointer receiver, KNativePointer param) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _param = reinterpret_cast(param); + GetImpl()->TSTypeParameterDeclarationAddParam(_context, _receiver, _param); + return ; +} +KOALA_INTEROP_V3(TSTypeParameterDeclarationAddParam, KNativePointer, KNativePointer, KNativePointer); + +KUInt impl_TSTypeParameterDeclarationRequiredParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSTypeParameterDeclarationRequiredParamsConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSTypeParameterDeclarationRequiredParamsConst, KUInt, KNativePointer, KNativePointer); + +KNativePointer impl_CreateMethodDefinition(KNativePointer context, KInt kind, KNativePointer key, KNativePointer value, KInt modifiers, KBoolean isComputed) +{ + const auto _context = reinterpret_cast(context); + const auto _kind = static_cast(kind); + const auto _key = reinterpret_cast(key); + const auto _value = reinterpret_cast(value); + const auto _modifiers = static_cast(modifiers); + const auto _isComputed = static_cast(isComputed); + auto result = GetImpl()->CreateMethodDefinition(_context, _kind, _key, _value, _modifiers, _isComputed); + return result; +} +KOALA_INTEROP_6(CreateMethodDefinition, KNativePointer, KNativePointer, KInt, KNativePointer, KNativePointer, KInt, KBoolean); + +KNativePointer impl_UpdateMethodDefinition(KNativePointer context, KNativePointer original, KInt kind, KNativePointer key, KNativePointer value, KInt modifiers, KBoolean isComputed) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _kind = static_cast(kind); + const auto _key = reinterpret_cast(key); + const auto _value = reinterpret_cast(value); + const auto _modifiers = static_cast(modifiers); + const auto _isComputed = static_cast(isComputed); + auto result = GetImpl()->UpdateMethodDefinition(_context, _original, _kind, _key, _value, _modifiers, _isComputed); + return result; +} +KOALA_INTEROP_7(UpdateMethodDefinition, KNativePointer, KNativePointer, KNativePointer, KInt, KNativePointer, KNativePointer, KInt, KBoolean); + +KInt impl_MethodDefinitionKindConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->MethodDefinitionKindConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(MethodDefinitionKindConst, KInt, KNativePointer, KNativePointer); + +KBoolean impl_MethodDefinitionIsConstructorConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->MethodDefinitionIsConstructorConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(MethodDefinitionIsConstructorConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_MethodDefinitionIsMethodConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->MethodDefinitionIsMethodConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(MethodDefinitionIsMethodConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_MethodDefinitionIsExtensionMethodConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->MethodDefinitionIsExtensionMethodConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(MethodDefinitionIsExtensionMethodConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_MethodDefinitionIsGetterConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->MethodDefinitionIsGetterConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(MethodDefinitionIsGetterConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_MethodDefinitionIsSetterConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->MethodDefinitionIsSetterConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(MethodDefinitionIsSetterConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_MethodDefinitionIsDefaultAccessModifierConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->MethodDefinitionIsDefaultAccessModifierConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(MethodDefinitionIsDefaultAccessModifierConst, KBoolean, KNativePointer, KNativePointer); + +void impl_MethodDefinitionSetDefaultAccessModifier(KNativePointer context, KNativePointer receiver, KBoolean isDefault) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _isDefault = static_cast(isDefault); + GetImpl()->MethodDefinitionSetDefaultAccessModifier(_context, _receiver, _isDefault); + return ; +} +KOALA_INTEROP_V3(MethodDefinitionSetDefaultAccessModifier, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_MethodDefinitionOverloadsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->MethodDefinitionOverloadsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(MethodDefinitionOverloadsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_MethodDefinitionBaseOverloadMethodConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->MethodDefinitionBaseOverloadMethodConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(MethodDefinitionBaseOverloadMethodConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_MethodDefinitionBaseOverloadMethod(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->MethodDefinitionBaseOverloadMethod(_context, _receiver); + return result; +} +KOALA_INTEROP_2(MethodDefinitionBaseOverloadMethod, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_MethodDefinitionAsyncPairMethodConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->MethodDefinitionAsyncPairMethodConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(MethodDefinitionAsyncPairMethodConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_MethodDefinitionAsyncPairMethod(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->MethodDefinitionAsyncPairMethod(_context, _receiver); + return result; +} +KOALA_INTEROP_2(MethodDefinitionAsyncPairMethod, KNativePointer, KNativePointer, KNativePointer); + +void impl_MethodDefinitionSetOverloads(KNativePointer context, KNativePointer receiver, KNativePointerArray overloads, KUInt overloadsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _overloads = reinterpret_cast(overloads); + const auto _overloadsSequenceLength = static_cast(overloadsSequenceLength); + GetImpl()->MethodDefinitionSetOverloads(_context, _receiver, _overloads, _overloadsSequenceLength); + return ; +} +KOALA_INTEROP_V4(MethodDefinitionSetOverloads, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +void impl_MethodDefinitionClearOverloads(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->MethodDefinitionClearOverloads(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(MethodDefinitionClearOverloads, KNativePointer, KNativePointer); + +void impl_MethodDefinitionAddOverload(KNativePointer context, KNativePointer receiver, KNativePointer overload) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _overload = reinterpret_cast(overload); + GetImpl()->MethodDefinitionAddOverload(_context, _receiver, _overload); + return ; +} +KOALA_INTEROP_V3(MethodDefinitionAddOverload, KNativePointer, KNativePointer, KNativePointer); + +void impl_MethodDefinitionSetBaseOverloadMethod(KNativePointer context, KNativePointer receiver, KNativePointer baseOverloadMethod) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _baseOverloadMethod = reinterpret_cast(baseOverloadMethod); + GetImpl()->MethodDefinitionSetBaseOverloadMethod(_context, _receiver, _baseOverloadMethod); + return ; +} +KOALA_INTEROP_V3(MethodDefinitionSetBaseOverloadMethod, KNativePointer, KNativePointer, KNativePointer); + +void impl_MethodDefinitionSetAsyncPairMethod(KNativePointer context, KNativePointer receiver, KNativePointer method) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _method = reinterpret_cast(method); + GetImpl()->MethodDefinitionSetAsyncPairMethod(_context, _receiver, _method); + return ; +} +KOALA_INTEROP_V3(MethodDefinitionSetAsyncPairMethod, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_MethodDefinitionHasOverload(KNativePointer context, KNativePointer receiver, KNativePointer overload) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _overload = reinterpret_cast(overload); + auto result = GetImpl()->MethodDefinitionHasOverload(_context, _receiver, _overload); + return result; +} +KOALA_INTEROP_3(MethodDefinitionHasOverload, KBoolean, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_MethodDefinitionFunction(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->MethodDefinitionFunction(_context, _receiver); + return result; +} +KOALA_INTEROP_2(MethodDefinitionFunction, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_MethodDefinitionFunctionConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->MethodDefinitionFunctionConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(MethodDefinitionFunctionConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_MethodDefinitionInitializeOverloadInfo(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->MethodDefinitionInitializeOverloadInfo(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(MethodDefinitionInitializeOverloadInfo, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSNullKeyword(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateTSNullKeyword(_context); + return result; +} +KOALA_INTEROP_1(CreateTSNullKeyword, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSNullKeyword(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateTSNullKeyword(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateTSNullKeyword, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSInterfaceHeritage(KNativePointer context, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _expr = reinterpret_cast(expr); + auto result = GetImpl()->CreateTSInterfaceHeritage(_context, _expr); + return result; +} +KOALA_INTEROP_2(CreateTSInterfaceHeritage, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSInterfaceHeritage(KNativePointer context, KNativePointer original, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _expr = reinterpret_cast(expr); + auto result = GetImpl()->UpdateTSInterfaceHeritage(_context, _original, _expr); + return result; +} +KOALA_INTEROP_3(UpdateTSInterfaceHeritage, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSInterfaceHeritageExpr(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSInterfaceHeritageExpr(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSInterfaceHeritageExpr, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSInterfaceHeritageExprConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSInterfaceHeritageExprConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSInterfaceHeritageExprConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_ExpressionIsGroupedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ExpressionIsGroupedConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ExpressionIsGroupedConst, KBoolean, KNativePointer, KNativePointer); + +void impl_ExpressionSetGrouped(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->ExpressionSetGrouped(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(ExpressionSetGrouped, KNativePointer, KNativePointer); + +KNativePointer impl_ExpressionAsLiteralConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ExpressionAsLiteralConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ExpressionAsLiteralConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ExpressionAsLiteral(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ExpressionAsLiteral(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ExpressionAsLiteral, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_ExpressionIsLiteralConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ExpressionIsLiteralConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ExpressionIsLiteralConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ExpressionIsTypeNodeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ExpressionIsTypeNodeConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ExpressionIsTypeNodeConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ExpressionIsAnnotatedExpressionConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ExpressionIsAnnotatedExpressionConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ExpressionIsAnnotatedExpressionConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_ExpressionAsTypeNode(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ExpressionAsTypeNode(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ExpressionAsTypeNode, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ExpressionAsTypeNodeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ExpressionAsTypeNodeConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ExpressionAsTypeNodeConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ExpressionAsAnnotatedExpression(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ExpressionAsAnnotatedExpression(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ExpressionAsAnnotatedExpression, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ExpressionAsAnnotatedExpressionConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ExpressionAsAnnotatedExpressionConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ExpressionAsAnnotatedExpressionConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_ExpressionIsBrokenExpressionConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ExpressionIsBrokenExpressionConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ExpressionIsBrokenExpressionConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_ExpressionToStringConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ExpressionToStringConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(ExpressionToStringConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AnnotatedExpressionTypeAnnotationConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AnnotatedExpressionTypeAnnotationConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(AnnotatedExpressionTypeAnnotationConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_AnnotatedExpressionSetTsTypeAnnotation(KNativePointer context, KNativePointer receiver, KNativePointer typeAnnotation) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + GetImpl()->AnnotatedExpressionSetTsTypeAnnotation(_context, _receiver, _typeAnnotation); + return ; +} +KOALA_INTEROP_V3(AnnotatedExpressionSetTsTypeAnnotation, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_MaybeOptionalExpressionIsOptionalConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->MaybeOptionalExpressionIsOptionalConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(MaybeOptionalExpressionIsOptionalConst, KBoolean, KNativePointer, KNativePointer); + +void impl_MaybeOptionalExpressionClearOptional(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->MaybeOptionalExpressionClearOptional(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(MaybeOptionalExpressionClearOptional, KNativePointer, KNativePointer); + +KNativePointer impl_CreateSrcDumper(KNativePointer context, KNativePointer node) +{ + const auto _context = reinterpret_cast(context); + const auto _node = reinterpret_cast(node); + auto result = GetImpl()->CreateSrcDumper(_context, _node); + return result; +} +KOALA_INTEROP_2(CreateSrcDumper, KNativePointer, KNativePointer, KNativePointer); + +void impl_SrcDumperAdd(KNativePointer context, KNativePointer receiver, KStringPtr& str) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _str = getStringCopy(str); + GetImpl()->SrcDumperAdd(_context, _receiver, _str); + return ; +} +KOALA_INTEROP_V3(SrcDumperAdd, KNativePointer, KNativePointer, KStringPtr); + +void impl_SrcDumperAdd1(KNativePointer context, KNativePointer receiver, KInt i) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _i = static_cast(i); + GetImpl()->SrcDumperAdd1(_context, _receiver, _i); + return ; +} +KOALA_INTEROP_V3(SrcDumperAdd1, KNativePointer, KNativePointer, KInt); + +void impl_SrcDumperAdd2(KNativePointer context, KNativePointer receiver, KLong l) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _l = static_cast(l); + GetImpl()->SrcDumperAdd2(_context, _receiver, _l); + return ; +} +KOALA_INTEROP_V3(SrcDumperAdd2, KNativePointer, KNativePointer, KLong); + +void impl_SrcDumperAdd3(KNativePointer context, KNativePointer receiver, KFloat f) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _f = static_cast(f); + GetImpl()->SrcDumperAdd3(_context, _receiver, _f); + return ; +} +KOALA_INTEROP_V3(SrcDumperAdd3, KNativePointer, KNativePointer, KFloat); + +void impl_SrcDumperAdd4(KNativePointer context, KNativePointer receiver, KDouble d) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _d = static_cast(d); + GetImpl()->SrcDumperAdd4(_context, _receiver, _d); + return ; +} +KOALA_INTEROP_V3(SrcDumperAdd4, KNativePointer, KNativePointer, KDouble); + +KNativePointer impl_SrcDumperStrConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->SrcDumperStrConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(SrcDumperStrConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_SrcDumperIncrIndent(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->SrcDumperIncrIndent(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(SrcDumperIncrIndent, KNativePointer, KNativePointer); + +void impl_SrcDumperDecrIndent(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->SrcDumperDecrIndent(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(SrcDumperDecrIndent, KNativePointer, KNativePointer); + +void impl_SrcDumperEndl(KNativePointer context, KNativePointer receiver, KUInt num) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _num = static_cast(num); + GetImpl()->SrcDumperEndl(_context, _receiver, _num); + return ; +} +KOALA_INTEROP_V3(SrcDumperEndl, KNativePointer, KNativePointer, KUInt); + +KNativePointer impl_CreateETSClassLiteral(KNativePointer context, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _expr = reinterpret_cast(expr); + auto result = GetImpl()->CreateETSClassLiteral(_context, _expr); + return result; +} +KOALA_INTEROP_2(CreateETSClassLiteral, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateETSClassLiteral(KNativePointer context, KNativePointer original, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _expr = reinterpret_cast(expr); + auto result = GetImpl()->UpdateETSClassLiteral(_context, _original, _expr); + return result; +} +KOALA_INTEROP_3(UpdateETSClassLiteral, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSClassLiteralExprConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSClassLiteralExprConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ETSClassLiteralExprConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateBreakStatement(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateBreakStatement(_context); + return result; +} +KOALA_INTEROP_1(CreateBreakStatement, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateBreakStatement(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateBreakStatement(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateBreakStatement, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateBreakStatement1(KNativePointer context, KNativePointer ident) +{ + const auto _context = reinterpret_cast(context); + const auto _ident = reinterpret_cast(ident); + auto result = GetImpl()->CreateBreakStatement1(_context, _ident); + return result; +} +KOALA_INTEROP_2(CreateBreakStatement1, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateBreakStatement1(KNativePointer context, KNativePointer original, KNativePointer ident) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _ident = reinterpret_cast(ident); + auto result = GetImpl()->UpdateBreakStatement1(_context, _original, _ident); + return result; +} +KOALA_INTEROP_3(UpdateBreakStatement1, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_BreakStatementIdentConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->BreakStatementIdentConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(BreakStatementIdentConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_BreakStatementIdent(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->BreakStatementIdent(_context, _receiver); + return result; +} +KOALA_INTEROP_2(BreakStatementIdent, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_BreakStatementTargetConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->BreakStatementTargetConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(BreakStatementTargetConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_BreakStatementHasTargetConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->BreakStatementHasTargetConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(BreakStatementHasTargetConst, KBoolean, KNativePointer, KNativePointer); + +void impl_BreakStatementSetTarget(KNativePointer context, KNativePointer receiver, KNativePointer target) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _target = reinterpret_cast(target); + GetImpl()->BreakStatementSetTarget(_context, _receiver, _target); + return ; +} +KOALA_INTEROP_V3(BreakStatementSetTarget, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateRegExpLiteral(KNativePointer context, KStringPtr& pattern, KInt flags, KStringPtr& flagsStr) +{ + const auto _context = reinterpret_cast(context); + const auto _pattern = getStringCopy(pattern); + const auto _flags = static_cast(flags); + const auto _flagsStr = getStringCopy(flagsStr); + auto result = GetImpl()->CreateRegExpLiteral(_context, _pattern, _flags, _flagsStr); + return result; +} +KOALA_INTEROP_4(CreateRegExpLiteral, KNativePointer, KNativePointer, KStringPtr, KInt, KStringPtr); + +KNativePointer impl_UpdateRegExpLiteral(KNativePointer context, KNativePointer original, KStringPtr& pattern, KInt flags, KStringPtr& flagsStr) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _pattern = getStringCopy(pattern); + const auto _flags = static_cast(flags); + const auto _flagsStr = getStringCopy(flagsStr); + auto result = GetImpl()->UpdateRegExpLiteral(_context, _original, _pattern, _flags, _flagsStr); + return result; +} +KOALA_INTEROP_5(UpdateRegExpLiteral, KNativePointer, KNativePointer, KNativePointer, KStringPtr, KInt, KStringPtr); + +KNativePointer impl_RegExpLiteralPatternConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->RegExpLiteralPatternConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(RegExpLiteralPatternConst, KNativePointer, KNativePointer, KNativePointer); + +KInt impl_RegExpLiteralFlagsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->RegExpLiteralFlagsConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(RegExpLiteralFlagsConst, KInt, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSMappedType(KNativePointer context, KNativePointer typeParameter, KNativePointer typeAnnotation, KInt readonly_arg, KInt optional_arg) +{ + const auto _context = reinterpret_cast(context); + const auto _typeParameter = reinterpret_cast(typeParameter); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + const auto _readonly_arg = static_cast(readonly_arg); + const auto _optional_arg = static_cast(optional_arg); + auto result = GetImpl()->CreateTSMappedType(_context, _typeParameter, _typeAnnotation, _readonly_arg, _optional_arg); + return result; +} +KOALA_INTEROP_5(CreateTSMappedType, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KInt, KInt); + +KNativePointer impl_UpdateTSMappedType(KNativePointer context, KNativePointer original, KNativePointer typeParameter, KNativePointer typeAnnotation, KInt readonly_arg, KInt optional_arg) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _typeParameter = reinterpret_cast(typeParameter); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + const auto _readonly_arg = static_cast(readonly_arg); + const auto _optional_arg = static_cast(optional_arg); + auto result = GetImpl()->UpdateTSMappedType(_context, _original, _typeParameter, _typeAnnotation, _readonly_arg, _optional_arg); + return result; +} +KOALA_INTEROP_6(UpdateTSMappedType, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KInt, KInt); + +KNativePointer impl_TSMappedTypeTypeParameter(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSMappedTypeTypeParameter(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSMappedTypeTypeParameter, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSMappedTypeTypeAnnotation(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSMappedTypeTypeAnnotation(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSMappedTypeTypeAnnotation, KNativePointer, KNativePointer, KNativePointer); + +KInt impl_TSMappedTypeReadonly(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSMappedTypeReadonly(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSMappedTypeReadonly, KInt, KNativePointer, KNativePointer); + +KInt impl_TSMappedTypeOptional(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSMappedTypeOptional(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSMappedTypeOptional, KInt, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSAnyKeyword(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateTSAnyKeyword(_context); + return result; +} +KOALA_INTEROP_1(CreateTSAnyKeyword, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSAnyKeyword(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateTSAnyKeyword(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateTSAnyKeyword, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateClassDeclaration(KNativePointer context, KNativePointer def) +{ + const auto _context = reinterpret_cast(context); + const auto _def = reinterpret_cast(def); + auto result = GetImpl()->CreateClassDeclaration(_context, _def); + return result; +} +KOALA_INTEROP_2(CreateClassDeclaration, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateClassDeclaration(KNativePointer context, KNativePointer original, KNativePointer def) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _def = reinterpret_cast(def); + auto result = GetImpl()->UpdateClassDeclaration(_context, _original, _def); + return result; +} +KOALA_INTEROP_3(UpdateClassDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassDeclarationDefinition(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDeclarationDefinition(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDeclarationDefinition, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassDeclarationDefinitionConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDeclarationDefinitionConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ClassDeclarationDefinitionConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassDeclarationDecoratorsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ClassDeclarationDecoratorsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(ClassDeclarationDecoratorsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSIndexedAccessType(KNativePointer context, KNativePointer objectType, KNativePointer indexType) +{ + const auto _context = reinterpret_cast(context); + const auto _objectType = reinterpret_cast(objectType); + const auto _indexType = reinterpret_cast(indexType); + auto result = GetImpl()->CreateTSIndexedAccessType(_context, _objectType, _indexType); + return result; +} +KOALA_INTEROP_3(CreateTSIndexedAccessType, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSIndexedAccessType(KNativePointer context, KNativePointer original, KNativePointer objectType, KNativePointer indexType) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _objectType = reinterpret_cast(objectType); + const auto _indexType = reinterpret_cast(indexType); + auto result = GetImpl()->UpdateTSIndexedAccessType(_context, _original, _objectType, _indexType); + return result; +} +KOALA_INTEROP_4(UpdateTSIndexedAccessType, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSIndexedAccessTypeObjectTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSIndexedAccessTypeObjectTypeConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSIndexedAccessTypeObjectTypeConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSIndexedAccessTypeIndexTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSIndexedAccessTypeIndexTypeConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSIndexedAccessTypeIndexTypeConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSQualifiedName(KNativePointer context, KNativePointer left, KNativePointer right) +{ + const auto _context = reinterpret_cast(context); + const auto _left = reinterpret_cast(left); + const auto _right = reinterpret_cast(right); + auto result = GetImpl()->CreateTSQualifiedName(_context, _left, _right); + return result; +} +KOALA_INTEROP_3(CreateTSQualifiedName, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSQualifiedName(KNativePointer context, KNativePointer original, KNativePointer left, KNativePointer right) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _left = reinterpret_cast(left); + const auto _right = reinterpret_cast(right); + auto result = GetImpl()->UpdateTSQualifiedName(_context, _original, _left, _right); + return result; +} +KOALA_INTEROP_4(UpdateTSQualifiedName, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSQualifiedNameLeftConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSQualifiedNameLeftConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSQualifiedNameLeftConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSQualifiedNameLeft(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSQualifiedNameLeft(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSQualifiedNameLeft, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSQualifiedNameRightConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSQualifiedNameRightConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSQualifiedNameRightConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSQualifiedNameRight(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSQualifiedNameRight(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSQualifiedNameRight, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSQualifiedNameNameConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSQualifiedNameNameConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(TSQualifiedNameNameConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSQualifiedNameResolveLeftMostQualifiedName(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSQualifiedNameResolveLeftMostQualifiedName(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSQualifiedNameResolveLeftMostQualifiedName, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSQualifiedNameResolveLeftMostQualifiedNameConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSQualifiedNameResolveLeftMostQualifiedNameConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSQualifiedNameResolveLeftMostQualifiedNameConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateAwaitExpression(KNativePointer context, KNativePointer argument) +{ + const auto _context = reinterpret_cast(context); + const auto _argument = reinterpret_cast(argument); + auto result = GetImpl()->CreateAwaitExpression(_context, _argument); + return result; +} +KOALA_INTEROP_2(CreateAwaitExpression, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateAwaitExpression(KNativePointer context, KNativePointer original, KNativePointer argument) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _argument = reinterpret_cast(argument); + auto result = GetImpl()->UpdateAwaitExpression(_context, _original, _argument); + return result; +} +KOALA_INTEROP_3(UpdateAwaitExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AwaitExpressionArgumentConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AwaitExpressionArgumentConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(AwaitExpressionArgumentConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateValidationInfo(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateValidationInfo(_context); + return result; +} +KOALA_INTEROP_1(CreateValidationInfo, KNativePointer, KNativePointer); + +KNativePointer impl_CreateValidationInfo1(KNativePointer context, KStringPtr& m, KNativePointer p) +{ + const auto _context = reinterpret_cast(context); + const auto _m = getStringCopy(m); + const auto _p = reinterpret_cast(p); + auto result = GetImpl()->CreateValidationInfo1(_context, _m, _p); + return result; +} +KOALA_INTEROP_3(CreateValidationInfo1, KNativePointer, KNativePointer, KStringPtr, KNativePointer); + +KBoolean impl_ValidationInfoFailConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ValidationInfoFailConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ValidationInfoFailConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_CreateContinueStatement(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateContinueStatement(_context); + return result; +} +KOALA_INTEROP_1(CreateContinueStatement, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateContinueStatement(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateContinueStatement(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateContinueStatement, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateContinueStatement1(KNativePointer context, KNativePointer ident) +{ + const auto _context = reinterpret_cast(context); + const auto _ident = reinterpret_cast(ident); + auto result = GetImpl()->CreateContinueStatement1(_context, _ident); + return result; +} +KOALA_INTEROP_2(CreateContinueStatement1, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateContinueStatement1(KNativePointer context, KNativePointer original, KNativePointer ident) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _ident = reinterpret_cast(ident); + auto result = GetImpl()->UpdateContinueStatement1(_context, _original, _ident); + return result; +} +KOALA_INTEROP_3(UpdateContinueStatement1, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ContinueStatementIdentConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ContinueStatementIdentConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ContinueStatementIdentConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ContinueStatementIdent(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ContinueStatementIdent(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ContinueStatementIdent, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ContinueStatementTargetConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ContinueStatementTargetConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ContinueStatementTargetConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_ContinueStatementHasTargetConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ContinueStatementHasTargetConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ContinueStatementHasTargetConst, KBoolean, KNativePointer, KNativePointer); + +void impl_ContinueStatementSetTarget(KNativePointer context, KNativePointer receiver, KNativePointer target) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _target = reinterpret_cast(target); + GetImpl()->ContinueStatementSetTarget(_context, _receiver, _target); + return ; +} +KOALA_INTEROP_V3(ContinueStatementSetTarget, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateETSNewMultiDimArrayInstanceExpression(KNativePointer context, KNativePointer typeReference, KNativePointerArray dimensions, KUInt dimensionsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _typeReference = reinterpret_cast(typeReference); + const auto _dimensions = reinterpret_cast(dimensions); + const auto _dimensionsSequenceLength = static_cast(dimensionsSequenceLength); + auto result = GetImpl()->CreateETSNewMultiDimArrayInstanceExpression(_context, _typeReference, _dimensions, _dimensionsSequenceLength); + return result; +} +KOALA_INTEROP_4(CreateETSNewMultiDimArrayInstanceExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_UpdateETSNewMultiDimArrayInstanceExpression(KNativePointer context, KNativePointer original, KNativePointer typeReference, KNativePointerArray dimensions, KUInt dimensionsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _typeReference = reinterpret_cast(typeReference); + const auto _dimensions = reinterpret_cast(dimensions); + const auto _dimensionsSequenceLength = static_cast(dimensionsSequenceLength); + auto result = GetImpl()->UpdateETSNewMultiDimArrayInstanceExpression(_context, _original, _typeReference, _dimensions, _dimensionsSequenceLength); + return result; +} +KOALA_INTEROP_5(UpdateETSNewMultiDimArrayInstanceExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_CreateETSNewMultiDimArrayInstanceExpression1(KNativePointer context, KNativePointer other) +{ + const auto _context = reinterpret_cast(context); + const auto _other = reinterpret_cast(other); + auto result = GetImpl()->CreateETSNewMultiDimArrayInstanceExpression1(_context, _other); + return result; +} +KOALA_INTEROP_2(CreateETSNewMultiDimArrayInstanceExpression1, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateETSNewMultiDimArrayInstanceExpression1(KNativePointer context, KNativePointer original, KNativePointer other) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _other = reinterpret_cast(other); + auto result = GetImpl()->UpdateETSNewMultiDimArrayInstanceExpression1(_context, _original, _other); + return result; +} +KOALA_INTEROP_3(UpdateETSNewMultiDimArrayInstanceExpression1, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSNewMultiDimArrayInstanceExpressionTypeReference(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSNewMultiDimArrayInstanceExpressionTypeReference(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSNewMultiDimArrayInstanceExpressionTypeReference, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSNewMultiDimArrayInstanceExpressionTypeReferenceConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSNewMultiDimArrayInstanceExpressionTypeReferenceConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ETSNewMultiDimArrayInstanceExpressionTypeReferenceConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSNewMultiDimArrayInstanceExpressionDimensions(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ETSNewMultiDimArrayInstanceExpressionDimensions(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(ETSNewMultiDimArrayInstanceExpressionDimensions, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSNewMultiDimArrayInstanceExpressionDimensionsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ETSNewMultiDimArrayInstanceExpressionDimensionsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(ETSNewMultiDimArrayInstanceExpressionDimensionsConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_ETSNewMultiDimArrayInstanceExpressionClearPreferredType(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->ETSNewMultiDimArrayInstanceExpressionClearPreferredType(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(ETSNewMultiDimArrayInstanceExpressionClearPreferredType, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSNamedTupleMember(KNativePointer context, KNativePointer label, KNativePointer elementType, KBoolean optional_arg) +{ + const auto _context = reinterpret_cast(context); + const auto _label = reinterpret_cast(label); + const auto _elementType = reinterpret_cast(elementType); + const auto _optional_arg = static_cast(optional_arg); + auto result = GetImpl()->CreateTSNamedTupleMember(_context, _label, _elementType, _optional_arg); + return result; +} +KOALA_INTEROP_4(CreateTSNamedTupleMember, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_UpdateTSNamedTupleMember(KNativePointer context, KNativePointer original, KNativePointer label, KNativePointer elementType, KBoolean optional_arg) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _label = reinterpret_cast(label); + const auto _elementType = reinterpret_cast(elementType); + const auto _optional_arg = static_cast(optional_arg); + auto result = GetImpl()->UpdateTSNamedTupleMember(_context, _original, _label, _elementType, _optional_arg); + return result; +} +KOALA_INTEROP_5(UpdateTSNamedTupleMember, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_TSNamedTupleMemberLabelConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSNamedTupleMemberLabelConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSNamedTupleMemberLabelConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSNamedTupleMemberElementType(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSNamedTupleMemberElementType(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSNamedTupleMemberElementType, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSNamedTupleMemberElementTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSNamedTupleMemberElementTypeConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSNamedTupleMemberElementTypeConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_TSNamedTupleMemberIsOptionalConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSNamedTupleMemberIsOptionalConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSNamedTupleMemberIsOptionalConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_CreateImportExpression(KNativePointer context, KNativePointer source) +{ + const auto _context = reinterpret_cast(context); + const auto _source = reinterpret_cast(source); + auto result = GetImpl()->CreateImportExpression(_context, _source); + return result; +} +KOALA_INTEROP_2(CreateImportExpression, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateImportExpression(KNativePointer context, KNativePointer original, KNativePointer source) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _source = reinterpret_cast(source); + auto result = GetImpl()->UpdateImportExpression(_context, _original, _source); + return result; +} +KOALA_INTEROP_3(UpdateImportExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ImportExpressionSource(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ImportExpressionSource(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ImportExpressionSource, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ImportExpressionSourceConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ImportExpressionSourceConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ImportExpressionSourceConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateAstDumper(KNativePointer context, KNativePointer node, KStringPtr& sourceCode) +{ + const auto _context = reinterpret_cast(context); + const auto _node = reinterpret_cast(node); + const auto _sourceCode = getStringCopy(sourceCode); + auto result = GetImpl()->CreateAstDumper(_context, _node, _sourceCode); + return result; +} +KOALA_INTEROP_3(CreateAstDumper, KNativePointer, KNativePointer, KNativePointer, KStringPtr); + +KNativePointer impl_AstDumperModifierToString(KNativePointer context, KNativePointer receiver, KInt flags) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _flags = static_cast(flags); + auto result = GetImpl()->AstDumperModifierToString(_context, _receiver, _flags); + return new std::string(result); +} +KOALA_INTEROP_3(AstDumperModifierToString, KNativePointer, KNativePointer, KNativePointer, KInt); + +KNativePointer impl_AstDumperTypeOperatorToString(KNativePointer context, KNativePointer receiver, KInt operatorType) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _operatorType = static_cast(operatorType); + auto result = GetImpl()->AstDumperTypeOperatorToString(_context, _receiver, _operatorType); + return new std::string(result); +} +KOALA_INTEROP_3(AstDumperTypeOperatorToString, KNativePointer, KNativePointer, KNativePointer, KInt); + +KNativePointer impl_AstDumperStrConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstDumperStrConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(AstDumperStrConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateETSNullType(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateETSNullTypeIr(_context); + return result; +} +KOALA_INTEROP_1(CreateETSNullType, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateETSNullType(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateETSNullTypeIr(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateETSNullType, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateETSUndefinedType(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateETSUndefinedTypeIr(_context); + return result; +} +KOALA_INTEROP_1(CreateETSUndefinedType, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateETSUndefinedType(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateETSUndefinedTypeIr(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateETSUndefinedType, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTypeofExpression(KNativePointer context, KNativePointer argument) +{ + const auto _context = reinterpret_cast(context); + const auto _argument = reinterpret_cast(argument); + auto result = GetImpl()->CreateTypeofExpression(_context, _argument); + return result; +} +KOALA_INTEROP_2(CreateTypeofExpression, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTypeofExpression(KNativePointer context, KNativePointer original, KNativePointer argument) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _argument = reinterpret_cast(argument); + auto result = GetImpl()->UpdateTypeofExpression(_context, _original, _argument); + return result; +} +KOALA_INTEROP_3(UpdateTypeofExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TypeofExpressionArgumentConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TypeofExpressionArgumentConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TypeofExpressionArgumentConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSEnumMember(KNativePointer context, KNativePointer key, KNativePointer init) +{ + const auto _context = reinterpret_cast(context); + const auto _key = reinterpret_cast(key); + const auto _init = reinterpret_cast(init); + auto result = GetImpl()->CreateTSEnumMember(_context, _key, _init); + return result; +} +KOALA_INTEROP_3(CreateTSEnumMember, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSEnumMember(KNativePointer context, KNativePointer original, KNativePointer key, KNativePointer init) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _key = reinterpret_cast(key); + const auto _init = reinterpret_cast(init); + auto result = GetImpl()->UpdateTSEnumMember(_context, _original, _key, _init); + return result; +} +KOALA_INTEROP_4(UpdateTSEnumMember, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSEnumMember1(KNativePointer context, KNativePointer key, KNativePointer init, KBoolean isGenerated) +{ + const auto _context = reinterpret_cast(context); + const auto _key = reinterpret_cast(key); + const auto _init = reinterpret_cast(init); + const auto _isGenerated = static_cast(isGenerated); + auto result = GetImpl()->CreateTSEnumMember1(_context, _key, _init, _isGenerated); + return result; +} +KOALA_INTEROP_4(CreateTSEnumMember1, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_UpdateTSEnumMember1(KNativePointer context, KNativePointer original, KNativePointer key, KNativePointer init, KBoolean isGenerated) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _key = reinterpret_cast(key); + const auto _init = reinterpret_cast(init); + const auto _isGenerated = static_cast(isGenerated); + auto result = GetImpl()->UpdateTSEnumMember1(_context, _original, _key, _init, _isGenerated); + return result; +} +KOALA_INTEROP_5(UpdateTSEnumMember1, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_TSEnumMemberKeyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSEnumMemberKeyConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSEnumMemberKeyConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSEnumMemberKey(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSEnumMemberKey(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSEnumMemberKey, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSEnumMemberInitConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSEnumMemberInitConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSEnumMemberInitConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSEnumMemberInit(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSEnumMemberInit(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSEnumMemberInit, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_TSEnumMemberIsGeneratedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSEnumMemberIsGeneratedConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSEnumMemberIsGeneratedConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_TSEnumMemberNameConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSEnumMemberNameConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(TSEnumMemberNameConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateSwitchStatement(KNativePointer context, KNativePointer discriminant, KNativePointerArray cases, KUInt casesSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _discriminant = reinterpret_cast(discriminant); + const auto _cases = reinterpret_cast(cases); + const auto _casesSequenceLength = static_cast(casesSequenceLength); + auto result = GetImpl()->CreateSwitchStatement(_context, _discriminant, _cases, _casesSequenceLength); + return result; +} +KOALA_INTEROP_4(CreateSwitchStatement, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_UpdateSwitchStatement(KNativePointer context, KNativePointer original, KNativePointer discriminant, KNativePointerArray cases, KUInt casesSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _discriminant = reinterpret_cast(discriminant); + const auto _cases = reinterpret_cast(cases); + const auto _casesSequenceLength = static_cast(casesSequenceLength); + auto result = GetImpl()->UpdateSwitchStatement(_context, _original, _discriminant, _cases, _casesSequenceLength); + return result; +} +KOALA_INTEROP_5(UpdateSwitchStatement, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_SwitchStatementDiscriminantConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->SwitchStatementDiscriminantConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(SwitchStatementDiscriminantConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_SwitchStatementDiscriminant(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->SwitchStatementDiscriminant(_context, _receiver); + return result; +} +KOALA_INTEROP_2(SwitchStatementDiscriminant, KNativePointer, KNativePointer, KNativePointer); + +void impl_SwitchStatementSetDiscriminant(KNativePointer context, KNativePointer receiver, KNativePointer discriminant) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _discriminant = reinterpret_cast(discriminant); + GetImpl()->SwitchStatementSetDiscriminant(_context, _receiver, _discriminant); + return ; +} +KOALA_INTEROP_V3(SwitchStatementSetDiscriminant, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_SwitchStatementCasesConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->SwitchStatementCasesConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(SwitchStatementCasesConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_SwitchStatementCases(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->SwitchStatementCases(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(SwitchStatementCases, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateDoWhileStatement(KNativePointer context, KNativePointer body, KNativePointer test) +{ + const auto _context = reinterpret_cast(context); + const auto _body = reinterpret_cast(body); + const auto _test = reinterpret_cast(test); + auto result = GetImpl()->CreateDoWhileStatement(_context, _body, _test); + return result; +} +KOALA_INTEROP_3(CreateDoWhileStatement, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateDoWhileStatement(KNativePointer context, KNativePointer original, KNativePointer body, KNativePointer test) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _body = reinterpret_cast(body); + const auto _test = reinterpret_cast(test); + auto result = GetImpl()->UpdateDoWhileStatement(_context, _original, _body, _test); + return result; +} +KOALA_INTEROP_4(UpdateDoWhileStatement, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_DoWhileStatementBodyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->DoWhileStatementBodyConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(DoWhileStatementBodyConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_DoWhileStatementBody(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->DoWhileStatementBody(_context, _receiver); + return result; +} +KOALA_INTEROP_2(DoWhileStatementBody, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_DoWhileStatementTestConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->DoWhileStatementTestConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(DoWhileStatementTestConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_DoWhileStatementTest(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->DoWhileStatementTest(_context, _receiver); + return result; +} +KOALA_INTEROP_2(DoWhileStatementTest, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateCatchClause(KNativePointer context, KNativePointer param, KNativePointer body) +{ + const auto _context = reinterpret_cast(context); + const auto _param = reinterpret_cast(param); + const auto _body = reinterpret_cast(body); + auto result = GetImpl()->CreateCatchClause(_context, _param, _body); + return result; +} +KOALA_INTEROP_3(CreateCatchClause, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateCatchClause(KNativePointer context, KNativePointer original, KNativePointer param, KNativePointer body) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _param = reinterpret_cast(param); + const auto _body = reinterpret_cast(body); + auto result = GetImpl()->UpdateCatchClause(_context, _original, _param, _body); + return result; +} +KOALA_INTEROP_4(UpdateCatchClause, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateCatchClause1(KNativePointer context, KNativePointer other) +{ + const auto _context = reinterpret_cast(context); + const auto _other = reinterpret_cast(other); + auto result = GetImpl()->CreateCatchClause1(_context, _other); + return result; +} +KOALA_INTEROP_2(CreateCatchClause1, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateCatchClause1(KNativePointer context, KNativePointer original, KNativePointer other) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _other = reinterpret_cast(other); + auto result = GetImpl()->UpdateCatchClause1(_context, _original, _other); + return result; +} +KOALA_INTEROP_3(UpdateCatchClause1, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CatchClauseParam(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->CatchClauseParam(_context, _receiver); + return result; +} +KOALA_INTEROP_2(CatchClauseParam, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CatchClauseParamConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->CatchClauseParamConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(CatchClauseParamConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CatchClauseBody(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->CatchClauseBody(_context, _receiver); + return result; +} +KOALA_INTEROP_2(CatchClauseBody, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CatchClauseBodyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->CatchClauseBodyConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(CatchClauseBodyConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_CatchClauseIsDefaultCatchClauseConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->CatchClauseIsDefaultCatchClauseConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(CatchClauseIsDefaultCatchClauseConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_CreateSequenceExpression(KNativePointer context, KNativePointerArray sequence_arg, KUInt sequence_argSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _sequence_arg = reinterpret_cast(sequence_arg); + const auto _sequence_argSequenceLength = static_cast(sequence_argSequenceLength); + auto result = GetImpl()->CreateSequenceExpression(_context, _sequence_arg, _sequence_argSequenceLength); + return result; +} +KOALA_INTEROP_3(CreateSequenceExpression, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_UpdateSequenceExpression(KNativePointer context, KNativePointer original, KNativePointerArray sequence_arg, KUInt sequence_argSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _sequence_arg = reinterpret_cast(sequence_arg); + const auto _sequence_argSequenceLength = static_cast(sequence_argSequenceLength); + auto result = GetImpl()->UpdateSequenceExpression(_context, _original, _sequence_arg, _sequence_argSequenceLength); + return result; +} +KOALA_INTEROP_4(UpdateSequenceExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_SequenceExpressionSequenceConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->SequenceExpressionSequenceConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(SequenceExpressionSequenceConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_SequenceExpressionSequence(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->SequenceExpressionSequence(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(SequenceExpressionSequence, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateArrowFunctionExpression(KNativePointer context, KNativePointer func) +{ + const auto _context = reinterpret_cast(context); + const auto _func = reinterpret_cast(func); + auto result = GetImpl()->CreateArrowFunctionExpression(_context, _func); + return result; +} +KOALA_INTEROP_2(CreateArrowFunctionExpression, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateArrowFunctionExpression(KNativePointer context, KNativePointer original, KNativePointer func) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _func = reinterpret_cast(func); + auto result = GetImpl()->UpdateArrowFunctionExpression(_context, _original, _func); + return result; +} +KOALA_INTEROP_3(UpdateArrowFunctionExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateArrowFunctionExpression1(KNativePointer context, KNativePointer other) +{ + const auto _context = reinterpret_cast(context); + const auto _other = reinterpret_cast(other); + auto result = GetImpl()->CreateArrowFunctionExpression1(_context, _other); + return result; +} +KOALA_INTEROP_2(CreateArrowFunctionExpression1, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateArrowFunctionExpression1(KNativePointer context, KNativePointer original, KNativePointer other) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _other = reinterpret_cast(other); + auto result = GetImpl()->UpdateArrowFunctionExpression1(_context, _original, _other); + return result; +} +KOALA_INTEROP_3(UpdateArrowFunctionExpression1, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ArrowFunctionExpressionFunctionConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ArrowFunctionExpressionFunctionConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ArrowFunctionExpressionFunctionConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ArrowFunctionExpressionFunction(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ArrowFunctionExpressionFunction(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ArrowFunctionExpressionFunction, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ArrowFunctionExpressionCreateTypeAnnotation(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ArrowFunctionExpressionCreateTypeAnnotation(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ArrowFunctionExpressionCreateTypeAnnotation, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ArrowFunctionExpressionAnnotations(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ArrowFunctionExpressionAnnotations(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(ArrowFunctionExpressionAnnotations, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ArrowFunctionExpressionAnnotationsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ArrowFunctionExpressionAnnotationsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(ArrowFunctionExpressionAnnotationsConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_ArrowFunctionExpressionSetAnnotations(KNativePointer context, KNativePointer receiver, KNativePointerArray annotations, KUInt annotationsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _annotations = reinterpret_cast(annotations); + const auto _annotationsSequenceLength = static_cast(annotationsSequenceLength); + GetImpl()->ArrowFunctionExpressionSetAnnotations(_context, _receiver, _annotations, _annotationsSequenceLength); + return ; +} +KOALA_INTEROP_V4(ArrowFunctionExpressionSetAnnotations, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_CreateOmittedExpression(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateOmittedExpression(_context); + return result; +} +KOALA_INTEROP_1(CreateOmittedExpression, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateOmittedExpression(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateOmittedExpression(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateOmittedExpression, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateETSNewClassInstanceExpression(KNativePointer context, KNativePointer typeReference, KNativePointerArray _arguments, KUInt _argumentsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _typeReference = reinterpret_cast(typeReference); + const auto __arguments = reinterpret_cast(_arguments); + const auto __argumentsSequenceLength = static_cast(_argumentsSequenceLength); + auto result = GetImpl()->CreateETSNewClassInstanceExpression(_context, _typeReference, __arguments, __argumentsSequenceLength); + return result; +} +KOALA_INTEROP_4(CreateETSNewClassInstanceExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_UpdateETSNewClassInstanceExpression(KNativePointer context, KNativePointer original, KNativePointer typeReference, KNativePointerArray _arguments, KUInt _argumentsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _typeReference = reinterpret_cast(typeReference); + const auto __arguments = reinterpret_cast(_arguments); + const auto __argumentsSequenceLength = static_cast(_argumentsSequenceLength); + auto result = GetImpl()->UpdateETSNewClassInstanceExpression(_context, _original, _typeReference, __arguments, __argumentsSequenceLength); + return result; +} +KOALA_INTEROP_5(UpdateETSNewClassInstanceExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_CreateETSNewClassInstanceExpression1(KNativePointer context, KNativePointer other) +{ + const auto _context = reinterpret_cast(context); + const auto _other = reinterpret_cast(other); + auto result = GetImpl()->CreateETSNewClassInstanceExpression1(_context, _other); + return result; +} +KOALA_INTEROP_2(CreateETSNewClassInstanceExpression1, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateETSNewClassInstanceExpression1(KNativePointer context, KNativePointer original, KNativePointer other) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _other = reinterpret_cast(other); + auto result = GetImpl()->UpdateETSNewClassInstanceExpression1(_context, _original, _other); + return result; +} +KOALA_INTEROP_3(UpdateETSNewClassInstanceExpression1, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSNewClassInstanceExpressionGetTypeRefConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSNewClassInstanceExpressionGetTypeRefConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ETSNewClassInstanceExpressionGetTypeRefConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSNewClassInstanceExpressionGetArguments(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ETSNewClassInstanceExpressionGetArguments(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(ETSNewClassInstanceExpressionGetArguments, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSNewClassInstanceExpressionGetArgumentsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ETSNewClassInstanceExpressionGetArgumentsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(ETSNewClassInstanceExpressionGetArgumentsConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_ETSNewClassInstanceExpressionSetArguments(KNativePointer context, KNativePointer receiver, KNativePointerArray _arguments, KUInt _argumentsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto __arguments = reinterpret_cast(_arguments); + const auto __argumentsSequenceLength = static_cast(_argumentsSequenceLength); + GetImpl()->ETSNewClassInstanceExpressionSetArguments(_context, _receiver, __arguments, __argumentsSequenceLength); + return ; +} +KOALA_INTEROP_V4(ETSNewClassInstanceExpressionSetArguments, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +void impl_ETSNewClassInstanceExpressionAddToArgumentsFront(KNativePointer context, KNativePointer receiver, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _expr = reinterpret_cast(expr); + GetImpl()->ETSNewClassInstanceExpressionAddToArgumentsFront(_context, _receiver, _expr); + return ; +} +KOALA_INTEROP_V3(ETSNewClassInstanceExpressionAddToArgumentsFront, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSAsExpression(KNativePointer context, KNativePointer expression, KNativePointer typeAnnotation, KBoolean isConst) +{ + const auto _context = reinterpret_cast(context); + const auto _expression = reinterpret_cast(expression); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + const auto _isConst = static_cast(isConst); + auto result = GetImpl()->CreateTSAsExpression(_context, _expression, _typeAnnotation, _isConst); + return result; +} +KOALA_INTEROP_4(CreateTSAsExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_UpdateTSAsExpression(KNativePointer context, KNativePointer original, KNativePointer expression, KNativePointer typeAnnotation, KBoolean isConst) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _expression = reinterpret_cast(expression); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + const auto _isConst = static_cast(isConst); + auto result = GetImpl()->UpdateTSAsExpression(_context, _original, _expression, _typeAnnotation, _isConst); + return result; +} +KOALA_INTEROP_5(UpdateTSAsExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_TSAsExpressionExprConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSAsExpressionExprConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSAsExpressionExprConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSAsExpressionExpr(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSAsExpressionExpr(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSAsExpressionExpr, KNativePointer, KNativePointer, KNativePointer); + +void impl_TSAsExpressionSetExpr(KNativePointer context, KNativePointer receiver, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _expr = reinterpret_cast(expr); + GetImpl()->TSAsExpressionSetExpr(_context, _receiver, _expr); + return ; +} +KOALA_INTEROP_V3(TSAsExpressionSetExpr, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_TSAsExpressionIsConstConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSAsExpressionIsConstConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSAsExpressionIsConstConst, KBoolean, KNativePointer, KNativePointer); + +void impl_TSAsExpressionSetUncheckedCast(KNativePointer context, KNativePointer receiver, KBoolean isUncheckedCast) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _isUncheckedCast = static_cast(isUncheckedCast); + GetImpl()->TSAsExpressionSetUncheckedCast(_context, _receiver, _isUncheckedCast); + return ; +} +KOALA_INTEROP_V3(TSAsExpressionSetUncheckedCast, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_TSAsExpressionTypeAnnotationConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSAsExpressionTypeAnnotationConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSAsExpressionTypeAnnotationConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_TSAsExpressionSetTsTypeAnnotation(KNativePointer context, KNativePointer receiver, KNativePointer typeAnnotation) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + GetImpl()->TSAsExpressionSetTsTypeAnnotation(_context, _receiver, _typeAnnotation); + return ; +} +KOALA_INTEROP_V3(TSAsExpressionSetTsTypeAnnotation, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateForUpdateStatement(KNativePointer context, KNativePointer init, KNativePointer test, KNativePointer update, KNativePointer body) +{ + const auto _context = reinterpret_cast(context); + const auto _init = reinterpret_cast(init); + const auto _test = reinterpret_cast(test); + const auto _update = reinterpret_cast(update); + const auto _body = reinterpret_cast(body); + auto result = GetImpl()->CreateForUpdateStatement(_context, _init, _test, _update, _body); + return result; +} +KOALA_INTEROP_5(CreateForUpdateStatement, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ForUpdateStatementInit(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ForUpdateStatementInit(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ForUpdateStatementInit, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ForUpdateStatementInitConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ForUpdateStatementInitConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ForUpdateStatementInitConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ForUpdateStatementTest(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ForUpdateStatementTest(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ForUpdateStatementTest, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ForUpdateStatementTestConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ForUpdateStatementTestConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ForUpdateStatementTestConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ForUpdateStatementUpdateConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ForUpdateStatementUpdateConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ForUpdateStatementUpdateConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ForUpdateStatementBody(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ForUpdateStatementBody(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ForUpdateStatementBody, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ForUpdateStatementBodyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ForUpdateStatementBodyConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ForUpdateStatementBodyConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateETSTypeReferencePart(KNativePointer context, KNativePointer name, KNativePointer typeParams, KNativePointer prev) +{ + const auto _context = reinterpret_cast(context); + const auto _name = reinterpret_cast(name); + const auto _typeParams = reinterpret_cast(typeParams); + const auto _prev = reinterpret_cast(prev); + auto result = GetImpl()->CreateETSTypeReferencePart(_context, _name, _typeParams, _prev); + return result; +} +KOALA_INTEROP_4(CreateETSTypeReferencePart, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateETSTypeReferencePart(KNativePointer context, KNativePointer original, KNativePointer name, KNativePointer typeParams, KNativePointer prev) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _name = reinterpret_cast(name); + const auto _typeParams = reinterpret_cast(typeParams); + const auto _prev = reinterpret_cast(prev); + auto result = GetImpl()->UpdateETSTypeReferencePart(_context, _original, _name, _typeParams, _prev); + return result; +} +KOALA_INTEROP_5(UpdateETSTypeReferencePart, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateETSTypeReferencePart1(KNativePointer context, KNativePointer name) +{ + const auto _context = reinterpret_cast(context); + const auto _name = reinterpret_cast(name); + auto result = GetImpl()->CreateETSTypeReferencePart1(_context, _name); + return result; +} +KOALA_INTEROP_2(CreateETSTypeReferencePart1, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateETSTypeReferencePart1(KNativePointer context, KNativePointer original, KNativePointer name) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _name = reinterpret_cast(name); + auto result = GetImpl()->UpdateETSTypeReferencePart1(_context, _original, _name); + return result; +} +KOALA_INTEROP_3(UpdateETSTypeReferencePart1, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSTypeReferencePartPrevious(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSTypeReferencePartPrevious(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSTypeReferencePartPrevious, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSTypeReferencePartPreviousConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSTypeReferencePartPreviousConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ETSTypeReferencePartPreviousConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSTypeReferencePartName(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSTypeReferencePartName(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSTypeReferencePartName, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSTypeReferencePartTypeParams(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSTypeReferencePartTypeParams(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSTypeReferencePartTypeParams, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSTypeReferencePartNameConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSTypeReferencePartNameConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ETSTypeReferencePartNameConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSTypeReferencePartGetIdent(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSTypeReferencePartGetIdent(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSTypeReferencePartGetIdent, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSReExportDeclarationGetETSImportDeclarationsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSReExportDeclarationGetETSImportDeclarationsConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ETSReExportDeclarationGetETSImportDeclarationsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSReExportDeclarationGetETSImportDeclarations(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSReExportDeclarationGetETSImportDeclarations(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSReExportDeclarationGetETSImportDeclarations, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSReExportDeclarationGetProgramPathConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSReExportDeclarationGetProgramPathConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(ETSReExportDeclarationGetProgramPathConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateETSPrimitiveType(KNativePointer context, KInt type) +{ + const auto _context = reinterpret_cast(context); + const auto _type = static_cast(type); + auto result = GetImpl()->CreateETSPrimitiveType(_context, _type); + return result; +} +KOALA_INTEROP_2(CreateETSPrimitiveType, KNativePointer, KNativePointer, KInt); + +KNativePointer impl_UpdateETSPrimitiveType(KNativePointer context, KNativePointer original, KInt type) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _type = static_cast(type); + auto result = GetImpl()->UpdateETSPrimitiveType(_context, _original, _type); + return result; +} +KOALA_INTEROP_3(UpdateETSPrimitiveType, KNativePointer, KNativePointer, KNativePointer, KInt); + +KInt impl_ETSPrimitiveTypeGetPrimitiveTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSPrimitiveTypeGetPrimitiveTypeConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSPrimitiveTypeGetPrimitiveTypeConst, KInt, KNativePointer, KNativePointer); + +KNativePointer impl_TypeNodeAnnotations(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TypeNodeAnnotations(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(TypeNodeAnnotations, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TypeNodeAnnotationsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TypeNodeAnnotationsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TypeNodeAnnotationsConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_TypeNodeSetAnnotations(KNativePointer context, KNativePointer receiver, KNativePointerArray annotations, KUInt annotationsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _annotations = reinterpret_cast(annotations); + const auto _annotationsSequenceLength = static_cast(annotationsSequenceLength); + GetImpl()->TypeNodeSetAnnotations(_context, _receiver, _annotations, _annotationsSequenceLength); + return ; +} +KOALA_INTEROP_V4(TypeNodeSetAnnotations, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_CreateNewExpression(KNativePointer context, KNativePointer callee, KNativePointerArray _arguments, KUInt _argumentsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _callee = reinterpret_cast(callee); + const auto __arguments = reinterpret_cast(_arguments); + const auto __argumentsSequenceLength = static_cast(_argumentsSequenceLength); + auto result = GetImpl()->CreateNewExpression(_context, _callee, __arguments, __argumentsSequenceLength); + return result; +} +KOALA_INTEROP_4(CreateNewExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_UpdateNewExpression(KNativePointer context, KNativePointer original, KNativePointer callee, KNativePointerArray _arguments, KUInt _argumentsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _callee = reinterpret_cast(callee); + const auto __arguments = reinterpret_cast(_arguments); + const auto __argumentsSequenceLength = static_cast(_argumentsSequenceLength); + auto result = GetImpl()->UpdateNewExpression(_context, _original, _callee, __arguments, __argumentsSequenceLength); + return result; +} +KOALA_INTEROP_5(UpdateNewExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_NewExpressionCalleeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->NewExpressionCalleeConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(NewExpressionCalleeConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_NewExpressionArgumentsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->NewExpressionArgumentsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(NewExpressionArgumentsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSParameterProperty(KNativePointer context, KInt accessibility, KNativePointer parameter, KBoolean readonly_arg, KBoolean isStatic, KBoolean isExport) +{ + const auto _context = reinterpret_cast(context); + const auto _accessibility = static_cast(accessibility); + const auto _parameter = reinterpret_cast(parameter); + const auto _readonly_arg = static_cast(readonly_arg); + const auto _isStatic = static_cast(isStatic); + const auto _isExport = static_cast(isExport); + auto result = GetImpl()->CreateTSParameterProperty(_context, _accessibility, _parameter, _readonly_arg, _isStatic, _isExport); + return result; +} +KOALA_INTEROP_6(CreateTSParameterProperty, KNativePointer, KNativePointer, KInt, KNativePointer, KBoolean, KBoolean, KBoolean); + +KNativePointer impl_UpdateTSParameterProperty(KNativePointer context, KNativePointer original, KInt accessibility, KNativePointer parameter, KBoolean readonly_arg, KBoolean isStatic, KBoolean isExport) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _accessibility = static_cast(accessibility); + const auto _parameter = reinterpret_cast(parameter); + const auto _readonly_arg = static_cast(readonly_arg); + const auto _isStatic = static_cast(isStatic); + const auto _isExport = static_cast(isExport); + auto result = GetImpl()->UpdateTSParameterProperty(_context, _original, _accessibility, _parameter, _readonly_arg, _isStatic, _isExport); + return result; +} +KOALA_INTEROP_7(UpdateTSParameterProperty, KNativePointer, KNativePointer, KNativePointer, KInt, KNativePointer, KBoolean, KBoolean, KBoolean); + +KInt impl_TSParameterPropertyAccessibilityConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSParameterPropertyAccessibilityConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSParameterPropertyAccessibilityConst, KInt, KNativePointer, KNativePointer); + +KBoolean impl_TSParameterPropertyReadonlyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSParameterPropertyReadonlyConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSParameterPropertyReadonlyConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_TSParameterPropertyIsStaticConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSParameterPropertyIsStaticConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSParameterPropertyIsStaticConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_TSParameterPropertyIsExportConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSParameterPropertyIsExportConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSParameterPropertyIsExportConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_TSParameterPropertyParameterConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSParameterPropertyParameterConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSParameterPropertyParameterConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateETSWildcardType(KNativePointer context, KNativePointer typeReference, KInt flags) +{ + const auto _context = reinterpret_cast(context); + const auto _typeReference = reinterpret_cast(typeReference); + const auto _flags = static_cast(flags); + auto result = GetImpl()->CreateETSWildcardType(_context, _typeReference, _flags); + return result; +} +KOALA_INTEROP_3(CreateETSWildcardType, KNativePointer, KNativePointer, KNativePointer, KInt); + +KNativePointer impl_UpdateETSWildcardType(KNativePointer context, KNativePointer original, KNativePointer typeReference, KInt flags) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _typeReference = reinterpret_cast(typeReference); + const auto _flags = static_cast(flags); + auto result = GetImpl()->UpdateETSWildcardType(_context, _original, _typeReference, _flags); + return result; +} +KOALA_INTEROP_4(UpdateETSWildcardType, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KInt); + +KNativePointer impl_ETSWildcardTypeTypeReference(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSWildcardTypeTypeReference(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSWildcardTypeTypeReference, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSWildcardTypeTypeReferenceConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSWildcardTypeTypeReferenceConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ETSWildcardTypeTypeReferenceConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSThisType(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateTSThisType(_context); + return result; +} +KOALA_INTEROP_1(CreateTSThisType, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSThisType(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateTSThisType(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateTSThisType, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateInterfaceDecl(KNativePointer context, KStringPtr& name) +{ + const auto _context = reinterpret_cast(context); + const auto _name = getStringCopy(name); + auto result = GetImpl()->CreateInterfaceDecl(_context, _name); + return result; +} +KOALA_INTEROP_2(CreateInterfaceDecl, KNativePointer, KNativePointer, KStringPtr); + +KNativePointer impl_CreateInterfaceDecl1(KNativePointer context, KStringPtr& name, KNativePointer declNode) +{ + const auto _context = reinterpret_cast(context); + const auto _name = getStringCopy(name); + const auto _declNode = reinterpret_cast(declNode); + auto result = GetImpl()->CreateInterfaceDecl1(_context, _name, _declNode); + return result; +} +KOALA_INTEROP_3(CreateInterfaceDecl1, KNativePointer, KNativePointer, KStringPtr, KNativePointer); + +KNativePointer impl_CreateFunctionDecl(KNativePointer context, KStringPtr& name, KNativePointer node) +{ + const auto _context = reinterpret_cast(context); + const auto _name = getStringCopy(name); + const auto _node = reinterpret_cast(node); + auto result = GetImpl()->CreateFunctionDecl(_context, _name, _node); + return result; +} +KOALA_INTEROP_3(CreateFunctionDecl, KNativePointer, KNativePointer, KStringPtr, KNativePointer); + diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/package.json b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/package.json new file mode 100644 index 0000000000000000000000000000000000000000..977974d599457e3817f860f25d5a6c48d4dc9aa3 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/package.json @@ -0,0 +1,63 @@ +{ + "name": "@koalaui/libarkts", + "version": "1.5.15+devel", + "bin": "./lib/es2panda", + "types": "./build/index.d.ts", + "exports": { + ".": "./lib/libarkts.js", + "./plugins/*": "./lib/plugins/*.js" + }, + "files": [ + "./lib/**/*", + "./build/**/*", + "./plugins/build/src/**/*" + ], + "config": { + "gen_version": "2.1.5", + "panda_sdk_path": "../../incremental/tools/panda/node_modules/@panda/sdk" + }, + "dependencies": { + "@koalaui/ets-tsc": "4.9.5-r5", + "@koalaui/build-common": "1.5.15+devel", + "@koalaui/compat": "1.5.15+devel", + "@koalaui/common": "1.5.15+devel", + "@koalaui/interop": "1.5.15+devel", + "node-addon-api": "8.0.0", + "node-api-headers": "0.0.5", + "commander": "10.0.1" + }, + "devDependencies": { + "rollup": "^4.13.0", + "@rollup/plugin-commonjs": "^26.0.1", + "@rollup/plugin-node-resolve": "^15.3.0", + "@rollup/plugin-terser": "^0.4.4", + "@rollup/plugin-typescript": "^11.1.6" + }, + "scripts": { + "clean": "rimraf build native/build* ./.rollup.cache tsconfig.tsbuildinfo lib", + "clean:plugins": "rimraf plugins/build", + "compile:koala:interop": "npm run --prefix ../../interop compile", + "compile:meson": "cd native && meson setup build && meson compile -C build", + "copy:.node": "mkdir -p ./build/native/build && cp ./native/build/es2panda.node ./build/native/build", + "compile:native": "npm run compile:koala:interop && npm run compile:meson && npm run copy:.node", + "compile:src": "npx ets-tsc -p ./tsconfig.json", + "compile": "npm run compile:native && npm run compile:src && rollup -c rollup.lib.mjs && rollup -c rollup.es2panda.mjs", + "compile:plugins": "npx rollup -c ./rollup.printer-plugin.mjs && npx rollup -c ./rollup.no-visitor-plugin.mjs ", + "restart": "npx fast-arktsc --config arktsconfig.json --compiler ../../incremental/tools/panda/arkts/ui2abc --link-name ./build/abc/main.abc --file-option --restart-stages && ninja -f build/abc/build.ninja", + "direct": "PANDA_SDK_PATH=../../incremental/tools/panda/node_modules/@panda/sdk node . --file ./plugins/input/direct.ets --output ./build/abc/direct.abc --dump-plugin-ast --arktsconfig ./arktsconfig-direct.json && file build/abc/direct.abc", + "memo": "PANDA_SDK_PATH=../../incremental/tools/panda/node_modules/@panda/sdk node . --file ./plugins/input/memo.ets --output ./build/abc/memo.abc --dump-plugin-ast --arktsconfig ./arktsconfig-memo.json --restart-stages", + "run": "npm run compile && npm run compile:plugins && npm run compile --prefix ../memo-plugin && npm run restart", + "run:memo": "npm run compile && npm run compile:plugins && npm run compile --prefix ../memo-plugin && npm run memo", + "run:abc": "../../incremental/tools/panda/node_modules/@panda/sdk/linux_host_tools/bin/ark --load-runtimes=ets --boot-panda-files=../../incremental/tools/panda/node_modules/@panda/sdk/ets/etsstdlib.abc ./main.abc main.ETSGLOBAL::main", + "mocha": "PANDA_SDK_PATH=../../incremental/tools/panda/node_modules/@panda/sdk TS_NODE_PROJECT=./test/tsconfig.json mocha -r tsconfig-paths/register --reporter-option maxDiffSize=0", + "test": "npm run compile:native && npm run mocha", + "compile:playground": "cd playground && meson setup build && meson compile -C build", + "run:playground": "npm run compile:playground && ./playground/build/playground.out", + "panda:sdk:clean": "cd ../../incremental/tools/panda && rimraf node_modules", + "panda:sdk:install": "cd ../../incremental/tools/panda && npm run panda:sdk:install", + "panda:sdk:reinstall": "npm run panda:sdk:clean && npm run panda:sdk:install", + "regenerate:current": "npm run compile -C ../../../arktscgen && node ../../../arktscgen --panda-sdk-path $npm_package_config_panda_sdk_path --output-dir ../ --options-file ./generator/options.json5 --no-initialize --debug", + "regenerate": "npx --yes @idlizer/arktscgen@$npm_package_config_gen_version --panda-sdk-path $npm_package_config_panda_sdk_path --output-dir ../ --options-file ./generator/options.json5 --no-initialize", + "reinstall:regenerate": "npm run panda:sdk:reinstall && npm run regenerate" + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/playground/meson.build b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/playground/meson.build new file mode 100644 index 0000000000000000000000000000000000000000..e70cb0ad810ed7ea6affd0cdecf3392400d14785 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/playground/meson.build @@ -0,0 +1,31 @@ +project('playground', 'cpp', + version: '1.0', + default_options: [ + 'cpp_std=c++17', + 'buildtype=debug', + ], +) + +cflags = [ + '-DKOALA_USE_NODE_VM', + '-DKOALA_NAPI' +] + +if target_machine.system() == 'windows' + cflags += ['-DKOALA_WINDOWS'] +else + cflags += ['-DKOALA_LINUX'] +endif + +executable( + 'playground.out', + [ + './src/playground.cc', + ], + include_directories: [ + get_option('panda_sdk_dir') / 'ohos_arm64/include/tools/es2panda/public', + get_option('panda_sdk_dir') / 'ohos_arm64/include/tools/es2panda', + get_option('interop_src_dir'), + ], + cpp_args: cflags +) diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/playground/meson_options.txt b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/playground/meson_options.txt new file mode 100644 index 0000000000000000000000000000000000000000..438cc37a430cad357339a85c8f6d1d9fc64eaf34 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/playground/meson_options.txt @@ -0,0 +1,4 @@ +option('panda_sdk_dir', type : 'string', value : '../../../incremental/tools/panda/node_modules/@panda/sdk/', + description : 'path to panda sdk') +option('interop_src_dir', type : 'string', value : '../../../interop/src/cpp/', + description : 'path to interop_src') diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/playground/src/playground.cc b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/playground/src/playground.cc new file mode 100644 index 0000000000000000000000000000000000000000..96c28c1a39810a788e55753c860de2eb61de7d0e --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/playground/src/playground.cc @@ -0,0 +1,160 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include "dynamic-loader.h" +#include "es2panda_lib.h" + +#ifdef __x86_64__ + #define PLUGIN_DIR "linux_host_tools" +#else + #define PLUGIN_DIR "linux_arm64_host_tools" +#endif + +const char* libpath = "../../incremental/tools/panda/node_modules/@panda/sdk/" PLUGIN_DIR "/lib/libes2panda-public.so"; + +static es2panda_Impl *impl = nullptr; + +es2panda_Impl *GetImpl() { + if (impl) { + return impl; + } + auto library = loadLibrary(libpath); + if (!library) { + throw std::runtime_error("No library"); + } + auto symbol = findSymbol(library, "es2panda_GetImpl"); + if (!symbol) { + throw std::runtime_error("No entry point"); + } + impl = reinterpret_cast(symbol)(ES2PANDA_LIB_VERSION); + return impl; +} + +static const char* source = +"export class XXX {}" +; +static es2panda_AstNode* newStatements[1]; + +int main() { + impl = GetImpl(); + const char* args[] = { + // command with which the program is invoked (ignored) + "", + "--arktsconfig", + // path to config + "./arktsconfig.json", + // path to source + "./plugins/input/main.ets", + "--stdlib", + "../../incremental/tools/panda/node_modules/@panda/sdk/ets/stdlib" + }; + + auto config = GetImpl()->CreateConfig(6, args); + auto context = GetImpl()->CreateContextFromString(config, source, args[3]); + + GetImpl()->ProceedToState(context, ES2PANDA_STATE_PARSED); + if(GetImpl()->ContextState(context) == ES2PANDA_STATE_ERROR) + { + std::cout << "PROCEED TO PARSE ERROR" << std::endl; + std::cout << GetImpl()->ContextErrorMessage(context) << std::endl; + } + else { + std::cout << "PROCEED TO PARSE SUCCESS" << std::endl; + } + + auto ast = GetImpl()->ProgramAst(context, GetImpl()->ContextProgram(context)); + + std::cout << GetImpl()->AstNodeDumpEtsSrcConst(context, ast) << std::endl; + + std::size_t count = 0; + auto statements = impl->BlockStatementStatements(context, ast, &count); + auto oldClass = statements[0]; + auto oldDef = GetImpl()->ClassDeclarationDefinition(context, oldClass); + + std::cout << "statement count: " << count << std::endl; + + auto *identifier = impl->CreateIdentifier1(context, (char *)"XXX"); + auto *newDef = impl->CreateClassDefinition1( + context, + // oldDef, + identifier, nullptr, 0, Es2pandaClassDefinitionModifiers::CLASS_DEFINITION_MODIFIERS_CLASS_DECL, + Es2pandaModifierFlags::MODIFIER_FLAGS_DECLARE + ); + auto *newClazz = impl->CreateClassDeclaration(context, newDef); + newStatements[0] = newClazz; + + impl->BlockStatementSetStatements(context, ast, newStatements, 1); + impl->AstNodeSetParent(context, newDef, newClazz); + impl->AstNodeSetParent(context, identifier, newDef); + + impl->BlockStatementSetStatements(context, ast, newStatements, 1); + + (void)impl->BlockStatementStatements(context, ast, &count); + std::cout << "new statement count: " << count << std::endl; + + std::cout << GetImpl()->AstNodeDumpEtsSrcConst(context, ast) << std::endl; + + GetImpl()->ProceedToState(context, ES2PANDA_STATE_BOUND); + if(GetImpl()->ContextState(context) == ES2PANDA_STATE_ERROR) + { + std::cout << "PROCEED TO BOUND ERROR" << std::endl; + std::cout << GetImpl()->ContextErrorMessage(context) << std::endl; + } + else { + std::cout << "PROCEED TO BOUND SUCCESS" << std::endl; + } + + GetImpl()->ProceedToState(context, ES2PANDA_STATE_CHECKED); + if(GetImpl()->ContextState(context) == ES2PANDA_STATE_ERROR) + { + std::cout << "PROCEED TO CHECKED ERROR" << std::endl; + std::cout << GetImpl()->ContextErrorMessage(context) << std::endl; + } + else { + std::cout << "PROCEED TO CHECKED SUCCESS" << std::endl; + } + + GetImpl()->ProceedToState(context, ES2PANDA_STATE_LOWERED); + if(GetImpl()->ContextState(context) == ES2PANDA_STATE_ERROR) + { + std::cout << "PROCEED TO LOWERED ERROR" << std::endl; + std::cout << GetImpl()->ContextErrorMessage(context) << std::endl; + } + else { + std::cout << "PROCEED TO LOWERED SUCCESS" << std::endl; + } + + GetImpl()->ProceedToState(context, ES2PANDA_STATE_ASM_GENERATED); + if(GetImpl()->ContextState(context) == ES2PANDA_STATE_ERROR) + { + std::cout << "PROCEED TO ASM ERROR" << std::endl; + std::cout << GetImpl()->ContextErrorMessage(context) << std::endl; + } + else { + std::cout << "PROCEED TO ASM SUCCESS" << std::endl; + } + + GetImpl()->ProceedToState(context, ES2PANDA_STATE_BIN_GENERATED); + if(GetImpl()->ContextState(context) == ES2PANDA_STATE_ERROR) + { + std::cout << "PROCEED TO BIN ERROR" << std::endl; + std::cout << GetImpl()->ContextErrorMessage(context) << std::endl; + } + else { + std::cout << "PROCEED TO BIN SUCCESS" << std::endl; + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/plugins/input/direct.ets b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/plugins/input/direct.ets new file mode 100644 index 0000000000000000000000000000000000000000..e265532a9ddbcffb7c9a29f5b794fe8a6041b355 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/plugins/input/direct.ets @@ -0,0 +1,21 @@ +import { __memo_context_type, __memo_id_type } from "@koalaui/runtime" + +@Retention({policy: "SOURCE"}) +@interface memo { } + +class A { + +} + +class Memo { + @memo static memo_method(): int { + return 1 + } + + @memo static memo_call(): int { + @memo const f = (): int => { + return 2 + } + return f() + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/plugins/input/export.ets b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/plugins/input/export.ets new file mode 100644 index 0000000000000000000000000000000000000000..d5f7c542e436e4b5a82ea4498e90b9b3af4f9a70 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/plugins/input/export.ets @@ -0,0 +1,5 @@ +export function foo() { + console.log("Hello, world!") +} + +export const TEST: double = 2.718281828459045; diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/plugins/input/f.ets b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/plugins/input/f.ets new file mode 100644 index 0000000000000000000000000000000000000000..369304938e2892f01a409bbf49294d1ad33537c5 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/plugins/input/f.ets @@ -0,0 +1,3 @@ +export function f() { + console.log("Hello, world!") +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/plugins/input/library.ets b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/plugins/input/library.ets new file mode 100644 index 0000000000000000000000000000000000000000..d801589a651ebcd28f90c4f3ec345f6887c555b6 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/plugins/input/library.ets @@ -0,0 +1 @@ +export @interface Component {} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/plugins/input/main.ets b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/plugins/input/main.ets new file mode 100644 index 0000000000000000000000000000000000000000..f55101d976576b7be10a2058fd3a0e5c8a8e4c57 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/plugins/input/main.ets @@ -0,0 +1,32 @@ +import { Component } from "./library" + +@interface BuilderLambda { + value: string +} + +@Component +struct MyComponent { + @BuilderLambda("MyComponent.instantiateImpl") + static $_instantiate(factory: () => MyComponent): MyComponent { + const instance = factory() + return instance + } + + static instantiateImpl(builder: (instance: MyComponent)=>void, factory: () => MyComponent): void { + const instance = factory() + builder(instance) + } + + width(value: number): MyComponent { return this } + build() {} +} + + +@Component +struct AnotherComponent { + + build() { + MyComponent() + .width(17.0) + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/plugins/input/no-import-no-struct.ets b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/plugins/input/no-import-no-struct.ets new file mode 100644 index 0000000000000000000000000000000000000000..e1231f9cbde4b47b62a9cbe5d4470e49b63484f5 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/plugins/input/no-import-no-struct.ets @@ -0,0 +1,32 @@ +@interface Component{} + +@interface BuilderLambda { + value: string +} + +@Component +class MyComponent { + @BuilderLambda("instantiateImpl") + static $_instantiate(factory: () => MyComponent): MyComponent { + const instance = factory() + return instance + } + + static instantiateImpl(builder: (instance: MyComponent)=>void, factory: () => MyComponent): void { + const instance = factory() + builder(instance) + } + + width(value: number): MyComponent { return this } + build() {} +} + + +@Component +class AnotherComponent { + + build() { + MyComponent() + .width(17.0) + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/plugins/input/variable.ets b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/plugins/input/variable.ets new file mode 100644 index 0000000000000000000000000000000000000000..b79405ec23477ead9379bb0ecc278ba6e1d5fbbe --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/plugins/input/variable.ets @@ -0,0 +1 @@ +export const X: number = 1.2345; diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/plugins/src/no-visitor.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/plugins/src/no-visitor.ts new file mode 100644 index 0000000000000000000000000000000000000000..9fa3f0800f9b2aaa5dd2391da60ff32c7625e1b3 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/plugins/src/no-visitor.ts @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as arkts from "@koalaui/libarkts" + +export default function noVisitor() { + return (node: arkts.ETSModule) => { + return node + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/plugins/src/print-visitor.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/plugins/src/print-visitor.ts new file mode 100644 index 0000000000000000000000000000000000000000..c2c30cbf5bd1a6c002ff3e3a458698ea47a01e0d --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/plugins/src/print-visitor.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as arkts from "@koalaui/libarkts" + + +export class PrintVisitor extends arkts.AbstractVisitor { + private result = "" + + private printNode(node: arkts.AstNode) { + return `${" ".repeat(4 * this.indentation)}${arkts.asString(node)}` + } + + visitor(node: arkts.AstNode): arkts.AstNode { + console.log(this.printNode(node)) + return this.visitEachChild(node) + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/plugins/src/printer-plugin.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/plugins/src/printer-plugin.ts new file mode 100644 index 0000000000000000000000000000000000000000..b600813d1999664ea0c10aeae653e4e279e885fb --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/plugins/src/printer-plugin.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +import * as arkts from "@koalaui/libarkts" +import { PrintVisitor } from './print-visitor' + +export interface TransformerOptions { + trace?: boolean, +} + +export default function printerTransformer( + userPluginOptions?: TransformerOptions +) { + return (node: arkts.ETSModule) => { + return new PrintVisitor().visitor(node) + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/plugins/tsconfig.json b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/plugins/tsconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..de1b23ea31f52df420f781af5e52bfa417d381ba --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/plugins/tsconfig.json @@ -0,0 +1,14 @@ +{ + "extends": "@koalaui/build-common/tsconfig.json", + "compilerOptions": { + "rootDir": ".", + "baseUrl": ".", + "outDir": "./build", + "module": "CommonJS" + }, + "include": [ + "./src/printer-plugin.ts", + "./src/print-visitor.ts", + "./src/no-visitor.ts" + ] +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/rollup.es2panda.mjs b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/rollup.es2panda.mjs new file mode 100644 index 0000000000000000000000000000000000000000..4f1f75870788bfd574d23f62beb94078677beecd --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/rollup.es2panda.mjs @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import nodeResolve from "@rollup/plugin-node-resolve"; +import typescript from "@rollup/plugin-typescript"; +import commonjs from '@rollup/plugin-commonjs' + +/** @type {import("rollup").RollupOptions} */ +export default { + input: "./src-host/es2panda.ts", + output: { + file: "./lib/es2panda.js", + format: "commonjs", + banner: [ + "#!/usr/bin/env node", + APACHE_LICENSE_HEADER() + ].join("\n"), + }, + external: ["commander", "typescript", "@koalaui/libarkts"], + plugins: [ + commonjs(), + typescript({ + outputToFilesystem: false, + module: "esnext", + sourceMap: false, + declarationMap: false, + declaration: false, + composite: false, + tsconfig: "./tsconfig.host.json" + }), + nodeResolve({ + extensions: [".js", ".mjs", ".cjs", ".ts", ".cts", ".mts"] + }) + ], +} + +function APACHE_LICENSE_HEADER() { + return ` +/** +* @license +* Copyright (c) ${new Date().getUTCFullYear()} Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +` +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/rollup.lib.mjs b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/rollup.lib.mjs new file mode 100644 index 0000000000000000000000000000000000000000..db773f233bf78ef79fa50b033f6a9927bf4a2d06 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/rollup.lib.mjs @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import nodeResolve from "@rollup/plugin-node-resolve"; +import typescript from "@rollup/plugin-typescript"; +import commonjs from '@rollup/plugin-commonjs' + +/** @type {import("rollup").RollupOptions} */ +export default { + input: "./src/index.ts", + output: { + file: "./lib/libarkts.js", + format: "commonjs", + plugins: [ + // terser() + ], + banner: [ + "#!/usr/bin/env node", + APACHE_LICENSE_HEADER() + ].join("\n"), + }, + external: ["commander", "typescript", "@koalaui/libarkts"], + plugins: [ + commonjs(), + typescript({ + outputToFilesystem: false, + module: "esnext", + sourceMap: false, + declarationMap: false, + declaration: false, + composite: false, + }), + nodeResolve({ + extensions: [".js", ".mjs", ".cjs", ".ts", ".cts", ".mts"] + }) + ], +} + +function APACHE_LICENSE_HEADER() { + return ` +/** +* @license +* Copyright (c) ${new Date().getUTCFullYear()} Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +` +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/rollup.no-visitor-plugin.mjs b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/rollup.no-visitor-plugin.mjs new file mode 100644 index 0000000000000000000000000000000000000000..cdd19aa5a92e2c1e42652af8ef0d6d902f9e648e --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/rollup.no-visitor-plugin.mjs @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import nodeResolve from "@rollup/plugin-node-resolve"; +import typescript from "@rollup/plugin-typescript"; +import commonjs from '@rollup/plugin-commonjs' + +/** @type {import("rollup").RollupOptions} */ +export default { + input: "./plugins/src/no-visitor.ts", + output: { + file: "./lib/plugins/no-visitor.js", + format: "commonjs", + banner: [ + "#!/usr/bin/env node", + APACHE_LICENSE_HEADER() + ].join("\n"), + }, + external: ["@koalaui/libarkts"], + plugins: [ + commonjs(), + typescript({ + outputToFilesystem: false, + module: "esnext", + sourceMap: false, + declarationMap: false, + declaration: false, + composite: false, + tsconfig: "./tsconfig.plugin.json" + }), + nodeResolve({ + extensions: [".js", ".mjs", ".cjs", ".ts", ".cts", ".mts"] + }) + ], +} + +function APACHE_LICENSE_HEADER() { + return ` +/** +* @license +* Copyright (c) ${new Date().getUTCFullYear()} Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +` +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/rollup.printer-plugin.mjs b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/rollup.printer-plugin.mjs new file mode 100644 index 0000000000000000000000000000000000000000..fc5779c87606020bf8ff7a4abd50a404393881d7 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/rollup.printer-plugin.mjs @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import nodeResolve from "@rollup/plugin-node-resolve"; +import typescript from "@rollup/plugin-typescript"; +import commonjs from '@rollup/plugin-commonjs' + +/** @type {import("rollup").RollupOptions} */ +export default { + input: "./plugins/src/printer-plugin.ts", + output: { + file: "./lib/plugins/printer-plugin.js", + format: "commonjs", + banner: [ + "#!/usr/bin/env node", + APACHE_LICENSE_HEADER() + ].join("\n"), + }, + external: ["@koalaui/libarkts"], + plugins: [ + commonjs(), + typescript({ + outputToFilesystem: false, + module: "esnext", + sourceMap: false, + declarationMap: false, + declaration: false, + composite: false, + tsconfig: "./tsconfig.plugin.json" + }), + nodeResolve({ + extensions: [".js", ".mjs", ".cjs", ".ts", ".cts", ".mts"] + }) + ], +} + +function APACHE_LICENSE_HEADER() { + return ` +/** +* @license +* Copyright (c) ${new Date().getUTCFullYear()} Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +` +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src-host/es2panda.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src-host/es2panda.ts new file mode 100644 index 0000000000000000000000000000000000000000..bcd5c256ef81e65c3b58dd362b485a738db782c2 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src-host/es2panda.ts @@ -0,0 +1,276 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as fs from "node:fs" +import * as path from "node:path" +import { arktsGlobal as global } from "@koalaui/libarkts" +import { Command } from "commander" +import { filterSource, isNumber, throwError, withWarning } from "@koalaui/libarkts" +import { Es2pandaContextState } from "@koalaui/libarkts" +import { AstNode, checkErrors, Config, Context, createETSModuleFromContext, proceedToState, rebindSubtree, recheckSubtree } from "@koalaui/libarkts" + +function parseCommandLineArgs() { + const commander = new Command() + .option('--file, ', 'Path to file to be compiled') + .option('--arktsconfig, ', 'Path to arkts configuration file') + .option('--ets-module', 'Do nothing, legacy compatibility') + .option('--output, ', 'The name of result file') + .option('--dump-plugin-ast', 'Dump ast before and after each plugin') + .option('--restart-stages', 'Restart the compiler to proceed to next stage') + .option('--stage ', 'Stage of multistage compilation (from 0 to number of plugins in arktsconfig + 1)') + .parse(process.argv) + .opts() + + const restOptions = commander.args + + const filePath = path.resolve(commander.file) + const configPath = path.resolve(commander.arktsconfig) + const outputPath = path.resolve(commander.output) + if (!fs.existsSync(filePath)) { + throw new Error(`File path doesn't exist: ${filePath}`) + } + if (!fs.existsSync(configPath)) { + throw new Error(`Arktsconfig path doesn't exist: ${configPath}`) + } + + const dumpAst = commander.dumpPluginAst ?? false + const restartStages = commander.restartStages ?? false + const stage = commander.stage ?? 0 + + return { filePath, configPath, outputPath, dumpAst, restartStages, stage } +} + +function insertPlugin(transform: (ast: AstNode) => void, state: Es2pandaContextState, dumpAst: boolean, restart: boolean, updateWith?: (node: AstNode) => void): AstNode { + proceedToState(state) + const script = createETSModuleFromContext() + if (script === undefined) { + throwError(`Failed to receive ast from es2panda`) + } + + if (dumpAst) { + console.log(`BEFORE ${stateName(state)}:`) + console.log(filterSource(script.dumpSrc())) + } + + const beforeTransform = Date.now() + + transform?.(script) + + const afterTransform = Date.now() + global.profiler.transformTime += afterTransform - beforeTransform + + if (dumpAst) { + console.log(`AFTER ${stateName(state)}:`) + console.log(filterSource(script.dumpSrc())) + } + + setAllParents(script) + + if (!restart) { + updateWith?.(script) + } + // note: sometimes errors are generated, but state not changed to Es2pandaContextState.ES2PANDA_STATE_ERROR (01.04.25) + return script +} + +function restartCompiler(configPath: string, filePath: string, stdlib: string, outputPath: string, verbose: boolean = true) { + if (verbose) { + console.log(`restarting with config ${configPath}, file ${filePath}`) + } + const srcText = filterSource(createETSModuleFromContext().dumpSrc()) + global.es2panda._DestroyContext(global.context) + global.es2panda._DestroyConfig(global.config) + + global.filePath = filePath + global.config = Config.create([ + '_', + '--arktsconfig', + configPath, + filePath, + '--extension', + 'ets', + '--stdlib', + stdlib, + '--output', + outputPath + ]).peer + global.compilerContext = Context.createFromString(srcText) +} + +const defaultPandaSdk = "../../../incremental/tools/panda/node_modules/@panda/sdk" +function invokeWithPlugins( + configPath: string, + packageName: string, + baseUrl: string, + outDir: string, + filePath: string, + outputPath: string, + pluginsByState: Map void)[]>, + dumpAst: boolean, + restart: boolean, + stage: number, + pluginNames: string[], +): void { + const source = fs.readFileSync(filePath).toString() + const sdk = process.env.PANDA_SDK_PATH ?? withWarning( + defaultPandaSdk, + `PANDA_SDK_PATH not set, assuming ${defaultPandaSdk}` + ) + const stdlib = `${sdk}/ets/stdlib` + + global.filePath = filePath + global.packageName = packageName + global.filePathFromPackageRoot = path.relative(path.join(path.dirname(configPath), baseUrl), filePath) + global.config = Config.create([ + '_', + '--arktsconfig', + configPath, + filePath, + '--extension', + 'ets', + '--stdlib', + stdlib, + '--output', + outputPath + ]).peer + fs.mkdirSync(path.dirname(outputPath), {recursive: true}) + global.compilerContext = Context.createFromString(source) + + console.log("PLUGINS: ", pluginsByState.size, pluginsByState) + + pluginNames.push(`_proceed_to_binary`) + let pluginsApplied = 0 + + const restartProcedure = () => { + if (restart) { + const before = Date.now() + const ext = path.extname(configPath) + const newConfigPath = `${configPath.substring(0, configPath.length - pluginNames[pluginsApplied].length - ext.length)}${pluginNames[pluginsApplied + 1]}${ext}` + const newFilePath = path.resolve(outDir, pluginNames[pluginsApplied], global.filePathFromPackageRoot) + if (pluginsApplied == stage) { + // uncomment if switch to dets generator + // restartCompiler(configPath, filePath, stdlib, outputPath, false) + generateDeclFromCurrentContext(newFilePath) + } + pluginsApplied++ + restartCompiler(newConfigPath, newFilePath, stdlib, outputPath) + configPath = newConfigPath + filePath = newFilePath + const after = Date.now() + global.profiler.restartTime += after - before + } + } + + pluginsByState.get(Es2pandaContextState.ES2PANDA_STATE_PARSED)?.forEach(plugin => { + insertPlugin(plugin, Es2pandaContextState.ES2PANDA_STATE_PARSED, dumpAst, restart) + restartProcedure() + }) + + pluginsByState.get(Es2pandaContextState.ES2PANDA_STATE_BOUND)?.forEach(plugin => { + insertPlugin(plugin, Es2pandaContextState.ES2PANDA_STATE_BOUND, dumpAst, restart, rebindSubtree) + restartProcedure() + }) + + pluginsByState.get(Es2pandaContextState.ES2PANDA_STATE_CHECKED)?.forEach(plugin => { + insertPlugin(plugin, Es2pandaContextState.ES2PANDA_STATE_CHECKED, dumpAst, restart, recheckSubtree) + restartProcedure() + }) + proceedToState(Es2pandaContextState.ES2PANDA_STATE_BIN_GENERATED) +} + +const exportsFromInitialFile: string[] = [] + +function generateDeclFromCurrentContext(filePath: string): never { + proceedToState(Es2pandaContextState.ES2PANDA_STATE_PARSED) + console.log(`Emitting to ${filePath}`) + let out = [ + filterSource(global.compilerContext.program.astNode.dumpSrc()), + ...exportsFromInitialFile + ].join('\n') + fs.mkdirSync(path.dirname(filePath), { recursive: true }) + fs.writeFileSync(filePath, out) + process.exit(0) +} + +function setAllParents(ast: AstNode) { + global.es2panda._AstNodeUpdateAll(global.context, ast.peer) +} + +function loadPlugin(configDir: string, jsonPlugin: any) { + const pluginPath = jsonPlugin.transform ?? throwError(`arktsconfig plugins objects should specify transform`) + /** TODO: read and pass plugin options */ + const plugin = (pluginPath.startsWith(".") || pluginPath.startsWith("/")) ? + path.resolve(configDir, pluginPath) : pluginPath + const pluginFunction: (config?: any) => any = require(plugin)(jsonPlugin) + return pluginFunction +} + +function selectPlugins(configDir: string, plugins: any[], stage: string): ((arg: AstNode) => AstNode)[] | undefined { + const selected = plugins + .filter(it => (it.stage == stage)) + .map(it => loadPlugin(configDir, it)) + if (selected.length == 0) { + return undefined + } + return selected +} + +function stateName(value: Es2pandaContextState): string { + return Es2pandaContextState[value].substring("ES2PANDA_STATE_".length) +} + +function readAndSortPlugins(configDir: string, plugins: any[]) { + const pluginsByState = new Map void)[]>() + + Object.values(Es2pandaContextState) + .filter(isNumber) + .forEach(it => { + const selected = selectPlugins(configDir, plugins, stateName(it).toLowerCase()) + if (selected) pluginsByState.set( + it, + selected + ) + }) + + return pluginsByState +} + +export function main() { + const before = Date.now() + const { filePath, configPath, outputPath, dumpAst, restartStages, stage } = parseCommandLineArgs() + const arktsconfig = JSON.parse(fs.readFileSync(configPath).toString()) + const configDir = path.dirname(configPath) + const compilerOptions = arktsconfig.compilerOptions ?? throwError(`arktsconfig should specify compilerOptions`) + const packageName = compilerOptions.package ?? "" + const baseUrl = compilerOptions.baseUrl ?? "." + const outDir = path.resolve(path.dirname(configPath), compilerOptions.outDir ?? ".") + const plugins = compilerOptions.plugins ?? [] + const pluginNames = plugins.map((it: any) => `${it.name}-${it.stage}`) + + const pluginsByState = readAndSortPlugins(configDir, plugins) + + exportsFromInitialFile.push( + ...[...fs.readFileSync(filePath).toString().matchAll(/export {([\s\S]*?)} from .*(\n|$)/g)].map(it => it[0]), + ...[...fs.readFileSync(filePath).toString().matchAll(/export \* from .*(\n|$)/g)].map(it => it[0]) + ) + + invokeWithPlugins(configPath, packageName, baseUrl, outDir, filePath, outputPath, pluginsByState, dumpAst, restartStages, stage, pluginNames) + + const after = Date.now() + global.profiler.totalTime = after - before + global.profiler.report() +} + +main() diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/Es2pandaNativeModule.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/Es2pandaNativeModule.ts new file mode 100644 index 0000000000000000000000000000000000000000..db72a97fa38a8be71246ea60710472015aca2954 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/Es2pandaNativeModule.ts @@ -0,0 +1,161 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + KNativePointer as KPtr, + KInt, + KBoolean, + KNativePointer, + registerNativeModuleLibraryName, + loadNativeModuleLibrary, + KDouble, + KUInt, +} from "@koalaui/interop" +import { Es2pandaNativeModule as GeneratedEs2pandaNativeModule, KNativePointerArray } from "./generated/Es2pandaNativeModule" +import * as path from "path" +import * as fs from "fs" + +// TODO: this type should be in interop +export type KPtrArray = BigUint64Array + +export class Es2pandaNativeModule { + _AnnotationAllowedAnnotations(context: KPtr, node: KPtr, returnLen: KPtr): KPtr { + throw new Error("Not implemented") + } + _AstNodeRebind(context: KPtr, node: KPtr): void { + throw new Error("Not implemented") + } + _AstNodeRecheck(context: KPtr, node: KPtr): void { + throw new Error("Not implemented") + } + _ContextState(context: KPtr): KInt { + throw new Error("Not implemented") + } + _ContextErrorMessage(context: KPtr): KPtr { + throw new Error("Not implemented") + } + _AstNodeChildren(context: KPtr, node: KPtr): KPtr { + throw new Error("Not implemented") + } + _AstNodeDumpModifiers(context: KPtr, node: KPtr): KPtr { + throw new Error("Not implemented") + } + _CreateConfig(argc: number, argv: string[]): KPtr { + throw new Error("Not implemented") + } + _DestroyConfig(peer: KNativePointer): void { + throw new Error("Not implemented") + } + _CreateContextFromString(config: KPtr, source: String, filename: String): KPtr { + throw new Error("Not implemented") + } + _DestroyContext(context: KPtr): void { + throw new Error("Not implemented") + } + _ProceedToState(context: KPtr, state: number): void { + throw new Error("Not implemented") + } + _ContextProgram(context: KPtr): KPtr { + throw new Error("Not implemented") + } + _ProgramAst(context: KPtr, program: KPtr): KPtr { + throw new Error("Not implemented") + } + _CheckerStartChecker(context: KPtr): KBoolean { + throw new Error("Not implemented") + } + _AstNodeVariableConst(context: KPtr, ast: KPtr): KPtr { + throw new Error("Not implemented") + } + _CreateNumberLiteral(context: KPtr, value: KDouble): KPtr { + throw new Error("Not implemented") + } + _AstNodeUpdateChildren(context: KPtr, node: KPtr): void { + throw new Error("Not implemented") + } + _AstNodeUpdateAll(context: KPtr, node: KPtr): void { + throw new Error("Not implemented") + } + _VariableDeclaration(context: KPtr, variable: KPtr): KPtr { + throw new Error("Not implemented") + } + _DeclNode(context: KPtr, decl: KPtr): KPtr { + throw new Error("Not implemented") + } + _DeclarationFromIdentifier(context: KPtr, identifier: KPtr): KPtr { + throw new Error("Not implemented") + } + _ProgramExternalSources(context: KNativePointer, instance: KNativePointer): KNativePointer { + throw new Error("Not implemented"); + } + _ExternalSourceName(instance: KNativePointer): KNativePointer { + throw new Error("Not implemented"); + } + _ExternalSourcePrograms(instance: KNativePointer): KNativePointer { + throw new Error("Not implemented"); + } + _ETSParserBuildImportDeclaration(context: KNativePointer, importKinds: KInt, specifiers: KNativePointerArray, specifiersSequenceLength: KUInt, source: KNativePointer, program: KNativePointer, flags: KInt): KNativePointer { + throw new Error("Not implemented"); + } + _InsertETSImportDeclarationAndParse(context: KNativePointer, program: KNativePointer, importDeclaration: KNativePointer): void { + throw new Error("Not implemented"); + } + _ImportPathManagerResolvePathConst(context: KNativePointer, importPathManager: KNativePointer, currentModulePath: String, importPath: String, sourcePosition: KNativePointer): KNativePointer { + throw new Error("Not implemented"); + } + _ETSParserGetImportPathManager(context: KNativePointer): KPtr { + throw new Error("Not implemented"); + } + _CreateSourcePosition(context: KNativePointer, index: KInt, line: KInt): KNativePointer { + throw new Error("Not implemented"); + } + _SourcePositionIndex(context: KNativePointer, instance: KNativePointer): KInt { + throw new Error("Not implemented"); + } + _SourcePositionLine(context: KNativePointer, instance: KNativePointer): KInt { + throw new Error("Not implemented"); + } +} + +export function findNativeModule(): string { + const candidates = [ + path.resolve(__dirname, "../native/build/es2panda.node"), + path.resolve(__dirname, "../build/native/build/es2panda.node"), + ] + let result = undefined + candidates.forEach(path => { + if (fs.existsSync(path)) { + result = path + return + } + }) + if (result) return result + throw new Error("Cannot find native module") +} + +export function initEs2panda(): Es2pandaNativeModule { + registerNativeModuleLibraryName("NativeModule", findNativeModule()) + const instance = new Es2pandaNativeModule() + loadNativeModuleLibrary("NativeModule", instance) + return instance +} + +export function initGeneratedEs2panda(): GeneratedEs2pandaNativeModule { + registerNativeModuleLibraryName("NativeModule", findNativeModule()) + const instance = new GeneratedEs2pandaNativeModule() + // registerNativeModule("InteropNativeModule", NativeModule) + loadNativeModuleLibrary("NativeModule", instance) + return instance +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/InteropNativeModule.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/InteropNativeModule.ts new file mode 100644 index 0000000000000000000000000000000000000000..ffdab5d83136aeea72a6e5be77b93798d3220ba8 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/InteropNativeModule.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + KNativePointer as KPtr, + KInt, + registerNativeModuleLibraryName, + loadNativeModuleLibrary +} from "@koalaui/interop" +import * as path from "path" +import { findNativeModule } from "./Es2pandaNativeModule" + +export class InteropNativeModule { + _StringLength(ptr: KPtr): KInt { + throw new Error("Not implemented") + } + _StringData(ptr: KPtr, buffer: KPtr, length: KInt): void { + throw new Error("Not implemented") + } + _GetStringFinalizer(): KPtr { + throw new Error("Not implemented") + } + _InvokeFinalizer(ptr: KPtr, finalizer: KPtr): void { + throw new Error("Not implemented") + } + _GetPtrVectorSize(ptr: KPtr): KInt { + throw new Error("Not implemented") + } + _GetPtrVectorElement(ptr: KPtr, index: KInt): KPtr { + throw new Error("Not implemented") + } +} + +export function initInterop(): InteropNativeModule { + registerNativeModuleLibraryName("InteropNativeModule", findNativeModule()) + const instance = new InteropNativeModule() + loadNativeModuleLibrary("InteropNativeModule", instance) + return instance +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/AbstractVisitor.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/AbstractVisitor.ts new file mode 100644 index 0000000000000000000000000000000000000000..684c098c7b8313de3f3a053bc4667bd5a0b78d8c --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/AbstractVisitor.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AstNode } from "./peers/AstNode" +import { Program } from "./peers/Program" +import { visitEachChild } from "./visitor" + +export interface VisitorOptions { + program?: Program +} + +export abstract class AbstractVisitor { + public program?: Program + + constructor(options?: VisitorOptions) { + this.program = options?.program; + } + + indentation = 0 + + withIndentation(exec: () => T) { + this.indentation++ + const result = exec() + this.indentation-- + return result + } + + abstract visitor(node: AstNode, options?: object): AstNode + + visitEachChild(node: AstNode, options?: object): AstNode { + return this.withIndentation(() => + visitEachChild( + node, + it => this.visitor(it, options) + ) + ) + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/class-by-peer.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/class-by-peer.ts new file mode 100644 index 0000000000000000000000000000000000000000..3d834489da7286da06cb99a0357eda7c59c50bc8 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/class-by-peer.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Es2pandaAstNodeType } from "../generated/Es2pandaEnums" +import { throwError } from "../utils" +import { global } from "./static/global" +import { KNativePointer, nullptr } from "@koalaui/interop" +import { AstNode } from "./peers/AstNode" +import { factory } from "@koalaui/ets-tsc" +import { unpackString } from "./utilities/private" + +export const nodeByType = new Map AstNode>([]) + +export function classByPeer(peer: KNativePointer): T { + if (peer === nullptr) { + throwError('classByPeer: peer is NULLPTR') + } + const type = global.generatedEs2panda._AstNodeTypeConst(global.context, peer) + const create = nodeByType.get(type) ?? throwError(`unknown node type: ${type}`) + return create(peer) as T +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/factory/nodeFactory.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/factory/nodeFactory.ts new file mode 100644 index 0000000000000000000000000000000000000000..e302ced355564c9874a088ce595c13e0d0f32c05 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/factory/nodeFactory.ts @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + ClassDefinition, + ClassProperty, + ETSStructDeclaration, + ETSTypeReferencePart, + MemberExpression, + TryStatement, + TSInterfaceDeclaration, + TSTypeParameter, + VariableDeclarator, + ObjectExpression, + ETSTuple, +} from "../../generated" +import { factory as generatedFactory } from "../../generated/factory" +import { createScriptFunction, updateScriptFunction } from "../node-utilities/ScriptFunction" +import { createCallExpression, updateCallExpression } from "../node-utilities/CallExpression" +import { createNumberLiteral, updateNumberLiteral } from "../node-utilities/NumberLiteral" +import { updateMemberExpression } from "../node-utilities/MemberExpression" +import { createETSParameterExpression, updateETSParameterExpression } from "../node-utilities/ETSParameterExpression" +import { updateTSTypeParameter } from "../node-utilities/TSTypeParameter" +import { updateETSTypeReferencePart } from "../node-utilities/TSTypeReferencePart" +import { createETSImportDeclaration, updateETSImportDeclaration } from "../node-utilities/ETSImportDeclaration" +import { updateVariableDeclarator } from "../node-utilities/VariableDeclarator" +import { updateClassDefinition } from "../node-utilities/ClassDefinition" +import { updateETSStructDeclaration } from "../node-utilities/ETSStructDeclaration" +import { updateClassProperty } from "../node-utilities/ClassProperty" +import { createETSFunctionType, updateETSFunctionType } from "../node-utilities/ETSFunctionType" +import { createMethodDefinition, updateMethodDefinition } from "../node-utilities/MethodDefinition" +import { updateTSInterfaceDeclaration } from "../node-utilities/TSInterfaceDeclaration" +import { createArrowFunctionExpression, updateArrowFunctionExpression } from "../node-utilities/ArrowFunctionExpression" +import { updateTryStatement } from "../node-utilities/TryStatement" +import { createVariableDeclaration, updateVariableDeclaration } from "../node-utilities/VariableDeclaration" +import { createAssignmentExpression, updateAssignmentExpression } from "../node-utilities/AssignmentExpression" +import { updateObjectExpression } from "../node-utilities/ObjectExpression" +import { updateETSTuple } from "../node-utilities/ETSTuple" +import { createArrayExpression, updateArrayExpression } from "../node-utilities/ArrayExpression" +import { createTSTypeAliasDeclaration, updateTSTypeAliasDeclaration } from "../node-utilities/TSTypeAliasDeclaration" + +export const factory = { + ...generatedFactory, + + createCallExpression, + updateCallExpression, + + createMemberExpression: MemberExpression.createMemberExpression, + updateMemberExpression, + + createScriptFunction, + updateScriptFunction, + + createNumberLiteral, + updateNumberLiteral, + + createETSParameterExpression, + updateETSParameterExpression, + + createTypeParameter: TSTypeParameter.create1TSTypeParameter, + updateTypeParameter: updateTSTypeParameter, + + createETSTypeReferencePart: ETSTypeReferencePart.createETSTypeReferencePart, + updateETSTypeReferencePart, + + createETSImportDeclaration, + updateETSImportDeclaration, + + createVariableDeclarator: VariableDeclarator.create1VariableDeclarator, + updateVariableDeclarator, + + createVariableDeclaration, + updateVariableDeclaration, + + createETSStructDeclaration: ETSStructDeclaration.createETSStructDeclaration, + updateETSStructDeclaration, + + createClassDefinition: ClassDefinition.createClassDefinition, + updateClassDefinition, + + createClassProperty: ClassProperty.createClassProperty, + updateClassProperty, + + createETSFunctionType, + updateETSFunctionType, + + createMethodDefinition, + updateMethodDefinition, + + createInterfaceDeclaration: TSInterfaceDeclaration.createTSInterfaceDeclaration, + updateInterfaceDeclaration: updateTSInterfaceDeclaration, + + createArrowFunctionExpression, + updateArrowFunctionExpression, + + createTryStatement: TryStatement.createTryStatement, + updateTryStatement, + + createAssignmentExpression, + updateAssignmentExpression, + + createObjectExpression: ObjectExpression.createObjectExpression, + updateObjectExpression, + + createETSTuple: ETSTuple.create2ETSTuple, + updateETSTuple, + + createArrayExpression, + updateArrayExpression, + + createTSTypeAliasDeclaration, + updateTSTypeAliasDeclaration, +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/index.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..6ce9b80d4b962ab7160b3ee7652c4d1035eb1efa --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/index.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export * from "../generated/Es2pandaEnums" +export * from "../generated" + +export * from "./utilities/private" +export * from "./utilities/public" +export * from "./factory/nodeFactory" +export * from "./visitor" +export * from "./AbstractVisitor" + +export * from "./peers/AstNode" +export * from "./peers/Config" +export * from "./peers/Context" +export * from "./peers/Program" +export * from "./peers/ImportPathManager" +export { global as arktsGlobal } from "./static/global" diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-cache.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-cache.ts new file mode 100644 index 0000000000000000000000000000000000000000..d409b72621dc7fdb3abbad8622f004a81050b7ce --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-cache.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ArktsObject } from "./peers/ArktsObject" +import { KNativePointer } from "@koalaui/interop" + +export class NodeCache { + private static cache = new Map() + + static cached(pointer: KNativePointer, factory: (pointer: KNativePointer) => ArktsObject): T { + const cached = NodeCache.cache.get(pointer) + if (cached !== undefined) { + return cached as T + } + const node = factory(pointer) + NodeCache.cache.set(pointer, node) + return node as T + } + + public static clear(): void { + NodeCache.cache.clear() + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/ArrayExpression.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/ArrayExpression.ts new file mode 100644 index 0000000000000000000000000000000000000000..5ea0798c36467d4aee0c500899896b97daa00dcb --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/ArrayExpression.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Es2pandaAstNodeType } from "../../generated/Es2pandaEnums" +import { ArrayExpression, Expression } from "../../generated" +import { isSameNativeObject } from "../peers/ArktsObject" +import { updateNodeByNode } from "../../reexport-for-generated" + +export function createArrayExpression( + elements: readonly Expression[] +): ArrayExpression { + return ArrayExpression.create1ArrayExpression( + Es2pandaAstNodeType.AST_NODE_TYPE_ARRAY_EXPRESSION, + elements, + false + ) +} + +export function updateArrayExpression( + original: ArrayExpression, + elements: readonly Expression[] +): ArrayExpression { + if (isSameNativeObject(original.elements, elements)) { + return original + } + return updateNodeByNode( + createArrayExpression(elements), + original + ) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/ArrowFunctionExpression.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/ArrowFunctionExpression.ts new file mode 100644 index 0000000000000000000000000000000000000000..cde917fbf48318f4765a56e9dc122b77566db141 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/ArrowFunctionExpression.ts @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ArrowFunctionExpression, AnnotationUsage, ScriptFunction } from "../../generated" +import { isSameNativeObject } from "../peers/ArktsObject" +import { updateNodeByNode } from "../utilities/private" + +export function createArrowFunctionExpression( + func?: ScriptFunction, + annotations?: readonly AnnotationUsage[], +): ArrowFunctionExpression { + const res = ArrowFunctionExpression.createArrowFunctionExpression( + func + ) + if (annotations) { + res.setAnnotations(annotations) + } + return res +} + +export function updateArrowFunctionExpression( + original: ArrowFunctionExpression, + func?: ScriptFunction, + annotations?: readonly AnnotationUsage[], +): ArrowFunctionExpression { + if (isSameNativeObject(original.function, func) + && isSameNativeObject(original.annotations, annotations)) { + return original + } + return updateNodeByNode( + createArrowFunctionExpression( + func, + annotations, + ), + original + ) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/AssignmentExpression.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/AssignmentExpression.ts new file mode 100644 index 0000000000000000000000000000000000000000..b5fa8024e53e4313536f4a373836a9911590dc47 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/AssignmentExpression.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AssignmentExpression, Expression } from "../../generated" +import { isSameNativeObject } from "../peers/ArktsObject" +import { updateNodeByNode } from "../utilities/private" +import { Es2pandaAstNodeType, Es2pandaTokenType } from "../../generated/Es2pandaEnums" + +export function createAssignmentExpression( + left: Expression | undefined, + right: Expression | undefined, + assignmentOperator: Es2pandaTokenType +): AssignmentExpression { + return AssignmentExpression.create1AssignmentExpression( + Es2pandaAstNodeType.AST_NODE_TYPE_ASSIGNMENT_EXPRESSION, + left, + right, + assignmentOperator, + ) +} + +export function updateAssignmentExpression( + original: AssignmentExpression, + left: Expression | undefined, + right: Expression | undefined, + assignmentOperator: Es2pandaTokenType +): AssignmentExpression { + if (isSameNativeObject(left, original.left) + && isSameNativeObject(right, original.right) + && isSameNativeObject(assignmentOperator, original.operatorType) + ) { + return original + } + return updateNodeByNode( + createAssignmentExpression(left, right, assignmentOperator), + original + ) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/CallExpression.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/CallExpression.ts new file mode 100644 index 0000000000000000000000000000000000000000..714b703e9272e153674c274ca96b95d8b03b8349 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/CallExpression.ts @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { BlockStatement, CallExpression, Expression, TSTypeParameterInstantiation } from "../../generated" +import { isSameNativeObject } from "../peers/ArktsObject" +import { updateNodeByNode } from "../utilities/private" + +export function createCallExpression( + callee: Expression | undefined, + _arguments: readonly Expression[], + typeParams: TSTypeParameterInstantiation | undefined, + optional_arg: boolean = false, + trailingComma: boolean = false, + trailingBlock: BlockStatement | undefined = undefined, +) { + const res = CallExpression.createCallExpression( + callee, + _arguments, + typeParams, + optional_arg, + trailingComma, + ) + if (trailingBlock) { + res.setTrailingBlock(trailingBlock) + } + return res +} + +export function updateCallExpression( + original: CallExpression, + callee: Expression | undefined, + _arguments: readonly Expression[], + typeParams: TSTypeParameterInstantiation | undefined, + optional_arg: boolean = false, + trailingComma: boolean = false, + trailingBlock: BlockStatement | undefined = undefined, +) { + if (isSameNativeObject(callee, original.callee) + && isSameNativeObject(_arguments, original.arguments) + && isSameNativeObject(typeParams, original.typeParams) + && isSameNativeObject(optional_arg, original.isOptional) + && isSameNativeObject(trailingComma, original.hasTrailingComma) + && isSameNativeObject(trailingBlock, original.trailingBlock) + ) { + return original + } + return updateNodeByNode( + createCallExpression(callee, _arguments, typeParams, optional_arg, trailingComma, trailingBlock), + original + ) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/ClassDefinition.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/ClassDefinition.ts new file mode 100644 index 0000000000000000000000000000000000000000..071127e44f4d4634632022964b40de05c84869e6 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/ClassDefinition.ts @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + ClassDefinition, + Expression, + Identifier, + isMethodDefinition, + MethodDefinition, + TSClassImplements, + TSTypeParameterDeclaration, + TSTypeParameterInstantiation +} from "../../generated" +import { isSameNativeObject } from "../peers/ArktsObject" +import { updateNodeByNode } from "../utilities/private" +import { AstNode } from "../peers/AstNode" +import { Es2pandaClassDefinitionModifiers, Es2pandaModifierFlags } from "../../generated/Es2pandaEnums" +import { throwError } from "../../utils" + +export function updateClassDefinition( + original: ClassDefinition, + ident: Identifier | undefined, + typeParams: TSTypeParameterDeclaration | undefined, + superTypeParams: TSTypeParameterInstantiation | undefined, + _implements: readonly TSClassImplements[], + ctor: MethodDefinition | undefined, + superClass: Expression | undefined, + body: readonly AstNode[], + modifiers: Es2pandaClassDefinitionModifiers, + flags: Es2pandaModifierFlags +) { + if (original.ctor !== undefined && !isMethodDefinition(original.ctor)) { + throwError(`class definition constructor is not method definition: ${ctor?.dump()}`) + } + if (isSameNativeObject(ident, original.ident) + && (isSameNativeObject(typeParams, original.typeParams)) + && (isSameNativeObject(superTypeParams, original.superTypeParams)) + && (isSameNativeObject(_implements, original.implements)) + && (isSameNativeObject(ctor, original.ctor)) + && (isSameNativeObject(superClass, original.super)) + && (isSameNativeObject(body, original.body)) + && (isSameNativeObject(modifiers, original.modifiers)) + && (isSameNativeObject(flags, original.modifierFlags)) + ) { + return original + } + return updateNodeByNode( + ClassDefinition.createClassDefinition( + ident, + typeParams, + superTypeParams, + _implements, + ctor, + superClass, + body, + modifiers, + flags + ).setAnnotations(original.annotations), + original + ) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/ClassProperty.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/ClassProperty.ts new file mode 100644 index 0000000000000000000000000000000000000000..5718f19de14e6e1948c5a92d381ca72e2a2efd54 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/ClassProperty.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ClassProperty, Expression, TypeNode } from "../../generated" +import { Es2pandaModifierFlags } from "../../generated/Es2pandaEnums" +import { isSameNativeObject } from "../peers/ArktsObject" +import { updateNodeByNode } from "../utilities/private" + +export function updateClassProperty( + original: ClassProperty, + key: Expression | undefined, + value: Expression | undefined, + typeAnnotation: TypeNode | undefined, + modifiers: Es2pandaModifierFlags, + isComputed: boolean +) { + if (isSameNativeObject(key, original.key) + && isSameNativeObject(value, original.value) + && isSameNativeObject(typeAnnotation, original.typeAnnotation) + && isSameNativeObject(modifiers, original.modifierFlags) + && isSameNativeObject(isComputed, original.isComputed) + ) { + return original + } + return updateNodeByNode( + ClassProperty.createClassProperty(key, value, typeAnnotation, modifiers, isComputed), + original + ) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/ETSFunctionType.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/ETSFunctionType.ts new file mode 100644 index 0000000000000000000000000000000000000000..7ca6883a2223f92ca366dab6a075ad0d23384fd1 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/ETSFunctionType.ts @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AnnotationUsage, ETSFunctionType, Expression, FunctionSignature, TSTypeParameterDeclaration, TypeNode } from "../../generated" +import { Es2pandaScriptFunctionFlags } from "../../generated/Es2pandaEnums" +import { isSameNativeObject } from "../peers/ArktsObject" +import { updateNodeByNode } from "../utilities/private" + +export function createETSFunctionType( + typeParams: TSTypeParameterDeclaration | undefined, + params: readonly Expression[], + returnTypeAnnotation: TypeNode | undefined, + hasReceiver: boolean, + funcFlags: Es2pandaScriptFunctionFlags, + annotations?: readonly AnnotationUsage[], +) { + const res = ETSFunctionType.createETSFunctionType( + FunctionSignature.createFunctionSignature( + typeParams, + params, + returnTypeAnnotation, + hasReceiver, + ), + funcFlags, + ) + if (annotations) { + res.setAnnotations(annotations) + } + return res +} + +export function updateETSFunctionType( + original: ETSFunctionType, + typeParams: TSTypeParameterDeclaration | undefined, + params: readonly Expression[], + returnTypeAnnotation: TypeNode | undefined, + hasReceiver: boolean, + funcFlags: Es2pandaScriptFunctionFlags, + annotations?: readonly AnnotationUsage[], +) { + if (isSameNativeObject(typeParams, original.typeParams) + && isSameNativeObject(params, original.params) + && isSameNativeObject(returnTypeAnnotation, original.returnType) + && isSameNativeObject(funcFlags, original.flags) + && isSameNativeObject(annotations, original.annotations) + ) { + return original + } + return updateNodeByNode( + createETSFunctionType(typeParams, params, returnTypeAnnotation, hasReceiver, funcFlags, annotations), + original + ) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/ETSImportDeclaration.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/ETSImportDeclaration.ts new file mode 100644 index 0000000000000000000000000000000000000000..4eabb1173e1c06bdd74777c746377990da43fb46 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/ETSImportDeclaration.ts @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ETSImportDeclaration, StringLiteral } from "../../generated" +import { isSameNativeObject } from "../peers/ArktsObject" +import { passNode, passNodeArray, unpackNonNullableNode, updateNodeByNode } from "../utilities/private" +import { AstNode } from "../peers/AstNode" +import { Es2pandaImportFlags, Es2pandaImportKinds } from "../../generated/Es2pandaEnums" +import { global } from "../static/global" +import { Program } from "../peers/Program" + +export function createETSImportDeclaration( + source: StringLiteral | undefined, + specifiers: readonly AstNode[], + importKind: Es2pandaImportKinds, + program: Program, + flags: Es2pandaImportFlags +): ETSImportDeclaration { + const res = unpackNonNullableNode( + global.es2panda._ETSParserBuildImportDeclaration( + global.context, + importKind, + passNodeArray(specifiers), + specifiers.length, + passNode(source), + program.peer, + flags + ) + ) + global.es2panda._InsertETSImportDeclarationAndParse(global.context, global.compilerContext.program.peer, res.peer) + return new ETSImportDeclaration(res.peer) +} + +export function updateETSImportDeclaration( + original: ETSImportDeclaration, + source: StringLiteral | undefined, + specifiers: readonly AstNode[], + importKind: Es2pandaImportKinds +) { + if (isSameNativeObject(source, original.source) + && isSameNativeObject(specifiers, original.specifiers) + /* no getter for importKind */ + ) { + /* TODO: probably should set importMetadata, but no getter provided yet */ + return original + } + return updateNodeByNode( + ETSImportDeclaration.createETSImportDeclaration(source, specifiers, importKind), + original + ) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/ETSParameterExpression.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/ETSParameterExpression.ts new file mode 100644 index 0000000000000000000000000000000000000000..8071ba195d51898a44a2ab631c8292cb29db7bf6 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/ETSParameterExpression.ts @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AnnotatedExpression, AnnotationUsage, ETSParameterExpression, Expression, TypeNode } from "../../generated" +import { isSameNativeObject } from "../peers/ArktsObject" +import { updateNodeByNode } from "../utilities/private" + +export function createETSParameterExpression( + identOrSpread: AnnotatedExpression | undefined, + isOptional: boolean, + initExpr?: Expression, + typeAnnotation?: TypeNode, + annotations?: readonly AnnotationUsage[] +) { + const res = ETSParameterExpression.createETSParameterExpression(identOrSpread, isOptional) + if (initExpr) { + res.setInitializer(initExpr) + } + if (typeAnnotation) { + res.setTypeAnnotation(typeAnnotation) + } + if (annotations) { + res.setAnnotations(annotations) + } + return res +} + +export function updateETSParameterExpression( + original: ETSParameterExpression, + identOrSpread: AnnotatedExpression | undefined, + isOptional: boolean, + initExpr?: Expression, + typeAnnotation?: TypeNode, + annotations?: readonly AnnotationUsage[], +) { + if ((isSameNativeObject(identOrSpread, original.ident) || isSameNativeObject(identOrSpread, original.restParameter)) + && isSameNativeObject(isOptional, original.isOptional) + && isSameNativeObject(initExpr, original.initializer) + && isSameNativeObject(typeAnnotation, original.typeAnnotation) + && isSameNativeObject(annotations, original.annotations) + ) { + return original + } + return updateNodeByNode( + createETSParameterExpression(identOrSpread, isOptional, initExpr, typeAnnotation, annotations), + original + ) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/ETSStructDeclaration.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/ETSStructDeclaration.ts new file mode 100644 index 0000000000000000000000000000000000000000..5d286ee13c9ea3f77f00a3606d7768df443053b9 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/ETSStructDeclaration.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ClassDefinition, ETSStructDeclaration } from "../../generated" +import { isSameNativeObject } from "../peers/ArktsObject" +import { updateNodeByNode } from "../utilities/private" + +export function updateETSStructDeclaration( + original: ETSStructDeclaration, + def?: ClassDefinition +) { + if (isSameNativeObject(def, original.definition)) { + return original + } + return updateNodeByNode( + ETSStructDeclaration.createETSStructDeclaration(def), + original + ) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/ETSTuple.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/ETSTuple.ts new file mode 100644 index 0000000000000000000000000000000000000000..10c683968d542207fe09d39b0ecbc02a7545efab --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/ETSTuple.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ETSTuple, TypeNode } from "../../generated" +import { isSameNativeObject } from "../peers/ArktsObject" +import { updateNodeByNode } from "../utilities/private" + +export function updateETSTuple( + original: ETSTuple, + typeList: readonly TypeNode[] +) { + if (isSameNativeObject(typeList, original.tupleTypeAnnotationsList)) { + return original + } + return updateNodeByNode( + ETSTuple.create2ETSTuple(typeList), + original + ) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/MemberExpression.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/MemberExpression.ts new file mode 100644 index 0000000000000000000000000000000000000000..1972a79a13ed558c92e26638d0d27ccb3c01a84b --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/MemberExpression.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Expression, MemberExpression } from "../../generated" +import { isSameNativeObject } from "../peers/ArktsObject" +import { updateNodeByNode } from "../utilities/private" +import { Es2pandaMemberExpressionKind } from "../../generated/Es2pandaEnums" + +export function updateMemberExpression( + original: MemberExpression, + object_arg: Expression | undefined, + property: Expression | undefined, + kind: Es2pandaMemberExpressionKind, + computed: boolean, + optional_arg: boolean +) { + if (isSameNativeObject(object_arg, original.object) + && isSameNativeObject(property, original.property) + && isSameNativeObject(kind, original.kind) + && isSameNativeObject(computed, original.isComputed) + && isSameNativeObject(optional_arg, original.isOptional) + ) { + return original + } + return updateNodeByNode( + MemberExpression.createMemberExpression(object_arg, property, kind, computed, optional_arg), + original + ) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/MethodDefinition.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/MethodDefinition.ts new file mode 100644 index 0000000000000000000000000000000000000000..3d8034cafa85dd21394a5d265449f394703d1ca4 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/MethodDefinition.ts @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ETSFunctionType, Expression, FunctionSignature, MethodDefinition } from "../../generated" +import { + Es2pandaMethodDefinitionKind, + Es2pandaModifierFlags, + Es2pandaScriptFunctionFlags +} from "../../generated/Es2pandaEnums" +import { isSameNativeObject } from "../peers/ArktsObject" +import { updateNodeByNode } from "../utilities/private" + +export function createMethodDefinition( + kind: Es2pandaMethodDefinitionKind, + key: Expression | undefined, + value: Expression | undefined, + modifiers: Es2pandaModifierFlags, + isComputed: boolean, + overloads?: readonly MethodDefinition[] +) { + const res = MethodDefinition.createMethodDefinition( + kind, + key, + value, + modifiers, + isComputed, + ) + if (overloads) { + res.setOverloads(overloads) + } + return res +} + +export function updateMethodDefinition( + original: MethodDefinition, + kind: Es2pandaMethodDefinitionKind, + key: Expression | undefined, + value: Expression | undefined, + modifiers: Es2pandaModifierFlags, + isComputed: boolean, + overloads?: readonly MethodDefinition[] +) { + if (isSameNativeObject(kind, original.kind) + && isSameNativeObject(key, original.key) + && isSameNativeObject(value, original.value) + && isSameNativeObject(modifiers, original.modifierFlags) + && isSameNativeObject(isComputed, original.isComputed) + && isSameNativeObject(overloads, original.overloads) + ) { + return original + } + return updateNodeByNode( + createMethodDefinition( + kind, + key, + value, + modifiers, + isComputed, + overloads, + ), + original + ) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/NumberLiteral.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/NumberLiteral.ts new file mode 100644 index 0000000000000000000000000000000000000000..f1ca111647863e5f627583368c0096fab9d66c31 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/NumberLiteral.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { global } from "../static/global" +import { NumberLiteral } from "../../generated" +import { isSameNativeObject } from "../peers/ArktsObject" +import { updateNodeByNode } from "../utilities/private" + +export function createNumberLiteral( + value: number +) { + return new NumberLiteral( + global.es2panda._CreateNumberLiteral( + global.context, + value + ) + ) +} + +export function updateNumberLiteral( + original: NumberLiteral, + value: number +) { + if (isSameNativeObject(value.toString(), original.str)) { + return original + } + return updateNodeByNode( + createNumberLiteral(value), + original + ) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/ObjectExpression.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/ObjectExpression.ts new file mode 100644 index 0000000000000000000000000000000000000000..8009b122aa20a500ff2365832b11289beb3bb02b --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/ObjectExpression.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ObjectExpression, Expression } from "../../generated" +import { isSameNativeObject } from "../peers/ArktsObject" +import { nodeType, updateNodeByNode } from "../utilities/private" + +export function updateObjectExpression( + original: ObjectExpression, + properties: readonly Expression[] +) { + if (isSameNativeObject(properties, original.properties)){ + return original + } + return updateNodeByNode( + ObjectExpression.createObjectExpression( + nodeType(original), + properties, + false), // TODO: provide trailingComma value from native module through ObjectExpression? + original + ) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/ScriptFunction.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/ScriptFunction.ts new file mode 100644 index 0000000000000000000000000000000000000000..b188dcb45a6a599ad8b5751bc46dabfb7716caf7 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/ScriptFunction.ts @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + AnnotationUsage, + Expression, + FunctionSignature, + Identifier, + ScriptFunction, + TSTypeParameterDeclaration, + TypeNode +} from "../../generated" +import { AstNode } from "../peers/AstNode" +import { Es2pandaModifierFlags, Es2pandaScriptFunctionFlags } from "../../generated/Es2pandaEnums" +import { isSameNativeObject } from "../peers/ArktsObject" +import { updateNodeByNode } from "../utilities/private" + +export function createScriptFunction( + databody: AstNode | undefined, + typeParams: TSTypeParameterDeclaration | undefined, + params: readonly Expression[], + returnTypeAnnotation: TypeNode | undefined, + hasReceiver: boolean, + datafuncFlags: Es2pandaScriptFunctionFlags, + dataflags: Es2pandaModifierFlags, + ident: Identifier | undefined, + annotations: readonly AnnotationUsage[] | undefined, +) { + const res = ScriptFunction.createScriptFunction( + databody, + FunctionSignature.createFunctionSignature( + typeParams, + params, + returnTypeAnnotation, + hasReceiver, + ), + datafuncFlags, + dataflags + ) + if (ident) { + res.setIdent(ident) + } + if (annotations) { + res.setAnnotations(annotations) + } + return res +} + +export function updateScriptFunction( + original: ScriptFunction, + databody: AstNode | undefined, + typeParams: TSTypeParameterDeclaration | undefined, + params: readonly Expression[], + returnTypeAnnotation: TypeNode | undefined, + hasReceiver: boolean, + datafuncFlags: Es2pandaScriptFunctionFlags, + dataflags: Es2pandaModifierFlags, + ident: Identifier | undefined, + annotations: readonly AnnotationUsage[] | undefined, +) { + if (isSameNativeObject(databody, original.body) + && isSameNativeObject(typeParams, original.typeParams) + && isSameNativeObject(params, original.params) + && isSameNativeObject(returnTypeAnnotation, original.returnTypeAnnotation) + && isSameNativeObject(hasReceiver, original.hasReceiver) + && isSameNativeObject(datafuncFlags, original.flags) + && isSameNativeObject(dataflags, original.modifierFlags) + && isSameNativeObject(ident, original.id) + && isSameNativeObject(annotations, original.annotations) + ) { + return original + } + return updateNodeByNode( + createScriptFunction( + databody, + typeParams, + params, + returnTypeAnnotation, + hasReceiver, + datafuncFlags, + dataflags, + ident, + annotations + ), + original + ) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/TSInterfaceDeclaration.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/TSInterfaceDeclaration.ts new file mode 100644 index 0000000000000000000000000000000000000000..2ea6cf3395d54b04d231b5a0eb76e9abd0bdbb9f --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/TSInterfaceDeclaration.ts @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + ETSFunctionType, + Expression, + FunctionSignature, + MethodDefinition, + TSInterfaceDeclaration, TSInterfaceHeritage +} from "../../generated" +import { + Es2pandaMethodDefinitionKind, + Es2pandaModifierFlags, + Es2pandaScriptFunctionFlags +} from "../../generated/Es2pandaEnums" +import { isSameNativeObject } from "../peers/ArktsObject" +import { updateNodeByNode } from "../utilities/private" +import { AstNode } from "../peers/AstNode" + +export function updateTSInterfaceDeclaration( + original: TSInterfaceDeclaration, + _extends: readonly TSInterfaceHeritage[], + id: AstNode | undefined, + typeParams: AstNode | undefined, + body: AstNode | undefined, + isStatic: boolean, + isExternal: boolean +) { + if (isSameNativeObject(_extends, original.extends) + && isSameNativeObject(id, original.id) + && isSameNativeObject(typeParams, original.typeParams) + && isSameNativeObject(body, original.body) + && isSameNativeObject(isStatic, original.isStatic) + && isSameNativeObject(isExternal, original.isFromExternal) + ) { + return original + } + return updateNodeByNode( + TSInterfaceDeclaration.createTSInterfaceDeclaration( + _extends, + id, + typeParams, + body, + isStatic, + isExternal + ), + original + ) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/TSTypeAliasDeclaration.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/TSTypeAliasDeclaration.ts new file mode 100644 index 0000000000000000000000000000000000000000..4f5d2ce136100c8947cbb4d417003b95f9ed417b --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/TSTypeAliasDeclaration.ts @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AnnotationUsage, Identifier, TSTypeAliasDeclaration, TSTypeParameterDeclaration, TypeNode } from "../../generated" +import { isSameNativeObject } from "../peers/ArktsObject" +import { updateNodeByNode } from "../utilities/private" + +export function createTSTypeAliasDeclaration( + id?: Identifier, + typeParams?: TSTypeParameterDeclaration, + typeAnnotation?: TypeNode, + annotations?: readonly AnnotationUsage[] +): TSTypeAliasDeclaration { + const res = TSTypeAliasDeclaration.createTSTypeAliasDeclaration( + id, + typeParams, + typeAnnotation + ) + if (annotations) { + res.setAnnotations(annotations) + } + return res +} + +export function updateTSTypeAliasDeclaration( + original: TSTypeAliasDeclaration, + id?: Identifier, + typeParams?: TSTypeParameterDeclaration, + typeAnnotation?: TypeNode, + annotations?: readonly AnnotationUsage[] +): TSTypeAliasDeclaration { + if (isSameNativeObject(id, original.id) + && isSameNativeObject(typeParams, original.typeParams) + && isSameNativeObject(typeAnnotation, original.typeAnnotation) + && isSameNativeObject(annotations, original.annotations) + ) { + return original + } + return updateNodeByNode( + createTSTypeAliasDeclaration( + id, + typeParams, + typeAnnotation, + annotations, + ), + original, + ) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/TSTypeParameter.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/TSTypeParameter.ts new file mode 100644 index 0000000000000000000000000000000000000000..5ac0dde4b312f6932eb9891efaa6dca32ae9cfcd --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/TSTypeParameter.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Identifier, TSTypeParameter, TypeNode } from "../../generated" +import { Es2pandaModifierFlags } from "../../generated/Es2pandaEnums" +import { isSameNativeObject } from "../peers/ArktsObject" +import { updateNodeByNode } from "../utilities/private" + +export function updateTSTypeParameter( + original: TSTypeParameter, + name: Identifier | undefined, + constraint: TypeNode | undefined, + defaultType: TypeNode | undefined, + flags: Es2pandaModifierFlags +) { + if (isSameNativeObject(name, original.name) + && isSameNativeObject(constraint, original.constraint) + && isSameNativeObject(defaultType, original.defaultType) + && isSameNativeObject(flags, original.modifierFlags) + ) { + return original + } + return updateNodeByNode( + TSTypeParameter.create1TSTypeParameter(name, constraint, defaultType, flags), + original + ) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/TSTypeReferencePart.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/TSTypeReferencePart.ts new file mode 100644 index 0000000000000000000000000000000000000000..a9d96fd03812dc0c7835016b0d525c169cd81f55 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/TSTypeReferencePart.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ETSTypeReferencePart, Expression, TSTypeParameterInstantiation } from "../../generated" +import { isSameNativeObject } from "../peers/ArktsObject" +import { updateNodeByNode } from "../utilities/private" + +export function updateETSTypeReferencePart( + original: ETSTypeReferencePart, + name?: Expression, + typeParams?: TSTypeParameterInstantiation, + prev?: ETSTypeReferencePart +) { + if (isSameNativeObject(name, original.name) + && isSameNativeObject(typeParams, original.typeParams) + && isSameNativeObject(prev, original.previous) + ) { + return original + } + return updateNodeByNode( + ETSTypeReferencePart.createETSTypeReferencePart(name, typeParams, prev), + original + ) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/TryStatement.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/TryStatement.ts new file mode 100644 index 0000000000000000000000000000000000000000..0a36dd51a43bc058fcb5ecf2e8f3d436ff7be87b --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/TryStatement.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { BlockStatement, CatchClause, LabelPair, Statement, TryStatement } from "../../generated" +import { isSameNativeObject } from "../peers/ArktsObject" +import { updateNodeByNode } from "../utilities/private" + +export function updateTryStatement( + original: TryStatement, + block: BlockStatement | undefined, + catchClauses: readonly CatchClause[], + finalizer: BlockStatement | undefined, + finalizerInsertionsLabelPair: readonly LabelPair[], + finalizerInsertionsStatement: readonly Statement[] +): TryStatement { + if (isSameNativeObject(block, original.block) + && isSameNativeObject(catchClauses, original.catchClauses) + && isSameNativeObject(finalizer, original.finallyBlock) + ) { + return original + } + return updateNodeByNode( + TryStatement.createTryStatement( + block, + catchClauses, + finalizer, + finalizerInsertionsLabelPair, + finalizerInsertionsStatement, + ), + original + ) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/VariableDeclaration.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/VariableDeclaration.ts new file mode 100644 index 0000000000000000000000000000000000000000..a37ca4964f52a17600fc92c8faa3f5e88259766a --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/VariableDeclaration.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AnnotationUsage, VariableDeclaration, VariableDeclarator } from "../../generated" +import { Es2pandaVariableDeclarationKind } from "../../generated/Es2pandaEnums" +import { isSameNativeObject } from "../peers/ArktsObject" +import { updateNodeByNode } from "../utilities/private" + +export function createVariableDeclaration( + kind: Es2pandaVariableDeclarationKind, + declarators: readonly VariableDeclarator[], + annotations?: readonly AnnotationUsage[] +): VariableDeclaration { + const res = VariableDeclaration.createVariableDeclaration( + kind, + declarators + ) + if (annotations) { + res.setAnnotations( + annotations + ) + } + return res +} + +export function updateVariableDeclaration( + original: VariableDeclaration, + kind: Es2pandaVariableDeclarationKind, + declarators: readonly VariableDeclarator[], + annotations?: readonly AnnotationUsage[] +) { + if (isSameNativeObject(kind, original.kind) + && isSameNativeObject(declarators, original.declarators) + && isSameNativeObject(annotations, original.annotations) + ) { + return original + } + return updateNodeByNode( + createVariableDeclaration(kind, declarators, annotations), + original + ) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/VariableDeclarator.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/VariableDeclarator.ts new file mode 100644 index 0000000000000000000000000000000000000000..c964396c26df1e38a754abe78b5b0fbc63823932 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/node-utilities/VariableDeclarator.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Expression, VariableDeclarator } from "../../generated" +import { Es2pandaVariableDeclaratorFlag } from "../../generated/Es2pandaEnums" +import { isSameNativeObject } from "../peers/ArktsObject" +import { updateNodeByNode } from "../utilities/private" + +export function updateVariableDeclarator( + original: VariableDeclarator, + flag: Es2pandaVariableDeclaratorFlag, + ident?: Expression, + init?: Expression +) { + if (isSameNativeObject(flag, original.flag) + && isSameNativeObject(ident, original.id) + && isSameNativeObject(init, original.init) + ) { + return original + } + return updateNodeByNode( + VariableDeclarator.create1VariableDeclarator(flag, ident, init), + original + ) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/peers/ArktsObject.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/peers/ArktsObject.ts new file mode 100644 index 0000000000000000000000000000000000000000..3b0a15deb445de74073d18ad586dfd8294179675 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/peers/ArktsObject.ts @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { KNativePointer } from "@koalaui/interop" + +export abstract class ArktsObject { + protected constructor(peer: KNativePointer) { + this.peer = peer + } + + readonly peer: KNativePointer +} + +export function isSameNativeObject( + first: T | readonly T[], + second: T | readonly T[] +): boolean { + if (Array.isArray(first) && Array.isArray(second)) { + if (first.length !== second.length) { + return false + } + for (let i = 0; i < first.length; i++) { + if (!isSameNativeObject(first[i], second[i])) { + return false + } + } + return true + } + if (first instanceof ArktsObject && second instanceof ArktsObject) { + return first?.peer === second?.peer + } + return first === second +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/peers/AstNode.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/peers/AstNode.ts new file mode 100644 index 0000000000000000000000000000000000000000..1ec8da92e464c4c02fd390c4531a3061545f529a --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/peers/AstNode.ts @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { isNullPtr, KInt, KNativePointer as KPtr, KNativePointer, nullptr } from "@koalaui/interop" +import { global } from "../static/global" +import { allFlags, nodeType, unpackNodeArray, unpackNonNullableNode, unpackString } from "../utilities/private" +import { throwError } from "../../utils" +import { Es2pandaAstNodeType, Es2pandaModifierFlags } from "../../generated/Es2pandaEnums" +import { ArktsObject } from "./ArktsObject" + +export abstract class AstNode extends ArktsObject { + protected constructor(peer: KNativePointer) { + global.profiler.createdNodes ++ + if (isNullPtr(peer)) { + throwError(`attempted to create AstNode from nullptr`) + } + super(peer) + this.updateChildren() + } + + public get originalPeer(): KNativePointer { + const result = global.generatedEs2panda._AstNodeOriginalNodeConst(global.context, this.peer) + if (result === nullptr) { + this.originalPeer = this.peer + return this.peer + } + return result + } + + public set originalPeer(peer: KNativePointer) { + global.generatedEs2panda._AstNodeSetOriginalNode(global.context, this.peer, peer) + } + + public getChildren(): readonly AstNode[] { + return unpackNodeArray(global.es2panda._AstNodeChildren(global.context, this.peer)) + } + + public getSubtree(): readonly AstNode[] { + return this.getChildren().reduce( + (prev: readonly AstNode[], curr) => { + return prev.concat(curr.getSubtree()) + }, + [this] + ) + } + + public updateChildren(): void { + if (this.peer === nullptr) { + throwError('updateChildren called on NULLPTR') + } + global.es2panda._AstNodeUpdateChildren(global.context, this.peer) + } + + public updateModifiers(modifierFlags: KInt | undefined): this { + global.generatedEs2panda._AstNodeClearModifier(global.context, this.peer, allFlags) + global.generatedEs2panda._AstNodeAddModifier(global.context, this.peer, modifierFlags ?? Es2pandaModifierFlags.MODIFIER_FLAGS_NONE) + return this + } + + public dump(indentation: number = 0): string { + const children = this.getChildren() + .map((it) => it.dump(indentation + 1)) + const msg = + `${indentation}_` + + ` ` + + this.dumpMessage() + return "> " + " ".repeat(4 * indentation) + msg + "\n" + children.join("") + } + + protected dumpMessage(): string { + return `` + } + + public dumpJson(): string { + return unpackString(global.generatedEs2panda._AstNodeDumpJSONConst(global.context, this.peer)) + } + + public dumpSrc(): string { + return unpackString(global.generatedEs2panda._AstNodeDumpEtsSrcConst(global.context, this.peer)) + } + + public dumpModifiers(): string { + return unpackString(global.es2panda._AstNodeDumpModifiers(global.context, this.peer)) + } + + public clone(): this { + return unpackNonNullableNode(global.generatedEs2panda._AstNodeClone(global.context, this.peer, this.parent.peer)); + } + + public get parent(): AstNode { + const parent = global.generatedEs2panda._AstNodeParent(global.context, this.peer) + if (parent === nullptr) { + throwError(`no parent`) + } + return unpackNonNullableNode(parent) + } + + public set parent(node: AstNode) { + global.generatedEs2panda._AstNodeSetParent(global.context, this.peer, node.peer) + } + + public get modifierFlags(): Es2pandaModifierFlags { + return global.generatedEs2panda._AstNodeModifiers(global.context, this.peer) + } + + public set modifierFlags(flags: KInt | undefined) { + global.generatedEs2panda._AstNodeClearModifier(global.context, this.peer, allFlags) + global.generatedEs2panda._AstNodeAddModifier(global.context, this.peer, flags ?? Es2pandaModifierFlags.MODIFIER_FLAGS_NONE) + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/peers/Config.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/peers/Config.ts new file mode 100644 index 0000000000000000000000000000000000000000..ca7984740d88ddc1fbf29dc412c51b59db758852 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/peers/Config.ts @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ArktsObject } from "./ArktsObject" +import { global } from "../static/global" +import { passStringArray } from "../utilities/private" +import { KNativePointer } from "@koalaui/interop" + +export class Config extends ArktsObject { + constructor(peer: KNativePointer) { + super(peer) + // TODO: wait for getter from api + this.path = `` + } + + static create( + input: readonly string[] + ): Config { + return new Config( + global.es2panda._CreateConfig(input.length, passStringArray(input)) + ) + } + + static createDefault(): Config { + if (global.configIsInitialized()) { + console.warn(`Config already initialized`) + return new Config( + global.config + ) + } + return new Config( + global.es2panda._CreateConfig( + 4, + passStringArray(["", "--arktsconfig", "./arktsconfig.json", global.filePath]) + ) + ) + } + + readonly path: string +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/peers/Context.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/peers/Context.ts new file mode 100644 index 0000000000000000000000000000000000000000..78f1bfc28cbf970989bb4c82e387378305adba5d --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/peers/Context.ts @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ArktsObject } from "./ArktsObject" +import { Program } from "./Program" +import { global } from "../static/global" +import { throwError } from "../../utils" +import { passString } from "../utilities/private" +import { KNativePointer } from "@koalaui/interop" + +export class Context extends ArktsObject { + constructor(peer: KNativePointer) { + super(peer) + } + + static createFromString( + source: string + ): Context { + if (!global.configIsInitialized()) { + throwError(`Config not initialized`) + } + return new Context( + global.es2panda._CreateContextFromString( + global.config, + passString(source), + passString(global.filePath) + ) + ) + } + + get program(): Program { + return new Program(global.es2panda._ContextProgram(this.peer)); + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/peers/ImportPathManager.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/peers/ImportPathManager.ts new file mode 100644 index 0000000000000000000000000000000000000000..020ac88c99073c0a9d08555db95afee8726e2cc6 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/peers/ImportPathManager.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ArktsObject } from "./ArktsObject" +import { global } from "../static/global" +import { KNativePointer } from "@koalaui/interop" + +export class ImportPathManager extends ArktsObject { + constructor(peer: KNativePointer) { + super(peer) + } + + static create(): ImportPathManager { + return new ImportPathManager( + global.es2panda._ETSParserGetImportPathManager(global.context) + ); + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/peers/Program.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/peers/Program.ts new file mode 100644 index 0000000000000000000000000000000000000000..f38f2c4a0f68c4758c3c464efed64422ebd8778e --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/peers/Program.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ArktsObject } from "./ArktsObject" +import { global } from "../static/global" +import { acceptNativeObjectArrayResult, unpackString } from "../utilities/private" +import { KNativePointer } from "@koalaui/interop" +import { ETSModule } from "../../generated" + +export class Program extends ArktsObject { + constructor(peer: KNativePointer) { + super(peer) + } + + get astNode(): ETSModule { + return new ETSModule(global.es2panda._ProgramAst(global.context, this.peer)) + } + + get externalSources(): ExternalSource[] { + return acceptNativeObjectArrayResult( + global.es2panda._ProgramExternalSources(global.context, this.peer), + (instance: KNativePointer) => new ExternalSource(instance) + ) + } + +} + +export class ExternalSource extends ArktsObject { + constructor(peer: KNativePointer) { + super(peer) + } + + getName(): string { + return unpackString(global.es2panda._ExternalSourceName(this.peer)) + } + + get programs(): Program[] { + return acceptNativeObjectArrayResult( + global.es2panda._ExternalSourcePrograms(this.peer), + (instance: KNativePointer) => new Program(instance) + ) + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/peers/SourcePosition.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/peers/SourcePosition.ts new file mode 100644 index 0000000000000000000000000000000000000000..9d84847a6c09a6c588e278f10c9b1fded3da0ff3 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/peers/SourcePosition.ts @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ArktsObject } from "./ArktsObject" +import { global } from "../static/global" +import { KNativePointer } from "@koalaui/interop" + +export class SourcePosition extends ArktsObject { + constructor(peer: KNativePointer) { + super(peer) + } + + static create(index: number, line: number): SourcePosition { + return new SourcePosition( + global.es2panda._CreateSourcePosition(global.context, index, line) + ); + } + + index(): number { + return global.es2panda._SourcePositionIndex(global.context, this.peer); + } + + line(): number { + return global.es2panda._SourcePositionLine(global.context, this.peer); + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/static/global.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/static/global.ts new file mode 100644 index 0000000000000000000000000000000000000000..34067cfafb36d498401664bfb3230ed83965164b --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/static/global.ts @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { throwError } from "../../utils" +import { KNativePointer } from "@koalaui/interop" +import { initEs2panda, Es2pandaNativeModule, initGeneratedEs2panda } from "../../Es2pandaNativeModule" +import { Es2pandaNativeModule as GeneratedEs2pandaNativeModule } from "../../generated/Es2pandaNativeModule" +import { initInterop, InteropNativeModule } from "../../InteropNativeModule" +import { Context } from "../peers/Context" +import { Profiler } from "./profiler" + +export class global { + public static filePath: string = "./plugins/input/main.ets" + public static packageName: string = "" + public static filePathFromPackageRoot: string = global.filePath + + private static _config?: KNativePointer + public static set config(config: KNativePointer) { + global._config = config + } + public static get config(): KNativePointer { + return global._config ?? throwError('Global.config not initialized') + } + public static configIsInitialized(): boolean { + return global._config !== undefined + } + + // TODO: rename to contextPeer + public static get context(): KNativePointer { + return global.compilerContext.peer ?? throwError('Global.context not initialized') + } + + // TODO: rename to context when the pointer valued one is eliminated + public static compilerContext: Context + + private static _es2panda: Es2pandaNativeModule | undefined = undefined + public static get es2panda(): Es2pandaNativeModule { + if (this._es2panda === undefined) { + this._es2panda = initEs2panda() + } + return this._es2panda + } + + private static _generatedEs2panda: GeneratedEs2pandaNativeModule | undefined = undefined + public static get generatedEs2panda(): GeneratedEs2pandaNativeModule { + if (this._generatedEs2panda === undefined) { + this._generatedEs2panda = initGeneratedEs2panda() + } + return this._generatedEs2panda + } + + private static _interop: InteropNativeModule | undefined = undefined + public static get interop(): InteropNativeModule { + if (this._interop === undefined) this._interop = initInterop() + return this._interop + + } + + public static profiler = new Profiler() +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/static/profiler.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/static/profiler.ts new file mode 100644 index 0000000000000000000000000000000000000000..06964da88fed25e432bec94da2683300b674fcff --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/static/profiler.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export class Profiler { + totalTime = 0 + transformTime = 0 + proceedTime = 0 + restartTime = 0 + visitedNodes = 0 + createdNodes = 0 + + report() { + console.log( + "total compiler:", + this.totalTime, + " proceeds:", + this.proceedTime, + " restarts", + this.restartTime, + " transforms:", + this.transformTime, + " visited:", + this.visitedNodes, + " created:", + this.createdNodes + ) + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/utilities/nativePtrDecoder.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/utilities/nativePtrDecoder.ts new file mode 100644 index 0000000000000000000000000000000000000000..1bb8900b4061655b8f07498018bc631468f80296 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/utilities/nativePtrDecoder.ts @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { int32 } from "@koalaui/common" +import { + Access, + ArrayDecoder, + CallbackRegistry, + NativeStringBase, + nullptr, + pointer, + providePlatformDefinedData, + withByteArray +} from "@koalaui/interop" +import { global } from "../static/global" + +class NativeString extends NativeStringBase { + constructor(ptr: pointer) { + super(ptr) + } + protected bytesLength(): int32 { + return global.interop._StringLength(this.ptr) + } + protected getData(data: Uint8Array): void { + withByteArray(data, Access.WRITE, (dataPtr: pointer) => { + global.interop._StringData(this.ptr, dataPtr, data.length) + }) + } + close(): void { + global.interop._InvokeFinalizer(this.ptr, global.interop._GetStringFinalizer()) + this.ptr = nullptr + } +} + +providePlatformDefinedData({ + nativeString(ptr: pointer): NativeStringBase { + return new NativeString(ptr) + }, + nativeStringArrayDecoder(): ArrayDecoder { + throw new Error("Not yet implemented") + }, + callbackRegistry(): CallbackRegistry | undefined { + return undefined + } +}) + +export class NativePtrDecoder extends ArrayDecoder { + getArraySize(blob: pointer) { + return global.interop._GetPtrVectorSize(blob) + } + disposeArray(blob: pointer): void { + // TODO + } + getArrayElement(blob: pointer, index: int32): pointer { + return global.interop._GetPtrVectorElement(blob, index) + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/utilities/private.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/utilities/private.ts new file mode 100644 index 0000000000000000000000000000000000000000..d6c67985176ab13cfbec3b70d914fb814a1195bb --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/utilities/private.ts @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { global } from "../static/global" +import { isNumber, throwError } from "../../utils" +import { + KInt, + KNativePointer as KPtr, + KNativePointer, + nullptr, + withString, + withStringArray, + withStringResult +} from "@koalaui/interop" +import { NativePtrDecoder } from "./nativePtrDecoder" +import { Es2pandaAstNodeType, Es2pandaModifierFlags, Es2pandaScriptFunctionFlags } from "../../generated/Es2pandaEnums" +import { classByPeer } from "../class-by-peer" +import { AstNode } from "../peers/AstNode" +import { ArktsObject } from "../peers/ArktsObject" + +export const arrayOfNullptr = new BigUint64Array([nullptr]) + +export const allFlags = + Object.values(Es2pandaModifierFlags) + .filter(isNumber) + .reduce( + (prev, next) => prev | next, + 0 + ) + +export function assertValidPeer(peer: KPtr, expectedKind: Es2pandaAstNodeType): void { + if (peer === nullptr) { + throwError(`invalid peer`) + } + const peerType = global.generatedEs2panda._AstNodeTypeConst(global.context, peer) + if (peerType === Es2pandaAstNodeType.AST_NODE_TYPE_STRUCT_DECLARATION && expectedKind === Es2pandaAstNodeType.AST_NODE_TYPE_CLASS_DECLARATION) { + // TODO: Struct is a child class of Class + return + } + if (peerType === Es2pandaAstNodeType.AST_NODE_TYPE_ETS_IMPORT_DECLARATION && expectedKind === Es2pandaAstNodeType.AST_NODE_TYPE_IMPORT_DECLARATION) { + // TODO: ETSImportDeclaration is a child of a ImportDeclaration + return + } + if (peerType === Es2pandaAstNodeType.AST_NODE_TYPE_ETS_MODULE && expectedKind === Es2pandaAstNodeType.AST_NODE_TYPE_BLOCK_STATEMENT) { + // TODO: ETSModule is a child of a BlockStatement + return + } + if (peerType !== expectedKind) { + throwError(`expected: ${Es2pandaAstNodeType[expectedKind]}, got: ${Es2pandaAstNodeType[peerType]}`) + } +} + +export function acceptNativeObjectArrayResult(arrayObject: KNativePointer, factory: (instance: KNativePointer) => T): T[] { + return new NativePtrDecoder().decode(arrayObject).map(factory); +} + +export function unpackNonNullableNode(peer: KNativePointer): T { + if (peer === nullptr) { + throwError('peer is NULLPTR (maybe you should use unpackNode)') + } + return classByPeer(peer) +} + +export function unpackNode(peer: KNativePointer): T | undefined { + if (peer === nullptr) { + return undefined + } + return classByPeer(peer) +} + +export function passNode(node: ArktsObject | undefined): KNativePointer { + return node?.peer ?? nullptr +} + +export function unpackNodeArray(nodesPtr: KNativePointer): T[] { + if (nodesPtr === nullptr) { + throwError('nodesPtr is NULLPTR (maybe you should use unpackNodeArray)') + } + return new NativePtrDecoder() + .decode(nodesPtr) + .map((peer: KNativePointer) => unpackNonNullableNode(peer)) +} + +export function passNodeArray(nodes: readonly ArktsObject[] | undefined): BigUint64Array { + return new BigUint64Array( + nodes + ?.filter(it => it.peer != undefined) + ?.map(node => BigInt(node.peer)) + ?? [] + ) +} + +export function unpackNonNullableObject(type: { new (peer: KNativePointer): T }, peer: KNativePointer): T { + if (peer === nullptr) { + throwError('peer is NULLPTR (maybe you should use unpackObject)') + } + return new type(peer) +} + +export function unpackObject(type: { new (peer: KNativePointer): T }, peer: KNativePointer): T | undefined { + if (peer === nullptr) { + return undefined + } + return new type(peer) +} + +export function unpackString(peer: KNativePointer): string { + return withStringResult(peer) ?? throwError(`failed to unpack (peer shouldn't be NULLPTR)`) +} + +export function passString(str: string | undefined): string { + if (str === undefined) { + return "" + } + return withString(str, (it: string) => it) +} + +export function passStringArray(strings: readonly string[]): string[] { + return withStringArray(strings, (it: string[]) => it) +} + +export function passNodeWithNewModifiers(node: T, modifiers: KInt): T { + return unpackNonNullableNode(node.peer).updateModifiers(modifiers) +} + +export function scriptFunctionHasBody(peer: KNativePointer): boolean { + const flags = global.generatedEs2panda._ScriptFunctionFlagsConst(global.context, peer) + return (flags & Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_EXTERNAL) === 0 + && (flags & Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_EXTERNAL_OVERLOAD) === 0 +} + +export function updateNodeByNode(node: T, original: T): T { + if (original.peer === nullptr) { + throwError('update called on NULLPTR') + } + if (original instanceof AstNode) { + global.generatedEs2panda._AstNodeSetOriginalNode(global.context, node.peer, original.originalPeer) + } + global.generatedEs2panda._AstNodeSetParent(global.context, node.peer, global.generatedEs2panda._AstNodeParent(global.context, original.peer)) + global.es2panda._AstNodeUpdateChildren(global.context, node.peer) + return node +} + +export function nodeType(node: AstNode): Es2pandaAstNodeType { + return global.generatedEs2panda._AstNodeTypeConst(global.context, passNode(node)) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/utilities/public.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/utilities/public.ts new file mode 100644 index 0000000000000000000000000000000000000000..d6290295ce87b517a5856a36b0e44541a952ed01 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/utilities/public.ts @@ -0,0 +1,193 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { global } from "../static/global" +import { isNumber, throwError } from "../../utils" +import { KNativePointer, nullptr } from "@koalaui/interop" +import { passNode, passNodeArray, unpackNodeArray, unpackNonNullableNode } from "./private" +import { Es2pandaContextState, Es2pandaModifierFlags } from "../../generated/Es2pandaEnums" +import type { AstNode } from "../peers/AstNode" +import { + type AnnotationUsage, + ClassDefinition, + ClassProperty, + ETSImportDeclaration, + ETSModule, + isClassDefinition, + isFunctionDeclaration, + isMemberExpression, + isScriptFunction, + isIdentifier +} from "../../generated" +import { Config } from "../peers/Config" +import { Context } from "../peers/Context" +import { NodeCache } from "../node-cache" + +export function createETSModuleFromContext(): ETSModule { + return new ETSModule(global.es2panda._ProgramAst(global.context, global.es2panda._ContextProgram(global.context))) +} + +export function createETSModuleFromSource( + source: string, + state: Es2pandaContextState = Es2pandaContextState.ES2PANDA_STATE_PARSED, +): ETSModule { + if (!global.configIsInitialized()) { + global.config = Config.createDefault().peer + } + global.compilerContext = Context.createFromString(source) + proceedToState(state) + return new ETSModule(global.es2panda._ProgramAst(global.context, global.es2panda._ContextProgram(global.context))) +} + +export function updateETSModuleByStatements( + node: ETSModule, + statements: readonly AstNode[], +): ETSModule { + global.generatedEs2panda._BlockStatementSetStatements(global.context, node.peer, passNodeArray(statements), statements.length) + return node +} + +export function checkErrors() { + if (global.es2panda._ContextState(global.context) === Es2pandaContextState.ES2PANDA_STATE_ERROR) { + console.log() + global.es2panda._DestroyConfig(global.config) + console.log() + process.exit(1) + } +} + +export function proceedToState(state: Es2pandaContextState): void { + if (state <= global.es2panda._ContextState(global.context)) { + return + } + const before = Date.now() + global.es2panda._ProceedToState(global.context, state) + const after = Date.now() + global.profiler.proceedTime += after-before + NodeCache.clear() + checkErrors() +} + +export function startChecker(): boolean { + return global.es2panda._CheckerStartChecker(global.context) +} + +export function recheckSubtree(node: AstNode): void { + global.es2panda._AstNodeRecheck(global.context, node.peer) + checkErrors() +} + +export function rebindSubtree(node: AstNode): void { + global.es2panda._AstNodeRebind(global.context, node.peer) + checkErrors() +} + +export function getDecl(node: AstNode): AstNode | undefined { + if (isMemberExpression(node)) { + return getDecl(node.property!) + } + return getPeerDecl(passNode(node)) +} + +export function getPeerDecl(peer: KNativePointer): AstNode | undefined { + const decl = global.es2panda._DeclarationFromIdentifier(global.context, peer) + if (decl === nullptr) { + return undefined + } + return unpackNonNullableNode(decl) +} + +export function getAnnotations(node: AstNode): readonly AnnotationUsage[] { + if (!isFunctionDeclaration(node) && !isScriptFunction(node) && !isClassDefinition(node)) { + throwError('for now annotations allowed only for: functionDeclaration, scriptFunction, classDefinition') + } + return unpackNodeArray(global.es2panda._AnnotationAllowedAnnotations(global.context, node.peer, nullptr)) +} + +export function getOriginalNode(node: AstNode): AstNode { + if (node === undefined) { + // TODO: fix this + throwError('there is no arkts pair of ts node (unable to getOriginalNode)') + } + if (node.originalPeer === nullptr) { + return node + } + return unpackNonNullableNode(node.originalPeer) +} + +export function getFileName(): string { + return global.filePath +} + +export function getPackageName(): string { + return global.packageName +} + +export function getFilePathFromPackageRoot(): string { + return global.filePathFromPackageRoot +} + +// TODO: It seems like Definition overrides AstNode modifiers +// with it's own modifiers which is completely unrelated set of flags. +// Use this function if you need +// the language level modifiers: public, declare, export, etc. +export function classDefinitionFlags(node: ClassDefinition): Es2pandaModifierFlags { + return global.generatedEs2panda._AstNodeModifiers(global.context, node.peer) +} + +// TODO: ClassProperty's optional flag is set by AstNode's modifiers flags. +export function classPropertySetOptional(node: ClassProperty, value: boolean): ClassProperty { + if (value) { + node.modifierFlags |= Es2pandaModifierFlags.MODIFIER_FLAGS_OPTIONAL; + } else { + node.modifierFlags &= Es2pandaModifierFlags.MODIFIER_FLAGS_OPTIONAL; + } + return node; +} + +// TODO: Import statements should be inserted to the statements. +export function importDeclarationInsert(node: ETSImportDeclaration): void { + const program = global.compilerContext.program; // TODO: external source has different program. Currently not considered. + global.es2panda._InsertETSImportDeclarationAndParse(global.context, program.peer, node.peer) +} + +export function hasModifierFlag(node: AstNode, flag: Es2pandaModifierFlags): boolean { + if (!node) return false; + + let modifiers; + if (isClassDefinition(node)) { + modifiers = classDefinitionFlags(node); + } else { + modifiers = node.modifierFlags + } + return (modifiers & flag) === flag; +} + +export function modifiersToString(modifiers: Es2pandaModifierFlags): string { + return Object.values(Es2pandaModifierFlags) + .filter(isNumber) + .map(it => { + console.log(it.valueOf(), Es2pandaModifierFlags[it], modifiers.valueOf() & it) + return ((modifiers.valueOf() & it) === it) ? Es2pandaModifierFlags[it] : "" + }).join(" ") +} + +export function nameIfIdentifier(node: AstNode): string { + return isIdentifier(node) ? `'${node.name}'` : "" +} + +export function asString(node: AstNode|undefined): string { + return `${node?.constructor.name} ${node ? nameIfIdentifier(node) : undefined}` +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/visitor.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/visitor.ts new file mode 100644 index 0000000000000000000000000000000000000000..8de8b14464606052d82e11a2fb43740bee7f99ee --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/arkts-api/visitor.ts @@ -0,0 +1,430 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { factory } from "./factory/nodeFactory" +import { AstNode } from "./peers/AstNode" +import { + isArrayExpression, + isArrowFunctionExpression, + isAssignmentExpression, + isBlockExpression, + isBlockStatement, + isCallExpression, + isChainExpression, + isClassDeclaration, + isClassDefinition, + isConditionalExpression, + isETSModule, + isETSStructDeclaration, + isETSTuple, + isExpressionStatement, + isFunctionDeclaration, + isFunctionExpression, + isIfStatement, + isMemberExpression, + isMethodDefinition, + isObjectExpression, + isReturnStatement, + isScriptFunction, + isTemplateLiteral, + isTryStatement, + isTSAsExpression, + isTSInterfaceBody, + isTSInterfaceDeclaration, + isTSTypeAliasDeclaration, + isVariableDeclaration, + isVariableDeclarator, + isClassProperty, + isIdentifier, + isETSParameterExpression, + isETSUnionType, + isETSFunctionType, + isWhileStatement, +} from "../generated" +import { updateETSModuleByStatements } from "./utilities/public" +import { global } from "./static/global" +import { Es2pandaScriptFunctionFlags } from "../generated/Es2pandaEnums" + +type Visitor = (node: AstNode, options?: object) => AstNode + +export interface DoubleNode { + originNode: AstNode; + translatedNode: AstNode; +} + +export class StructInfo { + stateVariables: Set = new Set(); + initializeBody: AstNode[] = []; + updateBody: AstNode[] = []; +} + +export class GlobalInfo { + private _structCollection: Set; + private static instance: GlobalInfo; + private _structMap: Map; + + private constructor() { + this._structCollection = new Set(); + this._structMap = new Map(); + } + + public static getInfoInstance(): GlobalInfo { + if (!this.instance) { + this.instance = new GlobalInfo(); + } + return this.instance; + } + + public add(str: string): void { + this._structCollection.add(str); + } + + public getStructCollection(): Set { + return this._structCollection; + } + + public getStructInfo(structName: string): StructInfo { + const structInfo = this._structMap.get(structName); + if (!structInfo) { + return new StructInfo(); + } + return structInfo; + } + + public setStructInfo(structName: string, info: StructInfo): void { + this._structMap.set(structName, info); + } +} + +// TODO: rethink (remove as) +function nodeVisitor(node: T, visitor: Visitor): T { + if (node === undefined) { + return node + } + return visitor(node) as T +} + +// TODO: rethink (remove as) +function nodesVisitor(nodes: TIn, visitor: Visitor): T[] | TIn { + if (nodes === undefined) { + return nodes + } + return nodes.map(node => visitor(node) as T) +} + +export function visitEachChild( + node: AstNode, + visitor: Visitor +): AstNode { + global.profiler.visitedNodes ++ + if (isETSModule(node)) { + return updateETSModuleByStatements( + node, + nodesVisitor(node.statements, visitor) + ) + } + if (isCallExpression(node)) { + return factory.updateCallExpression( + node, + nodeVisitor(node.callee, visitor), + nodesVisitor(node.arguments, visitor), + nodeVisitor(node.typeParams, visitor), + node.isOptional, + node.hasTrailingComma, + nodeVisitor(node.trailingBlock, visitor) + ) + } + if (isFunctionDeclaration(node)) { + return factory.updateFunctionDeclaration( + node, + nodeVisitor(node.function, visitor), + nodesVisitor(node.annotations, visitor), + node.isAnonymous, + ) + } + if (isBlockStatement(node)) { + return factory.updateBlockStatement( + node, + nodesVisitor(node.statements, visitor), + ) + } + if (isBlockExpression(node)) { + return factory.updateBlockExpression( + node, + nodesVisitor(node.statements, visitor), + ) + } + if (isChainExpression(node)) { + return factory.updateChainExpression( + node, + nodeVisitor(node.expression, visitor), + ) + } + if (isExpressionStatement(node)) { + return factory.updateExpressionStatement( + node, + nodeVisitor(node.expression, visitor) + ) + } + if (isETSStructDeclaration(node)) { + return factory.updateETSStructDeclaration( + node, + nodeVisitor(node.definition, visitor) + ) + } + if (isClassDeclaration(node)) { + const _node = factory.updateClassDeclaration( + node, + nodeVisitor(node.definition, visitor) + ) + _node.modifierFlags = node.modifierFlags + return _node + } + if (isClassDefinition(node)) { + return factory.updateClassDefinition( + node, + nodeVisitor(node.ident, visitor), + nodeVisitor(node.typeParams, visitor), + nodeVisitor(node.superTypeParams, visitor), + nodesVisitor(node.implements, visitor), + undefined, /* can not pass node.ctor here because of mismatching types */ + nodeVisitor(node.super, visitor), + nodesVisitor(node.body, visitor), + node.modifiers, + node.modifierFlags + ) + } + if (isMethodDefinition(node)) { + return factory.updateMethodDefinition( + node, + node.kind, + nodeVisitor(node.id, visitor), + nodeVisitor(node.value, visitor), + node.modifierFlags, + node.isComputed, + nodesVisitor(node.overloads, visitor) + ) + } + if (isScriptFunction(node)) { + return factory.updateScriptFunction( + node, + nodeVisitor(node.body, visitor), + nodeVisitor(node.typeParams, visitor), + nodesVisitor(node.params, visitor), + nodeVisitor(node.returnTypeAnnotation, visitor), + node.hasReceiver, + node.flags, + node.modifierFlags, + nodeVisitor(node.id, visitor), + nodesVisitor(node.annotations, visitor) + ) + } + if (isETSParameterExpression(node)) { + if (node.isRestParameter) { + /** there is no RestParameter node at .idl */ + return node + } + return factory.updateETSParameterExpression( + node, + nodeVisitor(node.ident, visitor), + node.isOptional, + nodeVisitor(node.initializer, visitor), + nodeVisitor(node.typeAnnotation, visitor), + nodesVisitor(node.annotations, visitor), + ) + } + if (isMemberExpression(node)) { + return factory.updateMemberExpression( + node, + nodeVisitor(node.object, visitor), + nodeVisitor(node.property, visitor), + node.kind, + node.isComputed, + node.isOptional + ) + } + if (isTSInterfaceDeclaration(node)) { + return factory.updateInterfaceDeclaration( + node, + nodesVisitor(node.extends, visitor), + nodeVisitor(node.id, visitor), + nodeVisitor(node.typeParams, visitor), + nodeVisitor(node.body, visitor), + node.isStatic, + node.isFromExternal + ) + } + if (isTSInterfaceBody(node)) { + return factory.updateTSInterfaceBody( + node, + nodesVisitor(node.body, visitor) + ) + } + if (isIfStatement(node)) { + return factory.updateIfStatement( + node, + nodeVisitor(node.test, visitor), + nodeVisitor(node.consequent, visitor), + nodeVisitor(node.alternate, visitor), + ) + } + if (isConditionalExpression(node)) { + return factory.updateConditionalExpression( + node, + nodeVisitor(node.test, visitor), + nodeVisitor(node.consequent, visitor), + nodeVisitor(node.alternate, visitor), + ) + } + if (isVariableDeclaration(node)) { + return factory.updateVariableDeclaration( + node, + node.kind, + nodesVisitor(node.declarators, visitor), + nodesVisitor(node.annotations, visitor) + ) + } + if (isVariableDeclarator(node)) { + return factory.updateVariableDeclarator( + node, + node.flag, + nodeVisitor(node.id, visitor), + nodeVisitor(node.init, visitor), + ) + } + if (isArrowFunctionExpression(node)) { + return factory.updateArrowFunctionExpression( + node, + nodeVisitor(node.function, visitor), + nodesVisitor(node.annotations, visitor) + ) + } + if (isReturnStatement(node)) { + return factory.updateReturnStatement( + node, + nodeVisitor(node.argument, visitor) + ) + } + if (isTSAsExpression(node)) { + return factory.updateTSAsExpression( + node, + nodeVisitor(node.expr, visitor), + nodeVisitor(node.typeAnnotation, visitor), + node.isConst + ) + } + if (isTemplateLiteral(node)) { + return factory.updateTemplateLiteral( + node, + nodesVisitor(node.quasis, visitor), + nodesVisitor(node.expressions, visitor), + node.multilineString + ) + } + if (isTSTypeAliasDeclaration(node)) { + return factory.updateTSTypeAliasDeclaration( + node, + nodeVisitor(node.id, visitor), + nodeVisitor(node.typeParams, visitor), + nodeVisitor(node.typeAnnotation, visitor), + nodesVisitor(node.annotations, visitor), + ) + } + if (isTryStatement(node)) { + return factory.updateTryStatement( + node, + nodeVisitor(node.block, visitor), + nodesVisitor(node.catchClauses, visitor), + nodeVisitor(node.finallyBlock, visitor), + [], + [] + ) + } + if (isObjectExpression(node)) { + return factory.updateObjectExpression( + node, + nodesVisitor(node.properties, visitor) + ) + } + if (isFunctionExpression(node)) { + return factory.updateFunctionExpression( + node, + nodeVisitor(node.id, visitor), + nodeVisitor(node.function, visitor) + ) + } + if (isArrayExpression(node)) { + return factory.updateArrayExpression( + node, + nodesVisitor(node.elements, visitor) + ) + } + if (isAssignmentExpression(node)) { + return factory.updateAssignmentExpression( + node, + nodeVisitor(node.left, visitor), + nodeVisitor(node.right, visitor), + node.operatorType, + ) + } + if (isETSTuple(node)) { + return factory.updateETSTuple( + node, + nodesVisitor(node.tupleTypeAnnotationsList, visitor) + ) + } + if (isETSUnionType(node)) { + return factory.updateETSUnionType( + node, + nodesVisitor(node.types, visitor), + ) + } + if (isETSFunctionType(node)) { + return factory.updateETSFunctionType( + node, + nodeVisitor(node.typeParams, visitor), + nodesVisitor(node.params, visitor), + nodeVisitor(node.returnType, visitor), + false, // TODO: how to get it? + Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_ARROW, + nodesVisitor(node.annotations, visitor), + ) + } + if (isClassProperty(node)) { + return factory.updateClassProperty( + node, + nodeVisitor(node.key, visitor), + nodeVisitor(node.value, visitor), + nodeVisitor(node.typeAnnotation, visitor), + node.modifierFlags, + node.isComputed + ) + } + if (isIdentifier(node)) { + return factory.updateIdentifier( + node, + node.name, + nodeVisitor(node.typeAnnotation, visitor) + ) + } + if (isWhileStatement(node)) { + return factory.updateWhileStatement( + node, + nodeVisitor(node.test, visitor), + nodeVisitor(node.body, visitor), + ) + } + return node +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/Es2pandaEnums.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/Es2pandaEnums.ts new file mode 100644 index 0000000000000000000000000000000000000000..6c0d5703445c4dba2340036a440ed6d3f1f44ca3 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/Es2pandaEnums.ts @@ -0,0 +1,1312 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export enum Es2pandaContextState { + ES2PANDA_STATE_NEW = 0, + ES2PANDA_STATE_PARSED = 1, + ES2PANDA_STATE_SCOPE_INITED = 2, + ES2PANDA_STATE_BOUND = 3, + ES2PANDA_STATE_CHECKED = 4, + ES2PANDA_STATE_LOWERED = 5, + ES2PANDA_STATE_ASM_GENERATED = 6, + ES2PANDA_STATE_BIN_GENERATED = 7, + ES2PANDA_STATE_ERROR = 8 +} +export enum Es2pandaAstNodeType { + AST_NODE_TYPE_ARROW_FUNCTION_EXPRESSION = 0, + AST_NODE_TYPE_ANNOTATION_DECLARATION = 1, + AST_NODE_TYPE_ANNOTATION_USAGE = 2, + AST_NODE_TYPE_ASSERT_STATEMENT = 3, + AST_NODE_TYPE_AWAIT_EXPRESSION = 4, + AST_NODE_TYPE_BIGINT_LITERAL = 5, + AST_NODE_TYPE_BINARY_EXPRESSION = 6, + AST_NODE_TYPE_BLOCK_STATEMENT = 7, + AST_NODE_TYPE_BOOLEAN_LITERAL = 8, + AST_NODE_TYPE_BREAK_STATEMENT = 9, + AST_NODE_TYPE_CALL_EXPRESSION = 10, + AST_NODE_TYPE_CATCH_CLAUSE = 11, + AST_NODE_TYPE_CHAIN_EXPRESSION = 12, + AST_NODE_TYPE_CHAR_LITERAL = 13, + AST_NODE_TYPE_CLASS_DEFINITION = 14, + AST_NODE_TYPE_CLASS_DECLARATION = 15, + AST_NODE_TYPE_CLASS_EXPRESSION = 16, + AST_NODE_TYPE_CLASS_PROPERTY = 17, + AST_NODE_TYPE_CLASS_STATIC_BLOCK = 18, + AST_NODE_TYPE_CONDITIONAL_EXPRESSION = 19, + AST_NODE_TYPE_CONTINUE_STATEMENT = 20, + AST_NODE_TYPE_DEBUGGER_STATEMENT = 21, + AST_NODE_TYPE_DECORATOR = 22, + AST_NODE_TYPE_DIRECT_EVAL = 23, + AST_NODE_TYPE_DO_WHILE_STATEMENT = 24, + AST_NODE_TYPE_EMPTY_STATEMENT = 25, + AST_NODE_TYPE_EXPORT_ALL_DECLARATION = 26, + AST_NODE_TYPE_EXPORT_DEFAULT_DECLARATION = 27, + AST_NODE_TYPE_EXPORT_NAMED_DECLARATION = 28, + AST_NODE_TYPE_EXPORT_SPECIFIER = 29, + AST_NODE_TYPE_EXPRESSION_STATEMENT = 30, + AST_NODE_TYPE_FOR_IN_STATEMENT = 31, + AST_NODE_TYPE_FOR_OF_STATEMENT = 32, + AST_NODE_TYPE_FOR_UPDATE_STATEMENT = 33, + AST_NODE_TYPE_FUNCTION_DECLARATION = 34, + AST_NODE_TYPE_FUNCTION_EXPRESSION = 35, + AST_NODE_TYPE_IDENTIFIER = 36, + AST_NODE_TYPE_DUMMYNODE = 37, + AST_NODE_TYPE_IF_STATEMENT = 38, + AST_NODE_TYPE_IMPORT_DECLARATION = 39, + AST_NODE_TYPE_IMPORT_EXPRESSION = 40, + AST_NODE_TYPE_IMPORT_DEFAULT_SPECIFIER = 41, + AST_NODE_TYPE_IMPORT_NAMESPACE_SPECIFIER = 42, + AST_NODE_TYPE_IMPORT_SPECIFIER = 43, + AST_NODE_TYPE_LABELLED_STATEMENT = 44, + AST_NODE_TYPE_MEMBER_EXPRESSION = 45, + AST_NODE_TYPE_META_PROPERTY_EXPRESSION = 46, + AST_NODE_TYPE_METHOD_DEFINITION = 47, + AST_NODE_TYPE_NAMED_TYPE = 48, + AST_NODE_TYPE_NEW_EXPRESSION = 49, + AST_NODE_TYPE_NULL_LITERAL = 50, + AST_NODE_TYPE_UNDEFINED_LITERAL = 51, + AST_NODE_TYPE_NUMBER_LITERAL = 52, + AST_NODE_TYPE_OMITTED_EXPRESSION = 53, + AST_NODE_TYPE_PREFIX_ASSERTION_EXPRESSION = 54, + AST_NODE_TYPE_PROPERTY = 55, + AST_NODE_TYPE_REGEXP_LITERAL = 56, + AST_NODE_TYPE_REEXPORT_STATEMENT = 57, + AST_NODE_TYPE_RETURN_STATEMENT = 58, + AST_NODE_TYPE_SCRIPT_FUNCTION = 59, + AST_NODE_TYPE_SEQUENCE_EXPRESSION = 60, + AST_NODE_TYPE_STRING_LITERAL = 61, + AST_NODE_TYPE_ETS_NULL_TYPE = 62, + AST_NODE_TYPE_ETS_UNDEFINED_TYPE = 63, + AST_NODE_TYPE_ETS_NEVER_TYPE = 64, + AST_NODE_TYPE_ETS_STRING_LITERAL_TYPE = 65, + AST_NODE_TYPE_ETS_FUNCTION_TYPE = 66, + AST_NODE_TYPE_ETS_WILDCARD_TYPE = 67, + AST_NODE_TYPE_ETS_PRIMITIVE_TYPE = 68, + AST_NODE_TYPE_ETS_PACKAGE_DECLARATION = 69, + AST_NODE_TYPE_ETS_CLASS_LITERAL = 70, + AST_NODE_TYPE_ETS_TYPE_REFERENCE = 71, + AST_NODE_TYPE_ETS_TYPE_REFERENCE_PART = 72, + AST_NODE_TYPE_ETS_UNION_TYPE = 73, + AST_NODE_TYPE_ETS_KEYOF_TYPE = 74, + AST_NODE_TYPE_ETS_NEW_ARRAY_INSTANCE_EXPRESSION = 75, + AST_NODE_TYPE_ETS_NEW_MULTI_DIM_ARRAY_INSTANCE_EXPRESSION = 76, + AST_NODE_TYPE_ETS_NEW_CLASS_INSTANCE_EXPRESSION = 77, + AST_NODE_TYPE_ETS_IMPORT_DECLARATION = 78, + AST_NODE_TYPE_ETS_PARAMETER_EXPRESSION = 79, + AST_NODE_TYPE_ETS_TUPLE = 80, + AST_NODE_TYPE_ETS_MODULE = 81, + AST_NODE_TYPE_SUPER_EXPRESSION = 82, + AST_NODE_TYPE_STRUCT_DECLARATION = 83, + AST_NODE_TYPE_SWITCH_CASE_STATEMENT = 84, + AST_NODE_TYPE_SWITCH_STATEMENT = 85, + AST_NODE_TYPE_TS_ENUM_DECLARATION = 86, + AST_NODE_TYPE_TS_ENUM_MEMBER = 87, + AST_NODE_TYPE_TS_EXTERNAL_MODULE_REFERENCE = 88, + AST_NODE_TYPE_TS_NUMBER_KEYWORD = 89, + AST_NODE_TYPE_TS_ANY_KEYWORD = 90, + AST_NODE_TYPE_TS_STRING_KEYWORD = 91, + AST_NODE_TYPE_TS_BOOLEAN_KEYWORD = 92, + AST_NODE_TYPE_TS_VOID_KEYWORD = 93, + AST_NODE_TYPE_TS_UNDEFINED_KEYWORD = 94, + AST_NODE_TYPE_TS_UNKNOWN_KEYWORD = 95, + AST_NODE_TYPE_TS_OBJECT_KEYWORD = 96, + AST_NODE_TYPE_TS_BIGINT_KEYWORD = 97, + AST_NODE_TYPE_TS_NEVER_KEYWORD = 98, + AST_NODE_TYPE_TS_NON_NULL_EXPRESSION = 99, + AST_NODE_TYPE_TS_NULL_KEYWORD = 100, + AST_NODE_TYPE_TS_ARRAY_TYPE = 101, + AST_NODE_TYPE_TS_UNION_TYPE = 102, + AST_NODE_TYPE_TS_TYPE_LITERAL = 103, + AST_NODE_TYPE_TS_PROPERTY_SIGNATURE = 104, + AST_NODE_TYPE_TS_METHOD_SIGNATURE = 105, + AST_NODE_TYPE_TS_SIGNATURE_DECLARATION = 106, + AST_NODE_TYPE_TS_PARENT_TYPE = 107, + AST_NODE_TYPE_TS_LITERAL_TYPE = 108, + AST_NODE_TYPE_TS_INFER_TYPE = 109, + AST_NODE_TYPE_TS_CONDITIONAL_TYPE = 110, + AST_NODE_TYPE_TS_IMPORT_TYPE = 111, + AST_NODE_TYPE_TS_INTERSECTION_TYPE = 112, + AST_NODE_TYPE_TS_MAPPED_TYPE = 113, + AST_NODE_TYPE_TS_MODULE_BLOCK = 114, + AST_NODE_TYPE_TS_THIS_TYPE = 115, + AST_NODE_TYPE_TS_TYPE_OPERATOR = 116, + AST_NODE_TYPE_TS_TYPE_PARAMETER = 117, + AST_NODE_TYPE_TS_TYPE_PARAMETER_DECLARATION = 118, + AST_NODE_TYPE_TS_TYPE_PARAMETER_INSTANTIATION = 119, + AST_NODE_TYPE_TS_TYPE_PREDICATE = 120, + AST_NODE_TYPE_TS_PARAMETER_PROPERTY = 121, + AST_NODE_TYPE_TS_MODULE_DECLARATION = 122, + AST_NODE_TYPE_TS_IMPORT_EQUALS_DECLARATION = 123, + AST_NODE_TYPE_TS_FUNCTION_TYPE = 124, + AST_NODE_TYPE_TS_CONSTRUCTOR_TYPE = 125, + AST_NODE_TYPE_TS_TYPE_ALIAS_DECLARATION = 126, + AST_NODE_TYPE_TS_TYPE_REFERENCE = 127, + AST_NODE_TYPE_TS_QUALIFIED_NAME = 128, + AST_NODE_TYPE_TS_INDEXED_ACCESS_TYPE = 129, + AST_NODE_TYPE_TS_INTERFACE_DECLARATION = 130, + AST_NODE_TYPE_TS_INTERFACE_BODY = 131, + AST_NODE_TYPE_TS_INTERFACE_HERITAGE = 132, + AST_NODE_TYPE_TS_TUPLE_TYPE = 133, + AST_NODE_TYPE_TS_NAMED_TUPLE_MEMBER = 134, + AST_NODE_TYPE_TS_INDEX_SIGNATURE = 135, + AST_NODE_TYPE_TS_TYPE_QUERY = 136, + AST_NODE_TYPE_TS_AS_EXPRESSION = 137, + AST_NODE_TYPE_TS_CLASS_IMPLEMENTS = 138, + AST_NODE_TYPE_TS_TYPE_ASSERTION = 139, + AST_NODE_TYPE_TAGGED_TEMPLATE_EXPRESSION = 140, + AST_NODE_TYPE_TEMPLATE_ELEMENT = 141, + AST_NODE_TYPE_TEMPLATE_LITERAL = 142, + AST_NODE_TYPE_THIS_EXPRESSION = 143, + AST_NODE_TYPE_TYPEOF_EXPRESSION = 144, + AST_NODE_TYPE_THROW_STATEMENT = 145, + AST_NODE_TYPE_TRY_STATEMENT = 146, + AST_NODE_TYPE_UNARY_EXPRESSION = 147, + AST_NODE_TYPE_UPDATE_EXPRESSION = 148, + AST_NODE_TYPE_VARIABLE_DECLARATION = 149, + AST_NODE_TYPE_VARIABLE_DECLARATOR = 150, + AST_NODE_TYPE_WHILE_STATEMENT = 151, + AST_NODE_TYPE_YIELD_EXPRESSION = 152, + AST_NODE_TYPE_OPAQUE_TYPE_NODE = 153, + AST_NODE_TYPE_BLOCK_EXPRESSION = 154, + AST_NODE_TYPE_BROKEN_TYPE_NODE = 155, + AST_NODE_TYPE_ARRAY_EXPRESSION = 156, + AST_NODE_TYPE_ARRAY_PATTERN = 157, + AST_NODE_TYPE_ASSIGNMENT_EXPRESSION = 158, + AST_NODE_TYPE_ASSIGNMENT_PATTERN = 159, + AST_NODE_TYPE_OBJECT_EXPRESSION = 160, + AST_NODE_TYPE_OBJECT_PATTERN = 161, + AST_NODE_TYPE_SPREAD_ELEMENT = 162, + AST_NODE_TYPE_REST_ELEMENT = 163 +} +export enum Es2pandaScopeType { + SCOPE_TYPE_PARAM = 0, + SCOPE_TYPE_CATCH_PARAM = 1, + SCOPE_TYPE_FUNCTION_PARAM = 2, + SCOPE_TYPE_CATCH = 3, + SCOPE_TYPE_CLASS = 4, + SCOPE_TYPE_ANNOTATION = 5, + SCOPE_TYPE_ANNOTATIONPARAMSCOPE = 6, + SCOPE_TYPE_LOCAL = 7, + SCOPE_TYPE_LOOP = 8, + SCOPE_TYPE_LOOP_DECL = 9, + SCOPE_TYPE_FUNCTION = 10, + SCOPE_TYPE_GLOBAL = 11, + SCOPE_TYPE_MODULE = 12 +} +export enum Es2pandaDeclType { + DECL_TYPE_NONE = 0, + DECL_TYPE_VAR = 1, + DECL_TYPE_LET = 2, + DECL_TYPE_CONST = 3, + DECL_TYPE_LABEL = 4, + DECL_TYPE_READONLY = 5, + DECL_TYPE_FUNC = 6, + DECL_TYPE_PARAM = 7, + DECL_TYPE_IMPORT = 8, + DECL_TYPE_DYNAMIC_IMPORT = 9, + DECL_TYPE_EXPORT = 10, + DECL_TYPE_ANNOTATIONDECL = 11, + DECL_TYPE_ANNOTATIONUSAGE = 12, + DECL_TYPE_TYPE_ALIAS = 13, + DECL_TYPE_NAMESPACE = 14, + DECL_TYPE_INTERFACE = 15, + DECL_TYPE_ENUM_LITERAL = 16, + DECL_TYPE_TYPE_PARAMETER = 17, + DECL_TYPE_PROPERTY = 18, + DECL_TYPE_CLASS = 19, + DECL_TYPE_METHOD = 20, + DECL_TYPE_ENUM = 21 +} +export enum Es2pandaResolveBindingOptions { + RESOLVE_BINDING_OPTIONS_BINDINGS = 0, + RESOLVE_BINDING_OPTIONS_INTERFACES = 1, + RESOLVE_BINDING_OPTIONS_VARIABLES = 2, + RESOLVE_BINDING_OPTIONS_METHODS = 4, + RESOLVE_BINDING_OPTIONS_DECLARATION = 8, + RESOLVE_BINDING_OPTIONS_STATIC_VARIABLES = 16, + RESOLVE_BINDING_OPTIONS_STATIC_METHODS = 32, + RESOLVE_BINDING_OPTIONS_STATIC_DECLARATION = 64, + RESOLVE_BINDING_OPTIONS_TYPE_ALIASES = 128, + RESOLVE_BINDING_OPTIONS_ALL = 256, + RESOLVE_BINDING_OPTIONS_ALL_VARIABLES = 18, + RESOLVE_BINDING_OPTIONS_ALL_METHOD = 36, + RESOLVE_BINDING_OPTIONS_ALL_DECLARATION = 72, + RESOLVE_BINDING_OPTIONS_ALL_STATIC = 112, + RESOLVE_BINDING_OPTIONS_ALL_NON_STATIC = 14, + RESOLVE_BINDING_OPTIONS_LAST = 128 +} +export enum Es2pandaVariableKind { + VARIABLE_KIND_NONE = 0, + VARIABLE_KIND_VAR = 1, + VARIABLE_KIND_LEXICAL = 2, + VARIABLE_KIND_FUNCTION = 3, + VARIABLE_KIND_MODULE = 4 +} +export enum Es2pandaLetOrConstStatus { + LET_OR_CONST_STATUS_INITIALIZED = 0, + LET_OR_CONST_STATUS_UNINITIALIZED = 1 +} +export enum Es2pandaScopeFlags { + SCOPE_FLAGS_NONE = 0, + SCOPE_FLAGS_SET_LEXICAL_FUNCTION = 1, + SCOPE_FLAGS_USE_ARGS = 2, + SCOPE_FLAGS_USE_SUPER = 4, + SCOPE_FLAGS_INNER_ARROW = 8, + SCOPE_FLAGS_NO_REG_STORE = 16, + SCOPE_FLAGS_DECL_SCOPE = 32, + SCOPE_FLAGS_FIELD_SCOPE = 64, + SCOPE_FLAGS_METHOD_SCOPE = 128, + SCOPE_FLAGS_STATIC = 256, + SCOPE_FLAGS_TYPE_ALIAS = 512, + SCOPE_FLAGS_LOOP_SCOPE = 1024, + SCOPE_FLAGS_STATIC_DECL_SCOPE = 288, + SCOPE_FLAGS_STATIC_FIELD_SCOPE = 320, + SCOPE_FLAGS_STATIC_METHOD_SCOPE = 384 +} +export enum Es2pandaEnum { + ENUM_NODE_HAS_PARENT = 0, + ENUM_NODE_HAS_SOURCE_RANGE = 1, + ENUM_EVERY_CHILD_HAS_VALID_PARENT = 2, + ENUM_EVERY_CHILD_IN_PARENT_RANGE = 3, + ENUM_CHECK_STRUCT_DECLARATION = 4, + ENUM_VARIABLE_HAS_SCOPE = 5, + ENUM_NODE_HAS_TYPE = 6, + ENUM_NO_PRIMITIVE_TYPES = 7, + ENUM_IDENTIFIER_HAS_VARIABLE = 8, + ENUM_REFERENCE_TYPE_ANNOTATION_IS_NULL = 9, + ENUM_ARITHMETIC_OPERATION_VALID = 10, + ENUM_SEQUENCE_EXPRESSION_HAS_LAST_TYPE = 11, + ENUM_FOR_LOOP_CORRECTLY_INITIALIZED = 12, + ENUM_VARIABLE_HAS_ENCLOSING_SCOPE = 13, + ENUM_MODIFIER_ACCESS_VALID = 14, + ENUM_VARIABLE_NAME_IDENTIFIER_NAME_SAME = 15, + ENUM_CHECK_ABSTRACT_METHOD = 16, + ENUM_GETTER_SETTER_VALIDATION = 17, + ENUM_CHECK_SCOPE_DECLARATION = 18, + ENUM_CHECK_CONST_PROPERTIES = 19, + ENUM_COUNT = 20, + ENUM_BASE_FIRST = 0, + ENUM_BASE_LAST = 3, + ENUM_AFTER_PLUGINS_AFTER_PARSE_FIRST = 4, + ENUM_AFTER_PLUGINS_AFTER_PARSE_LAST = 4, + ENUM_AFTER_SCOPES_INIT_PHASE_FIRST = 5, + ENUM_AFTER_SCOPES_INIT_PHASE_LAST = 5, + ENUM_AFTER_CHECKER_PHASE_FIRST = 6, + ENUM_AFTER_CHECKER_PHASE_LAST = 19, + ENUM_FIRST = 0, + ENUM_LAST = 19, + ENUM_INVALID = 20 +} +export enum Es2pandaRegExpFlags { + REG_EXP_FLAGS_EMPTY = 0, + REG_EXP_FLAGS_GLOBAL = 1, + REG_EXP_FLAGS_IGNORE_CASE = 2, + REG_EXP_FLAGS_MULTILINE = 4, + REG_EXP_FLAGS_DOTALL = 8, + REG_EXP_FLAGS_UNICODE = 16, + REG_EXP_FLAGS_STICKY = 32 +} +export enum Es2pandaId { + ID_AS = 0, + ID_JS = 1, + ID_TS = 2, + ID_ETS = 3, + ID_COUNT = 4 +} +export enum Es2pandaTokenType { + TOKEN_TYPE_EOS = 0, + TOKEN_TYPE_LITERAL_IDENT = 1, + TOKEN_TYPE_LITERAL_STRING = 2, + TOKEN_TYPE_LITERAL_CHAR = 3, + TOKEN_TYPE_LITERAL_NUMBER = 4, + TOKEN_TYPE_LITERAL_REGEXP = 5, + TOKEN_TYPE_PUNCTUATOR_BITWISE_AND = 6, + TOKEN_TYPE_PUNCTUATOR_BITWISE_OR = 7, + TOKEN_TYPE_PUNCTUATOR_MULTIPLY = 8, + TOKEN_TYPE_PUNCTUATOR_DIVIDE = 9, + TOKEN_TYPE_PUNCTUATOR_MINUS = 10, + TOKEN_TYPE_PUNCTUATOR_EXCLAMATION_MARK = 11, + TOKEN_TYPE_PUNCTUATOR_TILDE = 12, + TOKEN_TYPE_PUNCTUATOR_MINUS_MINUS = 13, + TOKEN_TYPE_PUNCTUATOR_LEFT_SHIFT = 14, + TOKEN_TYPE_PUNCTUATOR_RIGHT_SHIFT = 15, + TOKEN_TYPE_PUNCTUATOR_LESS_THAN_EQUAL = 16, + TOKEN_TYPE_PUNCTUATOR_GREATER_THAN_EQUAL = 17, + TOKEN_TYPE_PUNCTUATOR_MOD = 18, + TOKEN_TYPE_PUNCTUATOR_BITWISE_XOR = 19, + TOKEN_TYPE_PUNCTUATOR_EXPONENTIATION = 20, + TOKEN_TYPE_PUNCTUATOR_MULTIPLY_EQUAL = 21, + TOKEN_TYPE_PUNCTUATOR_EXPONENTIATION_EQUAL = 22, + TOKEN_TYPE_PUNCTUATOR_ARROW = 23, + TOKEN_TYPE_PUNCTUATOR_BACK_TICK = 24, + TOKEN_TYPE_PUNCTUATOR_HASH_MARK = 25, + TOKEN_TYPE_PUNCTUATOR_DIVIDE_EQUAL = 26, + TOKEN_TYPE_PUNCTUATOR_MOD_EQUAL = 27, + TOKEN_TYPE_PUNCTUATOR_MINUS_EQUAL = 28, + TOKEN_TYPE_PUNCTUATOR_LEFT_SHIFT_EQUAL = 29, + TOKEN_TYPE_PUNCTUATOR_RIGHT_SHIFT_EQUAL = 30, + TOKEN_TYPE_PUNCTUATOR_UNSIGNED_RIGHT_SHIFT = 31, + TOKEN_TYPE_PUNCTUATOR_UNSIGNED_RIGHT_SHIFT_EQUAL = 32, + TOKEN_TYPE_PUNCTUATOR_BITWISE_AND_EQUAL = 33, + TOKEN_TYPE_PUNCTUATOR_BITWISE_OR_EQUAL = 34, + TOKEN_TYPE_PUNCTUATOR_LOGICAL_AND_EQUAL = 35, + TOKEN_TYPE_PUNCTUATOR_NULLISH_COALESCING = 36, + TOKEN_TYPE_PUNCTUATOR_LOGICAL_OR_EQUAL = 37, + TOKEN_TYPE_PUNCTUATOR_LOGICAL_NULLISH_EQUAL = 38, + TOKEN_TYPE_PUNCTUATOR_BITWISE_XOR_EQUAL = 39, + TOKEN_TYPE_PUNCTUATOR_PLUS = 40, + TOKEN_TYPE_PUNCTUATOR_PLUS_PLUS = 41, + TOKEN_TYPE_PUNCTUATOR_PLUS_EQUAL = 42, + TOKEN_TYPE_PUNCTUATOR_LESS_THAN = 43, + TOKEN_TYPE_PUNCTUATOR_GREATER_THAN = 44, + TOKEN_TYPE_PUNCTUATOR_EQUAL = 45, + TOKEN_TYPE_PUNCTUATOR_NOT_EQUAL = 46, + TOKEN_TYPE_PUNCTUATOR_STRICT_EQUAL = 47, + TOKEN_TYPE_PUNCTUATOR_NOT_STRICT_EQUAL = 48, + TOKEN_TYPE_PUNCTUATOR_LOGICAL_AND = 49, + TOKEN_TYPE_PUNCTUATOR_LOGICAL_OR = 50, + TOKEN_TYPE_PUNCTUATOR_SUBSTITUTION = 51, + TOKEN_TYPE_PUNCTUATOR_QUESTION_MARK = 52, + TOKEN_TYPE_PUNCTUATOR_QUESTION_DOT = 53, + TOKEN_TYPE_PUNCTUATOR_AT = 54, + TOKEN_TYPE_PUNCTUATOR_FORMAT = 55, + TOKEN_TYPE_PUNCTUATOR_RIGHT_PARENTHESIS = 56, + TOKEN_TYPE_PUNCTUATOR_LEFT_PARENTHESIS = 57, + TOKEN_TYPE_PUNCTUATOR_RIGHT_SQUARE_BRACKET = 58, + TOKEN_TYPE_PUNCTUATOR_LEFT_SQUARE_BRACKET = 59, + TOKEN_TYPE_PUNCTUATOR_RIGHT_BRACE = 60, + TOKEN_TYPE_PUNCTUATOR_PERIOD = 61, + TOKEN_TYPE_PUNCTUATOR_PERIOD_PERIOD_PERIOD = 62, + TOKEN_TYPE_PUNCTUATOR_PERIOD_QUESTION = 63, + TOKEN_TYPE_PUNCTUATOR_LEFT_BRACE = 64, + TOKEN_TYPE_PUNCTUATOR_SEMI_COLON = 65, + TOKEN_TYPE_PUNCTUATOR_COLON = 66, + TOKEN_TYPE_PUNCTUATOR_COMMA = 67, + TOKEN_TYPE_KEYW_ABSTRACT = 68, + TOKEN_TYPE_KEYW_ANY = 69, + TOKEN_TYPE_KEYW_ANYREF = 70, + TOKEN_TYPE_KEYW_ARGUMENTS = 71, + TOKEN_TYPE_KEYW_AS = 72, + TOKEN_TYPE_KEYW_ASSERTS = 73, + TOKEN_TYPE_KEYW_ASYNC = 74, + TOKEN_TYPE_KEYW_AWAIT = 75, + TOKEN_TYPE_KEYW_BIGINT = 76, + TOKEN_TYPE_KEYW_BUILTIN_BIGINT = 77, + TOKEN_TYPE_KEYW_BOOLEAN = 78, + TOKEN_TYPE_KEYW_BUILTIN_BOOLEAN = 79, + TOKEN_TYPE_KEYW_BREAK = 80, + TOKEN_TYPE_KEYW_BYTE = 81, + TOKEN_TYPE_KEYW_BUILTIN_BYTE = 82, + TOKEN_TYPE_KEYW_CASE = 83, + TOKEN_TYPE_KEYW_CATCH = 84, + TOKEN_TYPE_KEYW_CHAR = 85, + TOKEN_TYPE_KEYW_BUILTIN_CHAR = 86, + TOKEN_TYPE_KEYW_CLASS = 87, + TOKEN_TYPE_KEYW_CONST = 88, + TOKEN_TYPE_KEYW_CONSTRUCTOR = 89, + TOKEN_TYPE_KEYW_CONTINUE = 90, + TOKEN_TYPE_KEYW_DATAREF = 91, + TOKEN_TYPE_KEYW_DEBUGGER = 92, + TOKEN_TYPE_KEYW_DECLARE = 93, + TOKEN_TYPE_KEYW_DEFAULT = 94, + TOKEN_TYPE_KEYW_DELETE = 95, + TOKEN_TYPE_KEYW_DO = 96, + TOKEN_TYPE_KEYW_DOUBLE = 97, + TOKEN_TYPE_KEYW_BUILTIN_DOUBLE = 98, + TOKEN_TYPE_KEYW_ELSE = 99, + TOKEN_TYPE_KEYW_ENUM = 100, + TOKEN_TYPE_KEYW_EQREF = 101, + TOKEN_TYPE_KEYW_EVAL = 102, + TOKEN_TYPE_KEYW_EXPORT = 103, + TOKEN_TYPE_KEYW_EXTENDS = 104, + TOKEN_TYPE_KEYW_EXTERNREF = 105, + TOKEN_TYPE_KEYW_F32 = 106, + TOKEN_TYPE_KEYW_F64 = 107, + TOKEN_TYPE_LITERAL_FALSE = 108, + TOKEN_TYPE_KEYW_FINALLY = 109, + TOKEN_TYPE_KEYW_FLOAT = 110, + TOKEN_TYPE_KEYW_BUILTIN_FLOAT = 111, + TOKEN_TYPE_KEYW_FOR = 112, + TOKEN_TYPE_KEYW_FROM = 113, + TOKEN_TYPE_KEYW_FUNCREF = 114, + TOKEN_TYPE_KEYW_FUNCTION = 115, + TOKEN_TYPE_KEYW_GET = 116, + TOKEN_TYPE_KEYW_GLOBAL = 117, + TOKEN_TYPE_KEYW_I8 = 118, + TOKEN_TYPE_KEYW_I16 = 119, + TOKEN_TYPE_KEYW_I31REF = 120, + TOKEN_TYPE_KEYW_I32 = 121, + TOKEN_TYPE_KEYW_I64 = 122, + TOKEN_TYPE_KEYW_IF = 123, + TOKEN_TYPE_KEYW_IMPLEMENTS = 124, + TOKEN_TYPE_KEYW_IMPORT = 125, + TOKEN_TYPE_KEYW_IN = 126, + TOKEN_TYPE_KEYW_INFER = 127, + TOKEN_TYPE_KEYW_INSTANCEOF = 128, + TOKEN_TYPE_KEYW_INT = 129, + TOKEN_TYPE_KEYW_BUILTIN_INT = 130, + TOKEN_TYPE_KEYW_INTERFACE = 131, + TOKEN_TYPE_KEYW_IS = 132, + TOKEN_TYPE_KEYW_ISIZE = 133, + TOKEN_TYPE_KEYW_KEYOF = 134, + TOKEN_TYPE_KEYW_LET = 135, + TOKEN_TYPE_KEYW_LONG = 136, + TOKEN_TYPE_KEYW_BUILTIN_LONG = 137, + TOKEN_TYPE_KEYW_META = 138, + TOKEN_TYPE_KEYW_MODULE = 139, + TOKEN_TYPE_KEYW_NAMESPACE = 140, + TOKEN_TYPE_KEYW_NATIVE = 141, + TOKEN_TYPE_KEYW_NEVER = 142, + TOKEN_TYPE_KEYW_NEW = 143, + TOKEN_TYPE_LITERAL_NULL = 144, + TOKEN_TYPE_KEYW_NUMBER = 145, + TOKEN_TYPE_KEYW_OBJECT = 146, + TOKEN_TYPE_KEYW_BUILTIN_OBJECT = 147, + TOKEN_TYPE_KEYW_OF = 148, + TOKEN_TYPE_KEYW_FINAL = 149, + TOKEN_TYPE_KEYW_OUT = 150, + TOKEN_TYPE_KEYW_OVERRIDE = 151, + TOKEN_TYPE_KEYW_PACKAGE = 152, + TOKEN_TYPE_KEYW_INTERNAL = 153, + TOKEN_TYPE_KEYW_PRIVATE = 154, + TOKEN_TYPE_KEYW_PROTECTED = 155, + TOKEN_TYPE_KEYW_PUBLIC = 156, + TOKEN_TYPE_KEYW_READONLY = 157, + TOKEN_TYPE_KEYW_RETHROWS = 158, + TOKEN_TYPE_KEYW_RETURN = 159, + TOKEN_TYPE_KEYW_REQUIRE = 160, + TOKEN_TYPE_KEYW_SET = 161, + TOKEN_TYPE_KEYW_SHORT = 162, + TOKEN_TYPE_KEYW_BUILTIN_SHORT = 163, + TOKEN_TYPE_KEYW_STATIC = 164, + TOKEN_TYPE_KEYW_STRING = 165, + TOKEN_TYPE_KEYW_BUILTIN_STRING = 166, + TOKEN_TYPE_KEYW_STRUCT = 167, + TOKEN_TYPE_KEYW_SUPER = 168, + TOKEN_TYPE_KEYW_SWITCH = 169, + TOKEN_TYPE_KEYW_TARGET = 170, + TOKEN_TYPE_KEYW_THIS = 171, + TOKEN_TYPE_KEYW_THROW = 172, + TOKEN_TYPE_KEYW_THROWS = 173, + TOKEN_TYPE_LITERAL_TRUE = 174, + TOKEN_TYPE_KEYW_TRY = 175, + TOKEN_TYPE_KEYW_TYPE = 176, + TOKEN_TYPE_KEYW_TYPEOF = 177, + TOKEN_TYPE_KEYW_U8 = 178, + TOKEN_TYPE_KEYW_U16 = 179, + TOKEN_TYPE_KEYW_U32 = 180, + TOKEN_TYPE_KEYW_U64 = 181, + TOKEN_TYPE_KEYW_UNDEFINED = 182, + TOKEN_TYPE_KEYW_UNKNOWN = 183, + TOKEN_TYPE_KEYW_USIZE = 184, + TOKEN_TYPE_KEYW_V128 = 185, + TOKEN_TYPE_KEYW_VAR = 186, + TOKEN_TYPE_KEYW_VOID = 187, + TOKEN_TYPE_KEYW_WHILE = 188, + TOKEN_TYPE_KEYW_WITH = 189, + TOKEN_TYPE_KEYW_YIELD = 190, + TOKEN_TYPE_JS_DOC_START = 191, + TOKEN_TYPE_JS_DOC_END = 192, + TOKEN_TYPE_FIRST_PUNCTUATOR = 6, + TOKEN_TYPE_FIRST_KEYW = 68 +} +export enum Es2pandaAstNodeFlags { + AST_NODE_FLAGS_NO_OPTS = 0, + AST_NODE_FLAGS_CHECKCAST = 1, + AST_NODE_FLAGS_CONVERT_TO_STRING = 2, + AST_NODE_FLAGS_ALLOW_REQUIRED_INSTANTIATION = 4, + AST_NODE_FLAGS_HAS_EXPORT_ALIAS = 8, + AST_NODE_FLAGS_GENERATE_VALUE_OF = 16, + AST_NODE_FLAGS_RECHECK = 32, + AST_NODE_FLAGS_NOCLEANUP = 64, + AST_NODE_FLAGS_RESIZABLE_REST = 128 +} +export enum Es2pandaModifierFlags { + MODIFIER_FLAGS_NONE = 0, + MODIFIER_FLAGS_STATIC = 1, + MODIFIER_FLAGS_ASYNC = 2, + MODIFIER_FLAGS_PUBLIC = 4, + MODIFIER_FLAGS_PROTECTED = 8, + MODIFIER_FLAGS_PRIVATE = 16, + MODIFIER_FLAGS_DECLARE = 32, + MODIFIER_FLAGS_READONLY = 64, + MODIFIER_FLAGS_OPTIONAL = 128, + MODIFIER_FLAGS_DEFINITE = 256, + MODIFIER_FLAGS_ABSTRACT = 512, + MODIFIER_FLAGS_CONST = 1024, + MODIFIER_FLAGS_FINAL = 2048, + MODIFIER_FLAGS_NATIVE = 4096, + MODIFIER_FLAGS_OVERRIDE = 8192, + MODIFIER_FLAGS_CONSTRUCTOR = 16384, + MODIFIER_FLAGS_SYNCHRONIZED = 32768, + MODIFIER_FLAGS_FUNCTIONAL = 65536, + MODIFIER_FLAGS_IN = 131072, + MODIFIER_FLAGS_OUT = 262144, + MODIFIER_FLAGS_INTERNAL = 524288, + MODIFIER_FLAGS_EXPORT = 1048576, + MODIFIER_FLAGS_GETTER = 2097152, + MODIFIER_FLAGS_SETTER = 4194304, + MODIFIER_FLAGS_DEFAULT_EXPORT = 8388608, + MODIFIER_FLAGS_EXPORT_TYPE = 16777216, + MODIFIER_FLAGS_SUPER_OWNER = 33554432, + MODIFIER_FLAGS_ANNOTATION_DECLARATION = 67108864, + MODIFIER_FLAGS_ANNOTATION_USAGE = 134217728, + MODIFIER_FLAGS_READONLY_PARAMETER = 268435456, + MODIFIER_FLAGS_ARRAY_SETTER = 536870912, + MODIFIER_FLAGS_ACCESS = 524316, + MODIFIER_FLAGS_ALL = 524927, + MODIFIER_FLAGS_ALLOWED_IN_CTOR_PARAMETER = 524380, + MODIFIER_FLAGS_INTERNAL_PROTECTED = 524296, + MODIFIER_FLAGS_ACCESSOR_MODIFIERS = 2560, + MODIFIER_FLAGS_GETTER_SETTER = 6291456, + MODIFIER_FLAGS_EXPORTED = 26214400 +} +export enum Es2pandaPrivateFieldKind { + PRIVATE_FIELD_KIND_FIELD = 0, + PRIVATE_FIELD_KIND_METHOD = 1, + PRIVATE_FIELD_KIND_GET = 2, + PRIVATE_FIELD_KIND_SET = 3, + PRIVATE_FIELD_KIND_STATIC_FIELD = 4, + PRIVATE_FIELD_KIND_STATIC_METHOD = 5, + PRIVATE_FIELD_KIND_STATIC_GET = 6, + PRIVATE_FIELD_KIND_STATIC_SET = 7 +} +export enum Es2pandaScriptFunctionFlags { + SCRIPT_FUNCTION_FLAGS_NONE = 0, + SCRIPT_FUNCTION_FLAGS_GENERATOR = 1, + SCRIPT_FUNCTION_FLAGS_ASYNC = 2, + SCRIPT_FUNCTION_FLAGS_ARROW = 4, + SCRIPT_FUNCTION_FLAGS_EXPRESSION = 8, + SCRIPT_FUNCTION_FLAGS_OVERLOAD = 16, + SCRIPT_FUNCTION_FLAGS_CONSTRUCTOR = 32, + SCRIPT_FUNCTION_FLAGS_METHOD = 64, + SCRIPT_FUNCTION_FLAGS_STATIC_BLOCK = 128, + SCRIPT_FUNCTION_FLAGS_HIDDEN = 256, + SCRIPT_FUNCTION_FLAGS_IMPLICIT_SUPER_CALL_NEEDED = 512, + SCRIPT_FUNCTION_FLAGS_ENUM = 1024, + SCRIPT_FUNCTION_FLAGS_EXTERNAL = 2048, + SCRIPT_FUNCTION_FLAGS_PROXY = 4096, + SCRIPT_FUNCTION_FLAGS_THROWS = 8192, + SCRIPT_FUNCTION_FLAGS_RETHROWS = 16384, + SCRIPT_FUNCTION_FLAGS_GETTER = 32768, + SCRIPT_FUNCTION_FLAGS_SETTER = 65536, + SCRIPT_FUNCTION_FLAGS_ENTRY_POINT = 131072, + SCRIPT_FUNCTION_FLAGS_HAS_RETURN = 262144, + SCRIPT_FUNCTION_FLAGS_ASYNC_IMPL = 524288, + SCRIPT_FUNCTION_FLAGS_EXTERNAL_OVERLOAD = 1048576, + SCRIPT_FUNCTION_FLAGS_HAS_THROW = 2097152 +} +export enum Es2pandaTSOperatorType { + TS_OPERATOR_TYPE_READONLY = 0, + TS_OPERATOR_TYPE_KEYOF = 1, + TS_OPERATOR_TYPE_UNIQUE = 2 +} +export enum Es2pandaMappedOption { + MAPPED_OPTION_NO_OPTS = 0, + MAPPED_OPTION_PLUS = 1, + MAPPED_OPTION_MINUS = 2 +} +export enum Es2pandaBoxingUnboxingFlags { + BOXING_UNBOXING_FLAGS_NONE = 0, + BOXING_UNBOXING_FLAGS_BOX_TO_BOOLEAN = 1, + BOXING_UNBOXING_FLAGS_BOX_TO_BYTE = 2, + BOXING_UNBOXING_FLAGS_BOX_TO_SHORT = 4, + BOXING_UNBOXING_FLAGS_BOX_TO_CHAR = 8, + BOXING_UNBOXING_FLAGS_BOX_TO_INT = 16, + BOXING_UNBOXING_FLAGS_BOX_TO_LONG = 32, + BOXING_UNBOXING_FLAGS_BOX_TO_FLOAT = 64, + BOXING_UNBOXING_FLAGS_BOX_TO_DOUBLE = 128, + BOXING_UNBOXING_FLAGS_BOX_TO_ENUM = 256, + BOXING_UNBOXING_FLAGS_UNBOX_TO_BOOLEAN = 512, + BOXING_UNBOXING_FLAGS_UNBOX_TO_BYTE = 1024, + BOXING_UNBOXING_FLAGS_UNBOX_TO_SHORT = 2048, + BOXING_UNBOXING_FLAGS_UNBOX_TO_CHAR = 4096, + BOXING_UNBOXING_FLAGS_UNBOX_TO_INT = 8192, + BOXING_UNBOXING_FLAGS_UNBOX_TO_LONG = 16384, + BOXING_UNBOXING_FLAGS_UNBOX_TO_FLOAT = 32768, + BOXING_UNBOXING_FLAGS_UNBOX_TO_DOUBLE = 65536, + BOXING_UNBOXING_FLAGS_BOXING_FLAG = 511, + BOXING_UNBOXING_FLAGS_UNBOXING_FLAG = 130560 +} +export enum Es2pandaClassDefinitionModifiers { + CLASS_DEFINITION_MODIFIERS_NONE = 0, + CLASS_DEFINITION_MODIFIERS_DECLARATION = 1, + CLASS_DEFINITION_MODIFIERS_ID_REQUIRED = 2, + CLASS_DEFINITION_MODIFIERS_GLOBAL = 4, + CLASS_DEFINITION_MODIFIERS_HAS_SUPER = 8, + CLASS_DEFINITION_MODIFIERS_SET_CTOR_ID = 16, + CLASS_DEFINITION_MODIFIERS_EXTERN = 32, + CLASS_DEFINITION_MODIFIERS_ANONYMOUS = 64, + CLASS_DEFINITION_MODIFIERS_GLOBAL_INITIALIZED = 128, + CLASS_DEFINITION_MODIFIERS_CLASS_DECL = 256, + CLASS_DEFINITION_MODIFIERS_INNER = 512, + CLASS_DEFINITION_MODIFIERS_FROM_EXTERNAL = 1024, + CLASS_DEFINITION_MODIFIERS_LOCAL = 2048, + CLASS_DEFINITION_MODIFIERS_CLASSDEFINITION_CHECKED = 4096, + CLASS_DEFINITION_MODIFIERS_NAMESPACE_TRANSFORMED = 8192, + CLASS_DEFINITION_MODIFIERS_STRING_ENUM_TRANSFORMED = 16384, + CLASS_DEFINITION_MODIFIERS_INT_ENUM_TRANSFORMED = 32768, + CLASS_DEFINITION_MODIFIERS_FROM_STRUCT = 65536, + CLASS_DEFINITION_MODIFIERS_DECLARATION_ID_REQUIRED = 3, + CLASS_DEFINITION_MODIFIERS_ETS_MODULE = 8196 +} +export enum Es2pandaOperandKind { + OPERAND_KIND_SRC_VREG = 0, + OPERAND_KIND_DST_VREG = 1, + OPERAND_KIND_SRC_DST_VREG = 2, + OPERAND_KIND_IMM = 3, + OPERAND_KIND_ID = 4, + OPERAND_KIND_STRING_ID = 5, + OPERAND_KIND_LABEL = 6 +} +export enum Es2pandaOperandType { + OPERAND_TYPE_REF = 0, + OPERAND_TYPE_B32 = 1, + OPERAND_TYPE_B64 = 2, + OPERAND_TYPE_ANY = 3, + OPERAND_TYPE_NONE = 4 +} +export enum Es2pandaTypeRelationFlag { + TYPE_RELATION_FLAG_NONE = 0, + TYPE_RELATION_FLAG_NARROWING = 1, + TYPE_RELATION_FLAG_WIDENING = 2, + TYPE_RELATION_FLAG_BOXING = 4, + TYPE_RELATION_FLAG_UNBOXING = 8, + TYPE_RELATION_FLAG_CAPTURE = 16, + TYPE_RELATION_FLAG_STRING = 32, + TYPE_RELATION_FLAG_VALUE_SET = 64, + TYPE_RELATION_FLAG_UNCHECKED = 128, + TYPE_RELATION_FLAG_NO_THROW = 256, + TYPE_RELATION_FLAG_SELF_REFERENCE = 512, + TYPE_RELATION_FLAG_NO_RETURN_TYPE_CHECK = 1024, + TYPE_RELATION_FLAG_DIRECT_RETURN = 2048, + TYPE_RELATION_FLAG_NO_WIDENING = 4096, + TYPE_RELATION_FLAG_NO_BOXING = 8192, + TYPE_RELATION_FLAG_NO_UNBOXING = 16384, + TYPE_RELATION_FLAG_ONLY_CHECK_WIDENING = 32768, + TYPE_RELATION_FLAG_ONLY_CHECK_BOXING_UNBOXING = 65536, + TYPE_RELATION_FLAG_IN_ASSIGNMENT_CONTEXT = 131072, + TYPE_RELATION_FLAG_IN_CASTING_CONTEXT = 262144, + TYPE_RELATION_FLAG_UNCHECKED_CAST = 524288, + TYPE_RELATION_FLAG_IGNORE_TYPE_PARAMETERS = 1048576, + TYPE_RELATION_FLAG_CHECK_PROXY = 2097152, + TYPE_RELATION_FLAG_NO_CHECK_TRAILING_LAMBDA = 4194304, + TYPE_RELATION_FLAG_NO_THROW_GENERIC_TYPEALIAS = 8388608, + TYPE_RELATION_FLAG_OVERRIDING_CONTEXT = 16777216, + TYPE_RELATION_FLAG_IGNORE_REST_PARAM = 33554432, + TYPE_RELATION_FLAG_STRING_TO_CHAR = 67108864, + TYPE_RELATION_FLAG_ASSIGNMENT_CONTEXT = 14, + TYPE_RELATION_FLAG_BRIDGE_CHECK = 17826816, + TYPE_RELATION_FLAG_CASTING_CONTEXT = 524303 +} +export enum Es2pandaRelationResult { + RELATION_RESULT_TRUE = 0, + RELATION_RESULT_FALSE = 1, + RELATION_RESULT_UNKNOWN = 2, + RELATION_RESULT_MAYBE = 3, + RELATION_RESULT_CACHE_MISS = 4, + RELATION_RESULT_ERROR = 5 +} +export enum Es2pandaRelationType { + RELATION_TYPE_COMPARABLE = 0, + RELATION_TYPE_ASSIGNABLE = 1, + RELATION_TYPE_IDENTICAL = 2, + RELATION_TYPE_UNCHECKED_CASTABLE = 3, + RELATION_TYPE_SUPERTYPE = 4 +} +export enum Es2pandaVarianceFlag { + VARIANCE_FLAG_COVARIANT = 0, + VARIANCE_FLAG_CONTRAVARIANT = 1, + VARIANCE_FLAG_INVARIANT = 2 +} +export enum Es2pandaImportKinds { + IMPORT_KINDS_ALL = 0, + IMPORT_KINDS_TYPES = 1 +} +export enum Es2pandaPropertyKind { + PROPERTY_KIND_INIT = 0, + PROPERTY_KIND_GET = 1, + PROPERTY_KIND_SET = 2, + PROPERTY_KIND_PROTO = 3 +} +export enum Es2pandaConstant { + CONSTANT_PROP_NULL = 0, + CONSTANT_PROP_UNDEFINED = 1, + CONSTANT_EMPTY_ARRAY = 2 +} +export enum Es2pandaTSSignatureDeclarationKind { + TS_SIGNATURE_DECLARATION_KIND_CALL_SIGNATURE = 0, + TS_SIGNATURE_DECLARATION_KIND_CONSTRUCT_SIGNATURE = 1 +} +export enum Es2pandaTSIndexSignatureKind { + TS_INDEX_SIGNATURE_KIND_NUMBER = 0, + TS_INDEX_SIGNATURE_KIND_STRING = 1 +} +export enum Es2pandaEnumLiteralTypeKind { + ENUM_LITERAL_TYPE_KIND_NUMERIC = 0, + ENUM_LITERAL_TYPE_KIND_LITERAL = 1 +} +export enum Es2pandaIdentifierFlags { + IDENTIFIER_FLAGS_NONE = 0, + IDENTIFIER_FLAGS_OPTIONAL = 1, + IDENTIFIER_FLAGS_TDZ = 2, + IDENTIFIER_FLAGS_PRIVATE = 4, + IDENTIFIER_FLAGS_GET = 8, + IDENTIFIER_FLAGS_SET = 16, + IDENTIFIER_FLAGS_IGNORE_BOX = 32, + IDENTIFIER_FLAGS_ANNOTATIONDECL = 64, + IDENTIFIER_FLAGS_ANNOTATIONUSAGE = 128, + IDENTIFIER_FLAGS_ERROR_PLACEHOLDER = 256 +} +export enum Es2pandaMemberExpressionKind { + MEMBER_EXPRESSION_KIND_NONE = 0, + MEMBER_EXPRESSION_KIND_ELEMENT_ACCESS = 1, + MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS = 2, + MEMBER_EXPRESSION_KIND_GETTER = 4, + MEMBER_EXPRESSION_KIND_SETTER = 8, + MEMBER_EXPRESSION_KIND_EXTENSION_ACCESSOR = 16 +} +export enum Es2pandaTSTupleKind { + TS_TUPLE_KIND_NONE = 0, + TS_TUPLE_KIND_NAMED = 1, + TS_TUPLE_KIND_DEFAULT = 2 +} +export enum Es2pandaMetaPropertyKind { + META_PROPERTY_KIND_NEW_TARGET = 0, + META_PROPERTY_KIND_IMPORT_META = 1 +} +export enum Es2pandaModuleFlag { + MODULE_FLAG_NONE = 0, + MODULE_FLAG_ETSSCRIPT = 1, + MODULE_FLAG_NAMESPACE = 2, + MODULE_FLAG_NAMESPACE_CHAIN_LAST_NODE = 4 +} +export enum Es2pandaElementFlags { + ELEMENT_FLAGS_NO_OPTS = 0, + ELEMENT_FLAGS_REQUIRED = 1, + ELEMENT_FLAGS_OPTIONAL = 2, + ELEMENT_FLAGS_REST = 4, + ELEMENT_FLAGS_VARIADIC = 8, + ELEMENT_FLAGS_FIXED = 3, + ELEMENT_FLAGS_VARIABLE = 12, + ELEMENT_FLAGS_NON_REQUIRED = 14, + ELEMENT_FLAGS_NON_REST = 11 +} +export enum Es2pandaSignatureFlags { + SIGNATURE_FLAGS_NO_OPTS = 0, + SIGNATURE_FLAGS_ABSTRACT = 1, + SIGNATURE_FLAGS_CALL = 2, + SIGNATURE_FLAGS_CONSTRUCT = 4, + SIGNATURE_FLAGS_PUBLIC = 8, + SIGNATURE_FLAGS_PROTECTED = 16, + SIGNATURE_FLAGS_PRIVATE = 32, + SIGNATURE_FLAGS_STATIC = 64, + SIGNATURE_FLAGS_FINAL = 128, + SIGNATURE_FLAGS_CONSTRUCTOR = 256, + SIGNATURE_FLAGS_PROXY = 512, + SIGNATURE_FLAGS_INTERNAL = 1024, + SIGNATURE_FLAGS_NEED_RETURN_TYPE = 2048, + SIGNATURE_FLAGS_INFERRED_RETURN_TYPE = 4096, + SIGNATURE_FLAGS_THIS_RETURN_TYPE = 8192, + SIGNATURE_FLAGS_GETTER = 16384, + SIGNATURE_FLAGS_SETTER = 32768, + SIGNATURE_FLAGS_THROWS = 65536, + SIGNATURE_FLAGS_RETHROWS = 131072, + SIGNATURE_FLAGS_EXTENSION_FUNCTION = 262144, + SIGNATURE_FLAGS_DUPLICATE_ASM = 524288, + SIGNATURE_FLAGS_INTERNAL_PROTECTED = 1040, + SIGNATURE_FLAGS_GETTER_OR_SETTER = 49152, + SIGNATURE_FLAGS_THROWING = 196608 +} +export enum Es2pandaPrimitiveType { + PRIMITIVE_TYPE_BYTE = 0, + PRIMITIVE_TYPE_INT = 1, + PRIMITIVE_TYPE_LONG = 2, + PRIMITIVE_TYPE_SHORT = 3, + PRIMITIVE_TYPE_FLOAT = 4, + PRIMITIVE_TYPE_DOUBLE = 5, + PRIMITIVE_TYPE_BOOLEAN = 6, + PRIMITIVE_TYPE_CHAR = 7, + PRIMITIVE_TYPE_VOID = 8 +} +export enum Es2pandaObjectFlags { + OBJECT_FLAGS_NO_OPTS = 0, + OBJECT_FLAGS_CHECK_EXCESS_PROPS = 1, + OBJECT_FLAGS_RESOLVED_MEMBERS = 2, + OBJECT_FLAGS_RESOLVED_BASE_TYPES = 4, + OBJECT_FLAGS_RESOLVED_DECLARED_MEMBERS = 8 +} +export enum Es2pandaObjectTypeKind { + OBJECT_TYPE_KIND_LITERAL = 0, + OBJECT_TYPE_KIND_CLASS = 1, + OBJECT_TYPE_KIND_INTERFACE = 2, + OBJECT_TYPE_KIND_TUPLE = 3, + OBJECT_TYPE_KIND_FUNCTION = 4 +} +export enum Es2pandaVariableDeclaratorFlag { + VARIABLE_DECLARATOR_FLAG_LET = 0, + VARIABLE_DECLARATOR_FLAG_CONST = 1, + VARIABLE_DECLARATOR_FLAG_VAR = 2, + VARIABLE_DECLARATOR_FLAG_UNKNOWN = 3 +} +export enum Es2pandaTypeFacts { + TYPE_FACTS_NONE = 0, + TYPE_FACTS_TYPEOF_EQ_STRING = 1, + TYPE_FACTS_TYPEOF_EQ_NUMBER = 2, + TYPE_FACTS_TYPEOF_EQ_BIGINT = 4, + TYPE_FACTS_TYPEOF_EQ_BOOLEAN = 8, + TYPE_FACTS_TYPEOF_EQ_SYMBOL = 16, + TYPE_FACTS_TYPEOF_EQ_OBJECT = 32, + TYPE_FACTS_TYPEOF_EQ_FUNCTION = 64, + TYPE_FACTS_TYPEOF_EQ_HOST_OBJECT = 128, + TYPE_FACTS_TYPEOF_NE_STRING = 256, + TYPE_FACTS_TYPEOF_NE_NUMBER = 512, + TYPE_FACTS_TYPEOF_NE_BIGINT = 1024, + TYPE_FACTS_TYPEOF_NE_BOOLEAN = 2048, + TYPE_FACTS_TYPEOF_NE_SYMBOL = 4096, + TYPE_FACTS_TYPEOF_NE_OBJECT = 8192, + TYPE_FACTS_TYPEOF_NE_FUNCTION = 16384, + TYPE_FACTS_TYPEOF_NE_HOST_OBJECT = 32768, + TYPE_FACTS_EQ_UNDEFINED = 65536, + TYPE_FACTS_EQ_NULL = 131072, + TYPE_FACTS_EQ_UNDEFINED_OR_NULL = 262144, + TYPE_FACTS_NE_UNDEFINED = 524288, + TYPE_FACTS_NE_NULL = 1048576, + TYPE_FACTS_NE_UNDEFINED_OR_NULL = 2097152, + TYPE_FACTS_TRUTHY = 4194304, + TYPE_FACTS_FALSY = 8388608, + TYPE_FACTS_ALL = 16777216, + TYPE_FACTS_LAST = 8388608, + TYPE_FACTS_BASE_NUMBER_STRICT_FACTS = 3734786, + TYPE_FACTS_BASE_NUMBER_FACTS = 12582146, + TYPE_FACTS_NUMBER_FACTS = 16776450, + TYPE_FACTS_ZERO_NUMBER_STRICT_FACTS = 12123394, + TYPE_FACTS_ZERO_NUMBER_FACTS = 12582146, + TYPE_FACTS_NON_ZERO_NUMBER_FACTS = 16776450, + TYPE_FACTS_BASE_STRING_STRICT_FACTS = 3735041, + TYPE_FACTS_BASE_STRING_FACTS = 12582401, + TYPE_FACTS_STRING_FACTS = 16776705, + TYPE_FACTS_EMPTY_STRING_STRICT_FACTS = 16317953, + TYPE_FACTS_EMPTY_STRING_FACTS = 12582401, + TYPE_FACTS_NON_EMPTY_STRING_FACTS = 16776705, + TYPE_FACTS_BASE_BIGINT_STRICT_FACTS = 3734276, + TYPE_FACTS_BASE_BIGINT_FACTS = 12581636, + TYPE_FACTS_BIGINT_FACTS = 16775940, + TYPE_FACTS_ZERO_BIGINT_STRICT_FACTS = 12122884, + TYPE_FACTS_ZERO_BIGINT_FACTS = 12581636, + TYPE_FACTS_NON_ZERO_BIGINT_FACTS = 16775940, + TYPE_FACTS_BASE_BOOLEAN_STRICT_FACTS = 3733256, + TYPE_FACTS_BASE_BOOLEAN_FACTS = 12580616, + TYPE_FACTS_BOOLEAN_FACTS = 16774920, + TYPE_FACTS_FALSE_STRICT_FACTS = 12121864, + TYPE_FACTS_FALSE_FACTS = 12580616, + TYPE_FACTS_TRUE_STRICT_FACTS = 7927560, + TYPE_FACTS_TRUE_FACTS = 16774920, + TYPE_FACTS_OBJECT_STRICT_FACTS = 7888800, + TYPE_FACTS_OBJECT_FACTS = 16736160, + TYPE_FACTS_EMPTY_OBJECT_FACTS = 16777216, + TYPE_FACTS_FUNCTION_STRICT_FACTS = 7880640, + TYPE_FACTS_FUNCTION_FACTS = 16728000, + TYPE_FACTS_UNDEFINED_FACTS = 9830144, + TYPE_FACTS_NULL_FACTS = 9363232 +} +export enum Es2pandaGlobalTypeId { + GLOBAL_TYPE_ID_NUMBER = 0, + GLOBAL_TYPE_ID_ANY = 1, + GLOBAL_TYPE_ID_STRING = 2, + GLOBAL_TYPE_ID_BOOLEAN = 3, + GLOBAL_TYPE_ID_VOID = 4, + GLOBAL_TYPE_ID_NULL_ID = 5, + GLOBAL_TYPE_ID_UNDEFINED = 6, + GLOBAL_TYPE_ID_UNKNOWN = 7, + GLOBAL_TYPE_ID_NEVER = 8, + GLOBAL_TYPE_ID_NON_PRIMITIVE = 9, + GLOBAL_TYPE_ID_BIGINT = 10, + GLOBAL_TYPE_ID_FALSE_ID = 11, + GLOBAL_TYPE_ID_TRUE_ID = 12, + GLOBAL_TYPE_ID_NUMBER_OR_BIGINT = 13, + GLOBAL_TYPE_ID_STRING_OR_NUMBER = 14, + GLOBAL_TYPE_ID_ZERO = 15, + GLOBAL_TYPE_ID_EMPTY_STRING = 16, + GLOBAL_TYPE_ID_ZERO_BIGINT = 17, + GLOBAL_TYPE_ID_PRIMITIVE = 18, + GLOBAL_TYPE_ID_EMPTY_TUPLE = 19, + GLOBAL_TYPE_ID_EMPTY_OBJECT = 20, + GLOBAL_TYPE_ID_RESOLVING_RETURN_TYPE = 21, + GLOBAL_TYPE_ID_ERROR_TYPE = 22, + GLOBAL_TYPE_ID_BYTE = 23, + GLOBAL_TYPE_ID_SHORT = 24, + GLOBAL_TYPE_ID_INT = 25, + GLOBAL_TYPE_ID_LONG = 26, + GLOBAL_TYPE_ID_FLOAT = 27, + GLOBAL_TYPE_ID_DOUBLE = 28, + GLOBAL_TYPE_ID_CHAR = 29, + GLOBAL_TYPE_ID_ETS_BOOLEAN = 30, + GLOBAL_TYPE_ID_ETS_STRING = 31, + GLOBAL_TYPE_ID_ETS_VOID = 32, + GLOBAL_TYPE_ID_ETS_OBJECT_BUILTIN = 33, + GLOBAL_TYPE_ID_ETS_NULL = 34, + GLOBAL_TYPE_ID_ETS_UNDEFINED = 35, + GLOBAL_TYPE_ID_ETS_NULLISH_TYPE = 36, + GLOBAL_TYPE_ID_ETS_NEVER = 37, + GLOBAL_TYPE_ID_ETS_NULLISH_OBJECT = 38, + GLOBAL_TYPE_ID_ETS_WILDCARD = 39, + GLOBAL_TYPE_ID_ETS_BOOLEAN_BUILTIN = 40, + GLOBAL_TYPE_ID_ETS_BYTE_BUILTIN = 41, + GLOBAL_TYPE_ID_ETS_CHAR_BUILTIN = 42, + GLOBAL_TYPE_ID_ETS_COMPARABLE_BUILTIN = 43, + GLOBAL_TYPE_ID_ETS_CONSOLE_BUILTIN = 44, + GLOBAL_TYPE_ID_ETS_DATE_BUILTIN = 45, + GLOBAL_TYPE_ID_ETS_DOUBLE_BUILTIN = 46, + GLOBAL_TYPE_ID_ETS_EXCEPTION_BUILTIN = 47, + GLOBAL_TYPE_ID_ETS_FLOAT_BUILTIN = 48, + GLOBAL_TYPE_ID_ETS_FLOATING_BUILTIN = 49, + GLOBAL_TYPE_ID_ETS_INT_BUILTIN = 50, + GLOBAL_TYPE_ID_ETS_INTEGRAL_BUILTIN = 51, + GLOBAL_TYPE_ID_ETS_LONG_BUILTIN = 52, + GLOBAL_TYPE_ID_ETS_MAP_BUILTIN = 53, + GLOBAL_TYPE_ID_ETS_ERROR_BUILTIN = 54, + GLOBAL_TYPE_ID_ETS_RUNTIME_BUILTIN = 55, + GLOBAL_TYPE_ID_ETS_RUNTIME_LINKER_BUILTIN = 56, + GLOBAL_TYPE_ID_ETS_SET_BUILTIN = 57, + GLOBAL_TYPE_ID_ETS_SHORT_BUILTIN = 58, + GLOBAL_TYPE_ID_ETS_STACK_TRACE_ELEMENT_BUILTIN = 59, + GLOBAL_TYPE_ID_ETS_STACK_TRACE_BUILTIN = 60, + GLOBAL_TYPE_ID_ETS_ARRAY_INDEX_OUT_OF_BOUNDS_ERROR_BUILTIN = 61, + GLOBAL_TYPE_ID_ETS_ARITHMETIC_ERROR_BUILTIN = 62, + GLOBAL_TYPE_ID_ETS_CLASS_CAST_ERROR_BUILTIN = 63, + GLOBAL_TYPE_ID_ETS_ASSERTION_ERROR_BUILTIN = 64, + GLOBAL_TYPE_ID_ETS_DIVIDE_BY_ZERO_ERROR_BUILTIN = 65, + GLOBAL_TYPE_ID_ETS_NULL_POINTER_ERROR_BUILTIN = 66, + GLOBAL_TYPE_ID_ETS_UNCAUGHT_EXCEPTION_ERROR_BUILTIN = 67, + GLOBAL_TYPE_ID_ETS_STRING_BUILTIN = 68, + GLOBAL_TYPE_ID_ETS_STRING_BUILDER_BUILTIN = 69, + GLOBAL_TYPE_ID_ETS_TYPE_BUILTIN = 70, + GLOBAL_TYPE_ID_ETS_TYPES_BUILTIN = 71, + GLOBAL_TYPE_ID_ETS_PROMISE_BUILTIN = 72, + GLOBAL_TYPE_ID_ETS_FUNCTION_BUILTIN = 73, + GLOBAL_TYPE_ID_ETS_REGEXP_BUILTIN = 74, + GLOBAL_TYPE_ID_ETS_ARRAY_BUILTIN = 75, + GLOBAL_TYPE_ID_ETS_ARRAY = 76, + GLOBAL_TYPE_ID_ETS_INTEROP_JSRUNTIME_BUILTIN = 77, + GLOBAL_TYPE_ID_ETS_INTEROP_JSVALUE_BUILTIN = 78, + GLOBAL_TYPE_ID_ETS_BOX_BUILTIN = 79, + GLOBAL_TYPE_ID_ETS_BOOLEAN_BOX_BUILTIN = 80, + GLOBAL_TYPE_ID_ETS_BYTE_BOX_BUILTIN = 81, + GLOBAL_TYPE_ID_ETS_CHAR_BOX_BUILTIN = 82, + GLOBAL_TYPE_ID_ETS_SHORT_BOX_BUILTIN = 83, + GLOBAL_TYPE_ID_ETS_INT_BOX_BUILTIN = 84, + GLOBAL_TYPE_ID_ETS_LONG_BOX_BUILTIN = 85, + GLOBAL_TYPE_ID_ETS_FLOAT_BOX_BUILTIN = 86, + GLOBAL_TYPE_ID_ETS_DOUBLE_BOX_BUILTIN = 87, + GLOBAL_TYPE_ID_ETS_BIG_INT_BUILTIN = 88, + GLOBAL_TYPE_ID_ETS_BIG_INT = 89, + GLOBAL_TYPE_ID_ETS_FUNCTION0_CLASS = 90, + GLOBAL_TYPE_ID_ETS_FUNCTION1_CLASS = 91, + GLOBAL_TYPE_ID_ETS_FUNCTION2_CLASS = 92, + GLOBAL_TYPE_ID_ETS_FUNCTION3_CLASS = 93, + GLOBAL_TYPE_ID_ETS_FUNCTION4_CLASS = 94, + GLOBAL_TYPE_ID_ETS_FUNCTION5_CLASS = 95, + GLOBAL_TYPE_ID_ETS_FUNCTION6_CLASS = 96, + GLOBAL_TYPE_ID_ETS_FUNCTION7_CLASS = 97, + GLOBAL_TYPE_ID_ETS_FUNCTION8_CLASS = 98, + GLOBAL_TYPE_ID_ETS_FUNCTION9_CLASS = 99, + GLOBAL_TYPE_ID_ETS_FUNCTION10_CLASS = 100, + GLOBAL_TYPE_ID_ETS_FUNCTION11_CLASS = 101, + GLOBAL_TYPE_ID_ETS_FUNCTION12_CLASS = 102, + GLOBAL_TYPE_ID_ETS_FUNCTION13_CLASS = 103, + GLOBAL_TYPE_ID_ETS_FUNCTION14_CLASS = 104, + GLOBAL_TYPE_ID_ETS_FUNCTION15_CLASS = 105, + GLOBAL_TYPE_ID_ETS_FUNCTION16_CLASS = 106, + GLOBAL_TYPE_ID_ETS_FUNCTIONN_CLASS = 107, + GLOBAL_TYPE_ID_ETS_LAMBDA0_CLASS = 108, + GLOBAL_TYPE_ID_ETS_LAMBDA1_CLASS = 109, + GLOBAL_TYPE_ID_ETS_LAMBDA2_CLASS = 110, + GLOBAL_TYPE_ID_ETS_LAMBDA3_CLASS = 111, + GLOBAL_TYPE_ID_ETS_LAMBDA4_CLASS = 112, + GLOBAL_TYPE_ID_ETS_LAMBDA5_CLASS = 113, + GLOBAL_TYPE_ID_ETS_LAMBDA6_CLASS = 114, + GLOBAL_TYPE_ID_ETS_LAMBDA7_CLASS = 115, + GLOBAL_TYPE_ID_ETS_LAMBDA8_CLASS = 116, + GLOBAL_TYPE_ID_ETS_LAMBDA9_CLASS = 117, + GLOBAL_TYPE_ID_ETS_LAMBDA10_CLASS = 118, + GLOBAL_TYPE_ID_ETS_LAMBDA11_CLASS = 119, + GLOBAL_TYPE_ID_ETS_LAMBDA12_CLASS = 120, + GLOBAL_TYPE_ID_ETS_LAMBDA13_CLASS = 121, + GLOBAL_TYPE_ID_ETS_LAMBDA14_CLASS = 122, + GLOBAL_TYPE_ID_ETS_LAMBDA15_CLASS = 123, + GLOBAL_TYPE_ID_ETS_LAMBDA16_CLASS = 124, + GLOBAL_TYPE_ID_ETS_LAMBDAN_CLASS = 125, + GLOBAL_TYPE_ID_ETS_FUNCTIONR0_CLASS = 126, + GLOBAL_TYPE_ID_ETS_FUNCTIONR1_CLASS = 127, + GLOBAL_TYPE_ID_ETS_FUNCTIONR2_CLASS = 128, + GLOBAL_TYPE_ID_ETS_FUNCTIONR3_CLASS = 129, + GLOBAL_TYPE_ID_ETS_FUNCTIONR4_CLASS = 130, + GLOBAL_TYPE_ID_ETS_FUNCTIONR5_CLASS = 131, + GLOBAL_TYPE_ID_ETS_FUNCTIONR6_CLASS = 132, + GLOBAL_TYPE_ID_ETS_FUNCTIONR7_CLASS = 133, + GLOBAL_TYPE_ID_ETS_FUNCTIONR8_CLASS = 134, + GLOBAL_TYPE_ID_ETS_FUNCTIONR9_CLASS = 135, + GLOBAL_TYPE_ID_ETS_FUNCTIONR10_CLASS = 136, + GLOBAL_TYPE_ID_ETS_FUNCTIONR11_CLASS = 137, + GLOBAL_TYPE_ID_ETS_FUNCTIONR12_CLASS = 138, + GLOBAL_TYPE_ID_ETS_FUNCTIONR13_CLASS = 139, + GLOBAL_TYPE_ID_ETS_FUNCTIONR14_CLASS = 140, + GLOBAL_TYPE_ID_ETS_FUNCTIONR15_CLASS = 141, + GLOBAL_TYPE_ID_ETS_FUNCTIONR16_CLASS = 142, + GLOBAL_TYPE_ID_ETS_LAMBDAR0_CLASS = 143, + GLOBAL_TYPE_ID_ETS_LAMBDAR1_CLASS = 144, + GLOBAL_TYPE_ID_ETS_LAMBDAR2_CLASS = 145, + GLOBAL_TYPE_ID_ETS_LAMBDAR3_CLASS = 146, + GLOBAL_TYPE_ID_ETS_LAMBDAR4_CLASS = 147, + GLOBAL_TYPE_ID_ETS_LAMBDAR5_CLASS = 148, + GLOBAL_TYPE_ID_ETS_LAMBDAR6_CLASS = 149, + GLOBAL_TYPE_ID_ETS_LAMBDAR7_CLASS = 150, + GLOBAL_TYPE_ID_ETS_LAMBDAR8_CLASS = 151, + GLOBAL_TYPE_ID_ETS_LAMBDAR9_CLASS = 152, + GLOBAL_TYPE_ID_ETS_LAMBDAR10_CLASS = 153, + GLOBAL_TYPE_ID_ETS_LAMBDAR11_CLASS = 154, + GLOBAL_TYPE_ID_ETS_LAMBDAR12_CLASS = 155, + GLOBAL_TYPE_ID_ETS_LAMBDAR13_CLASS = 156, + GLOBAL_TYPE_ID_ETS_LAMBDAR14_CLASS = 157, + GLOBAL_TYPE_ID_ETS_LAMBDAR15_CLASS = 158, + GLOBAL_TYPE_ID_ETS_LAMBDAR16_CLASS = 159, + GLOBAL_TYPE_ID_ETS_TUPLE0_CLASS = 160, + GLOBAL_TYPE_ID_ETS_TUPLE1_CLASS = 161, + GLOBAL_TYPE_ID_ETS_TUPLE2_CLASS = 162, + GLOBAL_TYPE_ID_ETS_TUPLE3_CLASS = 163, + GLOBAL_TYPE_ID_ETS_TUPLE4_CLASS = 164, + GLOBAL_TYPE_ID_ETS_TUPLE5_CLASS = 165, + GLOBAL_TYPE_ID_ETS_TUPLE6_CLASS = 166, + GLOBAL_TYPE_ID_ETS_TUPLE7_CLASS = 167, + GLOBAL_TYPE_ID_ETS_TUPLE8_CLASS = 168, + GLOBAL_TYPE_ID_ETS_TUPLE9_CLASS = 169, + GLOBAL_TYPE_ID_ETS_TUPLE10_CLASS = 170, + GLOBAL_TYPE_ID_ETS_TUPLE11_CLASS = 171, + GLOBAL_TYPE_ID_ETS_TUPLE12_CLASS = 172, + GLOBAL_TYPE_ID_ETS_TUPLE13_CLASS = 173, + GLOBAL_TYPE_ID_ETS_TUPLE14_CLASS = 174, + GLOBAL_TYPE_ID_ETS_TUPLE15_CLASS = 175, + GLOBAL_TYPE_ID_ETS_TUPLE16_CLASS = 176, + GLOBAL_TYPE_ID_ETS_TUPLEN_CLASS = 177, + GLOBAL_TYPE_ID_TYPE_ERROR = 178, + GLOBAL_TYPE_ID_COUNT = 179 +} +export enum Es2pandaMethodDefinitionKind { + METHOD_DEFINITION_KIND_NONE = 0, + METHOD_DEFINITION_KIND_CONSTRUCTOR = 1, + METHOD_DEFINITION_KIND_METHOD = 2, + METHOD_DEFINITION_KIND_EXTENSION_METHOD = 3, + METHOD_DEFINITION_KIND_GET = 4, + METHOD_DEFINITION_KIND_SET = 5, + METHOD_DEFINITION_KIND_EXTENSION_GET = 6, + METHOD_DEFINITION_KIND_EXTENSION_SET = 7 +} +export enum Es2pandaPropertySearchFlags { + PROPERTY_SEARCH_FLAGS_NO_OPTS = 0, + PROPERTY_SEARCH_FLAGS_SEARCH_INSTANCE_METHOD = 1, + PROPERTY_SEARCH_FLAGS_SEARCH_INSTANCE_FIELD = 2, + PROPERTY_SEARCH_FLAGS_SEARCH_INSTANCE_DECL = 4, + PROPERTY_SEARCH_FLAGS_SEARCH_STATIC_METHOD = 8, + PROPERTY_SEARCH_FLAGS_SEARCH_STATIC_FIELD = 16, + PROPERTY_SEARCH_FLAGS_SEARCH_STATIC_DECL = 32, + PROPERTY_SEARCH_FLAGS_SEARCH_IN_BASE = 64, + PROPERTY_SEARCH_FLAGS_SEARCH_IN_INTERFACES = 128, + PROPERTY_SEARCH_FLAGS_IGNORE_ABSTRACT = 256, + PROPERTY_SEARCH_FLAGS_ALLOW_FUNCTIONAL_INTERFACE = 512, + PROPERTY_SEARCH_FLAGS_DISALLOW_SYNTHETIC_METHOD_CREATION = 1024, + PROPERTY_SEARCH_FLAGS_IS_SETTER = 2048, + PROPERTY_SEARCH_FLAGS_IS_GETTER = 4096, + PROPERTY_SEARCH_FLAGS_SEARCH_INSTANCE = 7, + PROPERTY_SEARCH_FLAGS_SEARCH_STATIC = 56, + PROPERTY_SEARCH_FLAGS_SEARCH_METHOD = 9, + PROPERTY_SEARCH_FLAGS_SEARCH_FIELD = 18, + PROPERTY_SEARCH_FLAGS_SEARCH_DECL = 36, + PROPERTY_SEARCH_FLAGS_SEARCH_ALL = 63 +} +export enum Es2pandaPropertyType { + PROPERTY_TYPE_INSTANCE_METHOD = 0, + PROPERTY_TYPE_INSTANCE_FIELD = 1, + PROPERTY_TYPE_INSTANCE_DECL = 2, + PROPERTY_TYPE_STATIC_METHOD = 3, + PROPERTY_TYPE_STATIC_FIELD = 4, + PROPERTY_TYPE_STATIC_DECL = 5, + PROPERTY_TYPE_COUNT = 6 +} +export enum Es2pandaVariableDeclarationKind { + VARIABLE_DECLARATION_KIND_CONST = 0, + VARIABLE_DECLARATION_KIND_LET = 1, + VARIABLE_DECLARATION_KIND_VAR = 2 +} +export enum Es2pandaAccessibilityOption { + ACCESSIBILITY_OPTION_NO_OPTS = 0, + ACCESSIBILITY_OPTION_PUBLIC = 1, + ACCESSIBILITY_OPTION_PRIVATE = 2, + ACCESSIBILITY_OPTION_PROTECTED = 3 +} +export enum Es2pandaRetentionPolicy { + RETENTION_POLICY_SOURCE = 0, + RETENTION_POLICY_BYTECODE = 1, + RETENTION_POLICY_RUNTIME = 2 +} +export enum Es2pandaRecordTableFlags { + RECORD_TABLE_FLAGS_NONE = 0, + RECORD_TABLE_FLAGS_EXTERNAL = 1 +} +export enum Es2pandaCheckerStatus { + CHECKER_STATUS_NO_OPTS = 0, + CHECKER_STATUS_FORCE_TUPLE = 1, + CHECKER_STATUS_IN_CONST_CONTEXT = 2, + CHECKER_STATUS_KEEP_LITERAL_TYPE = 4, + CHECKER_STATUS_IN_PARAMETER = 8, + CHECKER_STATUS_IN_CLASS = 16, + CHECKER_STATUS_IN_INTERFACE = 32, + CHECKER_STATUS_IN_ABSTRACT = 64, + CHECKER_STATUS_IN_STATIC_CONTEXT = 128, + CHECKER_STATUS_IN_CONSTRUCTOR = 256, + CHECKER_STATUS_IN_STATIC_BLOCK = 512, + CHECKER_STATUS_INNER_CLASS = 1024, + CHECKER_STATUS_IN_ENUM = 2048, + CHECKER_STATUS_BUILTINS_INITIALIZED = 4096, + CHECKER_STATUS_IN_LAMBDA = 8192, + CHECKER_STATUS_IGNORE_VISIBILITY = 16384, + CHECKER_STATUS_IN_EXTENSION_METHOD = 32768, + CHECKER_STATUS_IN_LOCAL_CLASS = 65536, + CHECKER_STATUS_IN_INSTANCEOF_CONTEXT = 131072, + CHECKER_STATUS_IN_TEST_EXPRESSION = 262144, + CHECKER_STATUS_IN_LOOP = 524288, + CHECKER_STATUS_MEET_RETURN = 1048576, + CHECKER_STATUS_MEET_BREAK = 2097152, + CHECKER_STATUS_MEET_CONTINUE = 4194304, + CHECKER_STATUS_MEET_THROW = 8388608, + CHECKER_STATUS_IN_EXTERNAL = 16777216, + CHECKER_STATUS_IN_BRIDGE_TEST = 33554432, + CHECKER_STATUS_IN_GETTER = 67108864, + CHECKER_STATUS_IN_SETTER = 134217728, + CHECKER_STATUS_IN_EXTENSION_ACCESSOR_CHECK = 268435456, + CHECKER_STATUS_IN_TYPE_INFER = 536870912 +} +export enum Es2pandaOverrideErrorCode { + OVERRIDE_ERROR_CODE_NO_ERROR = 0, + OVERRIDE_ERROR_CODE_OVERRIDDEN_FINAL = 1, + OVERRIDE_ERROR_CODE_INCOMPATIBLE_RETURN = 2, + OVERRIDE_ERROR_CODE_INCOMPATIBLE_TYPEPARAM = 3, + OVERRIDE_ERROR_CODE_OVERRIDDEN_WEAKER = 4, + OVERRIDE_ERROR_CODE_OVERRIDDEN_INTERNAL = 5, + OVERRIDE_ERROR_CODE_ABSTRACT_OVERRIDES_CONCRETE = 6 +} +export enum Es2pandaResolvedKind { + RESOLVED_KIND_PROPERTY = 0, + RESOLVED_KIND_EXTENSION_FUNCTION = 1, + RESOLVED_KIND_EXTENSION_ACCESSOR = 2 +} +export enum Es2pandaLexicalScopeType { + LEXICAL_SCOPE_TYPE_BLOCK = 0, + LEXICAL_SCOPE_TYPE_STRICT_BLOCK = 1, + LEXICAL_SCOPE_TYPE_CATCH = 2, + LEXICAL_SCOPE_TYPE_FUNCTION_PARAM = 3, + LEXICAL_SCOPE_TYPE_TS_TYPE_LITERAL = 4 +} +export enum Es2pandaVariableParsingFlags { + VARIABLE_PARSING_FLAGS_NO_OPTS = 0, + VARIABLE_PARSING_FLAGS_NO_SKIP_VAR_KIND = 1, + VARIABLE_PARSING_FLAGS_ACCEPT_CONST_NO_INIT = 2, + VARIABLE_PARSING_FLAGS_DISALLOW_INIT = 4, + VARIABLE_PARSING_FLAGS_VAR = 8, + VARIABLE_PARSING_FLAGS_LET = 16, + VARIABLE_PARSING_FLAGS_CONST = 32, + VARIABLE_PARSING_FLAGS_STOP_AT_IN = 64, + VARIABLE_PARSING_FLAGS_IN_FOR = 128, + VARIABLE_PARSING_FLAGS_FOR_OF = 256 +} +export enum Es2pandaExpressionParseFlags { + EXPRESSION_PARSE_FLAGS_NO_OPTS = 0, + EXPRESSION_PARSE_FLAGS_ACCEPT_COMMA = 1, + EXPRESSION_PARSE_FLAGS_ACCEPT_REST = 2, + EXPRESSION_PARSE_FLAGS_EXP_DISALLOW_AS = 4, + EXPRESSION_PARSE_FLAGS_DISALLOW_ASSIGNMENT = 8, + EXPRESSION_PARSE_FLAGS_DISALLOW_YIELD = 16, + EXPRESSION_PARSE_FLAGS_STOP_AT_IN = 32, + EXPRESSION_PARSE_FLAGS_MUST_BE_PATTERN = 64, + EXPRESSION_PARSE_FLAGS_POTENTIALLY_IN_PATTERN = 128, + EXPRESSION_PARSE_FLAGS_OBJECT_PATTERN = 256, + EXPRESSION_PARSE_FLAGS_IN_REST = 512, + EXPRESSION_PARSE_FLAGS_IMPORT = 1024, + EXPRESSION_PARSE_FLAGS_POTENTIAL_CLASS_LITERAL = 2048, + EXPRESSION_PARSE_FLAGS_IN_FOR = 4096, + EXPRESSION_PARSE_FLAGS_INSTANCEOF = 8192, + EXPRESSION_PARSE_FLAGS_POTENTIAL_NEW_ARRAY = 16384 +} +export enum Es2pandaStatementParsingFlags { + STATEMENT_PARSING_FLAGS_NONE = 0, + STATEMENT_PARSING_FLAGS_ALLOW_LEXICAL = 1, + STATEMENT_PARSING_FLAGS_GLOBAL = 2, + STATEMENT_PARSING_FLAGS_IF_ELSE = 4, + STATEMENT_PARSING_FLAGS_LABELLED = 8, + STATEMENT_PARSING_FLAGS_STMT_LEXICAL_SCOPE_NEEDED = 12, + STATEMENT_PARSING_FLAGS_STMT_GLOBAL_LEXICAL = 3 +} +export enum Es2pandaForStatementKind { + FOR_STATEMENT_KIND_UPDATE = 0, + FOR_STATEMENT_KIND_IN = 1, + FOR_STATEMENT_KIND_OF = 2 +} +export enum Es2pandaTypeAnnotationParsingOptions { + TYPE_ANNOTATION_PARSING_OPTIONS_NO_OPTS = 0, + TYPE_ANNOTATION_PARSING_OPTIONS_IN_UNION = 1, + TYPE_ANNOTATION_PARSING_OPTIONS_ALLOW_CONST = 2, + TYPE_ANNOTATION_PARSING_OPTIONS_IN_INTERSECTION = 4, + TYPE_ANNOTATION_PARSING_OPTIONS_RESTRICT_EXTENDS = 8, + TYPE_ANNOTATION_PARSING_OPTIONS_REPORT_ERROR = 16, + TYPE_ANNOTATION_PARSING_OPTIONS_CAN_BE_TS_TYPE_PREDICATE = 32, + TYPE_ANNOTATION_PARSING_OPTIONS_BREAK_AT_NEW_LINE = 64, + TYPE_ANNOTATION_PARSING_OPTIONS_RETURN_TYPE = 128, + TYPE_ANNOTATION_PARSING_OPTIONS_POTENTIAL_CLASS_LITERAL = 256, + TYPE_ANNOTATION_PARSING_OPTIONS_ALLOW_INTERSECTION = 512, + TYPE_ANNOTATION_PARSING_OPTIONS_ADD_TYPE_PARAMETER_BINDING = 1024, + TYPE_ANNOTATION_PARSING_OPTIONS_DISALLOW_PRIMARY_TYPE = 2048, + TYPE_ANNOTATION_PARSING_OPTIONS_ALLOW_WILDCARD = 4096, + TYPE_ANNOTATION_PARSING_OPTIONS_IGNORE_FUNCTION_TYPE = 8192, + TYPE_ANNOTATION_PARSING_OPTIONS_ALLOW_DECLARATION_SITE_VARIANCE = 16384, + TYPE_ANNOTATION_PARSING_OPTIONS_DISALLOW_UNION = 32768, + TYPE_ANNOTATION_PARSING_OPTIONS_POTENTIAL_NEW_ARRAY = 65536, + TYPE_ANNOTATION_PARSING_OPTIONS_ANNOTATION_NOT_ALLOW = 131072 +} +export enum Es2pandaScriptKind { + SCRIPT_KIND_SCRIPT = 0, + SCRIPT_KIND_MODULE = 1, + SCRIPT_KIND_STDLIB = 2 +} +export enum Es2pandaEntityType { + ENTITY_TYPE_CLASS_PROPERTY = 0, + ENTITY_TYPE_METHOD_DEFINITION = 1, + ENTITY_TYPE_CLASS_DEFINITION = 2, + ENTITY_TYPE_TS_INTERFACE_DECLARATION = 3 +} +export enum Es2pandaCompilationMode { + COMPILATION_MODE_GEN_STD_LIB = 0, + COMPILATION_MODE_PROJECT = 1, + COMPILATION_MODE_SINGLE_FILE = 2 +} +export enum Es2pandaImportFlags { + IMPORT_FLAGS_NONE = 0, + IMPORT_FLAGS_DEFAULT_IMPORT = 1, + IMPORT_FLAGS_IMPLICIT_PACKAGE_IMPORT = 2 +} +export enum Es2pandaModuleKind { + MODULE_KIND_MODULE = 0, + MODULE_KIND_DECLARATION = 1, + MODULE_KIND_PACKAGE = 2 +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/Es2pandaNativeModule.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/Es2pandaNativeModule.ts new file mode 100644 index 0000000000000000000000000000000000000000..278c8ec0df022af199b807b1bbd3350137c652c5 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/Es2pandaNativeModule.ts @@ -0,0 +1,3895 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + KNativePointer, + KStringPtr, + KUInt, + KInt, + KBoolean, + KDouble, + KFloat, + KLong +} from "@koalaui/interop" + +// TODO: this type should be in interop +export type KNativePointerArray = BigUint64Array + +export class Es2pandaNativeModule { + _NumberLiteralStrConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateNumberLiteral(context: KNativePointer, value: KInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateNumberLiteral1(context: KNativePointer, value: KLong): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateNumberLiteral2(context: KNativePointer, value: KDouble): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateNumberLiteral3(context: KNativePointer, value: KFloat): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateNumberLiteral(context: KNativePointer, original: KNativePointer, value: KInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateNumberLiteral1(context: KNativePointer, original: KNativePointer, value: KLong): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateNumberLiteral2(context: KNativePointer, original: KNativePointer, value: KDouble): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateNumberLiteral3(context: KNativePointer, original: KNativePointer, value: KFloat): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateLabelledStatement(context: KNativePointer, ident: KNativePointer, body: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateLabelledStatement(context: KNativePointer, original: KNativePointer, ident: KNativePointer, body: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _LabelledStatementBody(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _LabelledStatementBodyConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _LabelledStatementIdentConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _LabelledStatementIdent(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _LabelledStatementGetReferencedStatementConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateThrowStatement(context: KNativePointer, argument: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateThrowStatement(context: KNativePointer, original: KNativePointer, argument: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ThrowStatementArgumentConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateClassProperty(context: KNativePointer, key: KNativePointer, value: KNativePointer, typeAnnotation: KNativePointer, modifiers: KInt, isComputed: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateClassProperty(context: KNativePointer, original: KNativePointer, key: KNativePointer, value: KNativePointer, typeAnnotation: KNativePointer, modifiers: KInt, isComputed: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassPropertyIsDefaultAccessModifierConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassPropertySetDefaultAccessModifier(context: KNativePointer, receiver: KNativePointer, isDefault: KBoolean): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassPropertyTypeAnnotationConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassPropertySetTypeAnnotation(context: KNativePointer, receiver: KNativePointer, typeAnnotation: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassPropertyNeedInitInStaticBlockConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassPropertySetInitInStaticBlock(context: KNativePointer, receiver: KNativePointer, needInitInStaticBlock: KBoolean): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassPropertyAnnotations(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassPropertyAnnotationsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassPropertySetAnnotations(context: KNativePointer, receiver: KNativePointer, annotations: BigUint64Array, annotationsSequenceLength: KUInt): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSVoidKeyword(context: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSVoidKeyword(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateETSFunctionType(context: KNativePointer, signature: KNativePointer, funcFlags: KInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateETSFunctionType(context: KNativePointer, original: KNativePointer, signature: KNativePointer, funcFlags: KInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSFunctionTypeTypeParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSFunctionTypeTypeParams(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSFunctionTypeParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSFunctionTypeReturnTypeConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSFunctionTypeReturnType(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSFunctionTypeFunctionalInterface(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSFunctionTypeFunctionalInterfaceConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSFunctionTypeSetFunctionalInterface(context: KNativePointer, receiver: KNativePointer, functionalInterface: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSFunctionTypeFlags(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSFunctionTypeIsThrowingConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSFunctionTypeIsRethrowingConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSFunctionTypeIsExtensionFunctionConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSTypeOperator(context: KNativePointer, type: KNativePointer, operatorType: KInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSTypeOperator(context: KNativePointer, original: KNativePointer, type: KNativePointer, operatorType: KInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSTypeOperatorTypeConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSTypeOperatorIsReadonlyConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSTypeOperatorIsKeyofConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSTypeOperatorIsUniqueConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateIfStatement(context: KNativePointer, test: KNativePointer, consequent: KNativePointer, alternate: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateIfStatement(context: KNativePointer, original: KNativePointer, test: KNativePointer, consequent: KNativePointer, alternate: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _IfStatementTestConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _IfStatementTest(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _IfStatementConsequentConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _IfStatementConsequent(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _IfStatementAlternate(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _IfStatementAlternateConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _IfStatementSetAlternate(context: KNativePointer, receiver: KNativePointer, alternate: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSConstructorType(context: KNativePointer, signature: KNativePointer, abstract: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSConstructorType(context: KNativePointer, original: KNativePointer, signature: KNativePointer, abstract: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSConstructorTypeTypeParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSConstructorTypeTypeParams(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSConstructorTypeParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSConstructorTypeReturnTypeConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSConstructorTypeReturnType(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSConstructorTypeAbstractConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateDecorator(context: KNativePointer, expr: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateDecorator(context: KNativePointer, original: KNativePointer, expr: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _DecoratorExprConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSEnumDeclaration(context: KNativePointer, key: KNativePointer, members: BigUint64Array, membersSequenceLength: KUInt, isConst: KBoolean, isStatic: KBoolean, isDeclare: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSEnumDeclaration(context: KNativePointer, original: KNativePointer, key: KNativePointer, members: BigUint64Array, membersSequenceLength: KUInt, isConst: KBoolean, isStatic: KBoolean, isDeclare: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSEnumDeclarationKeyConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSEnumDeclarationKey(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSEnumDeclarationMembersConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSEnumDeclarationInternalNameConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSEnumDeclarationSetInternalName(context: KNativePointer, receiver: KNativePointer, internalName: KStringPtr): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSEnumDeclarationBoxedClassConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSEnumDeclarationSetBoxedClass(context: KNativePointer, receiver: KNativePointer, wrapperClass: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSEnumDeclarationIsConstConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSEnumDeclarationDecoratorsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSNeverKeyword(context: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSNeverKeyword(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateImportDefaultSpecifier(context: KNativePointer, local: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateImportDefaultSpecifier(context: KNativePointer, original: KNativePointer, local: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ImportDefaultSpecifierLocalConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ImportDefaultSpecifierLocal(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateObjectExpression(context: KNativePointer, nodeType: KInt, properties: BigUint64Array, propertiesSequenceLength: KUInt, trailingComma: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateObjectExpression(context: KNativePointer, original: KNativePointer, nodeType: KInt, properties: BigUint64Array, propertiesSequenceLength: KUInt, trailingComma: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ObjectExpressionPropertiesConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ObjectExpressionIsDeclarationConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ObjectExpressionIsOptionalConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ObjectExpressionDecoratorsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ObjectExpressionValidateExpression(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ObjectExpressionConvertibleToObjectPattern(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ObjectExpressionSetDeclaration(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ObjectExpressionSetOptional(context: KNativePointer, receiver: KNativePointer, optional_arg: KBoolean): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ObjectExpressionTypeAnnotationConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ObjectExpressionSetTsTypeAnnotation(context: KNativePointer, receiver: KNativePointer, typeAnnotation: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateImportSpecifier(context: KNativePointer, imported: KNativePointer, local: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateImportSpecifier(context: KNativePointer, original: KNativePointer, imported: KNativePointer, local: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ImportSpecifierImported(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ImportSpecifierImportedConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ImportSpecifierLocal(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ImportSpecifierLocalConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ImportSpecifierIsRemovableConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ImportSpecifierSetRemovable(context: KNativePointer, receiver: KNativePointer, isRemovable: KBoolean): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateConditionalExpression(context: KNativePointer, test: KNativePointer, consequent: KNativePointer, alternate: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateConditionalExpression(context: KNativePointer, original: KNativePointer, test: KNativePointer, consequent: KNativePointer, alternate: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ConditionalExpressionTestConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ConditionalExpressionTest(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ConditionalExpressionSetTest(context: KNativePointer, receiver: KNativePointer, expr: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ConditionalExpressionConsequentConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ConditionalExpressionConsequent(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ConditionalExpressionSetConsequent(context: KNativePointer, receiver: KNativePointer, expr: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ConditionalExpressionAlternateConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ConditionalExpressionAlternate(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ConditionalExpressionSetAlternate(context: KNativePointer, receiver: KNativePointer, expr: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateCallExpression(context: KNativePointer, callee: KNativePointer, _arguments: BigUint64Array, _argumentsSequenceLength: KUInt, typeParams: KNativePointer, optional_arg: KBoolean, trailingComma: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateCallExpression1(context: KNativePointer, other: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateCallExpression1(context: KNativePointer, original: KNativePointer, other: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CallExpressionCalleeConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CallExpressionCallee(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CallExpressionSetCallee(context: KNativePointer, receiver: KNativePointer, callee: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _CallExpressionTypeParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CallExpressionTypeParams(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CallExpressionArgumentsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CallExpressionArguments(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CallExpressionHasTrailingCommaConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _CallExpressionSetTypeParams(context: KNativePointer, receiver: KNativePointer, typeParams: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _CallExpressionSetTrailingBlock(context: KNativePointer, receiver: KNativePointer, block: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _CallExpressionIsExtensionAccessorCall(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _CallExpressionTrailingBlockConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CallExpressionSetIsTrailingBlockInNewLine(context: KNativePointer, receiver: KNativePointer, isNewLine: KBoolean): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _CallExpressionIsTrailingBlockInNewLineConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _CallExpressionIsETSConstructorCallConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateBigIntLiteral(context: KNativePointer, src: KStringPtr): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateBigIntLiteral(context: KNativePointer, original: KNativePointer, src: KStringPtr): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _BigIntLiteralStrConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassElementId(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassElementIdConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassElementKey(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassElementKeyConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassElementValue(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassElementSetValue(context: KNativePointer, receiver: KNativePointer, value: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassElementValueConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassElementOriginEnumMemberConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassElementSetOrigEnumMember(context: KNativePointer, receiver: KNativePointer, enumMember: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassElementIsPrivateElementConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassElementDecoratorsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassElementIsComputedConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassElementAddDecorator(context: KNativePointer, receiver: KNativePointer, decorator: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassElementToPrivateFieldKindConst(context: KNativePointer, receiver: KNativePointer, isStatic: KBoolean): KInt { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSImportType(context: KNativePointer, param: KNativePointer, typeParams: KNativePointer, qualifier: KNativePointer, isTypeof: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSImportType(context: KNativePointer, original: KNativePointer, param: KNativePointer, typeParams: KNativePointer, qualifier: KNativePointer, isTypeof: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSImportTypeParamConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSImportTypeTypeParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSImportTypeQualifierConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSImportTypeIsTypeofConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTaggedTemplateExpression(context: KNativePointer, tag: KNativePointer, quasi: KNativePointer, typeParams: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTaggedTemplateExpression(context: KNativePointer, original: KNativePointer, tag: KNativePointer, quasi: KNativePointer, typeParams: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TaggedTemplateExpressionTagConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TaggedTemplateExpressionQuasiConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TaggedTemplateExpressionTypeParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateFunctionDeclaration(context: KNativePointer, func: KNativePointer, annotations: BigUint64Array, annotationsSequenceLength: KUInt, isAnonymous: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateFunctionDeclaration(context: KNativePointer, original: KNativePointer, func: KNativePointer, annotations: BigUint64Array, annotationsSequenceLength: KUInt, isAnonymous: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateFunctionDeclaration1(context: KNativePointer, func: KNativePointer, isAnonymous: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateFunctionDeclaration1(context: KNativePointer, original: KNativePointer, func: KNativePointer, isAnonymous: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _FunctionDeclarationFunction(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _FunctionDeclarationIsAnonymousConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _FunctionDeclarationFunctionConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _FunctionDeclarationAnnotations(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _FunctionDeclarationAnnotationsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _FunctionDeclarationSetAnnotations(context: KNativePointer, receiver: KNativePointer, annotations: BigUint64Array, annotationsSequenceLength: KUInt): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateETSTypeReference(context: KNativePointer, part: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateETSTypeReference(context: KNativePointer, original: KNativePointer, part: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSTypeReferencePart(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSTypeReferencePartConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSTypeReferenceBaseNameConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSTypeReference(context: KNativePointer, typeName: KNativePointer, typeParams: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSTypeReference(context: KNativePointer, original: KNativePointer, typeName: KNativePointer, typeParams: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSTypeReferenceTypeParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSTypeReferenceTypeNameConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSTypeReferenceBaseNameConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateNamedType(context: KNativePointer, name: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateNamedType(context: KNativePointer, original: KNativePointer, name: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _NamedTypeNameConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _NamedTypeTypeParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _NamedTypeIsNullableConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _NamedTypeSetNullable(context: KNativePointer, receiver: KNativePointer, nullable: KBoolean): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _NamedTypeSetNext(context: KNativePointer, receiver: KNativePointer, next: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _NamedTypeSetTypeParams(context: KNativePointer, receiver: KNativePointer, typeParams: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSFunctionType(context: KNativePointer, signature: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSFunctionType(context: KNativePointer, original: KNativePointer, signature: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSFunctionTypeTypeParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSFunctionTypeTypeParams(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSFunctionTypeParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSFunctionTypeReturnTypeConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSFunctionTypeReturnType(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSFunctionTypeSetNullable(context: KNativePointer, receiver: KNativePointer, nullable: KBoolean): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTemplateElement(context: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTemplateElement(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTemplateElement1(context: KNativePointer, raw: KStringPtr, cooked: KStringPtr): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTemplateElement1(context: KNativePointer, original: KNativePointer, raw: KStringPtr, cooked: KStringPtr): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TemplateElementRawConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("This methods was not overloaded by native module initialization") + } + _TemplateElementCookedConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSInterfaceDeclaration(context: KNativePointer, _extends: BigUint64Array, _extendsSequenceLength: KUInt, id: KNativePointer, typeParams: KNativePointer, body: KNativePointer, isStatic: KBoolean, isExternal: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSInterfaceDeclaration(context: KNativePointer, original: KNativePointer, _extends: BigUint64Array, _extendsSequenceLength: KUInt, id: KNativePointer, typeParams: KNativePointer, body: KNativePointer, isStatic: KBoolean, isExternal: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSInterfaceDeclarationBody(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSInterfaceDeclarationBodyConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSInterfaceDeclarationId(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSInterfaceDeclarationIdConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSInterfaceDeclarationInternalNameConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSInterfaceDeclarationSetInternalName(context: KNativePointer, receiver: KNativePointer, internalName: KStringPtr): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSInterfaceDeclarationIsStaticConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSInterfaceDeclarationIsFromExternalConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSInterfaceDeclarationTypeParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSInterfaceDeclarationTypeParams(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSInterfaceDeclarationExtends(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSInterfaceDeclarationExtendsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSInterfaceDeclarationDecoratorsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSInterfaceDeclarationGetAnonClass(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSInterfaceDeclarationGetAnonClassConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSInterfaceDeclarationSetAnonClass(context: KNativePointer, receiver: KNativePointer, anonClass: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSInterfaceDeclarationAnnotations(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSInterfaceDeclarationAnnotationsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSInterfaceDeclarationSetAnnotations(context: KNativePointer, receiver: KNativePointer, annotations: BigUint64Array, annotationsSequenceLength: KUInt): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateVariableDeclaration(context: KNativePointer, kind: KInt, declarators: BigUint64Array, declaratorsSequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateVariableDeclaration(context: KNativePointer, original: KNativePointer, kind: KInt, declarators: BigUint64Array, declaratorsSequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _VariableDeclarationDeclaratorsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _VariableDeclarationKindConst(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("This methods was not overloaded by native module initialization") + } + _VariableDeclarationDecoratorsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _VariableDeclarationGetDeclaratorByNameConst(context: KNativePointer, receiver: KNativePointer, name: KStringPtr): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _VariableDeclarationAnnotations(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _VariableDeclarationAnnotationsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _VariableDeclarationSetAnnotations(context: KNativePointer, receiver: KNativePointer, annotations: BigUint64Array, annotationsSequenceLength: KUInt): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateUndefinedLiteral(context: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateUndefinedLiteral(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateMemberExpression(context: KNativePointer, object_arg: KNativePointer, property: KNativePointer, kind: KInt, computed: KBoolean, optional_arg: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateMemberExpression(context: KNativePointer, original: KNativePointer, object_arg: KNativePointer, property: KNativePointer, kind: KInt, computed: KBoolean, optional_arg: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _MemberExpressionObject(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _MemberExpressionObjectConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _MemberExpressionSetObject(context: KNativePointer, receiver: KNativePointer, object_arg: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _MemberExpressionSetProperty(context: KNativePointer, receiver: KNativePointer, prop: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _MemberExpressionProperty(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _MemberExpressionPropertyConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _MemberExpressionIsComputedConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _MemberExpressionKindConst(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("This methods was not overloaded by native module initialization") + } + _MemberExpressionAddMemberKind(context: KNativePointer, receiver: KNativePointer, kind: KInt): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _MemberExpressionHasMemberKindConst(context: KNativePointer, receiver: KNativePointer, kind: KInt): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _MemberExpressionRemoveMemberKind(context: KNativePointer, receiver: KNativePointer, kind: KInt): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _MemberExpressionExtensionAccessorTypeConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _MemberExpressionIsIgnoreBoxConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _MemberExpressionSetIgnoreBox(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _MemberExpressionIsPrivateReferenceConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _MemberExpressionCompileToRegConst(context: KNativePointer, receiver: KNativePointer, pg: KNativePointer, objReg: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _MemberExpressionCompileToRegsConst(context: KNativePointer, receiver: KNativePointer, pg: KNativePointer, object_arg: KNativePointer, property: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSClassImplements(context: KNativePointer, expression: KNativePointer, typeParameters: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSClassImplements(context: KNativePointer, original: KNativePointer, expression: KNativePointer, typeParameters: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSClassImplements1(context: KNativePointer, expression: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSClassImplements1(context: KNativePointer, original: KNativePointer, expression: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSClassImplementsExpr(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSClassImplementsExprConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSClassImplementsTypeParametersConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSObjectKeyword(context: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSObjectKeyword(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateETSUnionType(context: KNativePointer, types: BigUint64Array, typesSequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateETSUnionType(context: KNativePointer, original: KNativePointer, types: BigUint64Array, typesSequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSUnionTypeTypesConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateETSKeyofType(context: KNativePointer, type: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateETSKeyofType(context: KNativePointer, original: KNativePointer, type: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSKeyofTypeGetTypeRefConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSPropertySignature(context: KNativePointer, key: KNativePointer, typeAnnotation: KNativePointer, computed: KBoolean, optional_arg: KBoolean, readonly_arg: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSPropertySignature(context: KNativePointer, original: KNativePointer, key: KNativePointer, typeAnnotation: KNativePointer, computed: KBoolean, optional_arg: KBoolean, readonly_arg: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSPropertySignatureKeyConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSPropertySignatureKey(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSPropertySignatureComputedConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSPropertySignatureOptionalConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSPropertySignatureReadonlyConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSPropertySignatureTypeAnnotationConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSPropertySignatureSetTsTypeAnnotation(context: KNativePointer, receiver: KNativePointer, typeAnnotation: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSConditionalType(context: KNativePointer, checkType: KNativePointer, extendsType: KNativePointer, trueType: KNativePointer, falseType: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSConditionalType(context: KNativePointer, original: KNativePointer, checkType: KNativePointer, extendsType: KNativePointer, trueType: KNativePointer, falseType: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSConditionalTypeCheckTypeConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSConditionalTypeExtendsTypeConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSConditionalTypeTrueTypeConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSConditionalTypeFalseTypeConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSLiteralType(context: KNativePointer, literal: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSLiteralType(context: KNativePointer, original: KNativePointer, literal: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSLiteralTypeLiteralConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSTypeAliasDeclaration(context: KNativePointer, id: KNativePointer, typeParams: KNativePointer, typeAnnotation: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSTypeAliasDeclaration(context: KNativePointer, original: KNativePointer, id: KNativePointer, typeParams: KNativePointer, typeAnnotation: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSTypeAliasDeclaration1(context: KNativePointer, id: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSTypeAliasDeclaration1(context: KNativePointer, original: KNativePointer, id: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSTypeAliasDeclarationId(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSTypeAliasDeclarationIdConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSTypeAliasDeclarationTypeParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSTypeAliasDeclarationDecoratorsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSTypeAliasDeclarationSetTypeParameters(context: KNativePointer, receiver: KNativePointer, typeParams: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSTypeAliasDeclarationAnnotations(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSTypeAliasDeclarationAnnotationsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSTypeAliasDeclarationSetAnnotations(context: KNativePointer, receiver: KNativePointer, annotations: BigUint64Array, annotationsSequenceLength: KUInt): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSTypeAliasDeclarationTypeAnnotationConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSTypeAliasDeclarationSetTsTypeAnnotation(context: KNativePointer, receiver: KNativePointer, typeAnnotation: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateDebuggerStatement(context: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateDebuggerStatement(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateReturnStatement(context: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateReturnStatement(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateReturnStatement1(context: KNativePointer, argument: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateReturnStatement1(context: KNativePointer, original: KNativePointer, argument: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ReturnStatementArgument(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ReturnStatementArgumentConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ReturnStatementSetArgument(context: KNativePointer, receiver: KNativePointer, arg: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ReturnStatementIsAsyncImplReturnConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateExportDefaultDeclaration(context: KNativePointer, decl: KNativePointer, exportEquals: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateExportDefaultDeclaration(context: KNativePointer, original: KNativePointer, decl: KNativePointer, exportEquals: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ExportDefaultDeclarationDecl(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ExportDefaultDeclarationDeclConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ExportDefaultDeclarationIsExportEqualsConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateScriptFunction(context: KNativePointer, databody: KNativePointer, datasignature: KNativePointer, datafuncFlags: KInt, dataflags: KInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateScriptFunction(context: KNativePointer, original: KNativePointer, databody: KNativePointer, datasignature: KNativePointer, datafuncFlags: KInt, dataflags: KInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionIdConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionId(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionParams(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionReturnStatementsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionReturnStatements(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionTypeParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionTypeParams(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionBodyConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionBody(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionAddReturnStatement(context: KNativePointer, receiver: KNativePointer, returnStatement: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionSetBody(context: KNativePointer, receiver: KNativePointer, body: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionReturnTypeAnnotationConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionReturnTypeAnnotation(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionSetReturnTypeAnnotation(context: KNativePointer, receiver: KNativePointer, node: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionIsEntryPointConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionIsGeneratorConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionIsAsyncFuncConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionIsAsyncImplFuncConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionIsArrowConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionIsOverloadConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionIsExternalOverloadConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionIsConstructorConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionIsGetterConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionIsSetterConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionIsExtensionAccessorConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionIsMethodConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionIsProxyConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionIsStaticBlockConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionIsEnumConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionIsHiddenConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionIsExternalConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionIsImplicitSuperCallNeededConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionHasBodyConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionHasRestParameterConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionHasReturnStatementConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionHasThrowStatementConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionIsThrowingConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionIsRethrowingConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionIsDynamicConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionIsExtensionMethodConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionFlagsConst(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionHasReceiverConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionSetIdent(context: KNativePointer, receiver: KNativePointer, id: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionAddFlag(context: KNativePointer, receiver: KNativePointer, flags: KInt): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionClearFlag(context: KNativePointer, receiver: KNativePointer, flags: KInt): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionAddModifier(context: KNativePointer, receiver: KNativePointer, flags: KInt): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionFormalParamsLengthConst(context: KNativePointer, receiver: KNativePointer): KUInt { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionAnnotations(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionAnnotationsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ScriptFunctionSetAnnotations(context: KNativePointer, receiver: KNativePointer, annotations: BigUint64Array, annotationsSequenceLength: KUInt): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateClassDefinition(context: KNativePointer, ident: KNativePointer, typeParams: KNativePointer, superTypeParams: KNativePointer, _implements: BigUint64Array, _implementsSequenceLength: KUInt, ctor: KNativePointer, superClass: KNativePointer, body: BigUint64Array, bodySequenceLength: KUInt, modifiers: KInt, flags: KInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateClassDefinition(context: KNativePointer, original: KNativePointer, ident: KNativePointer, typeParams: KNativePointer, superTypeParams: KNativePointer, _implements: BigUint64Array, _implementsSequenceLength: KUInt, ctor: KNativePointer, superClass: KNativePointer, body: BigUint64Array, bodySequenceLength: KUInt, modifiers: KInt, flags: KInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateClassDefinition1(context: KNativePointer, ident: KNativePointer, body: BigUint64Array, bodySequenceLength: KUInt, modifiers: KInt, flags: KInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateClassDefinition1(context: KNativePointer, original: KNativePointer, ident: KNativePointer, body: BigUint64Array, bodySequenceLength: KUInt, modifiers: KInt, flags: KInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateClassDefinition2(context: KNativePointer, ident: KNativePointer, modifiers: KInt, flags: KInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateClassDefinition2(context: KNativePointer, original: KNativePointer, ident: KNativePointer, modifiers: KInt, flags: KInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionIdentConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionIdent(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionSetIdent(context: KNativePointer, receiver: KNativePointer, ident: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionInternalNameConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionSetInternalName(context: KNativePointer, receiver: KNativePointer, internalName: KStringPtr): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionSuper(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionSuperConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionSetSuper(context: KNativePointer, receiver: KNativePointer, superClass: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionIsGlobalConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionIsLocalConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionIsExternConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionIsFromExternalConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionIsInnerConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionIsGlobalInitializedConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionIsClassDefinitionCheckedConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionIsAnonymousConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionIsIntEnumTransformedConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionIsStringEnumTransformedConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionIsEnumTransformedConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionIsNamespaceTransformedConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionIsFromStructConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionIsModuleConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionSetGlobalInitialized(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionSetInnerModifier(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionSetClassDefinitionChecked(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionSetAnonymousModifier(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionSetNamespaceTransformed(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionSetFromStructModifier(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionModifiersConst(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionSetModifiers(context: KNativePointer, receiver: KNativePointer, modifiers: KInt): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionAddProperties(context: KNativePointer, receiver: KNativePointer, body: BigUint64Array, bodySequenceLength: KUInt): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionBody(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionBodyConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionCtor(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionSetCtor(context: KNativePointer, receiver: KNativePointer, ctor: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionImplements(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionImplementsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionTypeParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionTypeParams(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionSetTypeParams(context: KNativePointer, receiver: KNativePointer, typeParams: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionSuperTypeParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionSuperTypeParams(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionLocalTypeCounter(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionLocalIndexConst(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionLocalPrefixConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionSetOrigEnumDecl(context: KNativePointer, receiver: KNativePointer, enumDecl: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionOrigEnumDeclConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionGetAnonClass(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionSetAnonClass(context: KNativePointer, receiver: KNativePointer, anonClass: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionCtorConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionHasPrivateMethodConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionHasNativeMethodConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionHasComputedInstanceFieldConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionHasMatchingPrivateKeyConst(context: KNativePointer, receiver: KNativePointer, name: KStringPtr): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionAddToExportedClasses(context: KNativePointer, receiver: KNativePointer, cls: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionAnnotations(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionAnnotationsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDefinitionSetAnnotations(context: KNativePointer, receiver: KNativePointer, annotations: BigUint64Array, annotationsSequenceLength: KUInt): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateArrayExpression(context: KNativePointer, elements: BigUint64Array, elementsSequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateArrayExpression(context: KNativePointer, original: KNativePointer, elements: BigUint64Array, elementsSequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateArrayExpression1(context: KNativePointer, nodeType: KInt, elements: BigUint64Array, elementsSequenceLength: KUInt, trailingComma: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateArrayExpression1(context: KNativePointer, original: KNativePointer, nodeType: KInt, elements: BigUint64Array, elementsSequenceLength: KUInt, trailingComma: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ArrayExpressionGetElementNodeAtIdxConst(context: KNativePointer, receiver: KNativePointer, idx: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ArrayExpressionElementsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ArrayExpressionElements(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ArrayExpressionSetElements(context: KNativePointer, receiver: KNativePointer, elements: BigUint64Array, elementsSequenceLength: KUInt): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ArrayExpressionIsDeclarationConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ArrayExpressionIsOptionalConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ArrayExpressionSetDeclaration(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ArrayExpressionSetOptional(context: KNativePointer, receiver: KNativePointer, optional_arg: KBoolean): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ArrayExpressionDecoratorsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ArrayExpressionClearPreferredType(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ArrayExpressionConvertibleToArrayPattern(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ArrayExpressionValidateExpression(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ArrayExpressionTrySetPreferredTypeForNestedArrayExprConst(context: KNativePointer, receiver: KNativePointer, nestedArrayExpr: KNativePointer, idx: KUInt): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ArrayExpressionTypeAnnotationConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ArrayExpressionSetTsTypeAnnotation(context: KNativePointer, receiver: KNativePointer, typeAnnotation: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSInterfaceBody(context: KNativePointer, body: BigUint64Array, bodySequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSInterfaceBody(context: KNativePointer, original: KNativePointer, body: BigUint64Array, bodySequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSInterfaceBodyBody(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSInterfaceBodyBodyConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSTypeQuery(context: KNativePointer, exprName: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSTypeQuery(context: KNativePointer, original: KNativePointer, exprName: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSTypeQueryExprNameConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSBigintKeyword(context: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSBigintKeyword(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateProperty(context: KNativePointer, key: KNativePointer, value: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateProperty(context: KNativePointer, original: KNativePointer, key: KNativePointer, value: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateProperty1(context: KNativePointer, kind: KInt, key: KNativePointer, value: KNativePointer, isMethod: KBoolean, isComputed: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateProperty1(context: KNativePointer, original: KNativePointer, kind: KInt, key: KNativePointer, value: KNativePointer, isMethod: KBoolean, isComputed: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _PropertyKey(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _PropertyKeyConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _PropertyValueConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _PropertyValue(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _PropertyKindConst(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("This methods was not overloaded by native module initialization") + } + _PropertyIsMethodConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _PropertyIsShorthandConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _PropertyIsComputedConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _PropertyIsAccessorConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _PropertyIsAccessorKind(context: KNativePointer, receiver: KNativePointer, kind: KInt): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _PropertyConvertibleToPatternProperty(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _PropertyValidateExpression(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateVariableDeclarator(context: KNativePointer, flag: KInt, ident: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateVariableDeclarator(context: KNativePointer, original: KNativePointer, flag: KInt, ident: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateVariableDeclarator1(context: KNativePointer, flag: KInt, ident: KNativePointer, init: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateVariableDeclarator1(context: KNativePointer, original: KNativePointer, flag: KInt, ident: KNativePointer, init: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _VariableDeclaratorInit(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _VariableDeclaratorInitConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _VariableDeclaratorSetInit(context: KNativePointer, receiver: KNativePointer, init: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _VariableDeclaratorId(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _VariableDeclaratorIdConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _VariableDeclaratorFlag(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateStringLiteral(context: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateStringLiteral(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateStringLiteral1(context: KNativePointer, str: KStringPtr): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateStringLiteral1(context: KNativePointer, original: KNativePointer, str: KStringPtr): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _StringLiteralStrConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSTypeAssertion(context: KNativePointer, typeAnnotation: KNativePointer, expression: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSTypeAssertion(context: KNativePointer, original: KNativePointer, typeAnnotation: KNativePointer, expression: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSTypeAssertionGetExpressionConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSTypeAssertionTypeAnnotationConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSTypeAssertionSetTsTypeAnnotation(context: KNativePointer, receiver: KNativePointer, typeAnnotation: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSExternalModuleReference(context: KNativePointer, expr: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSExternalModuleReference(context: KNativePointer, original: KNativePointer, expr: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSExternalModuleReferenceExprConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSUndefinedKeyword(context: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSUndefinedKeyword(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateETSTuple(context: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateETSTuple(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateETSTuple1(context: KNativePointer, size: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateETSTuple1(context: KNativePointer, original: KNativePointer, size: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateETSTuple2(context: KNativePointer, typeList: BigUint64Array, typeListSequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateETSTuple2(context: KNativePointer, original: KNativePointer, typeList: BigUint64Array, typeListSequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSTupleGetTupleSizeConst(context: KNativePointer, receiver: KNativePointer): KUInt { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSTupleGetTupleTypeAnnotationsList(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSTupleGetTupleTypeAnnotationsListConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSTupleSetTypeAnnotationsList(context: KNativePointer, receiver: KNativePointer, typeNodeList: BigUint64Array, typeNodeListSequenceLength: KUInt): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateETSStringLiteralType(context: KNativePointer, value: KStringPtr): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateETSStringLiteralType(context: KNativePointer, original: KNativePointer, value: KStringPtr): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTryStatement(context: KNativePointer, block: KNativePointer, catchClauses: BigUint64Array, catchClausesSequenceLength: KUInt, finalizer: KNativePointer, finalizerInsertionsLabelPair: BigUint64Array, finalizerInsertionsLabelPairSequenceLength: KUInt, finalizerInsertionsStatement: BigUint64Array, finalizerInsertionsStatementSequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTryStatement(context: KNativePointer, original: KNativePointer, block: KNativePointer, catchClauses: BigUint64Array, catchClausesSequenceLength: KUInt, finalizer: KNativePointer, finalizerInsertionsLabelPair: BigUint64Array, finalizerInsertionsLabelPairSequenceLength: KUInt, finalizerInsertionsStatement: BigUint64Array, finalizerInsertionsStatementSequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTryStatement1(context: KNativePointer, other: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTryStatement1(context: KNativePointer, original: KNativePointer, other: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TryStatementFinallyBlockConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TryStatementBlockConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TryStatementHasFinalizerConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _TryStatementHasDefaultCatchClauseConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _TryStatementCatchClausesConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TryStatementFinallyCanCompleteNormallyConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _TryStatementSetFinallyCanCompleteNormally(context: KNativePointer, receiver: KNativePointer, finallyCanCompleteNormally: KBoolean): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeIsProgramConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeIsStatementConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeIsExpressionConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeIsTypedConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeAsTyped(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeAsTypedConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeIsBrokenStatementConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeAsExpression(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeAsExpressionConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeAsStatement(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeAsStatementConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeSetRange(context: KNativePointer, receiver: KNativePointer, loc: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeSetStart(context: KNativePointer, receiver: KNativePointer, start: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeSetEnd(context: KNativePointer, receiver: KNativePointer, end: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeStartConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeEndConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeRangeConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeTypeConst(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeParent(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeParentConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeSetParent(context: KNativePointer, receiver: KNativePointer, parent: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeDecoratorsPtrConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeAddDecorators(context: KNativePointer, receiver: KNativePointer, decorators: BigUint64Array, decoratorsSequenceLength: KUInt): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeCanHaveDecoratorConst(context: KNativePointer, receiver: KNativePointer, inTs: KBoolean): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeIsReadonlyConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeIsReadonlyTypeConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeIsOptionalDeclarationConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeIsDefiniteConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeIsConstructorConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeIsOverrideConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeSetOverride(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeIsAsyncConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeIsSynchronizedConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeIsNativeConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeIsConstConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeIsStaticConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeIsFinalConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeIsAbstractConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeIsPublicConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeIsProtectedConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeIsPrivateConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeIsInternalConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeIsExportedConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeIsDefaultExportedConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeIsExportedTypeConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeIsDeclareConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeIsInConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeIsOutConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeIsSetterConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeAddModifier(context: KNativePointer, receiver: KNativePointer, flags: KInt): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeClearModifier(context: KNativePointer, receiver: KNativePointer, flags: KInt): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeModifiers(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeModifiersConst(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeHasExportAliasConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeAsClassElement(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeAsClassElementConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeIsScopeBearerConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeClearScope(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeGetTopStatement(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeGetTopStatementConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeClone(context: KNativePointer, receiver: KNativePointer, parent: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeDumpJSONConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeDumpEtsSrcConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeDumpConst(context: KNativePointer, receiver: KNativePointer, dumper: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeDumpConst1(context: KNativePointer, receiver: KNativePointer, dumper: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeCompileConst(context: KNativePointer, receiver: KNativePointer, pg: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeCompileConst1(context: KNativePointer, receiver: KNativePointer, etsg: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeSetTransformedNode(context: KNativePointer, receiver: KNativePointer, transformationName: KStringPtr, transformedNode: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeAccept(context: KNativePointer, receiver: KNativePointer, v: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeSetOriginalNode(context: KNativePointer, receiver: KNativePointer, originalNode: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeOriginalNodeConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeCleanUp(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstNodeShallowClone(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateUnaryExpression(context: KNativePointer, argument: KNativePointer, unaryOperator: KInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateUnaryExpression(context: KNativePointer, original: KNativePointer, argument: KNativePointer, unaryOperator: KInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UnaryExpressionOperatorTypeConst(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("This methods was not overloaded by native module initialization") + } + _UnaryExpressionArgument(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UnaryExpressionArgumentConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateForInStatement(context: KNativePointer, left: KNativePointer, right: KNativePointer, body: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateForInStatement(context: KNativePointer, original: KNativePointer, left: KNativePointer, right: KNativePointer, body: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ForInStatementLeft(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ForInStatementLeftConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ForInStatementRight(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ForInStatementRightConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ForInStatementBody(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ForInStatementBodyConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateThisExpression(context: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateThisExpression(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSMethodSignature(context: KNativePointer, key: KNativePointer, signature: KNativePointer, computed: KBoolean, optional_arg: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSMethodSignature(context: KNativePointer, original: KNativePointer, key: KNativePointer, signature: KNativePointer, computed: KBoolean, optional_arg: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSMethodSignatureKeyConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSMethodSignatureKey(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSMethodSignatureTypeParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSMethodSignatureTypeParams(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSMethodSignatureParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSMethodSignatureReturnTypeAnnotationConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSMethodSignatureReturnTypeAnnotation(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSMethodSignatureComputedConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSMethodSignatureOptionalConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateBinaryExpression(context: KNativePointer, left: KNativePointer, right: KNativePointer, operatorType: KInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateBinaryExpression(context: KNativePointer, original: KNativePointer, left: KNativePointer, right: KNativePointer, operatorType: KInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _BinaryExpressionLeftConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _BinaryExpressionLeft(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _BinaryExpressionRightConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _BinaryExpressionRight(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _BinaryExpressionResultConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _BinaryExpressionResult(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _BinaryExpressionOperatorTypeConst(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("This methods was not overloaded by native module initialization") + } + _BinaryExpressionIsLogicalConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _BinaryExpressionIsLogicalExtendedConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _BinaryExpressionIsBitwiseConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _BinaryExpressionIsArithmeticConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _BinaryExpressionSetLeft(context: KNativePointer, receiver: KNativePointer, expr: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _BinaryExpressionSetRight(context: KNativePointer, receiver: KNativePointer, expr: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _BinaryExpressionSetResult(context: KNativePointer, receiver: KNativePointer, expr: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _BinaryExpressionSetOperator(context: KNativePointer, receiver: KNativePointer, operatorType: KInt): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _BinaryExpressionCompileOperandsConst(context: KNativePointer, receiver: KNativePointer, etsg: KNativePointer, lhs: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateSuperExpression(context: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateSuperExpression(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateAssertStatement(context: KNativePointer, test: KNativePointer, second: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateAssertStatement(context: KNativePointer, original: KNativePointer, test: KNativePointer, second: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _AssertStatementTestConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _AssertStatementTest(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _AssertStatementSecondConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSStringKeyword(context: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSStringKeyword(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateAssignmentExpression(context: KNativePointer, left: KNativePointer, right: KNativePointer, assignmentOperator: KInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateAssignmentExpression(context: KNativePointer, original: KNativePointer, left: KNativePointer, right: KNativePointer, assignmentOperator: KInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateAssignmentExpression1(context: KNativePointer, type: KInt, left: KNativePointer, right: KNativePointer, assignmentOperator: KInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateAssignmentExpression1(context: KNativePointer, original: KNativePointer, type: KInt, left: KNativePointer, right: KNativePointer, assignmentOperator: KInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _AssignmentExpressionLeftConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _AssignmentExpressionLeft(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _AssignmentExpressionRight(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _AssignmentExpressionRightConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _AssignmentExpressionSetRight(context: KNativePointer, receiver: KNativePointer, expr: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _AssignmentExpressionSetLeft(context: KNativePointer, receiver: KNativePointer, expr: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _AssignmentExpressionResultConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _AssignmentExpressionResult(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _AssignmentExpressionOperatorTypeConst(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("This methods was not overloaded by native module initialization") + } + _AssignmentExpressionSetOperatorType(context: KNativePointer, receiver: KNativePointer, tokenType: KInt): KInt { + throw new Error("This methods was not overloaded by native module initialization") + } + _AssignmentExpressionSetResult(context: KNativePointer, receiver: KNativePointer, expr: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _AssignmentExpressionIsLogicalExtendedConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _AssignmentExpressionSetIgnoreConstAssign(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _AssignmentExpressionIsIgnoreConstAssignConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _AssignmentExpressionConvertibleToAssignmentPatternLeft(context: KNativePointer, receiver: KNativePointer, mustBePattern: KBoolean): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _AssignmentExpressionConvertibleToAssignmentPatternRight(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _AssignmentExpressionConvertibleToAssignmentPattern(context: KNativePointer, receiver: KNativePointer, mustBePattern: KBoolean): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _AssignmentExpressionCompilePatternConst(context: KNativePointer, receiver: KNativePointer, pg: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateExpressionStatement(context: KNativePointer, expr: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateExpressionStatement(context: KNativePointer, original: KNativePointer, expr: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ExpressionStatementGetExpressionConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ExpressionStatementGetExpression(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ExpressionStatementSetExpression(context: KNativePointer, receiver: KNativePointer, expr: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSModuleIdent(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSModuleIdentConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSModuleIsETSScriptConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSModuleIsNamespaceConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSModuleIsNamespaceChainLastNodeConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSModuleSetNamespaceChainLastNode(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSModuleAnnotations(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSModuleAnnotationsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSModuleSetAnnotations(context: KNativePointer, receiver: KNativePointer, annotations: BigUint64Array, annotationsSequenceLength: KUInt): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateMetaProperty(context: KNativePointer, kind: KInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateMetaProperty(context: KNativePointer, original: KNativePointer, kind: KInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _MetaPropertyKindConst(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSArrayType(context: KNativePointer, elementType: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSArrayType(context: KNativePointer, original: KNativePointer, elementType: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSArrayTypeElementTypeConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSSignatureDeclaration(context: KNativePointer, kind: KInt, signature: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSSignatureDeclaration(context: KNativePointer, original: KNativePointer, kind: KInt, signature: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSSignatureDeclarationTypeParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSSignatureDeclarationTypeParams(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSSignatureDeclarationParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSSignatureDeclarationReturnTypeAnnotationConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSSignatureDeclarationReturnTypeAnnotation(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSSignatureDeclarationKindConst(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateExportAllDeclaration(context: KNativePointer, source: KNativePointer, exported: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateExportAllDeclaration(context: KNativePointer, original: KNativePointer, source: KNativePointer, exported: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ExportAllDeclarationSourceConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ExportAllDeclarationExportedConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateExportSpecifier(context: KNativePointer, local: KNativePointer, exported: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateExportSpecifier(context: KNativePointer, original: KNativePointer, local: KNativePointer, exported: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ExportSpecifierLocalConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ExportSpecifierExportedConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSTupleType(context: KNativePointer, elementTypes: BigUint64Array, elementTypesSequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSTupleType(context: KNativePointer, original: KNativePointer, elementTypes: BigUint64Array, elementTypesSequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSTupleTypeElementTypeConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateFunctionExpression(context: KNativePointer, func: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateFunctionExpression(context: KNativePointer, original: KNativePointer, func: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateFunctionExpression1(context: KNativePointer, namedExpr: KNativePointer, func: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateFunctionExpression1(context: KNativePointer, original: KNativePointer, namedExpr: KNativePointer, func: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _FunctionExpressionFunctionConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _FunctionExpressionFunction(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _FunctionExpressionIsAnonymousConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _FunctionExpressionId(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSIndexSignature(context: KNativePointer, param: KNativePointer, typeAnnotation: KNativePointer, readonly_arg: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSIndexSignature(context: KNativePointer, original: KNativePointer, param: KNativePointer, typeAnnotation: KNativePointer, readonly_arg: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSIndexSignatureParamConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSIndexSignatureTypeAnnotationConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSIndexSignatureReadonlyConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSIndexSignatureKindConst(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSModuleDeclaration(context: KNativePointer, name: KNativePointer, body: KNativePointer, declare: KBoolean, _global: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSModuleDeclaration(context: KNativePointer, original: KNativePointer, name: KNativePointer, body: KNativePointer, declare: KBoolean, _global: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSModuleDeclarationNameConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSModuleDeclarationBodyConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSModuleDeclarationGlobalConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSModuleDeclarationIsExternalOrAmbientConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateImportDeclaration(context: KNativePointer, source: KNativePointer, specifiers: BigUint64Array, specifiersSequenceLength: KUInt, importKinds: KInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateImportDeclaration(context: KNativePointer, original: KNativePointer, source: KNativePointer, specifiers: BigUint64Array, specifiersSequenceLength: KUInt, importKinds: KInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ImportDeclarationSourceConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ImportDeclarationSource(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ImportDeclarationSpecifiersConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ImportDeclarationSpecifiers(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ImportDeclarationIsTypeKindConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSParenthesizedType(context: KNativePointer, type: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSParenthesizedType(context: KNativePointer, original: KNativePointer, type: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSParenthesizedTypeTypeConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateCharLiteral(context: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateCharLiteral(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateETSPackageDeclaration(context: KNativePointer, name: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateETSPackageDeclaration(context: KNativePointer, original: KNativePointer, name: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateETSImportDeclaration(context: KNativePointer, importPath: KNativePointer, specifiers: BigUint64Array, specifiersSequenceLength: KUInt, importKinds: KInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateETSImportDeclaration(context: KNativePointer, original: KNativePointer, importPath: KNativePointer, specifiers: BigUint64Array, specifiersSequenceLength: KUInt, importKinds: KInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSImportDeclarationSetImportMetadata(context: KNativePointer, receiver: KNativePointer, importFlags: KInt, lang: KInt, resolvedSource: KStringPtr, declPath: KStringPtr, ohmUrl: KStringPtr): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSImportDeclarationDeclPathConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSImportDeclarationOhmUrlConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSImportDeclarationIsValidConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSImportDeclarationIsPureDynamicConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSImportDeclarationAssemblerName(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSImportDeclarationAssemblerNameConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSImportDeclarationResolvedSourceConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateETSStructDeclaration(context: KNativePointer, def: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateETSStructDeclaration(context: KNativePointer, original: KNativePointer, def: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSModuleBlock(context: KNativePointer, statements: BigUint64Array, statementsSequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSModuleBlock(context: KNativePointer, original: KNativePointer, statements: BigUint64Array, statementsSequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSModuleBlockStatementsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateETSNewArrayInstanceExpression(context: KNativePointer, typeReference: KNativePointer, dimension: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateETSNewArrayInstanceExpression(context: KNativePointer, original: KNativePointer, typeReference: KNativePointer, dimension: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSNewArrayInstanceExpressionTypeReference(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSNewArrayInstanceExpressionTypeReferenceConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSNewArrayInstanceExpressionDimension(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSNewArrayInstanceExpressionDimensionConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSNewArrayInstanceExpressionSetDimension(context: KNativePointer, receiver: KNativePointer, dimension: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSNewArrayInstanceExpressionClearPreferredType(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateAnnotationDeclaration(context: KNativePointer, expr: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateAnnotationDeclaration(context: KNativePointer, original: KNativePointer, expr: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateAnnotationDeclaration1(context: KNativePointer, expr: KNativePointer, properties: BigUint64Array, propertiesSequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateAnnotationDeclaration1(context: KNativePointer, original: KNativePointer, expr: KNativePointer, properties: BigUint64Array, propertiesSequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _AnnotationDeclarationInternalNameConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("This methods was not overloaded by native module initialization") + } + _AnnotationDeclarationSetInternalName(context: KNativePointer, receiver: KNativePointer, internalName: KStringPtr): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _AnnotationDeclarationExprConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _AnnotationDeclarationExpr(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _AnnotationDeclarationProperties(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _AnnotationDeclarationPropertiesConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _AnnotationDeclarationAddProperties(context: KNativePointer, receiver: KNativePointer, properties: BigUint64Array, propertiesSequenceLength: KUInt): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _AnnotationDeclarationIsSourceRetentionConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _AnnotationDeclarationIsBytecodeRetentionConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _AnnotationDeclarationIsRuntimeRetentionConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _AnnotationDeclarationSetSourceRetention(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _AnnotationDeclarationSetBytecodeRetention(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _AnnotationDeclarationSetRuntimeRetention(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _AnnotationDeclarationGetBaseNameConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _AnnotationDeclarationAnnotations(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _AnnotationDeclarationAnnotationsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _AnnotationDeclarationSetAnnotations(context: KNativePointer, receiver: KNativePointer, annotations: BigUint64Array, annotationsSequenceLength: KUInt): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateAnnotationUsage(context: KNativePointer, expr: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateAnnotationUsage(context: KNativePointer, original: KNativePointer, expr: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateAnnotationUsage1(context: KNativePointer, expr: KNativePointer, properties: BigUint64Array, propertiesSequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateAnnotationUsage1(context: KNativePointer, original: KNativePointer, expr: KNativePointer, properties: BigUint64Array, propertiesSequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _AnnotationUsageExpr(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _AnnotationUsageProperties(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _AnnotationUsagePropertiesConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _AnnotationUsageAddProperty(context: KNativePointer, receiver: KNativePointer, property: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _AnnotationUsageSetProperties(context: KNativePointer, receiver: KNativePointer, properties: BigUint64Array, propertiesSequenceLength: KUInt): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _AnnotationUsageGetBaseNameConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateEmptyStatement(context: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateEmptyStatement(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateWhileStatement(context: KNativePointer, test: KNativePointer, body: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateWhileStatement(context: KNativePointer, original: KNativePointer, test: KNativePointer, body: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _WhileStatementTestConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _WhileStatementTest(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _WhileStatementBodyConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _WhileStatementBody(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateFunctionSignature(context: KNativePointer, typeParams: KNativePointer, params: BigUint64Array, paramsSequenceLength: KUInt, returnTypeAnnotation: KNativePointer, hasReceiver: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _FunctionSignatureParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _FunctionSignatureParams(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _FunctionSignatureTypeParams(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _FunctionSignatureTypeParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _FunctionSignatureReturnType(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _FunctionSignatureSetReturnType(context: KNativePointer, receiver: KNativePointer, type: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _FunctionSignatureReturnTypeConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _FunctionSignatureClone(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _FunctionSignatureHasReceiverConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateChainExpression(context: KNativePointer, expression: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateChainExpression(context: KNativePointer, original: KNativePointer, expression: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ChainExpressionGetExpressionConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ChainExpressionGetExpression(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ChainExpressionCompileToRegConst(context: KNativePointer, receiver: KNativePointer, pg: KNativePointer, objReg: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSIntersectionType(context: KNativePointer, types: BigUint64Array, typesSequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSIntersectionType(context: KNativePointer, original: KNativePointer, types: BigUint64Array, typesSequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSIntersectionTypeTypesConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateUpdateExpression(context: KNativePointer, argument: KNativePointer, updateOperator: KInt, isPrefix: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateUpdateExpression(context: KNativePointer, original: KNativePointer, argument: KNativePointer, updateOperator: KInt, isPrefix: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateExpressionOperatorTypeConst(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateExpressionArgument(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateExpressionArgumentConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateExpressionIsPrefixConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateBlockExpression(context: KNativePointer, statements: BigUint64Array, statementsSequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateBlockExpression(context: KNativePointer, original: KNativePointer, statements: BigUint64Array, statementsSequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _BlockExpressionStatementsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _BlockExpressionStatements(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _BlockExpressionAddStatements(context: KNativePointer, receiver: KNativePointer, statements: BigUint64Array, statementsSequenceLength: KUInt): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _BlockExpressionAddStatement(context: KNativePointer, receiver: KNativePointer, statement: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSTypeLiteral(context: KNativePointer, members: BigUint64Array, membersSequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSTypeLiteral(context: KNativePointer, original: KNativePointer, members: BigUint64Array, membersSequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSTypeLiteralMembersConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSTypeParameter(context: KNativePointer, name: KNativePointer, constraint: KNativePointer, defaultType: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSTypeParameter(context: KNativePointer, original: KNativePointer, name: KNativePointer, constraint: KNativePointer, defaultType: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSTypeParameter1(context: KNativePointer, name: KNativePointer, constraint: KNativePointer, defaultType: KNativePointer, flags: KInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSTypeParameter1(context: KNativePointer, original: KNativePointer, name: KNativePointer, constraint: KNativePointer, defaultType: KNativePointer, flags: KInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSTypeParameterNameConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSTypeParameterName(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSTypeParameterConstraint(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSTypeParameterConstraintConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSTypeParameterSetConstraint(context: KNativePointer, receiver: KNativePointer, constraint: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSTypeParameterDefaultTypeConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSTypeParameterSetDefaultType(context: KNativePointer, receiver: KNativePointer, defaultType: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSTypeParameterAnnotations(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSTypeParameterAnnotationsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSTypeParameterSetAnnotations(context: KNativePointer, receiver: KNativePointer, annotations: BigUint64Array, annotationsSequenceLength: KUInt): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSBooleanKeyword(context: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSBooleanKeyword(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateSpreadElement(context: KNativePointer, nodeType: KInt, argument: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateSpreadElement(context: KNativePointer, original: KNativePointer, nodeType: KInt, argument: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _SpreadElementArgumentConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _SpreadElementArgument(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _SpreadElementIsOptionalConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _SpreadElementDecoratorsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _SpreadElementSetOptional(context: KNativePointer, receiver: KNativePointer, optional_arg: KBoolean): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _SpreadElementValidateExpression(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _SpreadElementConvertibleToRest(context: KNativePointer, receiver: KNativePointer, isDeclaration: KBoolean, allowPattern: KBoolean): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _SpreadElementTypeAnnotationConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _SpreadElementSetTsTypeAnnotation(context: KNativePointer, receiver: KNativePointer, typeAnnotation: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSTypePredicate(context: KNativePointer, parameterName: KNativePointer, typeAnnotation: KNativePointer, asserts: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSTypePredicate(context: KNativePointer, original: KNativePointer, parameterName: KNativePointer, typeAnnotation: KNativePointer, asserts: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSTypePredicateParameterNameConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSTypePredicateTypeAnnotationConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSTypePredicateAssertsConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateImportNamespaceSpecifier(context: KNativePointer, local: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateImportNamespaceSpecifier(context: KNativePointer, original: KNativePointer, local: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ImportNamespaceSpecifierLocal(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ImportNamespaceSpecifierLocalConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateExportNamedDeclaration(context: KNativePointer, source: KNativePointer, specifiers: BigUint64Array, specifiersSequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateExportNamedDeclaration(context: KNativePointer, original: KNativePointer, source: KNativePointer, specifiers: BigUint64Array, specifiersSequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateExportNamedDeclaration1(context: KNativePointer, decl: KNativePointer, specifiers: BigUint64Array, specifiersSequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateExportNamedDeclaration1(context: KNativePointer, original: KNativePointer, decl: KNativePointer, specifiers: BigUint64Array, specifiersSequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateExportNamedDeclaration2(context: KNativePointer, decl: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateExportNamedDeclaration2(context: KNativePointer, original: KNativePointer, decl: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ExportNamedDeclarationDeclConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ExportNamedDeclarationSourceConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ExportNamedDeclarationSpecifiersConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateETSParameterExpression(context: KNativePointer, identOrSpread: KNativePointer, isOptional: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateETSParameterExpression(context: KNativePointer, original: KNativePointer, identOrSpread: KNativePointer, isOptional: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateETSParameterExpression1(context: KNativePointer, identOrSpread: KNativePointer, initializer: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateETSParameterExpression1(context: KNativePointer, original: KNativePointer, identOrSpread: KNativePointer, initializer: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSParameterExpressionNameConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSParameterExpressionIdentConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSParameterExpressionIdent(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSParameterExpressionSetIdent(context: KNativePointer, receiver: KNativePointer, ident: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSParameterExpressionRestParameterConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSParameterExpressionRestParameter(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSParameterExpressionInitializerConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSParameterExpressionInitializer(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSParameterExpressionSetLexerSaved(context: KNativePointer, receiver: KNativePointer, s: KStringPtr): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSParameterExpressionLexerSavedConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSParameterExpressionTypeAnnotationConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSParameterExpressionTypeAnnotation(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSParameterExpressionSetTypeAnnotation(context: KNativePointer, receiver: KNativePointer, typeNode: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSParameterExpressionIsOptionalConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSParameterExpressionSetOptional(context: KNativePointer, receiver: KNativePointer, value: KBoolean): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSParameterExpressionSetInitializer(context: KNativePointer, receiver: KNativePointer, initExpr: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSParameterExpressionIsRestParameterConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSParameterExpressionGetRequiredParamsConst(context: KNativePointer, receiver: KNativePointer): KUInt { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSParameterExpressionSetRequiredParams(context: KNativePointer, receiver: KNativePointer, value: KUInt): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSParameterExpressionAnnotations(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSParameterExpressionAnnotationsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSParameterExpressionSetAnnotations(context: KNativePointer, receiver: KNativePointer, annotations: BigUint64Array, annotationsSequenceLength: KUInt): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSTypeParameterInstantiation(context: KNativePointer, params: BigUint64Array, paramsSequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSTypeParameterInstantiation(context: KNativePointer, original: KNativePointer, params: BigUint64Array, paramsSequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSTypeParameterInstantiationParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateNullLiteral(context: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateNullLiteral(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSInferType(context: KNativePointer, typeParam: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSInferType(context: KNativePointer, original: KNativePointer, typeParam: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSInferTypeTypeParamConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateSwitchCaseStatement(context: KNativePointer, test: KNativePointer, consequent: BigUint64Array, consequentSequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateSwitchCaseStatement(context: KNativePointer, original: KNativePointer, test: KNativePointer, consequent: BigUint64Array, consequentSequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _SwitchCaseStatementTest(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _SwitchCaseStatementTestConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _SwitchCaseStatementSetTest(context: KNativePointer, receiver: KNativePointer, test: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _SwitchCaseStatementConsequentConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateYieldExpression(context: KNativePointer, argument: KNativePointer, isDelegate: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateYieldExpression(context: KNativePointer, original: KNativePointer, argument: KNativePointer, isDelegate: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _YieldExpressionHasDelegateConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _YieldExpressionArgumentConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSImportEqualsDeclaration(context: KNativePointer, id: KNativePointer, moduleReference: KNativePointer, isExport: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSImportEqualsDeclaration(context: KNativePointer, original: KNativePointer, id: KNativePointer, moduleReference: KNativePointer, isExport: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSImportEqualsDeclarationIdConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSImportEqualsDeclarationModuleReferenceConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSImportEqualsDeclarationIsExportConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateBooleanLiteral(context: KNativePointer, value: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateBooleanLiteral(context: KNativePointer, original: KNativePointer, value: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _BooleanLiteralValueConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSNumberKeyword(context: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSNumberKeyword(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateClassStaticBlock(context: KNativePointer, value: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateClassStaticBlock(context: KNativePointer, original: KNativePointer, value: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassStaticBlockFunction(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassStaticBlockFunctionConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassStaticBlockNameConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSNonNullExpression(context: KNativePointer, expr: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSNonNullExpression(context: KNativePointer, original: KNativePointer, expr: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSNonNullExpressionExprConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSNonNullExpressionExpr(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSNonNullExpressionSetExpr(context: KNativePointer, receiver: KNativePointer, expr: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreatePrefixAssertionExpression(context: KNativePointer, expr: KNativePointer, type: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdatePrefixAssertionExpression(context: KNativePointer, original: KNativePointer, expr: KNativePointer, type: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _PrefixAssertionExpressionExprConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _PrefixAssertionExpressionTypeConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateClassExpression(context: KNativePointer, def: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateClassExpression(context: KNativePointer, original: KNativePointer, def: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassExpressionDefinitionConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateForOfStatement(context: KNativePointer, left: KNativePointer, right: KNativePointer, body: KNativePointer, isAwait: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateForOfStatement(context: KNativePointer, original: KNativePointer, left: KNativePointer, right: KNativePointer, body: KNativePointer, isAwait: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ForOfStatementLeft(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ForOfStatementLeftConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ForOfStatementRight(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ForOfStatementRightConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ForOfStatementBody(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ForOfStatementBodyConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ForOfStatementIsAwaitConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTemplateLiteral(context: KNativePointer, quasis: BigUint64Array, quasisSequenceLength: KUInt, expressions: BigUint64Array, expressionsSequenceLength: KUInt, multilineString: KStringPtr): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTemplateLiteral(context: KNativePointer, original: KNativePointer, quasis: BigUint64Array, quasisSequenceLength: KUInt, expressions: BigUint64Array, expressionsSequenceLength: KUInt, multilineString: KStringPtr): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TemplateLiteralQuasisConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TemplateLiteralExpressionsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TemplateLiteralGetMultilineStringConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSUnionType(context: KNativePointer, types: BigUint64Array, typesSequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSUnionType(context: KNativePointer, original: KNativePointer, types: BigUint64Array, typesSequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSUnionTypeTypesConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSUnknownKeyword(context: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSUnknownKeyword(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateIdentifier(context: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateIdentifier(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateIdentifier1(context: KNativePointer, name: KStringPtr): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateIdentifier1(context: KNativePointer, original: KNativePointer, name: KStringPtr): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateIdentifier2(context: KNativePointer, name: KStringPtr, typeAnnotation: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateIdentifier2(context: KNativePointer, original: KNativePointer, name: KStringPtr, typeAnnotation: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _IdentifierNameConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("This methods was not overloaded by native module initialization") + } + _IdentifierName(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("This methods was not overloaded by native module initialization") + } + _IdentifierSetName(context: KNativePointer, receiver: KNativePointer, newName: KStringPtr): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _IdentifierDecoratorsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _IdentifierIsErrorPlaceHolderConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _IdentifierIsOptionalConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _IdentifierSetOptional(context: KNativePointer, receiver: KNativePointer, optional_arg: KBoolean): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _IdentifierIsReferenceConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _IdentifierIsTdzConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _IdentifierSetTdz(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _IdentifierSetAccessor(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _IdentifierIsAccessorConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _IdentifierSetMutator(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _IdentifierIsMutatorConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _IdentifierIsReceiverConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _IdentifierIsPrivateIdentConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _IdentifierSetPrivate(context: KNativePointer, receiver: KNativePointer, isPrivate: KBoolean): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _IdentifierIsIgnoreBoxConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _IdentifierSetIgnoreBox(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _IdentifierIsAnnotationDeclConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _IdentifierSetAnnotationDecl(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _IdentifierIsAnnotationUsageConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _IdentifierSetAnnotationUsage(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _IdentifierCloneReference(context: KNativePointer, receiver: KNativePointer, parent: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _IdentifierValidateExpression(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _IdentifierTypeAnnotationConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _IdentifierSetTsTypeAnnotation(context: KNativePointer, receiver: KNativePointer, typeAnnotation: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateOpaqueTypeNode1(context: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateOpaqueTypeNode1(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateBlockStatement(context: KNativePointer, statementList: BigUint64Array, statementListSequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateBlockStatement(context: KNativePointer, original: KNativePointer, statementList: BigUint64Array, statementListSequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _BlockStatementStatementsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _BlockStatementStatements(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _BlockStatementSetStatements(context: KNativePointer, receiver: KNativePointer, statementList: BigUint64Array, statementListSequenceLength: KUInt): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _BlockStatementAddStatement(context: KNativePointer, receiver: KNativePointer, stmt: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _BlockStatementAddStatements(context: KNativePointer, receiver: KNativePointer, stmts: BigUint64Array, stmtsSequenceLength: KUInt): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _BlockStatementAddTrailingBlock(context: KNativePointer, receiver: KNativePointer, stmt: KNativePointer, trailingBlock: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateDirectEvalExpression(context: KNativePointer, callee: KNativePointer, _arguments: BigUint64Array, _argumentsSequenceLength: KUInt, typeParams: KNativePointer, optional_arg: KBoolean, parserStatus: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateDirectEvalExpression(context: KNativePointer, original: KNativePointer, callee: KNativePointer, _arguments: BigUint64Array, _argumentsSequenceLength: KUInt, typeParams: KNativePointer, optional_arg: KBoolean, parserStatus: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSTypeParameterDeclaration(context: KNativePointer, params: BigUint64Array, paramsSequenceLength: KUInt, requiredParams: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSTypeParameterDeclaration(context: KNativePointer, original: KNativePointer, params: BigUint64Array, paramsSequenceLength: KUInt, requiredParams: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSTypeParameterDeclarationParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSTypeParameterDeclarationAddParam(context: KNativePointer, receiver: KNativePointer, param: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSTypeParameterDeclarationRequiredParamsConst(context: KNativePointer, receiver: KNativePointer): KUInt { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateMethodDefinition(context: KNativePointer, kind: KInt, key: KNativePointer, value: KNativePointer, modifiers: KInt, isComputed: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateMethodDefinition(context: KNativePointer, original: KNativePointer, kind: KInt, key: KNativePointer, value: KNativePointer, modifiers: KInt, isComputed: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _MethodDefinitionKindConst(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("This methods was not overloaded by native module initialization") + } + _MethodDefinitionIsConstructorConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _MethodDefinitionIsMethodConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _MethodDefinitionIsExtensionMethodConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _MethodDefinitionIsGetterConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _MethodDefinitionIsSetterConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _MethodDefinitionIsDefaultAccessModifierConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _MethodDefinitionSetDefaultAccessModifier(context: KNativePointer, receiver: KNativePointer, isDefault: KBoolean): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _MethodDefinitionOverloadsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _MethodDefinitionBaseOverloadMethodConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _MethodDefinitionBaseOverloadMethod(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _MethodDefinitionAsyncPairMethodConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _MethodDefinitionAsyncPairMethod(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _MethodDefinitionSetOverloads(context: KNativePointer, receiver: KNativePointer, overloads: BigUint64Array, overloadsSequenceLength: KUInt): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _MethodDefinitionClearOverloads(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _MethodDefinitionAddOverload(context: KNativePointer, receiver: KNativePointer, overload: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _MethodDefinitionSetBaseOverloadMethod(context: KNativePointer, receiver: KNativePointer, baseOverloadMethod: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _MethodDefinitionSetAsyncPairMethod(context: KNativePointer, receiver: KNativePointer, method: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _MethodDefinitionHasOverload(context: KNativePointer, receiver: KNativePointer, overload: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _MethodDefinitionFunction(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _MethodDefinitionFunctionConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _MethodDefinitionInitializeOverloadInfo(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSNullKeyword(context: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSNullKeyword(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSInterfaceHeritage(context: KNativePointer, expr: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSInterfaceHeritage(context: KNativePointer, original: KNativePointer, expr: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSInterfaceHeritageExpr(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSInterfaceHeritageExprConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ExpressionIsGroupedConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ExpressionSetGrouped(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ExpressionAsLiteralConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ExpressionAsLiteral(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ExpressionIsLiteralConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ExpressionIsTypeNodeConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ExpressionIsAnnotatedExpressionConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ExpressionAsTypeNode(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ExpressionAsTypeNodeConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ExpressionAsAnnotatedExpression(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ExpressionAsAnnotatedExpressionConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ExpressionIsBrokenExpressionConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ExpressionToStringConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("This methods was not overloaded by native module initialization") + } + _AnnotatedExpressionTypeAnnotationConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _AnnotatedExpressionSetTsTypeAnnotation(context: KNativePointer, receiver: KNativePointer, typeAnnotation: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _MaybeOptionalExpressionIsOptionalConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _MaybeOptionalExpressionClearOptional(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateSrcDumper(context: KNativePointer, node: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _SrcDumperAdd(context: KNativePointer, receiver: KNativePointer, str: KStringPtr): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _SrcDumperAdd1(context: KNativePointer, receiver: KNativePointer, i: KInt): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _SrcDumperAdd2(context: KNativePointer, receiver: KNativePointer, l: KLong): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _SrcDumperAdd3(context: KNativePointer, receiver: KNativePointer, f: KFloat): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _SrcDumperAdd4(context: KNativePointer, receiver: KNativePointer, d: KDouble): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _SrcDumperStrConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("This methods was not overloaded by native module initialization") + } + _SrcDumperIncrIndent(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _SrcDumperDecrIndent(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _SrcDumperEndl(context: KNativePointer, receiver: KNativePointer, num: KUInt): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateETSClassLiteral(context: KNativePointer, expr: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateETSClassLiteral(context: KNativePointer, original: KNativePointer, expr: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSClassLiteralExprConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateBreakStatement(context: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateBreakStatement(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateBreakStatement1(context: KNativePointer, ident: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateBreakStatement1(context: KNativePointer, original: KNativePointer, ident: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _BreakStatementIdentConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _BreakStatementIdent(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _BreakStatementTargetConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _BreakStatementHasTargetConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _BreakStatementSetTarget(context: KNativePointer, receiver: KNativePointer, target: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateRegExpLiteral(context: KNativePointer, pattern: KStringPtr, flags: KInt, flagsStr: KStringPtr): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateRegExpLiteral(context: KNativePointer, original: KNativePointer, pattern: KStringPtr, flags: KInt, flagsStr: KStringPtr): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _RegExpLiteralPatternConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("This methods was not overloaded by native module initialization") + } + _RegExpLiteralFlagsConst(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSMappedType(context: KNativePointer, typeParameter: KNativePointer, typeAnnotation: KNativePointer, readonly_arg: KInt, optional_arg: KInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSMappedType(context: KNativePointer, original: KNativePointer, typeParameter: KNativePointer, typeAnnotation: KNativePointer, readonly_arg: KInt, optional_arg: KInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSMappedTypeTypeParameter(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSMappedTypeTypeAnnotation(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSMappedTypeReadonly(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSMappedTypeOptional(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSAnyKeyword(context: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSAnyKeyword(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateClassDeclaration(context: KNativePointer, def: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateClassDeclaration(context: KNativePointer, original: KNativePointer, def: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDeclarationDefinition(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDeclarationDefinitionConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ClassDeclarationDecoratorsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSIndexedAccessType(context: KNativePointer, objectType: KNativePointer, indexType: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSIndexedAccessType(context: KNativePointer, original: KNativePointer, objectType: KNativePointer, indexType: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSIndexedAccessTypeObjectTypeConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSIndexedAccessTypeIndexTypeConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSQualifiedName(context: KNativePointer, left: KNativePointer, right: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSQualifiedName(context: KNativePointer, original: KNativePointer, left: KNativePointer, right: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSQualifiedNameLeftConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSQualifiedNameLeft(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSQualifiedNameRightConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSQualifiedNameRight(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSQualifiedNameNameConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSQualifiedNameResolveLeftMostQualifiedName(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSQualifiedNameResolveLeftMostQualifiedNameConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateAwaitExpression(context: KNativePointer, argument: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateAwaitExpression(context: KNativePointer, original: KNativePointer, argument: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _AwaitExpressionArgumentConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateValidationInfo(context: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateValidationInfo1(context: KNativePointer, m: KStringPtr, p: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ValidationInfoFailConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateContinueStatement(context: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateContinueStatement(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateContinueStatement1(context: KNativePointer, ident: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateContinueStatement1(context: KNativePointer, original: KNativePointer, ident: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ContinueStatementIdentConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ContinueStatementIdent(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ContinueStatementTargetConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ContinueStatementHasTargetConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _ContinueStatementSetTarget(context: KNativePointer, receiver: KNativePointer, target: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateETSNewMultiDimArrayInstanceExpression(context: KNativePointer, typeReference: KNativePointer, dimensions: BigUint64Array, dimensionsSequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateETSNewMultiDimArrayInstanceExpression(context: KNativePointer, original: KNativePointer, typeReference: KNativePointer, dimensions: BigUint64Array, dimensionsSequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateETSNewMultiDimArrayInstanceExpression1(context: KNativePointer, other: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateETSNewMultiDimArrayInstanceExpression1(context: KNativePointer, original: KNativePointer, other: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSNewMultiDimArrayInstanceExpressionTypeReference(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSNewMultiDimArrayInstanceExpressionTypeReferenceConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSNewMultiDimArrayInstanceExpressionDimensions(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSNewMultiDimArrayInstanceExpressionDimensionsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSNewMultiDimArrayInstanceExpressionClearPreferredType(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSNamedTupleMember(context: KNativePointer, label: KNativePointer, elementType: KNativePointer, optional_arg: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSNamedTupleMember(context: KNativePointer, original: KNativePointer, label: KNativePointer, elementType: KNativePointer, optional_arg: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSNamedTupleMemberLabelConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSNamedTupleMemberElementType(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSNamedTupleMemberElementTypeConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSNamedTupleMemberIsOptionalConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateImportExpression(context: KNativePointer, source: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateImportExpression(context: KNativePointer, original: KNativePointer, source: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ImportExpressionSource(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ImportExpressionSourceConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateAstDumper(context: KNativePointer, node: KNativePointer, sourceCode: KStringPtr): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstDumperModifierToString(context: KNativePointer, receiver: KNativePointer, flags: KInt): KStringPtr { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstDumperTypeOperatorToString(context: KNativePointer, receiver: KNativePointer, operatorType: KInt): KStringPtr { + throw new Error("This methods was not overloaded by native module initialization") + } + _AstDumperStrConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateETSNullType(context: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateETSNullType(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateETSUndefinedType(context: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateETSUndefinedType(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTypeofExpression(context: KNativePointer, argument: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTypeofExpression(context: KNativePointer, original: KNativePointer, argument: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TypeofExpressionArgumentConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSEnumMember(context: KNativePointer, key: KNativePointer, init: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSEnumMember(context: KNativePointer, original: KNativePointer, key: KNativePointer, init: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSEnumMember1(context: KNativePointer, key: KNativePointer, init: KNativePointer, isGenerated: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSEnumMember1(context: KNativePointer, original: KNativePointer, key: KNativePointer, init: KNativePointer, isGenerated: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSEnumMemberKeyConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSEnumMemberKey(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSEnumMemberInitConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSEnumMemberInit(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSEnumMemberIsGeneratedConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSEnumMemberNameConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateSwitchStatement(context: KNativePointer, discriminant: KNativePointer, cases: BigUint64Array, casesSequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateSwitchStatement(context: KNativePointer, original: KNativePointer, discriminant: KNativePointer, cases: BigUint64Array, casesSequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _SwitchStatementDiscriminantConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _SwitchStatementDiscriminant(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _SwitchStatementSetDiscriminant(context: KNativePointer, receiver: KNativePointer, discriminant: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _SwitchStatementCasesConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _SwitchStatementCases(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateDoWhileStatement(context: KNativePointer, body: KNativePointer, test: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateDoWhileStatement(context: KNativePointer, original: KNativePointer, body: KNativePointer, test: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _DoWhileStatementBodyConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _DoWhileStatementBody(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _DoWhileStatementTestConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _DoWhileStatementTest(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateCatchClause(context: KNativePointer, param: KNativePointer, body: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateCatchClause(context: KNativePointer, original: KNativePointer, param: KNativePointer, body: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateCatchClause1(context: KNativePointer, other: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateCatchClause1(context: KNativePointer, original: KNativePointer, other: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CatchClauseParam(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CatchClauseParamConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CatchClauseBody(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CatchClauseBodyConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CatchClauseIsDefaultCatchClauseConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateSequenceExpression(context: KNativePointer, sequence_arg: BigUint64Array, sequence_argSequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateSequenceExpression(context: KNativePointer, original: KNativePointer, sequence_arg: BigUint64Array, sequence_argSequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _SequenceExpressionSequenceConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _SequenceExpressionSequence(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateArrowFunctionExpression(context: KNativePointer, func: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateArrowFunctionExpression(context: KNativePointer, original: KNativePointer, func: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateArrowFunctionExpression1(context: KNativePointer, other: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateArrowFunctionExpression1(context: KNativePointer, original: KNativePointer, other: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ArrowFunctionExpressionFunctionConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ArrowFunctionExpressionFunction(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ArrowFunctionExpressionCreateTypeAnnotation(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ArrowFunctionExpressionAnnotations(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ArrowFunctionExpressionAnnotationsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ArrowFunctionExpressionSetAnnotations(context: KNativePointer, receiver: KNativePointer, annotations: BigUint64Array, annotationsSequenceLength: KUInt): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateOmittedExpression(context: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateOmittedExpression(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateETSNewClassInstanceExpression(context: KNativePointer, typeReference: KNativePointer, _arguments: BigUint64Array, _argumentsSequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateETSNewClassInstanceExpression(context: KNativePointer, original: KNativePointer, typeReference: KNativePointer, _arguments: BigUint64Array, _argumentsSequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateETSNewClassInstanceExpression1(context: KNativePointer, other: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateETSNewClassInstanceExpression1(context: KNativePointer, original: KNativePointer, other: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSNewClassInstanceExpressionGetTypeRefConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSNewClassInstanceExpressionGetArguments(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSNewClassInstanceExpressionGetArgumentsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSNewClassInstanceExpressionSetArguments(context: KNativePointer, receiver: KNativePointer, _arguments: BigUint64Array, _argumentsSequenceLength: KUInt): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSNewClassInstanceExpressionAddToArgumentsFront(context: KNativePointer, receiver: KNativePointer, expr: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSAsExpression(context: KNativePointer, expression: KNativePointer, typeAnnotation: KNativePointer, isConst: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSAsExpression(context: KNativePointer, original: KNativePointer, expression: KNativePointer, typeAnnotation: KNativePointer, isConst: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSAsExpressionExprConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSAsExpressionExpr(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSAsExpressionSetExpr(context: KNativePointer, receiver: KNativePointer, expr: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSAsExpressionIsConstConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSAsExpressionSetUncheckedCast(context: KNativePointer, receiver: KNativePointer, isUncheckedCast: KBoolean): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSAsExpressionTypeAnnotationConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSAsExpressionSetTsTypeAnnotation(context: KNativePointer, receiver: KNativePointer, typeAnnotation: KNativePointer): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateForUpdateStatement(context: KNativePointer, init: KNativePointer, test: KNativePointer, update: KNativePointer, body: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ForUpdateStatementInit(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ForUpdateStatementInitConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ForUpdateStatementTest(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ForUpdateStatementTestConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ForUpdateStatementUpdateConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ForUpdateStatementBody(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ForUpdateStatementBodyConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateETSTypeReferencePart(context: KNativePointer, name: KNativePointer, typeParams: KNativePointer, prev: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateETSTypeReferencePart(context: KNativePointer, original: KNativePointer, name: KNativePointer, typeParams: KNativePointer, prev: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateETSTypeReferencePart1(context: KNativePointer, name: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateETSTypeReferencePart1(context: KNativePointer, original: KNativePointer, name: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSTypeReferencePartPrevious(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSTypeReferencePartPreviousConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSTypeReferencePartName(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSTypeReferencePartTypeParams(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSTypeReferencePartNameConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSTypeReferencePartGetIdent(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSReExportDeclarationGetETSImportDeclarationsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSReExportDeclarationGetETSImportDeclarations(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSReExportDeclarationGetProgramPathConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateETSPrimitiveType(context: KNativePointer, type: KInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateETSPrimitiveType(context: KNativePointer, original: KNativePointer, type: KInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSPrimitiveTypeGetPrimitiveTypeConst(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("This methods was not overloaded by native module initialization") + } + _TypeNodeAnnotations(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TypeNodeAnnotationsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TypeNodeSetAnnotations(context: KNativePointer, receiver: KNativePointer, annotations: BigUint64Array, annotationsSequenceLength: KUInt): void { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateNewExpression(context: KNativePointer, callee: KNativePointer, _arguments: BigUint64Array, _argumentsSequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateNewExpression(context: KNativePointer, original: KNativePointer, callee: KNativePointer, _arguments: BigUint64Array, _argumentsSequenceLength: KUInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _NewExpressionCalleeConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _NewExpressionArgumentsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSParameterProperty(context: KNativePointer, accessibility: KInt, parameter: KNativePointer, readonly_arg: KBoolean, isStatic: KBoolean, isExport: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSParameterProperty(context: KNativePointer, original: KNativePointer, accessibility: KInt, parameter: KNativePointer, readonly_arg: KBoolean, isStatic: KBoolean, isExport: KBoolean): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSParameterPropertyAccessibilityConst(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSParameterPropertyReadonlyConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSParameterPropertyIsStaticConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSParameterPropertyIsExportConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("This methods was not overloaded by native module initialization") + } + _TSParameterPropertyParameterConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateETSWildcardType(context: KNativePointer, typeReference: KNativePointer, flags: KInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateETSWildcardType(context: KNativePointer, original: KNativePointer, typeReference: KNativePointer, flags: KInt): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSWildcardTypeTypeReference(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _ETSWildcardTypeTypeReferenceConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateTSThisType(context: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _UpdateTSThisType(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateInterfaceDecl(context: KNativePointer, name: KStringPtr): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateInterfaceDecl1(context: KNativePointer, name: KStringPtr, declNode: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } + _CreateFunctionDecl(context: KNativePointer, name: KStringPtr, node: KNativePointer): KNativePointer { + throw new Error("This methods was not overloaded by native module initialization") + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/factory.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/factory.ts new file mode 100644 index 0000000000000000000000000000000000000000..793066c97ac0f437f3a92ee6094bf43c5562bac4 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/factory.ts @@ -0,0 +1,1277 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + isSameNativeObject, + unpackString, + updateNodeByNode +} from "../reexport-for-generated" + +import { AnnotationDeclaration } from "./peers/AnnotationDeclaration" +import { AnnotationUsage } from "./peers/AnnotationUsage" +import { ArrowFunctionExpression } from "./peers/ArrowFunctionExpression" +import { AssertStatement } from "./peers/AssertStatement" +import { AwaitExpression } from "./peers/AwaitExpression" +import { BigIntLiteral } from "./peers/BigIntLiteral" +import { BinaryExpression } from "./peers/BinaryExpression" +import { BlockExpression } from "./peers/BlockExpression" +import { BlockStatement } from "./peers/BlockStatement" +import { BooleanLiteral } from "./peers/BooleanLiteral" +import { BreakStatement } from "./peers/BreakStatement" +import { CatchClause } from "./peers/CatchClause" +import { ChainExpression } from "./peers/ChainExpression" +import { CharLiteral } from "./peers/CharLiteral" +import { ClassDeclaration } from "./peers/ClassDeclaration" +import { ClassDefinition } from "./peers/ClassDefinition" +import { ClassExpression } from "./peers/ClassExpression" +import { ConditionalExpression } from "./peers/ConditionalExpression" +import { ContinueStatement } from "./peers/ContinueStatement" +import { DebuggerStatement } from "./peers/DebuggerStatement" +import { Decorator } from "./peers/Decorator" +import { DoWhileStatement } from "./peers/DoWhileStatement" +import { ETSClassLiteral } from "./peers/ETSClassLiteral" +import { ETSKeyofType } from "./peers/ETSKeyofType" +import { ETSNewArrayInstanceExpression } from "./peers/ETSNewArrayInstanceExpression" +import { ETSNewClassInstanceExpression } from "./peers/ETSNewClassInstanceExpression" +import { ETSNewMultiDimArrayInstanceExpression } from "./peers/ETSNewMultiDimArrayInstanceExpression" +import { ETSNullType } from "./peers/ETSNullType" +import { ETSPrimitiveType } from "./peers/ETSPrimitiveType" +import { ETSTypeReference } from "./peers/ETSTypeReference" +import { ETSTypeReferencePart } from "./peers/ETSTypeReferencePart" +import { ETSUndefinedType } from "./peers/ETSUndefinedType" +import { ETSUnionType } from "./peers/ETSUnionType" +import { EmptyStatement } from "./peers/EmptyStatement" +import { Es2pandaMetaPropertyKind } from "./Es2pandaEnums" +import { Es2pandaPrimitiveType } from "./Es2pandaEnums" +import { Es2pandaPropertyKind } from "./Es2pandaEnums" +import { Es2pandaTokenType } from "./Es2pandaEnums" +import { Es2pandaVariableDeclarationKind } from "./Es2pandaEnums" +import { ExportAllDeclaration } from "./peers/ExportAllDeclaration" +import { ExportDefaultDeclaration } from "./peers/ExportDefaultDeclaration" +import { ExportSpecifier } from "./peers/ExportSpecifier" +import { Expression } from "./peers/Expression" +import { ExpressionStatement } from "./peers/ExpressionStatement" +import { ForInStatement } from "./peers/ForInStatement" +import { ForOfStatement } from "./peers/ForOfStatement" +import { ForUpdateStatement } from "./peers/ForUpdateStatement" +import { FunctionDeclaration } from "./peers/FunctionDeclaration" +import { FunctionExpression } from "./peers/FunctionExpression" +import { FunctionSignature } from "./peers/FunctionSignature" +import { Identifier } from "./peers/Identifier" +import { IfStatement } from "./peers/IfStatement" +import { ImportDefaultSpecifier } from "./peers/ImportDefaultSpecifier" +import { ImportExpression } from "./peers/ImportExpression" +import { ImportNamespaceSpecifier } from "./peers/ImportNamespaceSpecifier" +import { ImportSpecifier } from "./peers/ImportSpecifier" +import { LabelledStatement } from "./peers/LabelledStatement" +import { MetaProperty } from "./peers/MetaProperty" +import { NamedType } from "./peers/NamedType" +import { NewExpression } from "./peers/NewExpression" +import { NullLiteral } from "./peers/NullLiteral" +import { OmittedExpression } from "./peers/OmittedExpression" +import { OpaqueTypeNode } from "./peers/OpaqueTypeNode" +import { PrefixAssertionExpression } from "./peers/PrefixAssertionExpression" +import { Property } from "./peers/Property" +import { ReturnStatement } from "./peers/ReturnStatement" +import { ScriptFunction } from "./peers/ScriptFunction" +import { SequenceExpression } from "./peers/SequenceExpression" +import { Statement } from "./peers/Statement" +import { StringLiteral } from "./peers/StringLiteral" +import { SuperExpression } from "./peers/SuperExpression" +import { SwitchCaseStatement } from "./peers/SwitchCaseStatement" +import { SwitchStatement } from "./peers/SwitchStatement" +import { TSAnyKeyword } from "./peers/TSAnyKeyword" +import { TSArrayType } from "./peers/TSArrayType" +import { TSAsExpression } from "./peers/TSAsExpression" +import { TSBigintKeyword } from "./peers/TSBigintKeyword" +import { TSBooleanKeyword } from "./peers/TSBooleanKeyword" +import { TSClassImplements } from "./peers/TSClassImplements" +import { TSConditionalType } from "./peers/TSConditionalType" +import { TSEnumMember } from "./peers/TSEnumMember" +import { TSExternalModuleReference } from "./peers/TSExternalModuleReference" +import { TSImportEqualsDeclaration } from "./peers/TSImportEqualsDeclaration" +import { TSImportType } from "./peers/TSImportType" +import { TSIndexSignature } from "./peers/TSIndexSignature" +import { TSIndexedAccessType } from "./peers/TSIndexedAccessType" +import { TSInferType } from "./peers/TSInferType" +import { TSInterfaceBody } from "./peers/TSInterfaceBody" +import { TSInterfaceHeritage } from "./peers/TSInterfaceHeritage" +import { TSIntersectionType } from "./peers/TSIntersectionType" +import { TSLiteralType } from "./peers/TSLiteralType" +import { TSModuleBlock } from "./peers/TSModuleBlock" +import { TSNamedTupleMember } from "./peers/TSNamedTupleMember" +import { TSNeverKeyword } from "./peers/TSNeverKeyword" +import { TSNonNullExpression } from "./peers/TSNonNullExpression" +import { TSNullKeyword } from "./peers/TSNullKeyword" +import { TSNumberKeyword } from "./peers/TSNumberKeyword" +import { TSObjectKeyword } from "./peers/TSObjectKeyword" +import { TSQualifiedName } from "./peers/TSQualifiedName" +import { TSStringKeyword } from "./peers/TSStringKeyword" +import { TSThisType } from "./peers/TSThisType" +import { TSTupleType } from "./peers/TSTupleType" +import { TSTypeAliasDeclaration } from "./peers/TSTypeAliasDeclaration" +import { TSTypeAssertion } from "./peers/TSTypeAssertion" +import { TSTypeLiteral } from "./peers/TSTypeLiteral" +import { TSTypeParameter } from "./peers/TSTypeParameter" +import { TSTypeParameterDeclaration } from "./peers/TSTypeParameterDeclaration" +import { TSTypeParameterInstantiation } from "./peers/TSTypeParameterInstantiation" +import { TSTypePredicate } from "./peers/TSTypePredicate" +import { TSTypeQuery } from "./peers/TSTypeQuery" +import { TSTypeReference } from "./peers/TSTypeReference" +import { TSUndefinedKeyword } from "./peers/TSUndefinedKeyword" +import { TSUnionType } from "./peers/TSUnionType" +import { TSUnknownKeyword } from "./peers/TSUnknownKeyword" +import { TSVoidKeyword } from "./peers/TSVoidKeyword" +import { TaggedTemplateExpression } from "./peers/TaggedTemplateExpression" +import { TemplateElement } from "./peers/TemplateElement" +import { TemplateLiteral } from "./peers/TemplateLiteral" +import { ThisExpression } from "./peers/ThisExpression" +import { ThrowStatement } from "./peers/ThrowStatement" +import { TypeNode } from "./peers/TypeNode" +import { TypeofExpression } from "./peers/TypeofExpression" +import { UnaryExpression } from "./peers/UnaryExpression" +import { UndefinedLiteral } from "./peers/UndefinedLiteral" +import { UpdateExpression } from "./peers/UpdateExpression" +import { VariableDeclaration } from "./peers/VariableDeclaration" +import { VariableDeclarator } from "./peers/VariableDeclarator" +import { WhileStatement } from "./peers/WhileStatement" +import { YieldExpression } from "./peers/YieldExpression" +export const factory = { + createLabelledStatement(ident?: Identifier, body?: Statement): LabelledStatement { + return LabelledStatement.createLabelledStatement(ident, body) + } + , + updateLabelledStatement(original: LabelledStatement, ident?: Identifier, body?: Statement): LabelledStatement { + if (isSameNativeObject(ident, original.ident) && isSameNativeObject(body, original.body)) + return original + return updateNodeByNode(LabelledStatement.createLabelledStatement(ident, body), original) + } + , + createThrowStatement(argument?: Expression): ThrowStatement { + return ThrowStatement.createThrowStatement(argument) + } + , + updateThrowStatement(original: ThrowStatement, argument?: Expression): ThrowStatement { + if (isSameNativeObject(argument, original.argument)) + return original + return updateNodeByNode(ThrowStatement.createThrowStatement(argument), original) + } + , + createTSVoidKeyword(): TSVoidKeyword { + return TSVoidKeyword.createTSVoidKeyword() + } + , + updateTSVoidKeyword(original: TSVoidKeyword): TSVoidKeyword { + return updateNodeByNode(TSVoidKeyword.createTSVoidKeyword(), original) + } + , + createIfStatement(test?: Expression, consequent?: Statement, alternate?: Statement): IfStatement { + return IfStatement.createIfStatement(test, consequent, alternate) + } + , + updateIfStatement(original: IfStatement, test?: Expression, consequent?: Statement, alternate?: Statement): IfStatement { + if (isSameNativeObject(test, original.test) && isSameNativeObject(consequent, original.consequent) && isSameNativeObject(alternate, original.alternate)) + return original + return updateNodeByNode(IfStatement.createIfStatement(test, consequent, alternate), original) + } + , + createDecorator(expr?: Expression): Decorator { + return Decorator.createDecorator(expr) + } + , + updateDecorator(original: Decorator, expr?: Expression): Decorator { + if (isSameNativeObject(expr, original.expr)) + return original + return updateNodeByNode(Decorator.createDecorator(expr), original) + } + , + createTSNeverKeyword(): TSNeverKeyword { + return TSNeverKeyword.createTSNeverKeyword() + } + , + updateTSNeverKeyword(original: TSNeverKeyword): TSNeverKeyword { + return updateNodeByNode(TSNeverKeyword.createTSNeverKeyword(), original) + } + , + createImportDefaultSpecifier(local?: Identifier): ImportDefaultSpecifier { + return ImportDefaultSpecifier.createImportDefaultSpecifier(local) + } + , + updateImportDefaultSpecifier(original: ImportDefaultSpecifier, local?: Identifier): ImportDefaultSpecifier { + if (isSameNativeObject(local, original.local)) + return original + return updateNodeByNode(ImportDefaultSpecifier.createImportDefaultSpecifier(local), original) + } + , + createImportSpecifier(imported?: Identifier, local?: Identifier): ImportSpecifier { + return ImportSpecifier.createImportSpecifier(imported, local) + } + , + updateImportSpecifier(original: ImportSpecifier, imported?: Identifier, local?: Identifier): ImportSpecifier { + if (isSameNativeObject(imported, original.imported) && isSameNativeObject(local, original.local)) + return original + return updateNodeByNode(ImportSpecifier.createImportSpecifier(imported, local), original) + } + , + createConditionalExpression(test?: Expression, consequent?: Expression, alternate?: Expression): ConditionalExpression { + return ConditionalExpression.createConditionalExpression(test, consequent, alternate) + } + , + updateConditionalExpression(original: ConditionalExpression, test?: Expression, consequent?: Expression, alternate?: Expression): ConditionalExpression { + if (isSameNativeObject(test, original.test) && isSameNativeObject(consequent, original.consequent) && isSameNativeObject(alternate, original.alternate)) + return original + return updateNodeByNode(ConditionalExpression.createConditionalExpression(test, consequent, alternate), original) + } + , + createBigIntLiteral(str: string): BigIntLiteral { + return BigIntLiteral.createBigIntLiteral(str) + } + , + updateBigIntLiteral(original: BigIntLiteral, str: string): BigIntLiteral { + if (isSameNativeObject(str, original.str)) + return original + return updateNodeByNode(BigIntLiteral.createBigIntLiteral(str), original) + } + , + createTSImportType(param: Expression | undefined, typeParams: TSTypeParameterInstantiation | undefined, qualifier: Expression | undefined, isTypeof: boolean): TSImportType { + return TSImportType.createTSImportType(param, typeParams, qualifier, isTypeof) + } + , + updateTSImportType(original: TSImportType, param: Expression | undefined, typeParams: TSTypeParameterInstantiation | undefined, qualifier: Expression | undefined, isTypeof: boolean): TSImportType { + if (isSameNativeObject(param, original.param) && isSameNativeObject(typeParams, original.typeParams) && isSameNativeObject(qualifier, original.qualifier) && isSameNativeObject(isTypeof, original.isTypeof)) + return original + return updateNodeByNode(TSImportType.createTSImportType(param, typeParams, qualifier, isTypeof), original) + } + , + createTaggedTemplateExpression(tag?: Expression, quasi?: TemplateLiteral, typeParams?: TSTypeParameterInstantiation): TaggedTemplateExpression { + return TaggedTemplateExpression.createTaggedTemplateExpression(tag, quasi, typeParams) + } + , + updateTaggedTemplateExpression(original: TaggedTemplateExpression, tag?: Expression, quasi?: TemplateLiteral, typeParams?: TSTypeParameterInstantiation): TaggedTemplateExpression { + if (isSameNativeObject(tag, original.tag) && isSameNativeObject(quasi, original.quasi) && isSameNativeObject(typeParams, original.typeParams)) + return original + return updateNodeByNode(TaggedTemplateExpression.createTaggedTemplateExpression(tag, quasi, typeParams), original) + } + , + createFunctionDeclaration(_function: ScriptFunction | undefined, annotations: readonly AnnotationUsage[], isAnonymous: boolean): FunctionDeclaration { + return FunctionDeclaration.createFunctionDeclaration(_function, annotations, isAnonymous) + } + , + updateFunctionDeclaration(original: FunctionDeclaration, _function: ScriptFunction | undefined, annotations: readonly AnnotationUsage[], isAnonymous: boolean): FunctionDeclaration { + if (isSameNativeObject(_function, original.function) && isSameNativeObject(annotations, original.annotations) && isSameNativeObject(isAnonymous, original.isAnonymous)) + return original + return updateNodeByNode(FunctionDeclaration.createFunctionDeclaration(_function, annotations, isAnonymous), original) + } + , + createETSTypeReference(part?: ETSTypeReferencePart): ETSTypeReference { + return ETSTypeReference.createETSTypeReference(part) + } + , + updateETSTypeReference(original: ETSTypeReference, part?: ETSTypeReferencePart): ETSTypeReference { + if (isSameNativeObject(part, original.part)) + return original + return updateNodeByNode(ETSTypeReference.createETSTypeReference(part), original) + } + , + createTSTypeReference(typeName?: Expression, typeParams?: TSTypeParameterInstantiation): TSTypeReference { + return TSTypeReference.createTSTypeReference(typeName, typeParams) + } + , + updateTSTypeReference(original: TSTypeReference, typeName?: Expression, typeParams?: TSTypeParameterInstantiation): TSTypeReference { + if (isSameNativeObject(typeName, original.typeName) && isSameNativeObject(typeParams, original.typeParams)) + return original + return updateNodeByNode(TSTypeReference.createTSTypeReference(typeName, typeParams), original) + } + , + createNamedType(name?: Identifier): NamedType { + return NamedType.createNamedType(name) + } + , + updateNamedType(original: NamedType, name?: Identifier): NamedType { + if (isSameNativeObject(name, original.name)) + return original + return updateNodeByNode(NamedType.createNamedType(name), original) + } + , + createTemplateElement(raw: string, cooked: string): TemplateElement { + return TemplateElement.create1TemplateElement(raw, cooked) + } + , + updateTemplateElement(original: TemplateElement, raw: string, cooked: string): TemplateElement { + if (isSameNativeObject(raw, original.raw) && isSameNativeObject(cooked, original.cooked)) + return original + return updateNodeByNode(TemplateElement.create1TemplateElement(raw, cooked), original) + } + , + createVariableDeclaration(kind: Es2pandaVariableDeclarationKind, declarators: readonly VariableDeclarator[]): VariableDeclaration { + return VariableDeclaration.createVariableDeclaration(kind, declarators) + } + , + updateVariableDeclaration(original: VariableDeclaration, kind: Es2pandaVariableDeclarationKind, declarators: readonly VariableDeclarator[]): VariableDeclaration { + if (isSameNativeObject(kind, original.kind) && isSameNativeObject(declarators, original.declarators)) + return original + return updateNodeByNode(VariableDeclaration.createVariableDeclaration(kind, declarators), original) + } + , + createUndefinedLiteral(): UndefinedLiteral { + return UndefinedLiteral.createUndefinedLiteral() + } + , + updateUndefinedLiteral(original: UndefinedLiteral): UndefinedLiteral { + return updateNodeByNode(UndefinedLiteral.createUndefinedLiteral(), original) + } + , + createTSClassImplements(expr?: Expression, typeParameters?: TSTypeParameterInstantiation): TSClassImplements { + return TSClassImplements.createTSClassImplements(expr, typeParameters) + } + , + updateTSClassImplements(original: TSClassImplements, expr?: Expression, typeParameters?: TSTypeParameterInstantiation): TSClassImplements { + if (isSameNativeObject(expr, original.expr) && isSameNativeObject(typeParameters, original.typeParameters)) + return original + return updateNodeByNode(TSClassImplements.createTSClassImplements(expr, typeParameters), original) + } + , + createTSObjectKeyword(): TSObjectKeyword { + return TSObjectKeyword.createTSObjectKeyword() + } + , + updateTSObjectKeyword(original: TSObjectKeyword): TSObjectKeyword { + return updateNodeByNode(TSObjectKeyword.createTSObjectKeyword(), original) + } + , + createETSUnionType(types: readonly TypeNode[]): ETSUnionType { + return ETSUnionType.createETSUnionType(types) + } + , + updateETSUnionType(original: ETSUnionType, types: readonly TypeNode[]): ETSUnionType { + if (isSameNativeObject(types, original.types)) + return original + return updateNodeByNode(ETSUnionType.createETSUnionType(types), original) + } + , + createETSKeyofType(typeRef?: TypeNode): ETSKeyofType { + return ETSKeyofType.createETSKeyofType(typeRef) + } + , + updateETSKeyofType(original: ETSKeyofType, typeRef?: TypeNode): ETSKeyofType { + if (isSameNativeObject(typeRef, original.typeRef)) + return original + return updateNodeByNode(ETSKeyofType.createETSKeyofType(typeRef), original) + } + , + createTSConditionalType(checkType?: Expression, extendsType?: Expression, trueType?: Expression, falseType?: Expression): TSConditionalType { + return TSConditionalType.createTSConditionalType(checkType, extendsType, trueType, falseType) + } + , + updateTSConditionalType(original: TSConditionalType, checkType?: Expression, extendsType?: Expression, trueType?: Expression, falseType?: Expression): TSConditionalType { + if (isSameNativeObject(checkType, original.checkType) && isSameNativeObject(extendsType, original.extendsType) && isSameNativeObject(trueType, original.trueType) && isSameNativeObject(falseType, original.falseType)) + return original + return updateNodeByNode(TSConditionalType.createTSConditionalType(checkType, extendsType, trueType, falseType), original) + } + , + createTSLiteralType(literal?: Expression): TSLiteralType { + return TSLiteralType.createTSLiteralType(literal) + } + , + updateTSLiteralType(original: TSLiteralType, literal?: Expression): TSLiteralType { + if (isSameNativeObject(literal, original.literal)) + return original + return updateNodeByNode(TSLiteralType.createTSLiteralType(literal), original) + } + , + createTSTypeAliasDeclaration(id: Identifier | undefined, typeParams: TSTypeParameterDeclaration | undefined, typeAnnotation: TypeNode): TSTypeAliasDeclaration { + return TSTypeAliasDeclaration.createTSTypeAliasDeclaration(id, typeParams, typeAnnotation) + } + , + updateTSTypeAliasDeclaration(original: TSTypeAliasDeclaration, id: Identifier | undefined, typeParams: TSTypeParameterDeclaration | undefined, typeAnnotation: TypeNode): TSTypeAliasDeclaration { + if (isSameNativeObject(id, original.id) && isSameNativeObject(typeParams, original.typeParams) && isSameNativeObject(typeAnnotation, original.typeAnnotation)) + return original + return updateNodeByNode(TSTypeAliasDeclaration.createTSTypeAliasDeclaration(id, typeParams, typeAnnotation), original) + } + , + createDebuggerStatement(): DebuggerStatement { + return DebuggerStatement.createDebuggerStatement() + } + , + updateDebuggerStatement(original: DebuggerStatement): DebuggerStatement { + return updateNodeByNode(DebuggerStatement.createDebuggerStatement(), original) + } + , + createReturnStatement(argument?: Expression): ReturnStatement { + return ReturnStatement.create1ReturnStatement(argument) + } + , + updateReturnStatement(original: ReturnStatement, argument?: Expression): ReturnStatement { + if (isSameNativeObject(argument, original.argument)) + return original + return updateNodeByNode(ReturnStatement.create1ReturnStatement(argument), original) + } + , + createExportDefaultDeclaration(decl: AstNode | undefined, isExportEquals: boolean): ExportDefaultDeclaration { + return ExportDefaultDeclaration.createExportDefaultDeclaration(decl, isExportEquals) + } + , + updateExportDefaultDeclaration(original: ExportDefaultDeclaration, decl: AstNode | undefined, isExportEquals: boolean): ExportDefaultDeclaration { + if (isSameNativeObject(decl, original.decl) && isSameNativeObject(isExportEquals, original.isExportEquals)) + return original + return updateNodeByNode(ExportDefaultDeclaration.createExportDefaultDeclaration(decl, isExportEquals), original) + } + , + createTSInterfaceBody(body: readonly AstNode[]): TSInterfaceBody { + return TSInterfaceBody.createTSInterfaceBody(body) + } + , + updateTSInterfaceBody(original: TSInterfaceBody, body: readonly AstNode[]): TSInterfaceBody { + if (isSameNativeObject(body, original.body)) + return original + return updateNodeByNode(TSInterfaceBody.createTSInterfaceBody(body), original) + } + , + createTSTypeQuery(exprName?: Expression): TSTypeQuery { + return TSTypeQuery.createTSTypeQuery(exprName) + } + , + updateTSTypeQuery(original: TSTypeQuery, exprName?: Expression): TSTypeQuery { + if (isSameNativeObject(exprName, original.exprName)) + return original + return updateNodeByNode(TSTypeQuery.createTSTypeQuery(exprName), original) + } + , + createTSBigintKeyword(): TSBigintKeyword { + return TSBigintKeyword.createTSBigintKeyword() + } + , + updateTSBigintKeyword(original: TSBigintKeyword): TSBigintKeyword { + return updateNodeByNode(TSBigintKeyword.createTSBigintKeyword(), original) + } + , + createProperty(kind: Es2pandaPropertyKind, key: Expression | undefined, value: Expression | undefined, isMethod: boolean, isComputed: boolean): Property { + return Property.create1Property(kind, key, value, isMethod, isComputed) + } + , + updateProperty(original: Property, kind: Es2pandaPropertyKind, key: Expression | undefined, value: Expression | undefined, isMethod: boolean, isComputed: boolean): Property { + if (isSameNativeObject(kind, original.kind) && isSameNativeObject(key, original.key) && isSameNativeObject(value, original.value) && isSameNativeObject(isMethod, original.isMethod) && isSameNativeObject(isComputed, original.isComputed)) + return original + return updateNodeByNode(Property.create1Property(kind, key, value, isMethod, isComputed), original) + } + , + createStringLiteral(str: string): StringLiteral { + return StringLiteral.create1StringLiteral(str) + } + , + updateStringLiteral(original: StringLiteral, str: string): StringLiteral { + if (isSameNativeObject(str, original.str)) + return original + return updateNodeByNode(StringLiteral.create1StringLiteral(str), original) + } + , + createTSTypeAssertion(typeAnnotation?: TypeNode, expression?: Expression): TSTypeAssertion { + return TSTypeAssertion.createTSTypeAssertion(typeAnnotation, expression) + } + , + updateTSTypeAssertion(original: TSTypeAssertion, typeAnnotation?: TypeNode, expression?: Expression): TSTypeAssertion { + if (isSameNativeObject(typeAnnotation, original.typeAnnotation) && isSameNativeObject(expression, original.expression)) + return original + return updateNodeByNode(TSTypeAssertion.createTSTypeAssertion(typeAnnotation, expression), original) + } + , + createTSExternalModuleReference(expr?: Expression): TSExternalModuleReference { + return TSExternalModuleReference.createTSExternalModuleReference(expr) + } + , + updateTSExternalModuleReference(original: TSExternalModuleReference, expr?: Expression): TSExternalModuleReference { + if (isSameNativeObject(expr, original.expr)) + return original + return updateNodeByNode(TSExternalModuleReference.createTSExternalModuleReference(expr), original) + } + , + createTSUndefinedKeyword(): TSUndefinedKeyword { + return TSUndefinedKeyword.createTSUndefinedKeyword() + } + , + updateTSUndefinedKeyword(original: TSUndefinedKeyword): TSUndefinedKeyword { + return updateNodeByNode(TSUndefinedKeyword.createTSUndefinedKeyword(), original) + } + , + createUnaryExpression(argument: Expression | undefined, operatorType: Es2pandaTokenType): UnaryExpression { + return UnaryExpression.createUnaryExpression(argument, operatorType) + } + , + updateUnaryExpression(original: UnaryExpression, argument: Expression | undefined, operatorType: Es2pandaTokenType): UnaryExpression { + if (isSameNativeObject(argument, original.argument) && isSameNativeObject(operatorType, original.operatorType)) + return original + return updateNodeByNode(UnaryExpression.createUnaryExpression(argument, operatorType), original) + } + , + createForInStatement(left?: AstNode, right?: Expression, body?: Statement): ForInStatement { + return ForInStatement.createForInStatement(left, right, body) + } + , + updateForInStatement(original: ForInStatement, left?: AstNode, right?: Expression, body?: Statement): ForInStatement { + if (isSameNativeObject(left, original.left) && isSameNativeObject(right, original.right) && isSameNativeObject(body, original.body)) + return original + return updateNodeByNode(ForInStatement.createForInStatement(left, right, body), original) + } + , + createThisExpression(): ThisExpression { + return ThisExpression.createThisExpression() + } + , + updateThisExpression(original: ThisExpression): ThisExpression { + return updateNodeByNode(ThisExpression.createThisExpression(), original) + } + , + createBinaryExpression(left: Expression | undefined, right: Expression | undefined, operatorType: Es2pandaTokenType): BinaryExpression { + return BinaryExpression.createBinaryExpression(left, right, operatorType) + } + , + updateBinaryExpression(original: BinaryExpression, left: Expression | undefined, right: Expression | undefined, operatorType: Es2pandaTokenType): BinaryExpression { + if (isSameNativeObject(left, original.left) && isSameNativeObject(right, original.right) && isSameNativeObject(operatorType, original.operatorType)) + return original + return updateNodeByNode(BinaryExpression.createBinaryExpression(left, right, operatorType), original) + } + , + createSuperExpression(): SuperExpression { + return SuperExpression.createSuperExpression() + } + , + updateSuperExpression(original: SuperExpression): SuperExpression { + return updateNodeByNode(SuperExpression.createSuperExpression(), original) + } + , + createAssertStatement(test?: Expression, second?: Expression): AssertStatement { + return AssertStatement.createAssertStatement(test, second) + } + , + updateAssertStatement(original: AssertStatement, test?: Expression, second?: Expression): AssertStatement { + if (isSameNativeObject(test, original.test) && isSameNativeObject(second, original.second)) + return original + return updateNodeByNode(AssertStatement.createAssertStatement(test, second), original) + } + , + createTSStringKeyword(): TSStringKeyword { + return TSStringKeyword.createTSStringKeyword() + } + , + updateTSStringKeyword(original: TSStringKeyword): TSStringKeyword { + return updateNodeByNode(TSStringKeyword.createTSStringKeyword(), original) + } + , + createExpressionStatement(expression?: Expression): ExpressionStatement { + return ExpressionStatement.createExpressionStatement(expression) + } + , + updateExpressionStatement(original: ExpressionStatement, expression?: Expression): ExpressionStatement { + if (isSameNativeObject(expression, original.expression)) + return original + return updateNodeByNode(ExpressionStatement.createExpressionStatement(expression), original) + } + , + createMetaProperty(kind: Es2pandaMetaPropertyKind): MetaProperty { + return MetaProperty.createMetaProperty(kind) + } + , + updateMetaProperty(original: MetaProperty, kind: Es2pandaMetaPropertyKind): MetaProperty { + if (isSameNativeObject(kind, original.kind)) + return original + return updateNodeByNode(MetaProperty.createMetaProperty(kind), original) + } + , + createTSArrayType(elementType?: TypeNode): TSArrayType { + return TSArrayType.createTSArrayType(elementType) + } + , + updateTSArrayType(original: TSArrayType, elementType?: TypeNode): TSArrayType { + if (isSameNativeObject(elementType, original.elementType)) + return original + return updateNodeByNode(TSArrayType.createTSArrayType(elementType), original) + } + , + createExportAllDeclaration(source?: StringLiteral, exported?: Identifier): ExportAllDeclaration { + return ExportAllDeclaration.createExportAllDeclaration(source, exported) + } + , + updateExportAllDeclaration(original: ExportAllDeclaration, source?: StringLiteral, exported?: Identifier): ExportAllDeclaration { + if (isSameNativeObject(source, original.source) && isSameNativeObject(exported, original.exported)) + return original + return updateNodeByNode(ExportAllDeclaration.createExportAllDeclaration(source, exported), original) + } + , + createExportSpecifier(local?: Identifier, exported?: Identifier): ExportSpecifier { + return ExportSpecifier.createExportSpecifier(local, exported) + } + , + updateExportSpecifier(original: ExportSpecifier, local?: Identifier, exported?: Identifier): ExportSpecifier { + if (isSameNativeObject(local, original.local) && isSameNativeObject(exported, original.exported)) + return original + return updateNodeByNode(ExportSpecifier.createExportSpecifier(local, exported), original) + } + , + createTSTupleType(elementType: readonly TypeNode[]): TSTupleType { + return TSTupleType.createTSTupleType(elementType) + } + , + updateTSTupleType(original: TSTupleType, elementType: readonly TypeNode[]): TSTupleType { + if (isSameNativeObject(elementType, original.elementType)) + return original + return updateNodeByNode(TSTupleType.createTSTupleType(elementType), original) + } + , + createFunctionExpression(id?: Identifier, _function?: ScriptFunction): FunctionExpression { + return FunctionExpression.create1FunctionExpression(id, _function) + } + , + updateFunctionExpression(original: FunctionExpression, id?: Identifier, _function?: ScriptFunction): FunctionExpression { + if (isSameNativeObject(id, original.id) && isSameNativeObject(_function, original.function)) + return original + return updateNodeByNode(FunctionExpression.create1FunctionExpression(id, _function), original) + } + , + createTSIndexSignature(param: Expression | undefined, typeAnnotation: TypeNode | undefined, readonly: boolean): TSIndexSignature { + return TSIndexSignature.createTSIndexSignature(param, typeAnnotation, readonly) + } + , + updateTSIndexSignature(original: TSIndexSignature, param: Expression | undefined, typeAnnotation: TypeNode | undefined, readonly: boolean): TSIndexSignature { + if (isSameNativeObject(param, original.param) && isSameNativeObject(typeAnnotation, original.typeAnnotation) && isSameNativeObject(readonly, original.readonly)) + return original + return updateNodeByNode(TSIndexSignature.createTSIndexSignature(param, typeAnnotation, readonly), original) + } + , + createCharLiteral(): CharLiteral { + return CharLiteral.createCharLiteral() + } + , + updateCharLiteral(original: CharLiteral): CharLiteral { + return updateNodeByNode(CharLiteral.createCharLiteral(), original) + } + , + createTSModuleBlock(statements: readonly Statement[]): TSModuleBlock { + return TSModuleBlock.createTSModuleBlock(statements) + } + , + updateTSModuleBlock(original: TSModuleBlock, statements: readonly Statement[]): TSModuleBlock { + if (isSameNativeObject(statements, original.statements)) + return original + return updateNodeByNode(TSModuleBlock.createTSModuleBlock(statements), original) + } + , + createETSNewArrayInstanceExpression(typeReference?: TypeNode, dimension?: Expression): ETSNewArrayInstanceExpression { + return ETSNewArrayInstanceExpression.createETSNewArrayInstanceExpression(typeReference, dimension) + } + , + updateETSNewArrayInstanceExpression(original: ETSNewArrayInstanceExpression, typeReference?: TypeNode, dimension?: Expression): ETSNewArrayInstanceExpression { + if (isSameNativeObject(typeReference, original.typeReference) && isSameNativeObject(dimension, original.dimension)) + return original + return updateNodeByNode(ETSNewArrayInstanceExpression.createETSNewArrayInstanceExpression(typeReference, dimension), original) + } + , + createAnnotationDeclaration(expr: Expression | undefined, properties: readonly AstNode[]): AnnotationDeclaration { + return AnnotationDeclaration.create1AnnotationDeclaration(expr, properties) + } + , + updateAnnotationDeclaration(original: AnnotationDeclaration, expr: Expression | undefined, properties: readonly AstNode[]): AnnotationDeclaration { + if (isSameNativeObject(expr, original.expr) && isSameNativeObject(properties, original.properties)) + return original + return updateNodeByNode(AnnotationDeclaration.create1AnnotationDeclaration(expr, properties), original) + } + , + createAnnotationUsage(expr: Expression | undefined, properties: readonly AstNode[]): AnnotationUsage { + return AnnotationUsage.create1AnnotationUsage(expr, properties) + } + , + updateAnnotationUsage(original: AnnotationUsage, expr: Expression | undefined, properties: readonly AstNode[]): AnnotationUsage { + if (isSameNativeObject(expr, original.expr) && isSameNativeObject(properties, original.properties)) + return original + return updateNodeByNode(AnnotationUsage.create1AnnotationUsage(expr, properties), original) + } + , + createEmptyStatement(): EmptyStatement { + return EmptyStatement.createEmptyStatement() + } + , + updateEmptyStatement(original: EmptyStatement): EmptyStatement { + return updateNodeByNode(EmptyStatement.createEmptyStatement(), original) + } + , + createWhileStatement(test?: Expression, body?: Statement): WhileStatement { + return WhileStatement.createWhileStatement(test, body) + } + , + updateWhileStatement(original: WhileStatement, test?: Expression, body?: Statement): WhileStatement { + if (isSameNativeObject(test, original.test) && isSameNativeObject(body, original.body)) + return original + return updateNodeByNode(WhileStatement.createWhileStatement(test, body), original) + } + , + createFunctionSignature(typeParams: TSTypeParameterDeclaration | undefined, params: readonly Expression[], returnType: TypeNode | undefined, hasReceiver: boolean): FunctionSignature { + return FunctionSignature.createFunctionSignature(typeParams, params, returnType, hasReceiver) + } + , + updateFunctionSignature(original: FunctionSignature, typeParams: TSTypeParameterDeclaration | undefined, params: readonly Expression[], returnType: TypeNode | undefined, hasReceiver: boolean): FunctionSignature { + if (isSameNativeObject(typeParams, original.typeParams) && isSameNativeObject(params, original.params) && isSameNativeObject(returnType, original.returnType) && isSameNativeObject(hasReceiver, original.hasReceiver)) + return original + return updateNodeByNode(FunctionSignature.createFunctionSignature(typeParams, params, returnType, hasReceiver), original) + } + , + createChainExpression(expression?: Expression): ChainExpression { + return ChainExpression.createChainExpression(expression) + } + , + updateChainExpression(original: ChainExpression, expression?: Expression): ChainExpression { + if (isSameNativeObject(expression, original.expression)) + return original + return updateNodeByNode(ChainExpression.createChainExpression(expression), original) + } + , + createTSIntersectionType(types: readonly Expression[]): TSIntersectionType { + return TSIntersectionType.createTSIntersectionType(types) + } + , + updateTSIntersectionType(original: TSIntersectionType, types: readonly Expression[]): TSIntersectionType { + if (isSameNativeObject(types, original.types)) + return original + return updateNodeByNode(TSIntersectionType.createTSIntersectionType(types), original) + } + , + createUpdateExpression(argument: Expression | undefined, operatorType: Es2pandaTokenType, isPrefix: boolean): UpdateExpression { + return UpdateExpression.createUpdateExpression(argument, operatorType, isPrefix) + } + , + updateUpdateExpression(original: UpdateExpression, argument: Expression | undefined, operatorType: Es2pandaTokenType, isPrefix: boolean): UpdateExpression { + if (isSameNativeObject(argument, original.argument) && isSameNativeObject(operatorType, original.operatorType) && isSameNativeObject(isPrefix, original.isPrefix)) + return original + return updateNodeByNode(UpdateExpression.createUpdateExpression(argument, operatorType, isPrefix), original) + } + , + createBlockExpression(statements: readonly Statement[]): BlockExpression { + return BlockExpression.createBlockExpression(statements) + } + , + updateBlockExpression(original: BlockExpression, statements: readonly Statement[]): BlockExpression { + if (isSameNativeObject(statements, original.statements)) + return original + return updateNodeByNode(BlockExpression.createBlockExpression(statements), original) + } + , + createTSTypeLiteral(members: readonly AstNode[]): TSTypeLiteral { + return TSTypeLiteral.createTSTypeLiteral(members) + } + , + updateTSTypeLiteral(original: TSTypeLiteral, members: readonly AstNode[]): TSTypeLiteral { + if (isSameNativeObject(members, original.members)) + return original + return updateNodeByNode(TSTypeLiteral.createTSTypeLiteral(members), original) + } + , + createTSBooleanKeyword(): TSBooleanKeyword { + return TSBooleanKeyword.createTSBooleanKeyword() + } + , + updateTSBooleanKeyword(original: TSBooleanKeyword): TSBooleanKeyword { + return updateNodeByNode(TSBooleanKeyword.createTSBooleanKeyword(), original) + } + , + createTSTypePredicate(parameterName: Expression | undefined, typeAnnotation: TypeNode | undefined, asserts: boolean): TSTypePredicate { + return TSTypePredicate.createTSTypePredicate(parameterName, typeAnnotation, asserts) + } + , + updateTSTypePredicate(original: TSTypePredicate, parameterName: Expression | undefined, typeAnnotation: TypeNode | undefined, asserts: boolean): TSTypePredicate { + if (isSameNativeObject(parameterName, original.parameterName) && isSameNativeObject(typeAnnotation, original.typeAnnotation) && isSameNativeObject(asserts, original.asserts)) + return original + return updateNodeByNode(TSTypePredicate.createTSTypePredicate(parameterName, typeAnnotation, asserts), original) + } + , + createImportNamespaceSpecifier(local?: Identifier): ImportNamespaceSpecifier { + return ImportNamespaceSpecifier.createImportNamespaceSpecifier(local) + } + , + updateImportNamespaceSpecifier(original: ImportNamespaceSpecifier, local?: Identifier): ImportNamespaceSpecifier { + if (isSameNativeObject(local, original.local)) + return original + return updateNodeByNode(ImportNamespaceSpecifier.createImportNamespaceSpecifier(local), original) + } + , + createTSTypeParameterInstantiation(params: readonly TypeNode[]): TSTypeParameterInstantiation { + return TSTypeParameterInstantiation.createTSTypeParameterInstantiation(params) + } + , + updateTSTypeParameterInstantiation(original: TSTypeParameterInstantiation, params: readonly TypeNode[]): TSTypeParameterInstantiation { + if (isSameNativeObject(params, original.params)) + return original + return updateNodeByNode(TSTypeParameterInstantiation.createTSTypeParameterInstantiation(params), original) + } + , + createNullLiteral(): NullLiteral { + return NullLiteral.createNullLiteral() + } + , + updateNullLiteral(original: NullLiteral): NullLiteral { + return updateNodeByNode(NullLiteral.createNullLiteral(), original) + } + , + createTSInferType(typeParam?: TSTypeParameter): TSInferType { + return TSInferType.createTSInferType(typeParam) + } + , + updateTSInferType(original: TSInferType, typeParam?: TSTypeParameter): TSInferType { + if (isSameNativeObject(typeParam, original.typeParam)) + return original + return updateNodeByNode(TSInferType.createTSInferType(typeParam), original) + } + , + createSwitchCaseStatement(test: Expression | undefined, consequent: readonly Statement[]): SwitchCaseStatement { + return SwitchCaseStatement.createSwitchCaseStatement(test, consequent) + } + , + updateSwitchCaseStatement(original: SwitchCaseStatement, test: Expression | undefined, consequent: readonly Statement[]): SwitchCaseStatement { + if (isSameNativeObject(test, original.test) && isSameNativeObject(consequent, original.consequent)) + return original + return updateNodeByNode(SwitchCaseStatement.createSwitchCaseStatement(test, consequent), original) + } + , + createYieldExpression(argument: Expression | undefined, hasDelegate: boolean): YieldExpression { + return YieldExpression.createYieldExpression(argument, hasDelegate) + } + , + updateYieldExpression(original: YieldExpression, argument: Expression | undefined, hasDelegate: boolean): YieldExpression { + if (isSameNativeObject(argument, original.argument) && isSameNativeObject(hasDelegate, original.hasDelegate)) + return original + return updateNodeByNode(YieldExpression.createYieldExpression(argument, hasDelegate), original) + } + , + createTSImportEqualsDeclaration(id: Identifier | undefined, moduleReference: Expression | undefined, isExport: boolean): TSImportEqualsDeclaration { + return TSImportEqualsDeclaration.createTSImportEqualsDeclaration(id, moduleReference, isExport) + } + , + updateTSImportEqualsDeclaration(original: TSImportEqualsDeclaration, id: Identifier | undefined, moduleReference: Expression | undefined, isExport: boolean): TSImportEqualsDeclaration { + if (isSameNativeObject(id, original.id) && isSameNativeObject(moduleReference, original.moduleReference) && isSameNativeObject(isExport, original.isExport)) + return original + return updateNodeByNode(TSImportEqualsDeclaration.createTSImportEqualsDeclaration(id, moduleReference, isExport), original) + } + , + createBooleanLiteral(value: boolean): BooleanLiteral { + return BooleanLiteral.createBooleanLiteral(value) + } + , + updateBooleanLiteral(original: BooleanLiteral, value: boolean): BooleanLiteral { + if (isSameNativeObject(value, original.value)) + return original + return updateNodeByNode(BooleanLiteral.createBooleanLiteral(value), original) + } + , + createTSNumberKeyword(): TSNumberKeyword { + return TSNumberKeyword.createTSNumberKeyword() + } + , + updateTSNumberKeyword(original: TSNumberKeyword): TSNumberKeyword { + return updateNodeByNode(TSNumberKeyword.createTSNumberKeyword(), original) + } + , + createTSNonNullExpression(expr?: Expression): TSNonNullExpression { + return TSNonNullExpression.createTSNonNullExpression(expr) + } + , + updateTSNonNullExpression(original: TSNonNullExpression, expr?: Expression): TSNonNullExpression { + if (isSameNativeObject(expr, original.expr)) + return original + return updateNodeByNode(TSNonNullExpression.createTSNonNullExpression(expr), original) + } + , + createPrefixAssertionExpression(expr?: Expression, type?: TypeNode): PrefixAssertionExpression { + return PrefixAssertionExpression.createPrefixAssertionExpression(expr, type) + } + , + updatePrefixAssertionExpression(original: PrefixAssertionExpression, expr?: Expression, type?: TypeNode): PrefixAssertionExpression { + if (isSameNativeObject(expr, original.expr) && isSameNativeObject(type, original.type)) + return original + return updateNodeByNode(PrefixAssertionExpression.createPrefixAssertionExpression(expr, type), original) + } + , + createClassExpression(definition?: ClassDefinition): ClassExpression { + return ClassExpression.createClassExpression(definition) + } + , + updateClassExpression(original: ClassExpression, definition?: ClassDefinition): ClassExpression { + if (isSameNativeObject(definition, original.definition)) + return original + return updateNodeByNode(ClassExpression.createClassExpression(definition), original) + } + , + createForOfStatement(left: AstNode | undefined, right: Expression | undefined, body: Statement | undefined, isAwait: boolean): ForOfStatement { + return ForOfStatement.createForOfStatement(left, right, body, isAwait) + } + , + updateForOfStatement(original: ForOfStatement, left: AstNode | undefined, right: Expression | undefined, body: Statement | undefined, isAwait: boolean): ForOfStatement { + if (isSameNativeObject(left, original.left) && isSameNativeObject(right, original.right) && isSameNativeObject(body, original.body) && isSameNativeObject(isAwait, original.isAwait)) + return original + return updateNodeByNode(ForOfStatement.createForOfStatement(left, right, body, isAwait), original) + } + , + createTemplateLiteral(quasis: readonly TemplateElement[], expressions: readonly Expression[], multilineString: string): TemplateLiteral { + return TemplateLiteral.createTemplateLiteral(quasis, expressions, multilineString) + } + , + updateTemplateLiteral(original: TemplateLiteral, quasis: readonly TemplateElement[], expressions: readonly Expression[], multilineString: string): TemplateLiteral { + if (isSameNativeObject(quasis, original.quasis) && isSameNativeObject(expressions, original.expressions) && isSameNativeObject(multilineString, original.multilineString)) + return original + return updateNodeByNode(TemplateLiteral.createTemplateLiteral(quasis, expressions, multilineString), original) + } + , + createTSUnionType(types: readonly TypeNode[]): TSUnionType { + return TSUnionType.createTSUnionType(types) + } + , + updateTSUnionType(original: TSUnionType, types: readonly TypeNode[]): TSUnionType { + if (isSameNativeObject(types, original.types)) + return original + return updateNodeByNode(TSUnionType.createTSUnionType(types), original) + } + , + createTSUnknownKeyword(): TSUnknownKeyword { + return TSUnknownKeyword.createTSUnknownKeyword() + } + , + updateTSUnknownKeyword(original: TSUnknownKeyword): TSUnknownKeyword { + return updateNodeByNode(TSUnknownKeyword.createTSUnknownKeyword(), original) + } + , + createIdentifier(name: string, typeAnnotation?: TypeNode): Identifier { + return Identifier.create2Identifier(name, typeAnnotation) + } + , + updateIdentifier(original: Identifier, name: string, typeAnnotation?: TypeNode): Identifier { + if (isSameNativeObject(name, original.name) && isSameNativeObject(typeAnnotation, original.typeAnnotation)) + return original + return updateNodeByNode(Identifier.create2Identifier(name, typeAnnotation), original) + } + , + createOpaqueTypeNode(): OpaqueTypeNode { + return OpaqueTypeNode.create1OpaqueTypeNode() + } + , + updateOpaqueTypeNode(original: OpaqueTypeNode): OpaqueTypeNode { + return updateNodeByNode(OpaqueTypeNode.create1OpaqueTypeNode(), original) + } + , + createBlockStatement(statements: readonly Statement[]): BlockStatement { + return BlockStatement.createBlockStatement(statements) + } + , + updateBlockStatement(original: BlockStatement, statements: readonly Statement[]): BlockStatement { + if (isSameNativeObject(statements, original.statements)) + return original + return updateNodeByNode(BlockStatement.createBlockStatement(statements), original) + } + , + createTSTypeParameterDeclaration(params: readonly TSTypeParameter[], requiredParams: number): TSTypeParameterDeclaration { + return TSTypeParameterDeclaration.createTSTypeParameterDeclaration(params, requiredParams) + } + , + updateTSTypeParameterDeclaration(original: TSTypeParameterDeclaration, params: readonly TSTypeParameter[], requiredParams: number): TSTypeParameterDeclaration { + if (isSameNativeObject(params, original.params) && isSameNativeObject(requiredParams, original.requiredParams)) + return original + return updateNodeByNode(TSTypeParameterDeclaration.createTSTypeParameterDeclaration(params, requiredParams), original) + } + , + createTSNullKeyword(): TSNullKeyword { + return TSNullKeyword.createTSNullKeyword() + } + , + updateTSNullKeyword(original: TSNullKeyword): TSNullKeyword { + return updateNodeByNode(TSNullKeyword.createTSNullKeyword(), original) + } + , + createTSInterfaceHeritage(expr?: TypeNode): TSInterfaceHeritage { + return TSInterfaceHeritage.createTSInterfaceHeritage(expr) + } + , + updateTSInterfaceHeritage(original: TSInterfaceHeritage, expr?: TypeNode): TSInterfaceHeritage { + if (isSameNativeObject(expr, original.expr)) + return original + return updateNodeByNode(TSInterfaceHeritage.createTSInterfaceHeritage(expr), original) + } + , + createETSClassLiteral(expr?: TypeNode): ETSClassLiteral { + return ETSClassLiteral.createETSClassLiteral(expr) + } + , + updateETSClassLiteral(original: ETSClassLiteral, expr?: TypeNode): ETSClassLiteral { + if (isSameNativeObject(expr, original.expr)) + return original + return updateNodeByNode(ETSClassLiteral.createETSClassLiteral(expr), original) + } + , + createBreakStatement(ident?: Identifier): BreakStatement { + return BreakStatement.create1BreakStatement(ident) + } + , + updateBreakStatement(original: BreakStatement, ident?: Identifier): BreakStatement { + if (isSameNativeObject(ident, original.ident)) + return original + return updateNodeByNode(BreakStatement.create1BreakStatement(ident), original) + } + , + createTSAnyKeyword(): TSAnyKeyword { + return TSAnyKeyword.createTSAnyKeyword() + } + , + updateTSAnyKeyword(original: TSAnyKeyword): TSAnyKeyword { + return updateNodeByNode(TSAnyKeyword.createTSAnyKeyword(), original) + } + , + createClassDeclaration(definition?: ClassDefinition): ClassDeclaration { + return ClassDeclaration.createClassDeclaration(definition) + } + , + updateClassDeclaration(original: ClassDeclaration, definition?: ClassDefinition): ClassDeclaration { + if (isSameNativeObject(definition, original.definition)) + return original + return updateNodeByNode(ClassDeclaration.createClassDeclaration(definition), original) + } + , + createTSIndexedAccessType(objectType?: TypeNode, indexType?: TypeNode): TSIndexedAccessType { + return TSIndexedAccessType.createTSIndexedAccessType(objectType, indexType) + } + , + updateTSIndexedAccessType(original: TSIndexedAccessType, objectType?: TypeNode, indexType?: TypeNode): TSIndexedAccessType { + if (isSameNativeObject(objectType, original.objectType) && isSameNativeObject(indexType, original.indexType)) + return original + return updateNodeByNode(TSIndexedAccessType.createTSIndexedAccessType(objectType, indexType), original) + } + , + createTSQualifiedName(left?: Expression, right?: Identifier): TSQualifiedName { + return TSQualifiedName.createTSQualifiedName(left, right) + } + , + updateTSQualifiedName(original: TSQualifiedName, left?: Expression, right?: Identifier): TSQualifiedName { + if (isSameNativeObject(left, original.left) && isSameNativeObject(right, original.right)) + return original + return updateNodeByNode(TSQualifiedName.createTSQualifiedName(left, right), original) + } + , + createAwaitExpression(argument?: Expression): AwaitExpression { + return AwaitExpression.createAwaitExpression(argument) + } + , + updateAwaitExpression(original: AwaitExpression, argument?: Expression): AwaitExpression { + if (isSameNativeObject(argument, original.argument)) + return original + return updateNodeByNode(AwaitExpression.createAwaitExpression(argument), original) + } + , + createContinueStatement(ident?: Identifier): ContinueStatement { + return ContinueStatement.create1ContinueStatement(ident) + } + , + updateContinueStatement(original: ContinueStatement, ident?: Identifier): ContinueStatement { + if (isSameNativeObject(ident, original.ident)) + return original + return updateNodeByNode(ContinueStatement.create1ContinueStatement(ident), original) + } + , + createETSNewMultiDimArrayInstanceExpression(typeReference: TypeNode | undefined, dimensions: readonly Expression[]): ETSNewMultiDimArrayInstanceExpression { + return ETSNewMultiDimArrayInstanceExpression.createETSNewMultiDimArrayInstanceExpression(typeReference, dimensions) + } + , + updateETSNewMultiDimArrayInstanceExpression(original: ETSNewMultiDimArrayInstanceExpression, typeReference: TypeNode | undefined, dimensions: readonly Expression[]): ETSNewMultiDimArrayInstanceExpression { + if (isSameNativeObject(typeReference, original.typeReference) && isSameNativeObject(dimensions, original.dimensions)) + return original + return updateNodeByNode(ETSNewMultiDimArrayInstanceExpression.createETSNewMultiDimArrayInstanceExpression(typeReference, dimensions), original) + } + , + createTSNamedTupleMember(label: Expression | undefined, elementType: TypeNode | undefined, isOptional: boolean): TSNamedTupleMember { + return TSNamedTupleMember.createTSNamedTupleMember(label, elementType, isOptional) + } + , + updateTSNamedTupleMember(original: TSNamedTupleMember, label: Expression | undefined, elementType: TypeNode | undefined, isOptional: boolean): TSNamedTupleMember { + if (isSameNativeObject(label, original.label) && isSameNativeObject(elementType, original.elementType) && isSameNativeObject(isOptional, original.isOptional)) + return original + return updateNodeByNode(TSNamedTupleMember.createTSNamedTupleMember(label, elementType, isOptional), original) + } + , + createImportExpression(source?: Expression): ImportExpression { + return ImportExpression.createImportExpression(source) + } + , + updateImportExpression(original: ImportExpression, source?: Expression): ImportExpression { + if (isSameNativeObject(source, original.source)) + return original + return updateNodeByNode(ImportExpression.createImportExpression(source), original) + } + , + createETSNullType(): ETSNullType { + return ETSNullType.createETSNullType() + } + , + updateETSNullType(original: ETSNullType): ETSNullType { + return updateNodeByNode(ETSNullType.createETSNullType(), original) + } + , + createETSUndefinedType(): ETSUndefinedType { + return ETSUndefinedType.createETSUndefinedType() + } + , + updateETSUndefinedType(original: ETSUndefinedType): ETSUndefinedType { + return updateNodeByNode(ETSUndefinedType.createETSUndefinedType(), original) + } + , + createTypeofExpression(argument?: Expression): TypeofExpression { + return TypeofExpression.createTypeofExpression(argument) + } + , + updateTypeofExpression(original: TypeofExpression, argument?: Expression): TypeofExpression { + if (isSameNativeObject(argument, original.argument)) + return original + return updateNodeByNode(TypeofExpression.createTypeofExpression(argument), original) + } + , + createTSEnumMember(key: Expression | undefined, init: Expression | undefined, isGenerated: boolean): TSEnumMember { + return TSEnumMember.create1TSEnumMember(key, init, isGenerated) + } + , + updateTSEnumMember(original: TSEnumMember, key: Expression | undefined, init: Expression | undefined, isGenerated: boolean): TSEnumMember { + if (isSameNativeObject(key, original.key) && isSameNativeObject(init, original.init) && isSameNativeObject(isGenerated, original.isGenerated)) + return original + return updateNodeByNode(TSEnumMember.create1TSEnumMember(key, init, isGenerated), original) + } + , + createSwitchStatement(discriminant: Expression | undefined, cases: readonly SwitchCaseStatement[]): SwitchStatement { + return SwitchStatement.createSwitchStatement(discriminant, cases) + } + , + updateSwitchStatement(original: SwitchStatement, discriminant: Expression | undefined, cases: readonly SwitchCaseStatement[]): SwitchStatement { + if (isSameNativeObject(discriminant, original.discriminant) && isSameNativeObject(cases, original.cases)) + return original + return updateNodeByNode(SwitchStatement.createSwitchStatement(discriminant, cases), original) + } + , + createDoWhileStatement(body?: Statement, test?: Expression): DoWhileStatement { + return DoWhileStatement.createDoWhileStatement(body, test) + } + , + updateDoWhileStatement(original: DoWhileStatement, body?: Statement, test?: Expression): DoWhileStatement { + if (isSameNativeObject(body, original.body) && isSameNativeObject(test, original.test)) + return original + return updateNodeByNode(DoWhileStatement.createDoWhileStatement(body, test), original) + } + , + createCatchClause(param?: Expression, body?: BlockStatement): CatchClause { + return CatchClause.createCatchClause(param, body) + } + , + updateCatchClause(original: CatchClause, param?: Expression, body?: BlockStatement): CatchClause { + if (isSameNativeObject(param, original.param) && isSameNativeObject(body, original.body)) + return original + return updateNodeByNode(CatchClause.createCatchClause(param, body), original) + } + , + createSequenceExpression(sequence: readonly Expression[]): SequenceExpression { + return SequenceExpression.createSequenceExpression(sequence) + } + , + updateSequenceExpression(original: SequenceExpression, sequence: readonly Expression[]): SequenceExpression { + if (isSameNativeObject(sequence, original.sequence)) + return original + return updateNodeByNode(SequenceExpression.createSequenceExpression(sequence), original) + } + , + createArrowFunctionExpression(_function?: ScriptFunction): ArrowFunctionExpression { + return ArrowFunctionExpression.createArrowFunctionExpression(_function) + } + , + updateArrowFunctionExpression(original: ArrowFunctionExpression, _function?: ScriptFunction): ArrowFunctionExpression { + if (isSameNativeObject(_function, original.function)) + return original + return updateNodeByNode(ArrowFunctionExpression.createArrowFunctionExpression(_function), original) + } + , + createOmittedExpression(): OmittedExpression { + return OmittedExpression.createOmittedExpression() + } + , + updateOmittedExpression(original: OmittedExpression): OmittedExpression { + return updateNodeByNode(OmittedExpression.createOmittedExpression(), original) + } + , + createETSNewClassInstanceExpression(typeRef: Expression | undefined, _arguments: readonly Expression[]): ETSNewClassInstanceExpression { + return ETSNewClassInstanceExpression.createETSNewClassInstanceExpression(typeRef, _arguments) + } + , + updateETSNewClassInstanceExpression(original: ETSNewClassInstanceExpression, typeRef: Expression | undefined, _arguments: readonly Expression[]): ETSNewClassInstanceExpression { + if (isSameNativeObject(typeRef, original.typeRef) && isSameNativeObject(_arguments, original.arguments)) + return original + return updateNodeByNode(ETSNewClassInstanceExpression.createETSNewClassInstanceExpression(typeRef, _arguments), original) + } + , + createTSAsExpression(expr: Expression | undefined, typeAnnotation: TypeNode | undefined, isConst: boolean): TSAsExpression { + return TSAsExpression.createTSAsExpression(expr, typeAnnotation, isConst) + } + , + updateTSAsExpression(original: TSAsExpression, expr: Expression | undefined, typeAnnotation: TypeNode | undefined, isConst: boolean): TSAsExpression { + if (isSameNativeObject(expr, original.expr) && isSameNativeObject(typeAnnotation, original.typeAnnotation) && isSameNativeObject(isConst, original.isConst)) + return original + return updateNodeByNode(TSAsExpression.createTSAsExpression(expr, typeAnnotation, isConst), original) + } + , + createForUpdateStatement(init?: AstNode, test?: Expression, update?: Expression, body?: Statement): ForUpdateStatement { + return ForUpdateStatement.createForUpdateStatement(init, test, update, body) + } + , + updateForUpdateStatement(original: ForUpdateStatement, init?: AstNode, test?: Expression, update?: Expression, body?: Statement): ForUpdateStatement { + if (isSameNativeObject(init, original.init) && isSameNativeObject(test, original.test) && isSameNativeObject(update, original.update) && isSameNativeObject(body, original.body)) + return original + return updateNodeByNode(ForUpdateStatement.createForUpdateStatement(init, test, update, body), original) + } + , + createETSPrimitiveType(primitiveType: Es2pandaPrimitiveType): ETSPrimitiveType { + return ETSPrimitiveType.createETSPrimitiveType(primitiveType) + } + , + updateETSPrimitiveType(original: ETSPrimitiveType, primitiveType: Es2pandaPrimitiveType): ETSPrimitiveType { + if (isSameNativeObject(primitiveType, original.primitiveType)) + return original + return updateNodeByNode(ETSPrimitiveType.createETSPrimitiveType(primitiveType), original) + } + , + createNewExpression(callee: Expression | undefined, _arguments: readonly Expression[]): NewExpression { + return NewExpression.createNewExpression(callee, _arguments) + } + , + updateNewExpression(original: NewExpression, callee: Expression | undefined, _arguments: readonly Expression[]): NewExpression { + if (isSameNativeObject(callee, original.callee) && isSameNativeObject(_arguments, original.arguments)) + return original + return updateNodeByNode(NewExpression.createNewExpression(callee, _arguments), original) + } + , + createTSThisType(): TSThisType { + return TSThisType.createTSThisType() + } + , + updateTSThisType(original: TSThisType): TSThisType { + return updateNodeByNode(TSThisType.createTSThisType(), original) + } + , +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/index.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..a6cbf260ea87e5610ca037ae99ee08861bcf7efd --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/index.ts @@ -0,0 +1,212 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export * from "./peers/SourcePosition" +export * from "./peers/SourceRange" +export * from "./peers/LabelPair" +export * from "./peers/ScriptFunctionData" +export * from "./peers/ImportSource" +export * from "./peers/SignatureInfo" +export * from "./peers/IndexInfo" +export * from "./peers/ObjectDescriptor" +export * from "./peers/ScopeFindResult" +export * from "./peers/BindingProps" +export * from "./peers/Declaration" +export * from "./peers/AstVisitor" +export * from "./peers/AstVerifier" +export * from "./peers/VerifierMessage" +export * from "./peers/CodeGen" +export * from "./peers/VReg" +export * from "./peers/IRNode" +export * from "./peers/ErrorLogger" +export * from "./peers/VerificationContext" +export * from "./peers/DynamicImportData" +export * from "./peers/OverloadInfo" +export * from "./peers/NumberLiteral" +export * from "./peers/TypedAstNode" +export * from "./peers/AnnotatedAstNode" +export * from "./peers/TypedStatement" +export * from "./peers/AnnotatedStatement" +export * from "./peers/LabelledStatement" +export * from "./peers/ThrowStatement" +export * from "./peers/ClassProperty" +export * from "./peers/TSVoidKeyword" +export * from "./peers/ETSFunctionType" +export * from "./peers/TSTypeOperator" +export * from "./peers/IfStatement" +export * from "./peers/TSConstructorType" +export * from "./peers/Decorator" +export * from "./peers/TSEnumDeclaration" +export * from "./peers/TSNeverKeyword" +export * from "./peers/ImportDefaultSpecifier" +export * from "./peers/ObjectExpression" +export * from "./peers/ImportSpecifier" +export * from "./peers/ConditionalExpression" +export * from "./peers/CallExpression" +export * from "./peers/BigIntLiteral" +export * from "./peers/ClassElement" +export * from "./peers/TSImportType" +export * from "./peers/TaggedTemplateExpression" +export * from "./peers/FunctionDeclaration" +export * from "./peers/ETSTypeReference" +export * from "./peers/TSTypeReference" +export * from "./peers/NamedType" +export * from "./peers/TSFunctionType" +export * from "./peers/TemplateElement" +export * from "./peers/TSInterfaceDeclaration" +export * from "./peers/VariableDeclaration" +export * from "./peers/UndefinedLiteral" +export * from "./peers/MemberExpression" +export * from "./peers/TSClassImplements" +export * from "./peers/TSObjectKeyword" +export * from "./peers/ETSUnionType" +export * from "./peers/ETSKeyofType" +export * from "./peers/TSPropertySignature" +export * from "./peers/TSConditionalType" +export * from "./peers/TSLiteralType" +export * from "./peers/TSTypeAliasDeclaration" +export * from "./peers/DebuggerStatement" +export * from "./peers/ReturnStatement" +export * from "./peers/ExportDefaultDeclaration" +export * from "./peers/ScriptFunction" +export * from "./peers/ClassDefinition" +export * from "./peers/ArrayExpression" +export * from "./peers/TSInterfaceBody" +export * from "./peers/TSTypeQuery" +export * from "./peers/TSBigintKeyword" +export * from "./peers/Property" +export * from "./peers/VariableDeclarator" +export * from "./peers/StringLiteral" +export * from "./peers/TSTypeAssertion" +export * from "./peers/TSExternalModuleReference" +export * from "./peers/TSUndefinedKeyword" +export * from "./peers/ETSTuple" +export * from "./peers/ETSStringLiteralType" +export * from "./peers/TryStatement" +export * from "./peers/UnaryExpression" +export * from "./peers/ForInStatement" +export * from "./peers/ThisExpression" +export * from "./peers/TSMethodSignature" +export * from "./peers/BinaryExpression" +export * from "./peers/SuperExpression" +export * from "./peers/AssertStatement" +export * from "./peers/TSStringKeyword" +export * from "./peers/AssignmentExpression" +export * from "./peers/ExpressionStatement" +export * from "./peers/ETSModule" +export * from "./peers/MetaProperty" +export * from "./peers/TSArrayType" +export * from "./peers/TSSignatureDeclaration" +export * from "./peers/ExportAllDeclaration" +export * from "./peers/ExportSpecifier" +export * from "./peers/TSTupleType" +export * from "./peers/FunctionExpression" +export * from "./peers/TSIndexSignature" +export * from "./peers/TSModuleDeclaration" +export * from "./peers/ImportDeclaration" +export * from "./peers/TSParenthesizedType" +export * from "./peers/Literal" +export * from "./peers/CharLiteral" +export * from "./peers/ETSPackageDeclaration" +export * from "./peers/ETSImportDeclaration" +export * from "./peers/ETSStructDeclaration" +export * from "./peers/TSModuleBlock" +export * from "./peers/ETSNewArrayInstanceExpression" +export * from "./peers/LoopStatement" +export * from "./peers/AnnotationDeclaration" +export * from "./peers/AnnotationUsage" +export * from "./peers/EmptyStatement" +export * from "./peers/WhileStatement" +export * from "./peers/FunctionSignature" +export * from "./peers/ChainExpression" +export * from "./peers/TSIntersectionType" +export * from "./peers/UpdateExpression" +export * from "./peers/BlockExpression" +export * from "./peers/TSTypeLiteral" +export * from "./peers/TSTypeParameter" +export * from "./peers/TSBooleanKeyword" +export * from "./peers/SpreadElement" +export * from "./peers/TSTypePredicate" +export * from "./peers/ImportNamespaceSpecifier" +export * from "./peers/ExportNamedDeclaration" +export * from "./peers/ETSParameterExpression" +export * from "./peers/TSTypeParameterInstantiation" +export * from "./peers/NullLiteral" +export * from "./peers/TSInferType" +export * from "./peers/SwitchCaseStatement" +export * from "./peers/YieldExpression" +export * from "./peers/TSImportEqualsDeclaration" +export * from "./peers/BooleanLiteral" +export * from "./peers/TSNumberKeyword" +export * from "./peers/ClassStaticBlock" +export * from "./peers/TSNonNullExpression" +export * from "./peers/PrefixAssertionExpression" +export * from "./peers/ClassExpression" +export * from "./peers/ForOfStatement" +export * from "./peers/TemplateLiteral" +export * from "./peers/TSUnionType" +export * from "./peers/TSUnknownKeyword" +export * from "./peers/Identifier" +export * from "./peers/OpaqueTypeNode" +export * from "./peers/BlockStatement" +export * from "./peers/Statement" +export * from "./peers/DirectEvalExpression" +export * from "./peers/TSTypeParameterDeclaration" +export * from "./peers/MethodDefinition" +export * from "./peers/TSNullKeyword" +export * from "./peers/TSInterfaceHeritage" +export * from "./peers/Expression" +export * from "./peers/AnnotatedExpression" +export * from "./peers/MaybeOptionalExpression" +export * from "./peers/SrcDumper" +export * from "./peers/ETSClassLiteral" +export * from "./peers/BreakStatement" +export * from "./peers/RegExpLiteral" +export * from "./peers/TSMappedType" +export * from "./peers/TSAnyKeyword" +export * from "./peers/ClassDeclaration" +export * from "./peers/TSIndexedAccessType" +export * from "./peers/TSQualifiedName" +export * from "./peers/AwaitExpression" +export * from "./peers/ValidationInfo" +export * from "./peers/ContinueStatement" +export * from "./peers/ETSNewMultiDimArrayInstanceExpression" +export * from "./peers/TSNamedTupleMember" +export * from "./peers/ImportExpression" +export * from "./peers/AstDumper" +export * from "./peers/ETSNullType" +export * from "./peers/ETSUndefinedType" +export * from "./peers/TypeofExpression" +export * from "./peers/TSEnumMember" +export * from "./peers/SwitchStatement" +export * from "./peers/DoWhileStatement" +export * from "./peers/CatchClause" +export * from "./peers/SequenceExpression" +export * from "./peers/ArrowFunctionExpression" +export * from "./peers/OmittedExpression" +export * from "./peers/ETSNewClassInstanceExpression" +export * from "./peers/TSAsExpression" +export * from "./peers/ForUpdateStatement" +export * from "./peers/ETSTypeReferencePart" +export * from "./peers/ETSReExportDeclaration" +export * from "./peers/ETSPrimitiveType" +export * from "./peers/TypeNode" +export * from "./peers/NewExpression" +export * from "./peers/TSParameterProperty" +export * from "./peers/ETSWildcardType" +export * from "./peers/TSThisType" +export * from "./peers/ETSDynamicFunctionType" +export * from "./peers/InterfaceDecl" +export * from "./peers/FunctionDecl" \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/AnnotatedAstNode.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/AnnotatedAstNode.ts new file mode 100644 index 0000000000000000000000000000000000000000..a58b17140b964e057d211ed0e1d38292dc3a7509 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/AnnotatedAstNode.ts @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +export class AnnotatedAstNode extends AstNode { + constructor(pointer: KNativePointer) { + super(pointer) + } +} +export function isAnnotatedAstNode(node: object | undefined): node is AnnotatedAstNode { + return node instanceof AnnotatedAstNode +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/AnnotatedExpression.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/AnnotatedExpression.ts new file mode 100644 index 0000000000000000000000000000000000000000..733135e5abcd25bd811e0fd6ab54375faec78806 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/AnnotatedExpression.ts @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +import { TypeNode } from "./TypeNode" +export class AnnotatedExpression extends Expression { + constructor(pointer: KNativePointer) { + super(pointer) + } + get typeAnnotation(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._AnnotatedExpressionTypeAnnotationConst(global.context, this.peer)) + } + /** @deprecated */ + setTsTypeAnnotation(typeAnnotation?: TypeNode): this { + global.generatedEs2panda._AnnotatedExpressionSetTsTypeAnnotation(global.context, this.peer, passNode(typeAnnotation)) + return this + } +} +export function isAnnotatedExpression(node: object | undefined): node is AnnotatedExpression { + return node instanceof AnnotatedExpression +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/AnnotatedStatement.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/AnnotatedStatement.ts new file mode 100644 index 0000000000000000000000000000000000000000..42965c2daf1aeb71cf6b700d7b0166ff9622367a --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/AnnotatedStatement.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Statement } from "./Statement" +export class AnnotatedStatement extends Statement { + constructor(pointer: KNativePointer) { + super(pointer) + } +} +export function isAnnotatedStatement(node: object | undefined): node is AnnotatedStatement { + return node instanceof AnnotatedStatement +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/AnnotationDeclaration.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/AnnotationDeclaration.ts new file mode 100644 index 0000000000000000000000000000000000000000..a9f4a613910905172f5dc8e2fda1d2aa3b9bd562 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/AnnotationDeclaration.ts @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { AnnotationUsage } from "./AnnotationUsage" +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { Identifier } from "./Identifier" +import { Statement } from "./Statement" +export class AnnotationDeclaration extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 1) + super(pointer) + } + static create1AnnotationDeclaration(expr: Expression | undefined, properties: readonly AstNode[]): AnnotationDeclaration { + return new AnnotationDeclaration(global.generatedEs2panda._CreateAnnotationDeclaration1(global.context, passNode(expr), passNodeArray(properties), properties.length)) + } + static updateAnnotationDeclaration(original?: AnnotationDeclaration, expr?: Expression): AnnotationDeclaration { + return new AnnotationDeclaration(global.generatedEs2panda._UpdateAnnotationDeclaration(global.context, passNode(original), passNode(expr))) + } + static update1AnnotationDeclaration(original: AnnotationDeclaration | undefined, expr: Expression | undefined, properties: readonly AstNode[]): AnnotationDeclaration { + return new AnnotationDeclaration(global.generatedEs2panda._UpdateAnnotationDeclaration1(global.context, passNode(original), passNode(expr), passNodeArray(properties), properties.length)) + } + get internalName(): string { + return unpackString(global.generatedEs2panda._AnnotationDeclarationInternalNameConst(global.context, this.peer)) + } + /** @deprecated */ + setInternalName(internalName: string): this { + global.generatedEs2panda._AnnotationDeclarationSetInternalName(global.context, this.peer, internalName) + return this + } + get expr(): Expression | undefined { + return unpackNode(global.generatedEs2panda._AnnotationDeclarationExpr(global.context, this.peer)) + } + get properties(): readonly AstNode[] { + return unpackNodeArray(global.generatedEs2panda._AnnotationDeclarationProperties(global.context, this.peer)) + } + /** @deprecated */ + addProperties(properties: readonly AstNode[]): this { + global.generatedEs2panda._AnnotationDeclarationAddProperties(global.context, this.peer, passNodeArray(properties), properties.length) + return this + } + get isSourceRetention(): boolean { + return global.generatedEs2panda._AnnotationDeclarationIsSourceRetentionConst(global.context, this.peer) + } + get isBytecodeRetention(): boolean { + return global.generatedEs2panda._AnnotationDeclarationIsBytecodeRetentionConst(global.context, this.peer) + } + get isRuntimeRetention(): boolean { + return global.generatedEs2panda._AnnotationDeclarationIsRuntimeRetentionConst(global.context, this.peer) + } + /** @deprecated */ + setSourceRetention(): this { + global.generatedEs2panda._AnnotationDeclarationSetSourceRetention(global.context, this.peer) + return this + } + /** @deprecated */ + setBytecodeRetention(): this { + global.generatedEs2panda._AnnotationDeclarationSetBytecodeRetention(global.context, this.peer) + return this + } + /** @deprecated */ + setRuntimeRetention(): this { + global.generatedEs2panda._AnnotationDeclarationSetRuntimeRetention(global.context, this.peer) + return this + } + get baseName(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._AnnotationDeclarationGetBaseNameConst(global.context, this.peer)) + } + get annotations(): readonly AnnotationUsage[] { + return unpackNodeArray(global.generatedEs2panda._AnnotationDeclarationAnnotations(global.context, this.peer)) + } + /** @deprecated */ + setAnnotations(annotations: readonly AnnotationUsage[]): this { + global.generatedEs2panda._AnnotationDeclarationSetAnnotations(global.context, this.peer, passNodeArray(annotations), annotations.length) + return this + } +} +export function isAnnotationDeclaration(node: object | undefined): node is AnnotationDeclaration { + return node instanceof AnnotationDeclaration +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_ANNOTATION_DECLARATION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_ANNOTATION_DECLARATION, (peer: KNativePointer) => new AnnotationDeclaration(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/AnnotationUsage.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/AnnotationUsage.ts new file mode 100644 index 0000000000000000000000000000000000000000..9fff4ca36774b947acff9c8119767b935e26d276 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/AnnotationUsage.ts @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { Identifier } from "./Identifier" +import { Statement } from "./Statement" +export class AnnotationUsage extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 2) + super(pointer) + } + static create1AnnotationUsage(expr: Expression | undefined, properties: readonly AstNode[]): AnnotationUsage { + return new AnnotationUsage(global.generatedEs2panda._CreateAnnotationUsage1(global.context, passNode(expr), passNodeArray(properties), properties.length)) + } + static updateAnnotationUsage(original?: AnnotationUsage, expr?: Expression): AnnotationUsage { + return new AnnotationUsage(global.generatedEs2panda._UpdateAnnotationUsage(global.context, passNode(original), passNode(expr))) + } + static update1AnnotationUsage(original: AnnotationUsage | undefined, expr: Expression | undefined, properties: readonly AstNode[]): AnnotationUsage { + return new AnnotationUsage(global.generatedEs2panda._UpdateAnnotationUsage1(global.context, passNode(original), passNode(expr), passNodeArray(properties), properties.length)) + } + get expr(): Expression | undefined { + return unpackNode(global.generatedEs2panda._AnnotationUsageExpr(global.context, this.peer)) + } + get properties(): readonly AstNode[] { + return unpackNodeArray(global.generatedEs2panda._AnnotationUsageProperties(global.context, this.peer)) + } + /** @deprecated */ + addProperty(property?: AstNode): this { + global.generatedEs2panda._AnnotationUsageAddProperty(global.context, this.peer, passNode(property)) + return this + } + /** @deprecated */ + setProperties(properties: readonly AstNode[]): this { + global.generatedEs2panda._AnnotationUsageSetProperties(global.context, this.peer, passNodeArray(properties), properties.length) + return this + } + get baseName(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._AnnotationUsageGetBaseNameConst(global.context, this.peer)) + } +} +export function isAnnotationUsage(node: object | undefined): node is AnnotationUsage { + return node instanceof AnnotationUsage +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_ANNOTATION_USAGE)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_ANNOTATION_USAGE, (peer: KNativePointer) => new AnnotationUsage(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ArrayExpression.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ArrayExpression.ts new file mode 100644 index 0000000000000000000000000000000000000000..8bb8abad31d7ffd1b0e4baacb6897023f10879e8 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ArrayExpression.ts @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { AnnotatedExpression } from "./AnnotatedExpression" +import { Decorator } from "./Decorator" +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { TypeNode } from "./TypeNode" +import { ValidationInfo } from "./ValidationInfo" +export class ArrayExpression extends AnnotatedExpression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 156) + super(pointer) + } + static create1ArrayExpression(nodeType: Es2pandaAstNodeType, elements: readonly Expression[], trailingComma: boolean): ArrayExpression { + return new ArrayExpression(global.generatedEs2panda._CreateArrayExpression1(global.context, nodeType, passNodeArray(elements), elements.length, trailingComma)) + } + static updateArrayExpression(original: ArrayExpression | undefined, elements: readonly Expression[]): ArrayExpression { + return new ArrayExpression(global.generatedEs2panda._UpdateArrayExpression(global.context, passNode(original), passNodeArray(elements), elements.length)) + } + static update1ArrayExpression(original: ArrayExpression | undefined, nodeType: Es2pandaAstNodeType, elements: readonly Expression[], trailingComma: boolean): ArrayExpression { + return new ArrayExpression(global.generatedEs2panda._UpdateArrayExpression1(global.context, passNode(original), nodeType, passNodeArray(elements), elements.length, trailingComma)) + } + get elements(): readonly Expression[] { + return unpackNodeArray(global.generatedEs2panda._ArrayExpressionElements(global.context, this.peer)) + } + /** @deprecated */ + setElements(elements: readonly Expression[]): this { + global.generatedEs2panda._ArrayExpressionSetElements(global.context, this.peer, passNodeArray(elements), elements.length) + return this + } + get isDeclaration(): boolean { + return global.generatedEs2panda._ArrayExpressionIsDeclarationConst(global.context, this.peer) + } + get isOptional(): boolean { + return global.generatedEs2panda._ArrayExpressionIsOptionalConst(global.context, this.peer) + } + /** @deprecated */ + setDeclaration(): this { + global.generatedEs2panda._ArrayExpressionSetDeclaration(global.context, this.peer) + return this + } + /** @deprecated */ + setOptional(optional_arg: boolean): this { + global.generatedEs2panda._ArrayExpressionSetOptional(global.context, this.peer, optional_arg) + return this + } + get decorators(): readonly Decorator[] { + return unpackNodeArray(global.generatedEs2panda._ArrayExpressionDecoratorsConst(global.context, this.peer)) + } + /** @deprecated */ + clearPreferredType(): this { + global.generatedEs2panda._ArrayExpressionClearPreferredType(global.context, this.peer) + return this + } + get convertibleToArrayPattern(): boolean { + return global.generatedEs2panda._ArrayExpressionConvertibleToArrayPattern(global.context, this.peer) + } + get validateExpression(): ValidationInfo | undefined { + return new ValidationInfo(global.generatedEs2panda._ArrayExpressionValidateExpression(global.context, this.peer)) + } + get typeAnnotation(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._ArrayExpressionTypeAnnotationConst(global.context, this.peer)) + } + /** @deprecated */ + setTsTypeAnnotation(typeAnnotation?: TypeNode): this { + global.generatedEs2panda._ArrayExpressionSetTsTypeAnnotation(global.context, this.peer, passNode(typeAnnotation)) + return this + } +} +export function isArrayExpression(node: object | undefined): node is ArrayExpression { + return node instanceof ArrayExpression +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_ARRAY_EXPRESSION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_ARRAY_EXPRESSION, (peer: KNativePointer) => new ArrayExpression(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ArrowFunctionExpression.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ArrowFunctionExpression.ts new file mode 100644 index 0000000000000000000000000000000000000000..b05cf90a6db19388ccad0cbb18e8ccc56719f305 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ArrowFunctionExpression.ts @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { AnnotationUsage } from "./AnnotationUsage" +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { ScriptFunction } from "./ScriptFunction" +import { TypeNode } from "./TypeNode" +export class ArrowFunctionExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 0) + super(pointer) + } + static createArrowFunctionExpression(func?: ScriptFunction): ArrowFunctionExpression { + return new ArrowFunctionExpression(global.generatedEs2panda._CreateArrowFunctionExpression(global.context, passNode(func))) + } + static updateArrowFunctionExpression(original?: ArrowFunctionExpression, func?: ScriptFunction): ArrowFunctionExpression { + return new ArrowFunctionExpression(global.generatedEs2panda._UpdateArrowFunctionExpression(global.context, passNode(original), passNode(func))) + } + static update1ArrowFunctionExpression(original?: ArrowFunctionExpression, other?: ArrowFunctionExpression): ArrowFunctionExpression { + return new ArrowFunctionExpression(global.generatedEs2panda._UpdateArrowFunctionExpression1(global.context, passNode(original), passNode(other))) + } + get function(): ScriptFunction | undefined { + return unpackNode(global.generatedEs2panda._ArrowFunctionExpressionFunction(global.context, this.peer)) + } + get createTypeAnnotation(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._ArrowFunctionExpressionCreateTypeAnnotation(global.context, this.peer)) + } + get annotations(): readonly AnnotationUsage[] { + return unpackNodeArray(global.generatedEs2panda._ArrowFunctionExpressionAnnotations(global.context, this.peer)) + } + /** @deprecated */ + setAnnotations(annotations: readonly AnnotationUsage[]): this { + global.generatedEs2panda._ArrowFunctionExpressionSetAnnotations(global.context, this.peer, passNodeArray(annotations), annotations.length) + return this + } +} +export function isArrowFunctionExpression(node: object | undefined): node is ArrowFunctionExpression { + return node instanceof ArrowFunctionExpression +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_ARROW_FUNCTION_EXPRESSION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_ARROW_FUNCTION_EXPRESSION, (peer: KNativePointer) => new ArrowFunctionExpression(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/AssertStatement.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/AssertStatement.ts new file mode 100644 index 0000000000000000000000000000000000000000..9f76de1d9b88a272b59c20da210cf5407a68a3a0 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/AssertStatement.ts @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { Statement } from "./Statement" +export class AssertStatement extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 3) + super(pointer) + } + static createAssertStatement(test?: Expression, second?: Expression): AssertStatement { + return new AssertStatement(global.generatedEs2panda._CreateAssertStatement(global.context, passNode(test), passNode(second))) + } + static updateAssertStatement(original?: AssertStatement, test?: Expression, second?: Expression): AssertStatement { + return new AssertStatement(global.generatedEs2panda._UpdateAssertStatement(global.context, passNode(original), passNode(test), passNode(second))) + } + get test(): Expression | undefined { + return unpackNode(global.generatedEs2panda._AssertStatementTest(global.context, this.peer)) + } + get second(): Expression | undefined { + return unpackNode(global.generatedEs2panda._AssertStatementSecondConst(global.context, this.peer)) + } +} +export function isAssertStatement(node: object | undefined): node is AssertStatement { + return node instanceof AssertStatement +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_ASSERT_STATEMENT)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_ASSERT_STATEMENT, (peer: KNativePointer) => new AssertStatement(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/AssignmentExpression.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/AssignmentExpression.ts new file mode 100644 index 0000000000000000000000000000000000000000..5433f16e0b57495f62572741265edb0550459cbb --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/AssignmentExpression.ts @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { CodeGen } from "./CodeGen" +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Es2pandaTokenType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +export class AssignmentExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 158) + super(pointer) + } + static create1AssignmentExpression(type: Es2pandaAstNodeType, left: Expression | undefined, right: Expression | undefined, assignmentOperator: Es2pandaTokenType): AssignmentExpression { + return new AssignmentExpression(global.generatedEs2panda._CreateAssignmentExpression1(global.context, type, passNode(left), passNode(right), assignmentOperator)) + } + static updateAssignmentExpression(original: AssignmentExpression | undefined, left: Expression | undefined, right: Expression | undefined, assignmentOperator: Es2pandaTokenType): AssignmentExpression { + return new AssignmentExpression(global.generatedEs2panda._UpdateAssignmentExpression(global.context, passNode(original), passNode(left), passNode(right), assignmentOperator)) + } + static update1AssignmentExpression(original: AssignmentExpression | undefined, type: Es2pandaAstNodeType, left: Expression | undefined, right: Expression | undefined, assignmentOperator: Es2pandaTokenType): AssignmentExpression { + return new AssignmentExpression(global.generatedEs2panda._UpdateAssignmentExpression1(global.context, passNode(original), type, passNode(left), passNode(right), assignmentOperator)) + } + get left(): Expression | undefined { + return unpackNode(global.generatedEs2panda._AssignmentExpressionLeft(global.context, this.peer)) + } + get right(): Expression | undefined { + return unpackNode(global.generatedEs2panda._AssignmentExpressionRight(global.context, this.peer)) + } + /** @deprecated */ + setRight(expr?: Expression): this { + global.generatedEs2panda._AssignmentExpressionSetRight(global.context, this.peer, passNode(expr)) + return this + } + /** @deprecated */ + setLeft(expr?: Expression): this { + global.generatedEs2panda._AssignmentExpressionSetLeft(global.context, this.peer, passNode(expr)) + return this + } + get result(): Expression | undefined { + return unpackNode(global.generatedEs2panda._AssignmentExpressionResult(global.context, this.peer)) + } + get operatorType(): Es2pandaTokenType { + return global.generatedEs2panda._AssignmentExpressionOperatorTypeConst(global.context, this.peer) + } + /** @deprecated */ + setResult(expr?: Expression): this { + global.generatedEs2panda._AssignmentExpressionSetResult(global.context, this.peer, passNode(expr)) + return this + } + get isLogicalExtended(): boolean { + return global.generatedEs2panda._AssignmentExpressionIsLogicalExtendedConst(global.context, this.peer) + } + /** @deprecated */ + setIgnoreConstAssign(): this { + global.generatedEs2panda._AssignmentExpressionSetIgnoreConstAssign(global.context, this.peer) + return this + } + get isIgnoreConstAssign(): boolean { + return global.generatedEs2panda._AssignmentExpressionIsIgnoreConstAssignConst(global.context, this.peer) + } + get convertibleToAssignmentPatternRight(): boolean { + return global.generatedEs2panda._AssignmentExpressionConvertibleToAssignmentPatternRight(global.context, this.peer) + } + /** @deprecated */ + compilePattern(pg?: CodeGen): this { + global.generatedEs2panda._AssignmentExpressionCompilePatternConst(global.context, this.peer, passNode(pg)) + return this + } +} +export function isAssignmentExpression(node: object | undefined): node is AssignmentExpression { + return node instanceof AssignmentExpression +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_ASSIGNMENT_EXPRESSION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_ASSIGNMENT_EXPRESSION, (peer: KNativePointer) => new AssignmentExpression(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/AstDumper.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/AstDumper.ts new file mode 100644 index 0000000000000000000000000000000000000000..d3d96873aff42559e6e5b229a2c04694c536f8a9 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/AstDumper.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +export class AstDumper extends ArktsObject { + constructor(pointer: KNativePointer) { + super(pointer) + } + static createAstDumper(node: AstNode | undefined, sourceCode: string): AstDumper { + return new AstDumper(global.generatedEs2panda._CreateAstDumper(global.context, passNode(node), sourceCode)) + } + get str(): string { + return unpackString(global.generatedEs2panda._AstDumperStrConst(global.context, this.peer)) + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/AstVerifier.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/AstVerifier.ts new file mode 100644 index 0000000000000000000000000000000000000000..4ca896b98498a82170c6b74626be972b781116a3 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/AstVerifier.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +export class AstVerifier extends ArktsObject { + constructor(pointer: KNativePointer) { + super(pointer) + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/AstVisitor.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/AstVisitor.ts new file mode 100644 index 0000000000000000000000000000000000000000..1577d85a8b8f2acc0bdd0ea95b5bd26d2f593064 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/AstVisitor.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +export class AstVisitor extends ArktsObject { + constructor(pointer: KNativePointer) { + super(pointer) + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/AwaitExpression.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/AwaitExpression.ts new file mode 100644 index 0000000000000000000000000000000000000000..83bf21143a62155b763faa52f3f10f896e55f4b2 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/AwaitExpression.ts @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +export class AwaitExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 4) + super(pointer) + } + static createAwaitExpression(argument?: Expression): AwaitExpression { + return new AwaitExpression(global.generatedEs2panda._CreateAwaitExpression(global.context, passNode(argument))) + } + static updateAwaitExpression(original?: AwaitExpression, argument?: Expression): AwaitExpression { + return new AwaitExpression(global.generatedEs2panda._UpdateAwaitExpression(global.context, passNode(original), passNode(argument))) + } + get argument(): Expression | undefined { + return unpackNode(global.generatedEs2panda._AwaitExpressionArgumentConst(global.context, this.peer)) + } +} +export function isAwaitExpression(node: object | undefined): node is AwaitExpression { + return node instanceof AwaitExpression +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_AWAIT_EXPRESSION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_AWAIT_EXPRESSION, (peer: KNativePointer) => new AwaitExpression(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/BigIntLiteral.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/BigIntLiteral.ts new file mode 100644 index 0000000000000000000000000000000000000000..3d3165461334f01f86e3934b2106e087ec25c5cc --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/BigIntLiteral.ts @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Literal } from "./Literal" +export class BigIntLiteral extends Literal { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 5) + super(pointer) + } + static createBigIntLiteral(src: string): BigIntLiteral { + return new BigIntLiteral(global.generatedEs2panda._CreateBigIntLiteral(global.context, src)) + } + static updateBigIntLiteral(original: BigIntLiteral | undefined, src: string): BigIntLiteral { + return new BigIntLiteral(global.generatedEs2panda._UpdateBigIntLiteral(global.context, passNode(original), src)) + } + get str(): string { + return unpackString(global.generatedEs2panda._BigIntLiteralStrConst(global.context, this.peer)) + } +} +export function isBigIntLiteral(node: object | undefined): node is BigIntLiteral { + return node instanceof BigIntLiteral +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_BIGINT_LITERAL)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_BIGINT_LITERAL, (peer: KNativePointer) => new BigIntLiteral(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/BinaryExpression.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/BinaryExpression.ts new file mode 100644 index 0000000000000000000000000000000000000000..7ad8078283d3a84978dcf3cc45f6dab6bda5effe --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/BinaryExpression.ts @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { CodeGen } from "./CodeGen" +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Es2pandaTokenType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { VReg } from "./VReg" +export class BinaryExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 6) + super(pointer) + } + static createBinaryExpression(left: Expression | undefined, right: Expression | undefined, operatorType: Es2pandaTokenType): BinaryExpression { + return new BinaryExpression(global.generatedEs2panda._CreateBinaryExpression(global.context, passNode(left), passNode(right), operatorType)) + } + static updateBinaryExpression(original: BinaryExpression | undefined, left: Expression | undefined, right: Expression | undefined, operatorType: Es2pandaTokenType): BinaryExpression { + return new BinaryExpression(global.generatedEs2panda._UpdateBinaryExpression(global.context, passNode(original), passNode(left), passNode(right), operatorType)) + } + get left(): Expression | undefined { + return unpackNode(global.generatedEs2panda._BinaryExpressionLeft(global.context, this.peer)) + } + get right(): Expression | undefined { + return unpackNode(global.generatedEs2panda._BinaryExpressionRight(global.context, this.peer)) + } + get result(): Expression | undefined { + return unpackNode(global.generatedEs2panda._BinaryExpressionResult(global.context, this.peer)) + } + get operatorType(): Es2pandaTokenType { + return global.generatedEs2panda._BinaryExpressionOperatorTypeConst(global.context, this.peer) + } + get isLogical(): boolean { + return global.generatedEs2panda._BinaryExpressionIsLogicalConst(global.context, this.peer) + } + get isLogicalExtended(): boolean { + return global.generatedEs2panda._BinaryExpressionIsLogicalExtendedConst(global.context, this.peer) + } + get isBitwise(): boolean { + return global.generatedEs2panda._BinaryExpressionIsBitwiseConst(global.context, this.peer) + } + get isArithmetic(): boolean { + return global.generatedEs2panda._BinaryExpressionIsArithmeticConst(global.context, this.peer) + } + /** @deprecated */ + setLeft(expr?: Expression): this { + global.generatedEs2panda._BinaryExpressionSetLeft(global.context, this.peer, passNode(expr)) + return this + } + /** @deprecated */ + setRight(expr?: Expression): this { + global.generatedEs2panda._BinaryExpressionSetRight(global.context, this.peer, passNode(expr)) + return this + } + /** @deprecated */ + setResult(expr?: Expression): this { + global.generatedEs2panda._BinaryExpressionSetResult(global.context, this.peer, passNode(expr)) + return this + } + /** @deprecated */ + setOperator(operatorType: Es2pandaTokenType): this { + global.generatedEs2panda._BinaryExpressionSetOperator(global.context, this.peer, operatorType) + return this + } + /** @deprecated */ + compileOperands(etsg?: CodeGen, lhs?: VReg): this { + global.generatedEs2panda._BinaryExpressionCompileOperandsConst(global.context, this.peer, passNode(etsg), passNode(lhs)) + return this + } +} +export function isBinaryExpression(node: object | undefined): node is BinaryExpression { + return node instanceof BinaryExpression +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_BINARY_EXPRESSION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_BINARY_EXPRESSION, (peer: KNativePointer) => new BinaryExpression(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/BindingProps.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/BindingProps.ts new file mode 100644 index 0000000000000000000000000000000000000000..555f17f58d245c2d475e9b66cfebe2a20bc3b6f2 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/BindingProps.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +export class BindingProps extends ArktsObject { + constructor(pointer: KNativePointer) { + super(pointer) + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/BlockExpression.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/BlockExpression.ts new file mode 100644 index 0000000000000000000000000000000000000000..045fb82a5ace8e607ba02d74c72731497c8ca4b5 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/BlockExpression.ts @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { Statement } from "./Statement" +export class BlockExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 154) + super(pointer) + } + static createBlockExpression(statements: readonly Statement[]): BlockExpression { + return new BlockExpression(global.generatedEs2panda._CreateBlockExpression(global.context, passNodeArray(statements), statements.length)) + } + static updateBlockExpression(original: BlockExpression | undefined, statements: readonly Statement[]): BlockExpression { + return new BlockExpression(global.generatedEs2panda._UpdateBlockExpression(global.context, passNode(original), passNodeArray(statements), statements.length)) + } + get statements(): readonly Statement[] { + return unpackNodeArray(global.generatedEs2panda._BlockExpressionStatements(global.context, this.peer)) + } + /** @deprecated */ + addStatements(statements: readonly Statement[]): this { + global.generatedEs2panda._BlockExpressionAddStatements(global.context, this.peer, passNodeArray(statements), statements.length) + return this + } + /** @deprecated */ + addStatement(statement?: Statement): this { + global.generatedEs2panda._BlockExpressionAddStatement(global.context, this.peer, passNode(statement)) + return this + } +} +export function isBlockExpression(node: object | undefined): node is BlockExpression { + return node instanceof BlockExpression +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_BLOCK_EXPRESSION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_BLOCK_EXPRESSION, (peer: KNativePointer) => new BlockExpression(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/BlockStatement.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/BlockStatement.ts new file mode 100644 index 0000000000000000000000000000000000000000..c9e2bd2d07851c36991efc4d82b1b4e1ff3d3ea0 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/BlockStatement.ts @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Statement } from "./Statement" +export class BlockStatement extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 7) + super(pointer) + } + static createBlockStatement(statementList: readonly Statement[]): BlockStatement { + return new BlockStatement(global.generatedEs2panda._CreateBlockStatement(global.context, passNodeArray(statementList), statementList.length)) + } + static updateBlockStatement(original: BlockStatement | undefined, statementList: readonly Statement[]): BlockStatement { + return new BlockStatement(global.generatedEs2panda._UpdateBlockStatement(global.context, passNode(original), passNodeArray(statementList), statementList.length)) + } + get statements(): readonly Statement[] { + return unpackNodeArray(global.generatedEs2panda._BlockStatementStatements(global.context, this.peer)) + } + /** @deprecated */ + setStatements(statementList: readonly Statement[]): this { + global.generatedEs2panda._BlockStatementSetStatements(global.context, this.peer, passNodeArray(statementList), statementList.length) + return this + } + /** @deprecated */ + addStatement(stmt?: Statement): this { + global.generatedEs2panda._BlockStatementAddStatement(global.context, this.peer, passNode(stmt)) + return this + } + /** @deprecated */ + addStatements(stmts: readonly Statement[]): this { + global.generatedEs2panda._BlockStatementAddStatements(global.context, this.peer, passNodeArray(stmts), stmts.length) + return this + } + /** @deprecated */ + addTrailingBlock(stmt?: AstNode, trailingBlock?: BlockStatement): this { + global.generatedEs2panda._BlockStatementAddTrailingBlock(global.context, this.peer, passNode(stmt), passNode(trailingBlock)) + return this + } +} +export function isBlockStatement(node: object | undefined): node is BlockStatement { + return node instanceof BlockStatement +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_BLOCK_STATEMENT)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_BLOCK_STATEMENT, (peer: KNativePointer) => new BlockStatement(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/BooleanLiteral.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/BooleanLiteral.ts new file mode 100644 index 0000000000000000000000000000000000000000..3468be119449a0ba87b4ac08effff3421803e186 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/BooleanLiteral.ts @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Literal } from "./Literal" +export class BooleanLiteral extends Literal { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 8) + super(pointer) + } + static createBooleanLiteral(value: boolean): BooleanLiteral { + return new BooleanLiteral(global.generatedEs2panda._CreateBooleanLiteral(global.context, value)) + } + static updateBooleanLiteral(original: BooleanLiteral | undefined, value: boolean): BooleanLiteral { + return new BooleanLiteral(global.generatedEs2panda._UpdateBooleanLiteral(global.context, passNode(original), value)) + } + get value(): boolean { + return global.generatedEs2panda._BooleanLiteralValueConst(global.context, this.peer) + } +} +export function isBooleanLiteral(node: object | undefined): node is BooleanLiteral { + return node instanceof BooleanLiteral +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_BOOLEAN_LITERAL)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_BOOLEAN_LITERAL, (peer: KNativePointer) => new BooleanLiteral(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/BreakStatement.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/BreakStatement.ts new file mode 100644 index 0000000000000000000000000000000000000000..329dc483665288aeaf3821985733a3ed45667a85 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/BreakStatement.ts @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Identifier } from "./Identifier" +import { Statement } from "./Statement" +export class BreakStatement extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 9) + super(pointer) + } + static create1BreakStatement(ident?: Identifier): BreakStatement { + return new BreakStatement(global.generatedEs2panda._CreateBreakStatement1(global.context, passNode(ident))) + } + static updateBreakStatement(original?: BreakStatement): BreakStatement { + return new BreakStatement(global.generatedEs2panda._UpdateBreakStatement(global.context, passNode(original))) + } + static update1BreakStatement(original?: BreakStatement, ident?: Identifier): BreakStatement { + return new BreakStatement(global.generatedEs2panda._UpdateBreakStatement1(global.context, passNode(original), passNode(ident))) + } + get ident(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._BreakStatementIdent(global.context, this.peer)) + } + get target(): AstNode | undefined { + return unpackNode(global.generatedEs2panda._BreakStatementTargetConst(global.context, this.peer)) + } + get hasTarget(): boolean { + return global.generatedEs2panda._BreakStatementHasTargetConst(global.context, this.peer) + } + /** @deprecated */ + setTarget(target?: AstNode): this { + global.generatedEs2panda._BreakStatementSetTarget(global.context, this.peer, passNode(target)) + return this + } +} +export function isBreakStatement(node: object | undefined): node is BreakStatement { + return node instanceof BreakStatement +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_BREAK_STATEMENT)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_BREAK_STATEMENT, (peer: KNativePointer) => new BreakStatement(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/CallExpression.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/CallExpression.ts new file mode 100644 index 0000000000000000000000000000000000000000..ac2373d4e63f303cd69e8ee625f6ccc767c8541e --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/CallExpression.ts @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { BlockStatement } from "./BlockStatement" +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { MaybeOptionalExpression } from "./MaybeOptionalExpression" +import { TSTypeParameterInstantiation } from "./TSTypeParameterInstantiation" +export class CallExpression extends MaybeOptionalExpression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 10) + super(pointer) + } + static createCallExpression(callee: Expression | undefined, _arguments: readonly Expression[], typeParams: TSTypeParameterInstantiation | undefined, optional_arg: boolean, trailingComma: boolean): CallExpression { + return new CallExpression(global.generatedEs2panda._CreateCallExpression(global.context, passNode(callee), passNodeArray(_arguments), _arguments.length, passNode(typeParams), optional_arg, trailingComma)) + } + static update1CallExpression(original?: CallExpression, other?: CallExpression): CallExpression { + return new CallExpression(global.generatedEs2panda._UpdateCallExpression1(global.context, passNode(original), passNode(other))) + } + get callee(): Expression | undefined { + return unpackNode(global.generatedEs2panda._CallExpressionCallee(global.context, this.peer)) + } + /** @deprecated */ + setCallee(callee?: Expression): this { + global.generatedEs2panda._CallExpressionSetCallee(global.context, this.peer, passNode(callee)) + return this + } + get typeParams(): TSTypeParameterInstantiation | undefined { + return unpackNode(global.generatedEs2panda._CallExpressionTypeParams(global.context, this.peer)) + } + get arguments(): readonly Expression[] { + return unpackNodeArray(global.generatedEs2panda._CallExpressionArguments(global.context, this.peer)) + } + get hasTrailingComma(): boolean { + return global.generatedEs2panda._CallExpressionHasTrailingCommaConst(global.context, this.peer) + } + /** @deprecated */ + setTypeParams(typeParams?: TSTypeParameterInstantiation): this { + global.generatedEs2panda._CallExpressionSetTypeParams(global.context, this.peer, passNode(typeParams)) + return this + } + /** @deprecated */ + setTrailingBlock(block?: BlockStatement): this { + global.generatedEs2panda._CallExpressionSetTrailingBlock(global.context, this.peer, passNode(block)) + return this + } + get isExtensionAccessorCall(): boolean { + return global.generatedEs2panda._CallExpressionIsExtensionAccessorCall(global.context, this.peer) + } + get trailingBlock(): BlockStatement | undefined { + return unpackNode(global.generatedEs2panda._CallExpressionTrailingBlockConst(global.context, this.peer)) + } + /** @deprecated */ + setIsTrailingBlockInNewLine(isNewLine: boolean): this { + global.generatedEs2panda._CallExpressionSetIsTrailingBlockInNewLine(global.context, this.peer, isNewLine) + return this + } + get isTrailingBlockInNewLine(): boolean { + return global.generatedEs2panda._CallExpressionIsTrailingBlockInNewLineConst(global.context, this.peer) + } + get isETSConstructorCall(): boolean { + return global.generatedEs2panda._CallExpressionIsETSConstructorCallConst(global.context, this.peer) + } +} +export function isCallExpression(node: object | undefined): node is CallExpression { + return node instanceof CallExpression +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_CALL_EXPRESSION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_CALL_EXPRESSION, (peer: KNativePointer) => new CallExpression(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/CatchClause.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/CatchClause.ts new file mode 100644 index 0000000000000000000000000000000000000000..7c4756fa8678925d7646a44643b5cc8f0b3306a5 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/CatchClause.ts @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { BlockStatement } from "./BlockStatement" +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { TypedStatement } from "./TypedStatement" +export class CatchClause extends TypedStatement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 11) + super(pointer) + } + static createCatchClause(param?: Expression, body?: BlockStatement): CatchClause { + return new CatchClause(global.generatedEs2panda._CreateCatchClause(global.context, passNode(param), passNode(body))) + } + static updateCatchClause(original?: CatchClause, param?: Expression, body?: BlockStatement): CatchClause { + return new CatchClause(global.generatedEs2panda._UpdateCatchClause(global.context, passNode(original), passNode(param), passNode(body))) + } + static update1CatchClause(original?: CatchClause, other?: CatchClause): CatchClause { + return new CatchClause(global.generatedEs2panda._UpdateCatchClause1(global.context, passNode(original), passNode(other))) + } + get param(): Expression | undefined { + return unpackNode(global.generatedEs2panda._CatchClauseParam(global.context, this.peer)) + } + get body(): BlockStatement | undefined { + return unpackNode(global.generatedEs2panda._CatchClauseBody(global.context, this.peer)) + } + get isDefaultCatchClause(): boolean { + return global.generatedEs2panda._CatchClauseIsDefaultCatchClauseConst(global.context, this.peer) + } +} +export function isCatchClause(node: object | undefined): node is CatchClause { + return node instanceof CatchClause +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_CATCH_CLAUSE)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_CATCH_CLAUSE, (peer: KNativePointer) => new CatchClause(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ChainExpression.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ChainExpression.ts new file mode 100644 index 0000000000000000000000000000000000000000..f856567f16da5db093b1077005866c800977c2e6 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ChainExpression.ts @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { CodeGen } from "./CodeGen" +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { VReg } from "./VReg" +export class ChainExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 12) + super(pointer) + } + static createChainExpression(expression?: Expression): ChainExpression { + return new ChainExpression(global.generatedEs2panda._CreateChainExpression(global.context, passNode(expression))) + } + static updateChainExpression(original?: ChainExpression, expression?: Expression): ChainExpression { + return new ChainExpression(global.generatedEs2panda._UpdateChainExpression(global.context, passNode(original), passNode(expression))) + } + get expression(): Expression | undefined { + return unpackNode(global.generatedEs2panda._ChainExpressionGetExpression(global.context, this.peer)) + } + /** @deprecated */ + compileToReg(pg?: CodeGen, objReg?: VReg): this { + global.generatedEs2panda._ChainExpressionCompileToRegConst(global.context, this.peer, passNode(pg), passNode(objReg)) + return this + } +} +export function isChainExpression(node: object | undefined): node is ChainExpression { + return node instanceof ChainExpression +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_CHAIN_EXPRESSION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_CHAIN_EXPRESSION, (peer: KNativePointer) => new ChainExpression(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/CharLiteral.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/CharLiteral.ts new file mode 100644 index 0000000000000000000000000000000000000000..75add9d3ce5bb138193e510b41c5f1646dceed12 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/CharLiteral.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Literal } from "./Literal" +export class CharLiteral extends Literal { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 13) + super(pointer) + } + static createCharLiteral(): CharLiteral { + return new CharLiteral(global.generatedEs2panda._CreateCharLiteral(global.context)) + } + static updateCharLiteral(original?: CharLiteral): CharLiteral { + return new CharLiteral(global.generatedEs2panda._UpdateCharLiteral(global.context, passNode(original))) + } +} +export function isCharLiteral(node: object | undefined): node is CharLiteral { + return node instanceof CharLiteral +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_CHAR_LITERAL)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_CHAR_LITERAL, (peer: KNativePointer) => new CharLiteral(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ClassDeclaration.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ClassDeclaration.ts new file mode 100644 index 0000000000000000000000000000000000000000..a9d3f3f00b2f429eb3c4c793d80e2c9727cc7a47 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ClassDeclaration.ts @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { ClassDefinition } from "./ClassDefinition" +import { Decorator } from "./Decorator" +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Statement } from "./Statement" +export class ClassDeclaration extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 15) + super(pointer) + } + static createClassDeclaration(def?: ClassDefinition): ClassDeclaration { + return new ClassDeclaration(global.generatedEs2panda._CreateClassDeclaration(global.context, passNode(def))) + } + static updateClassDeclaration(original?: ClassDeclaration, def?: ClassDefinition): ClassDeclaration { + return new ClassDeclaration(global.generatedEs2panda._UpdateClassDeclaration(global.context, passNode(original), passNode(def))) + } + get definition(): ClassDefinition | undefined { + return unpackNode(global.generatedEs2panda._ClassDeclarationDefinition(global.context, this.peer)) + } + get decorators(): readonly Decorator[] { + return unpackNodeArray(global.generatedEs2panda._ClassDeclarationDecoratorsConst(global.context, this.peer)) + } +} +export function isClassDeclaration(node: object | undefined): node is ClassDeclaration { + return node instanceof ClassDeclaration +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_CLASS_DECLARATION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_CLASS_DECLARATION, (peer: KNativePointer) => new ClassDeclaration(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ClassDefinition.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ClassDefinition.ts new file mode 100644 index 0000000000000000000000000000000000000000..46e2e70fd90fad2c83ebf6a8b6ffbce641184b84 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ClassDefinition.ts @@ -0,0 +1,248 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { AnnotationUsage } from "./AnnotationUsage" +import { ClassDeclaration } from "./ClassDeclaration" +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Es2pandaClassDefinitionModifiers } from "./../Es2pandaEnums" +import { Es2pandaModifierFlags } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { Identifier } from "./Identifier" +import { MethodDefinition } from "./MethodDefinition" +import { TSClassImplements } from "./TSClassImplements" +import { TSEnumDeclaration } from "./TSEnumDeclaration" +import { TSTypeParameterDeclaration } from "./TSTypeParameterDeclaration" +import { TSTypeParameterInstantiation } from "./TSTypeParameterInstantiation" +import { TypedAstNode } from "./TypedAstNode" +export class ClassDefinition extends TypedAstNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 14) + super(pointer) + } + static createClassDefinition(ident: Identifier | undefined, typeParams: TSTypeParameterDeclaration | undefined, superTypeParams: TSTypeParameterInstantiation | undefined, _implements: readonly TSClassImplements[], ctor: MethodDefinition | undefined, superClass: Expression | undefined, body: readonly AstNode[], modifiers: Es2pandaClassDefinitionModifiers, flags: Es2pandaModifierFlags): ClassDefinition { + return new ClassDefinition(global.generatedEs2panda._CreateClassDefinition(global.context, passNode(ident), passNode(typeParams), passNode(superTypeParams), passNodeArray(_implements), _implements.length, passNode(ctor), passNode(superClass), passNodeArray(body), body.length, modifiers, flags)) + } + static updateClassDefinition(original: ClassDefinition | undefined, ident: Identifier | undefined, typeParams: TSTypeParameterDeclaration | undefined, superTypeParams: TSTypeParameterInstantiation | undefined, _implements: readonly TSClassImplements[], ctor: MethodDefinition | undefined, superClass: Expression | undefined, body: readonly AstNode[], modifiers: Es2pandaClassDefinitionModifiers, flags: Es2pandaModifierFlags): ClassDefinition { + return new ClassDefinition(global.generatedEs2panda._UpdateClassDefinition(global.context, passNode(original), passNode(ident), passNode(typeParams), passNode(superTypeParams), passNodeArray(_implements), _implements.length, passNode(ctor), passNode(superClass), passNodeArray(body), body.length, modifiers, flags)) + } + static update1ClassDefinition(original: ClassDefinition | undefined, ident: Identifier | undefined, body: readonly AstNode[], modifiers: Es2pandaClassDefinitionModifiers, flags: Es2pandaModifierFlags): ClassDefinition { + return new ClassDefinition(global.generatedEs2panda._UpdateClassDefinition1(global.context, passNode(original), passNode(ident), passNodeArray(body), body.length, modifiers, flags)) + } + static update2ClassDefinition(original: ClassDefinition | undefined, ident: Identifier | undefined, modifiers: Es2pandaClassDefinitionModifiers, flags: Es2pandaModifierFlags): ClassDefinition { + return new ClassDefinition(global.generatedEs2panda._UpdateClassDefinition2(global.context, passNode(original), passNode(ident), modifiers, flags)) + } + get ident(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._ClassDefinitionIdent(global.context, this.peer)) + } + /** @deprecated */ + setIdent(ident?: Identifier): this { + global.generatedEs2panda._ClassDefinitionSetIdent(global.context, this.peer, passNode(ident)) + return this + } + get internalName(): string { + return unpackString(global.generatedEs2panda._ClassDefinitionInternalNameConst(global.context, this.peer)) + } + /** @deprecated */ + setInternalName(internalName: string): this { + global.generatedEs2panda._ClassDefinitionSetInternalName(global.context, this.peer, internalName) + return this + } + get super(): Expression | undefined { + return unpackNode(global.generatedEs2panda._ClassDefinitionSuper(global.context, this.peer)) + } + /** @deprecated */ + setSuper(superClass?: Expression): this { + global.generatedEs2panda._ClassDefinitionSetSuper(global.context, this.peer, passNode(superClass)) + return this + } + get isGlobal(): boolean { + return global.generatedEs2panda._ClassDefinitionIsGlobalConst(global.context, this.peer) + } + get isLocal(): boolean { + return global.generatedEs2panda._ClassDefinitionIsLocalConst(global.context, this.peer) + } + get isExtern(): boolean { + return global.generatedEs2panda._ClassDefinitionIsExternConst(global.context, this.peer) + } + get isFromExternal(): boolean { + return global.generatedEs2panda._ClassDefinitionIsFromExternalConst(global.context, this.peer) + } + get isInner(): boolean { + return global.generatedEs2panda._ClassDefinitionIsInnerConst(global.context, this.peer) + } + get isGlobalInitialized(): boolean { + return global.generatedEs2panda._ClassDefinitionIsGlobalInitializedConst(global.context, this.peer) + } + get isClassDefinitionChecked(): boolean { + return global.generatedEs2panda._ClassDefinitionIsClassDefinitionCheckedConst(global.context, this.peer) + } + get isAnonymous(): boolean { + return global.generatedEs2panda._ClassDefinitionIsAnonymousConst(global.context, this.peer) + } + get isIntEnumTransformed(): boolean { + return global.generatedEs2panda._ClassDefinitionIsIntEnumTransformedConst(global.context, this.peer) + } + get isStringEnumTransformed(): boolean { + return global.generatedEs2panda._ClassDefinitionIsStringEnumTransformedConst(global.context, this.peer) + } + get isEnumTransformed(): boolean { + return global.generatedEs2panda._ClassDefinitionIsEnumTransformedConst(global.context, this.peer) + } + get isNamespaceTransformed(): boolean { + return global.generatedEs2panda._ClassDefinitionIsNamespaceTransformedConst(global.context, this.peer) + } + get isFromStruct(): boolean { + return global.generatedEs2panda._ClassDefinitionIsFromStructConst(global.context, this.peer) + } + get isModule(): boolean { + return global.generatedEs2panda._ClassDefinitionIsModuleConst(global.context, this.peer) + } + /** @deprecated */ + setGlobalInitialized(): this { + global.generatedEs2panda._ClassDefinitionSetGlobalInitialized(global.context, this.peer) + return this + } + /** @deprecated */ + setInnerModifier(): this { + global.generatedEs2panda._ClassDefinitionSetInnerModifier(global.context, this.peer) + return this + } + /** @deprecated */ + setClassDefinitionChecked(): this { + global.generatedEs2panda._ClassDefinitionSetClassDefinitionChecked(global.context, this.peer) + return this + } + /** @deprecated */ + setAnonymousModifier(): this { + global.generatedEs2panda._ClassDefinitionSetAnonymousModifier(global.context, this.peer) + return this + } + /** @deprecated */ + setNamespaceTransformed(): this { + global.generatedEs2panda._ClassDefinitionSetNamespaceTransformed(global.context, this.peer) + return this + } + /** @deprecated */ + setFromStructModifier(): this { + global.generatedEs2panda._ClassDefinitionSetFromStructModifier(global.context, this.peer) + return this + } + get modifiers(): Es2pandaClassDefinitionModifiers { + return global.generatedEs2panda._ClassDefinitionModifiersConst(global.context, this.peer) + } + /** @deprecated */ + setModifiers(modifiers: Es2pandaClassDefinitionModifiers): this { + global.generatedEs2panda._ClassDefinitionSetModifiers(global.context, this.peer, modifiers) + return this + } + /** @deprecated */ + addProperties(body: readonly AstNode[]): this { + global.generatedEs2panda._ClassDefinitionAddProperties(global.context, this.peer, passNodeArray(body), body.length) + return this + } + get body(): readonly AstNode[] { + return unpackNodeArray(global.generatedEs2panda._ClassDefinitionBody(global.context, this.peer)) + } + get ctor(): MethodDefinition | undefined { + return unpackNode(global.generatedEs2panda._ClassDefinitionCtor(global.context, this.peer)) + } + /** @deprecated */ + setCtor(ctor?: MethodDefinition): this { + global.generatedEs2panda._ClassDefinitionSetCtor(global.context, this.peer, passNode(ctor)) + return this + } + get implements(): readonly TSClassImplements[] { + return unpackNodeArray(global.generatedEs2panda._ClassDefinitionImplements(global.context, this.peer)) + } + get typeParams(): TSTypeParameterDeclaration | undefined { + return unpackNode(global.generatedEs2panda._ClassDefinitionTypeParams(global.context, this.peer)) + } + /** @deprecated */ + setTypeParams(typeParams?: TSTypeParameterDeclaration): this { + global.generatedEs2panda._ClassDefinitionSetTypeParams(global.context, this.peer, passNode(typeParams)) + return this + } + get superTypeParams(): TSTypeParameterInstantiation | undefined { + return unpackNode(global.generatedEs2panda._ClassDefinitionSuperTypeParams(global.context, this.peer)) + } + get localTypeCounter(): number { + return global.generatedEs2panda._ClassDefinitionLocalTypeCounter(global.context, this.peer) + } + get localIndex(): number { + return global.generatedEs2panda._ClassDefinitionLocalIndexConst(global.context, this.peer) + } + get localPrefix(): string { + return unpackString(global.generatedEs2panda._ClassDefinitionLocalPrefixConst(global.context, this.peer)) + } + /** @deprecated */ + setOrigEnumDecl(enumDecl?: TSEnumDeclaration): this { + global.generatedEs2panda._ClassDefinitionSetOrigEnumDecl(global.context, this.peer, passNode(enumDecl)) + return this + } + get origEnumDecl(): TSEnumDeclaration | undefined { + return unpackNode(global.generatedEs2panda._ClassDefinitionOrigEnumDeclConst(global.context, this.peer)) + } + get anonClass(): ClassDeclaration | undefined { + return unpackNode(global.generatedEs2panda._ClassDefinitionGetAnonClass(global.context, this.peer)) + } + /** @deprecated */ + setAnonClass(anonClass?: ClassDeclaration): this { + global.generatedEs2panda._ClassDefinitionSetAnonClass(global.context, this.peer, passNode(anonClass)) + return this + } + get hasPrivateMethod(): boolean { + return global.generatedEs2panda._ClassDefinitionHasPrivateMethodConst(global.context, this.peer) + } + get hasNativeMethod(): boolean { + return global.generatedEs2panda._ClassDefinitionHasNativeMethodConst(global.context, this.peer) + } + get hasComputedInstanceField(): boolean { + return global.generatedEs2panda._ClassDefinitionHasComputedInstanceFieldConst(global.context, this.peer) + } + /** @deprecated */ + addToExportedClasses(cls?: ClassDeclaration): this { + global.generatedEs2panda._ClassDefinitionAddToExportedClasses(global.context, this.peer, passNode(cls)) + return this + } + get annotations(): readonly AnnotationUsage[] { + return unpackNodeArray(global.generatedEs2panda._ClassDefinitionAnnotations(global.context, this.peer)) + } + /** @deprecated */ + setAnnotations(annotations: readonly AnnotationUsage[]): this { + global.generatedEs2panda._ClassDefinitionSetAnnotations(global.context, this.peer, passNodeArray(annotations), annotations.length) + return this + } +} +export function isClassDefinition(node: object | undefined): node is ClassDefinition { + return node instanceof ClassDefinition +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_CLASS_DEFINITION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_CLASS_DEFINITION, (peer: KNativePointer) => new ClassDefinition(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ClassElement.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ClassElement.ts new file mode 100644 index 0000000000000000000000000000000000000000..4542cc579413192d5be0a44e05d543744c97dd0d --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ClassElement.ts @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Decorator } from "./Decorator" +import { Expression } from "./Expression" +import { Identifier } from "./Identifier" +import { TSEnumMember } from "./TSEnumMember" +import { TypedStatement } from "./TypedStatement" +export class ClassElement extends TypedStatement { + constructor(pointer: KNativePointer) { + super(pointer) + } + get id(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._ClassElementId(global.context, this.peer)) + } + get key(): Expression | undefined { + return unpackNode(global.generatedEs2panda._ClassElementKey(global.context, this.peer)) + } + get value(): Expression | undefined { + return unpackNode(global.generatedEs2panda._ClassElementValue(global.context, this.peer)) + } + /** @deprecated */ + setValue(value?: Expression): this { + global.generatedEs2panda._ClassElementSetValue(global.context, this.peer, passNode(value)) + return this + } + get originEnumMember(): TSEnumMember | undefined { + return unpackNode(global.generatedEs2panda._ClassElementOriginEnumMemberConst(global.context, this.peer)) + } + /** @deprecated */ + setOrigEnumMember(enumMember?: TSEnumMember): this { + global.generatedEs2panda._ClassElementSetOrigEnumMember(global.context, this.peer, passNode(enumMember)) + return this + } + get isPrivateElement(): boolean { + return global.generatedEs2panda._ClassElementIsPrivateElementConst(global.context, this.peer) + } + get decorators(): readonly Decorator[] { + return unpackNodeArray(global.generatedEs2panda._ClassElementDecoratorsConst(global.context, this.peer)) + } + get isComputed(): boolean { + return global.generatedEs2panda._ClassElementIsComputedConst(global.context, this.peer) + } + /** @deprecated */ + addDecorator(decorator?: Decorator): this { + global.generatedEs2panda._ClassElementAddDecorator(global.context, this.peer, passNode(decorator)) + return this + } +} +export function isClassElement(node: object | undefined): node is ClassElement { + return node instanceof ClassElement +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ClassExpression.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ClassExpression.ts new file mode 100644 index 0000000000000000000000000000000000000000..0698f07ee3772fcbf654d8365898041981085d62 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ClassExpression.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { ClassDefinition } from "./ClassDefinition" +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +export class ClassExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 16) + super(pointer) + } + static createClassExpression(def?: ClassDefinition): ClassExpression { + return new ClassExpression(global.generatedEs2panda._CreateClassExpression(global.context, passNode(def))) + } + static updateClassExpression(original?: ClassExpression, def?: ClassDefinition): ClassExpression { + return new ClassExpression(global.generatedEs2panda._UpdateClassExpression(global.context, passNode(original), passNode(def))) + } + get definition(): ClassDefinition | undefined { + return unpackNode(global.generatedEs2panda._ClassExpressionDefinitionConst(global.context, this.peer)) + } +} +export function isClassExpression(node: object | undefined): node is ClassExpression { + return node instanceof ClassExpression +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_CLASS_EXPRESSION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_CLASS_EXPRESSION, (peer: KNativePointer) => new ClassExpression(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ClassProperty.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ClassProperty.ts new file mode 100644 index 0000000000000000000000000000000000000000..146fff171f5ce2124d181aaf0723d1f0e5310501 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ClassProperty.ts @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { AnnotationUsage } from "./AnnotationUsage" +import { ClassElement } from "./ClassElement" +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Es2pandaModifierFlags } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { TypeNode } from "./TypeNode" +export class ClassProperty extends ClassElement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 17) + super(pointer) + } + static createClassProperty(key: Expression | undefined, value: Expression | undefined, typeAnnotation: TypeNode | undefined, modifiers: Es2pandaModifierFlags, isComputed: boolean): ClassProperty { + return new ClassProperty(global.generatedEs2panda._CreateClassProperty(global.context, passNode(key), passNode(value), passNode(typeAnnotation), modifiers, isComputed)) + } + static updateClassProperty(original: ClassProperty | undefined, key: Expression | undefined, value: Expression | undefined, typeAnnotation: TypeNode | undefined, modifiers: Es2pandaModifierFlags, isComputed: boolean): ClassProperty { + return new ClassProperty(global.generatedEs2panda._UpdateClassProperty(global.context, passNode(original), passNode(key), passNode(value), passNode(typeAnnotation), modifiers, isComputed)) + } + get isDefaultAccessModifier(): boolean { + return global.generatedEs2panda._ClassPropertyIsDefaultAccessModifierConst(global.context, this.peer) + } + /** @deprecated */ + setDefaultAccessModifier(isDefault: boolean): this { + global.generatedEs2panda._ClassPropertySetDefaultAccessModifier(global.context, this.peer, isDefault) + return this + } + get typeAnnotation(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._ClassPropertyTypeAnnotationConst(global.context, this.peer)) + } + /** @deprecated */ + setTypeAnnotation(typeAnnotation?: TypeNode): this { + global.generatedEs2panda._ClassPropertySetTypeAnnotation(global.context, this.peer, passNode(typeAnnotation)) + return this + } + get needInitInStaticBlock(): boolean { + return global.generatedEs2panda._ClassPropertyNeedInitInStaticBlockConst(global.context, this.peer) + } + /** @deprecated */ + setInitInStaticBlock(needInitInStaticBlock: boolean): this { + global.generatedEs2panda._ClassPropertySetInitInStaticBlock(global.context, this.peer, needInitInStaticBlock) + return this + } + get annotations(): readonly AnnotationUsage[] { + return unpackNodeArray(global.generatedEs2panda._ClassPropertyAnnotations(global.context, this.peer)) + } + /** @deprecated */ + setAnnotations(annotations: readonly AnnotationUsage[]): this { + global.generatedEs2panda._ClassPropertySetAnnotations(global.context, this.peer, passNodeArray(annotations), annotations.length) + return this + } +} +export function isClassProperty(node: object | undefined): node is ClassProperty { + return node instanceof ClassProperty +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_CLASS_PROPERTY)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_CLASS_PROPERTY, (peer: KNativePointer) => new ClassProperty(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ClassStaticBlock.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ClassStaticBlock.ts new file mode 100644 index 0000000000000000000000000000000000000000..59a6b9742f45a747bcd6d131354f16be6a99c39f --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ClassStaticBlock.ts @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { ClassElement } from "./ClassElement" +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { ScriptFunction } from "./ScriptFunction" +export class ClassStaticBlock extends ClassElement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 18) + super(pointer) + } + static createClassStaticBlock(value?: Expression): ClassStaticBlock { + return new ClassStaticBlock(global.generatedEs2panda._CreateClassStaticBlock(global.context, passNode(value))) + } + static updateClassStaticBlock(original?: ClassStaticBlock, value?: Expression): ClassStaticBlock { + return new ClassStaticBlock(global.generatedEs2panda._UpdateClassStaticBlock(global.context, passNode(original), passNode(value))) + } + get function(): ScriptFunction | undefined { + return unpackNode(global.generatedEs2panda._ClassStaticBlockFunction(global.context, this.peer)) + } + get name(): string { + return unpackString(global.generatedEs2panda._ClassStaticBlockNameConst(global.context, this.peer)) + } +} +export function isClassStaticBlock(node: object | undefined): node is ClassStaticBlock { + return node instanceof ClassStaticBlock +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_CLASS_STATIC_BLOCK)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_CLASS_STATIC_BLOCK, (peer: KNativePointer) => new ClassStaticBlock(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/CodeGen.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/CodeGen.ts new file mode 100644 index 0000000000000000000000000000000000000000..d549ee2035cd49c70d65148d2c62c43ae3f01def --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/CodeGen.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +export class CodeGen extends ArktsObject { + constructor(pointer: KNativePointer) { + super(pointer) + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ConditionalExpression.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ConditionalExpression.ts new file mode 100644 index 0000000000000000000000000000000000000000..5d2cc7ab7bad96b9986a58b18eaa220366883fd3 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ConditionalExpression.ts @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +export class ConditionalExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 19) + super(pointer) + } + static createConditionalExpression(test?: Expression, consequent?: Expression, alternate?: Expression): ConditionalExpression { + return new ConditionalExpression(global.generatedEs2panda._CreateConditionalExpression(global.context, passNode(test), passNode(consequent), passNode(alternate))) + } + static updateConditionalExpression(original?: ConditionalExpression, test?: Expression, consequent?: Expression, alternate?: Expression): ConditionalExpression { + return new ConditionalExpression(global.generatedEs2panda._UpdateConditionalExpression(global.context, passNode(original), passNode(test), passNode(consequent), passNode(alternate))) + } + get test(): Expression | undefined { + return unpackNode(global.generatedEs2panda._ConditionalExpressionTest(global.context, this.peer)) + } + /** @deprecated */ + setTest(expr?: Expression): this { + global.generatedEs2panda._ConditionalExpressionSetTest(global.context, this.peer, passNode(expr)) + return this + } + get consequent(): Expression | undefined { + return unpackNode(global.generatedEs2panda._ConditionalExpressionConsequent(global.context, this.peer)) + } + /** @deprecated */ + setConsequent(expr?: Expression): this { + global.generatedEs2panda._ConditionalExpressionSetConsequent(global.context, this.peer, passNode(expr)) + return this + } + get alternate(): Expression | undefined { + return unpackNode(global.generatedEs2panda._ConditionalExpressionAlternate(global.context, this.peer)) + } + /** @deprecated */ + setAlternate(expr?: Expression): this { + global.generatedEs2panda._ConditionalExpressionSetAlternate(global.context, this.peer, passNode(expr)) + return this + } +} +export function isConditionalExpression(node: object | undefined): node is ConditionalExpression { + return node instanceof ConditionalExpression +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_CONDITIONAL_EXPRESSION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_CONDITIONAL_EXPRESSION, (peer: KNativePointer) => new ConditionalExpression(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ContinueStatement.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ContinueStatement.ts new file mode 100644 index 0000000000000000000000000000000000000000..550ed567b6b0d95d05dcfe82df02cd00bcab37fa --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ContinueStatement.ts @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Identifier } from "./Identifier" +import { Statement } from "./Statement" +export class ContinueStatement extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 20) + super(pointer) + } + static create1ContinueStatement(ident?: Identifier): ContinueStatement { + return new ContinueStatement(global.generatedEs2panda._CreateContinueStatement1(global.context, passNode(ident))) + } + static updateContinueStatement(original?: ContinueStatement): ContinueStatement { + return new ContinueStatement(global.generatedEs2panda._UpdateContinueStatement(global.context, passNode(original))) + } + static update1ContinueStatement(original?: ContinueStatement, ident?: Identifier): ContinueStatement { + return new ContinueStatement(global.generatedEs2panda._UpdateContinueStatement1(global.context, passNode(original), passNode(ident))) + } + get ident(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._ContinueStatementIdent(global.context, this.peer)) + } + get target(): AstNode | undefined { + return unpackNode(global.generatedEs2panda._ContinueStatementTargetConst(global.context, this.peer)) + } + get hasTarget(): boolean { + return global.generatedEs2panda._ContinueStatementHasTargetConst(global.context, this.peer) + } + /** @deprecated */ + setTarget(target?: AstNode): this { + global.generatedEs2panda._ContinueStatementSetTarget(global.context, this.peer, passNode(target)) + return this + } +} +export function isContinueStatement(node: object | undefined): node is ContinueStatement { + return node instanceof ContinueStatement +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_CONTINUE_STATEMENT)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_CONTINUE_STATEMENT, (peer: KNativePointer) => new ContinueStatement(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/DebuggerStatement.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/DebuggerStatement.ts new file mode 100644 index 0000000000000000000000000000000000000000..7427a54459d7e0db41fa53b8cdd157a38f82f916 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/DebuggerStatement.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Statement } from "./Statement" +export class DebuggerStatement extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 21) + super(pointer) + } + static createDebuggerStatement(): DebuggerStatement { + return new DebuggerStatement(global.generatedEs2panda._CreateDebuggerStatement(global.context)) + } + static updateDebuggerStatement(original?: DebuggerStatement): DebuggerStatement { + return new DebuggerStatement(global.generatedEs2panda._UpdateDebuggerStatement(global.context, passNode(original))) + } +} +export function isDebuggerStatement(node: object | undefined): node is DebuggerStatement { + return node instanceof DebuggerStatement +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_DEBUGGER_STATEMENT)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_DEBUGGER_STATEMENT, (peer: KNativePointer) => new DebuggerStatement(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/Declaration.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/Declaration.ts new file mode 100644 index 0000000000000000000000000000000000000000..9a4e6dbd346b25fe54aae6be51a9a7939bcda6fa --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/Declaration.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +export class Declaration extends ArktsObject { + constructor(pointer: KNativePointer) { + super(pointer) + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/Decorator.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/Decorator.ts new file mode 100644 index 0000000000000000000000000000000000000000..6ee385b2bcc6a53f9142ce97c9f8debed896bba2 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/Decorator.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { Statement } from "./Statement" +export class Decorator extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 22) + super(pointer) + } + static createDecorator(expr?: Expression): Decorator { + return new Decorator(global.generatedEs2panda._CreateDecorator(global.context, passNode(expr))) + } + static updateDecorator(original?: Decorator, expr?: Expression): Decorator { + return new Decorator(global.generatedEs2panda._UpdateDecorator(global.context, passNode(original), passNode(expr))) + } + get expr(): Expression | undefined { + return unpackNode(global.generatedEs2panda._DecoratorExprConst(global.context, this.peer)) + } +} +export function isDecorator(node: object | undefined): node is Decorator { + return node instanceof Decorator +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_DECORATOR)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_DECORATOR, (peer: KNativePointer) => new Decorator(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/DirectEvalExpression.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/DirectEvalExpression.ts new file mode 100644 index 0000000000000000000000000000000000000000..1b4dd7e16b91c7c60ef7ac8b9c6aae72d3da6156 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/DirectEvalExpression.ts @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { CallExpression } from "./CallExpression" +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { TSTypeParameterInstantiation } from "./TSTypeParameterInstantiation" +export class DirectEvalExpression extends CallExpression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 23) + super(pointer) + } + static createDirectEvalExpression(callee: Expression | undefined, _arguments: readonly Expression[], typeParams: TSTypeParameterInstantiation | undefined, optional_arg: boolean, parserStatus: number): DirectEvalExpression { + return new DirectEvalExpression(global.generatedEs2panda._CreateDirectEvalExpression(global.context, passNode(callee), passNodeArray(_arguments), _arguments.length, passNode(typeParams), optional_arg, parserStatus)) + } + static updateDirectEvalExpression(original: DirectEvalExpression | undefined, callee: Expression | undefined, _arguments: readonly Expression[], typeParams: TSTypeParameterInstantiation | undefined, optional_arg: boolean, parserStatus: number): DirectEvalExpression { + return new DirectEvalExpression(global.generatedEs2panda._UpdateDirectEvalExpression(global.context, passNode(original), passNode(callee), passNodeArray(_arguments), _arguments.length, passNode(typeParams), optional_arg, parserStatus)) + } +} +export function isDirectEvalExpression(node: object | undefined): node is DirectEvalExpression { + return node instanceof DirectEvalExpression +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_DIRECT_EVAL)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_DIRECT_EVAL, (peer: KNativePointer) => new DirectEvalExpression(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/DoWhileStatement.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/DoWhileStatement.ts new file mode 100644 index 0000000000000000000000000000000000000000..7978649405d3ead041524eadfc3b9f18cc7cc466 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/DoWhileStatement.ts @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { LoopStatement } from "./LoopStatement" +import { Statement } from "./Statement" +export class DoWhileStatement extends LoopStatement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 24) + super(pointer) + } + static createDoWhileStatement(body?: Statement, test?: Expression): DoWhileStatement { + return new DoWhileStatement(global.generatedEs2panda._CreateDoWhileStatement(global.context, passNode(body), passNode(test))) + } + static updateDoWhileStatement(original?: DoWhileStatement, body?: Statement, test?: Expression): DoWhileStatement { + return new DoWhileStatement(global.generatedEs2panda._UpdateDoWhileStatement(global.context, passNode(original), passNode(body), passNode(test))) + } + get body(): Statement | undefined { + return unpackNode(global.generatedEs2panda._DoWhileStatementBody(global.context, this.peer)) + } + get test(): Expression | undefined { + return unpackNode(global.generatedEs2panda._DoWhileStatementTest(global.context, this.peer)) + } +} +export function isDoWhileStatement(node: object | undefined): node is DoWhileStatement { + return node instanceof DoWhileStatement +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_DO_WHILE_STATEMENT)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_DO_WHILE_STATEMENT, (peer: KNativePointer) => new DoWhileStatement(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/DynamicImportData.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/DynamicImportData.ts new file mode 100644 index 0000000000000000000000000000000000000000..01d6859b0544edab7061704cae15b3a242877724 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/DynamicImportData.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +export class DynamicImportData extends ArktsObject { + constructor(pointer: KNativePointer) { + super(pointer) + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSClassLiteral.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSClassLiteral.ts new file mode 100644 index 0000000000000000000000000000000000000000..d3c2d422eb80ca91112aa83a83e0e0a47382bc75 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSClassLiteral.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { TypeNode } from "./TypeNode" +export class ETSClassLiteral extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 70) + super(pointer) + } + static createETSClassLiteral(expr?: TypeNode): ETSClassLiteral { + return new ETSClassLiteral(global.generatedEs2panda._CreateETSClassLiteral(global.context, passNode(expr))) + } + static updateETSClassLiteral(original?: ETSClassLiteral, expr?: TypeNode): ETSClassLiteral { + return new ETSClassLiteral(global.generatedEs2panda._UpdateETSClassLiteral(global.context, passNode(original), passNode(expr))) + } + get expr(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._ETSClassLiteralExprConst(global.context, this.peer)) + } +} +export function isETSClassLiteral(node: object | undefined): node is ETSClassLiteral { + return node instanceof ETSClassLiteral +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_ETS_CLASS_LITERAL)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_ETS_CLASS_LITERAL, (peer: KNativePointer) => new ETSClassLiteral(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSDynamicFunctionType.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSDynamicFunctionType.ts new file mode 100644 index 0000000000000000000000000000000000000000..ee7aaf50e76acee57b161e990a507fb7e6cf4275 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSDynamicFunctionType.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { ETSFunctionType } from "./ETSFunctionType" +export class ETSDynamicFunctionType extends ETSFunctionType { + constructor(pointer: KNativePointer) { + super(pointer) + } +} +export function isETSDynamicFunctionType(node: object | undefined): node is ETSDynamicFunctionType { + return node instanceof ETSDynamicFunctionType +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSFunctionType.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSFunctionType.ts new file mode 100644 index 0000000000000000000000000000000000000000..7d17651d445675f8f86ee9101b1edda659b4b80c --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSFunctionType.ts @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Es2pandaScriptFunctionFlags } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { FunctionSignature } from "./FunctionSignature" +import { TSInterfaceDeclaration } from "./TSInterfaceDeclaration" +import { TSTypeParameterDeclaration } from "./TSTypeParameterDeclaration" +import { TypeNode } from "./TypeNode" +export class ETSFunctionType extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 66) + super(pointer) + } + static createETSFunctionType(signature: FunctionSignature | undefined, funcFlags: Es2pandaScriptFunctionFlags): ETSFunctionType { + return new ETSFunctionType(global.generatedEs2panda._CreateETSFunctionType(global.context, passNode(signature), funcFlags)) + } + static updateETSFunctionType(original: ETSFunctionType | undefined, signature: FunctionSignature | undefined, funcFlags: Es2pandaScriptFunctionFlags): ETSFunctionType { + return new ETSFunctionType(global.generatedEs2panda._UpdateETSFunctionType(global.context, passNode(original), passNode(signature), funcFlags)) + } + get typeParams(): TSTypeParameterDeclaration | undefined { + return unpackNode(global.generatedEs2panda._ETSFunctionTypeTypeParams(global.context, this.peer)) + } + get params(): readonly Expression[] { + return unpackNodeArray(global.generatedEs2panda._ETSFunctionTypeParamsConst(global.context, this.peer)) + } + get returnType(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._ETSFunctionTypeReturnType(global.context, this.peer)) + } + get functionalInterface(): TSInterfaceDeclaration | undefined { + return unpackNode(global.generatedEs2panda._ETSFunctionTypeFunctionalInterface(global.context, this.peer)) + } + /** @deprecated */ + setFunctionalInterface(functionalInterface?: TSInterfaceDeclaration): this { + global.generatedEs2panda._ETSFunctionTypeSetFunctionalInterface(global.context, this.peer, passNode(functionalInterface)) + return this + } + get flags(): Es2pandaScriptFunctionFlags { + return global.generatedEs2panda._ETSFunctionTypeFlags(global.context, this.peer) + } + get isThrowing(): boolean { + return global.generatedEs2panda._ETSFunctionTypeIsThrowingConst(global.context, this.peer) + } + get isRethrowing(): boolean { + return global.generatedEs2panda._ETSFunctionTypeIsRethrowingConst(global.context, this.peer) + } + get isExtensionFunction(): boolean { + return global.generatedEs2panda._ETSFunctionTypeIsExtensionFunctionConst(global.context, this.peer) + } +} +export function isETSFunctionType(node: object | undefined): node is ETSFunctionType { + return node instanceof ETSFunctionType +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_ETS_FUNCTION_TYPE)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_ETS_FUNCTION_TYPE, (peer: KNativePointer) => new ETSFunctionType(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSImportDeclaration.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSImportDeclaration.ts new file mode 100644 index 0000000000000000000000000000000000000000..54a080415f80b5181c7d39b32bbef236779474c0 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSImportDeclaration.ts @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Es2pandaId } from "./../Es2pandaEnums" +import { Es2pandaImportFlags } from "./../Es2pandaEnums" +import { Es2pandaImportKinds } from "./../Es2pandaEnums" +import { ImportDeclaration } from "./ImportDeclaration" +import { StringLiteral } from "./StringLiteral" +export class ETSImportDeclaration extends ImportDeclaration { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 78) + super(pointer) + } + static createETSImportDeclaration(importPath: StringLiteral | undefined, specifiers: readonly AstNode[], importKinds: Es2pandaImportKinds): ETSImportDeclaration { + return new ETSImportDeclaration(global.generatedEs2panda._CreateETSImportDeclaration(global.context, passNode(importPath), passNodeArray(specifiers), specifiers.length, importKinds)) + } + static updateETSImportDeclaration(original: ETSImportDeclaration | undefined, importPath: StringLiteral | undefined, specifiers: readonly AstNode[], importKinds: Es2pandaImportKinds): ETSImportDeclaration { + return new ETSImportDeclaration(global.generatedEs2panda._UpdateETSImportDeclaration(global.context, passNode(original), passNode(importPath), passNodeArray(specifiers), specifiers.length, importKinds)) + } + /** @deprecated */ + setImportMetadata(importFlags: Es2pandaImportFlags, lang: Es2pandaId, resolvedSource: string, declPath: string, ohmUrl: string): this { + global.generatedEs2panda._ETSImportDeclarationSetImportMetadata(global.context, this.peer, importFlags, lang, resolvedSource, declPath, ohmUrl) + return this + } + get declPath(): string { + return unpackString(global.generatedEs2panda._ETSImportDeclarationDeclPathConst(global.context, this.peer)) + } + get ohmUrl(): string { + return unpackString(global.generatedEs2panda._ETSImportDeclarationOhmUrlConst(global.context, this.peer)) + } + get isValid(): boolean { + return global.generatedEs2panda._ETSImportDeclarationIsValidConst(global.context, this.peer) + } + get isPureDynamic(): boolean { + return global.generatedEs2panda._ETSImportDeclarationIsPureDynamicConst(global.context, this.peer) + } + get assemblerName(): string { + return unpackString(global.generatedEs2panda._ETSImportDeclarationAssemblerName(global.context, this.peer)) + } + get resolvedSource(): string { + return unpackString(global.generatedEs2panda._ETSImportDeclarationResolvedSourceConst(global.context, this.peer)) + } +} +export function isETSImportDeclaration(node: object | undefined): node is ETSImportDeclaration { + return node instanceof ETSImportDeclaration +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_ETS_IMPORT_DECLARATION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_ETS_IMPORT_DECLARATION, (peer: KNativePointer) => new ETSImportDeclaration(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSKeyofType.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSKeyofType.ts new file mode 100644 index 0000000000000000000000000000000000000000..d387864ef1577a445ec28df0a9838909e1bf609d --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSKeyofType.ts @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { TypeNode } from "./TypeNode" +export class ETSKeyofType extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 74) + super(pointer) + } + static createETSKeyofType(type?: TypeNode): ETSKeyofType { + return new ETSKeyofType(global.generatedEs2panda._CreateETSKeyofType(global.context, passNode(type))) + } + static updateETSKeyofType(original?: ETSKeyofType, type?: TypeNode): ETSKeyofType { + return new ETSKeyofType(global.generatedEs2panda._UpdateETSKeyofType(global.context, passNode(original), passNode(type))) + } + get typeRef(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._ETSKeyofTypeGetTypeRefConst(global.context, this.peer)) + } +} +export function isETSKeyofType(node: object | undefined): node is ETSKeyofType { + return node instanceof ETSKeyofType +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_ETS_KEYOF_TYPE)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_ETS_KEYOF_TYPE, (peer: KNativePointer) => new ETSKeyofType(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSModule.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSModule.ts new file mode 100644 index 0000000000000000000000000000000000000000..ebaf0600e3368e97829dd06182a02f90cad4a552 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSModule.ts @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { AnnotationUsage } from "./AnnotationUsage" +import { BlockStatement } from "./BlockStatement" +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Identifier } from "./Identifier" +export class ETSModule extends BlockStatement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 81) + super(pointer) + } + get ident(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._ETSModuleIdent(global.context, this.peer)) + } + get isETSScript(): boolean { + return global.generatedEs2panda._ETSModuleIsETSScriptConst(global.context, this.peer) + } + get isNamespace(): boolean { + return global.generatedEs2panda._ETSModuleIsNamespaceConst(global.context, this.peer) + } + get isNamespaceChainLastNode(): boolean { + return global.generatedEs2panda._ETSModuleIsNamespaceChainLastNodeConst(global.context, this.peer) + } + /** @deprecated */ + setNamespaceChainLastNode(): this { + global.generatedEs2panda._ETSModuleSetNamespaceChainLastNode(global.context, this.peer) + return this + } + get annotations(): readonly AnnotationUsage[] { + return unpackNodeArray(global.generatedEs2panda._ETSModuleAnnotations(global.context, this.peer)) + } + /** @deprecated */ + setAnnotations(annotations: readonly AnnotationUsage[]): this { + global.generatedEs2panda._ETSModuleSetAnnotations(global.context, this.peer, passNodeArray(annotations), annotations.length) + return this + } +} +export function isETSModule(node: object | undefined): node is ETSModule { + return node instanceof ETSModule +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_ETS_MODULE)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_ETS_MODULE, (peer: KNativePointer) => new ETSModule(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSNewArrayInstanceExpression.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSNewArrayInstanceExpression.ts new file mode 100644 index 0000000000000000000000000000000000000000..f253841aa33d9f8074f056f13715e81af5851809 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSNewArrayInstanceExpression.ts @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { TypeNode } from "./TypeNode" +export class ETSNewArrayInstanceExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 75) + super(pointer) + } + static createETSNewArrayInstanceExpression(typeReference?: TypeNode, dimension?: Expression): ETSNewArrayInstanceExpression { + return new ETSNewArrayInstanceExpression(global.generatedEs2panda._CreateETSNewArrayInstanceExpression(global.context, passNode(typeReference), passNode(dimension))) + } + static updateETSNewArrayInstanceExpression(original?: ETSNewArrayInstanceExpression, typeReference?: TypeNode, dimension?: Expression): ETSNewArrayInstanceExpression { + return new ETSNewArrayInstanceExpression(global.generatedEs2panda._UpdateETSNewArrayInstanceExpression(global.context, passNode(original), passNode(typeReference), passNode(dimension))) + } + get typeReference(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._ETSNewArrayInstanceExpressionTypeReference(global.context, this.peer)) + } + get dimension(): Expression | undefined { + return unpackNode(global.generatedEs2panda._ETSNewArrayInstanceExpressionDimension(global.context, this.peer)) + } + /** @deprecated */ + setDimension(dimension?: Expression): this { + global.generatedEs2panda._ETSNewArrayInstanceExpressionSetDimension(global.context, this.peer, passNode(dimension)) + return this + } + /** @deprecated */ + clearPreferredType(): this { + global.generatedEs2panda._ETSNewArrayInstanceExpressionClearPreferredType(global.context, this.peer) + return this + } +} +export function isETSNewArrayInstanceExpression(node: object | undefined): node is ETSNewArrayInstanceExpression { + return node instanceof ETSNewArrayInstanceExpression +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_ETS_NEW_ARRAY_INSTANCE_EXPRESSION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_ETS_NEW_ARRAY_INSTANCE_EXPRESSION, (peer: KNativePointer) => new ETSNewArrayInstanceExpression(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSNewClassInstanceExpression.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSNewClassInstanceExpression.ts new file mode 100644 index 0000000000000000000000000000000000000000..5bb759388ec1c22d38718c3bab6c38e5988e98c4 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSNewClassInstanceExpression.ts @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +export class ETSNewClassInstanceExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 77) + super(pointer) + } + static createETSNewClassInstanceExpression(typeReference: Expression | undefined, _arguments: readonly Expression[]): ETSNewClassInstanceExpression { + return new ETSNewClassInstanceExpression(global.generatedEs2panda._CreateETSNewClassInstanceExpression(global.context, passNode(typeReference), passNodeArray(_arguments), _arguments.length)) + } + static updateETSNewClassInstanceExpression(original: ETSNewClassInstanceExpression | undefined, typeReference: Expression | undefined, _arguments: readonly Expression[]): ETSNewClassInstanceExpression { + return new ETSNewClassInstanceExpression(global.generatedEs2panda._UpdateETSNewClassInstanceExpression(global.context, passNode(original), passNode(typeReference), passNodeArray(_arguments), _arguments.length)) + } + static update1ETSNewClassInstanceExpression(original?: ETSNewClassInstanceExpression, other?: ETSNewClassInstanceExpression): ETSNewClassInstanceExpression { + return new ETSNewClassInstanceExpression(global.generatedEs2panda._UpdateETSNewClassInstanceExpression1(global.context, passNode(original), passNode(other))) + } + get typeRef(): Expression | undefined { + return unpackNode(global.generatedEs2panda._ETSNewClassInstanceExpressionGetTypeRefConst(global.context, this.peer)) + } + get arguments(): readonly Expression[] { + return unpackNodeArray(global.generatedEs2panda._ETSNewClassInstanceExpressionGetArguments(global.context, this.peer)) + } + /** @deprecated */ + setArguments(_arguments: readonly Expression[]): this { + global.generatedEs2panda._ETSNewClassInstanceExpressionSetArguments(global.context, this.peer, passNodeArray(_arguments), _arguments.length) + return this + } + /** @deprecated */ + addToArgumentsFront(expr?: Expression): this { + global.generatedEs2panda._ETSNewClassInstanceExpressionAddToArgumentsFront(global.context, this.peer, passNode(expr)) + return this + } +} +export function isETSNewClassInstanceExpression(node: object | undefined): node is ETSNewClassInstanceExpression { + return node instanceof ETSNewClassInstanceExpression +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_ETS_NEW_CLASS_INSTANCE_EXPRESSION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_ETS_NEW_CLASS_INSTANCE_EXPRESSION, (peer: KNativePointer) => new ETSNewClassInstanceExpression(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSNewMultiDimArrayInstanceExpression.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSNewMultiDimArrayInstanceExpression.ts new file mode 100644 index 0000000000000000000000000000000000000000..9a03ce6a840f67424eb62c1361cbd0e1ba95d60f --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSNewMultiDimArrayInstanceExpression.ts @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { TypeNode } from "./TypeNode" +export class ETSNewMultiDimArrayInstanceExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 76) + super(pointer) + } + static createETSNewMultiDimArrayInstanceExpression(typeReference: TypeNode | undefined, dimensions: readonly Expression[]): ETSNewMultiDimArrayInstanceExpression { + return new ETSNewMultiDimArrayInstanceExpression(global.generatedEs2panda._CreateETSNewMultiDimArrayInstanceExpression(global.context, passNode(typeReference), passNodeArray(dimensions), dimensions.length)) + } + static updateETSNewMultiDimArrayInstanceExpression(original: ETSNewMultiDimArrayInstanceExpression | undefined, typeReference: TypeNode | undefined, dimensions: readonly Expression[]): ETSNewMultiDimArrayInstanceExpression { + return new ETSNewMultiDimArrayInstanceExpression(global.generatedEs2panda._UpdateETSNewMultiDimArrayInstanceExpression(global.context, passNode(original), passNode(typeReference), passNodeArray(dimensions), dimensions.length)) + } + static update1ETSNewMultiDimArrayInstanceExpression(original?: ETSNewMultiDimArrayInstanceExpression, other?: ETSNewMultiDimArrayInstanceExpression): ETSNewMultiDimArrayInstanceExpression { + return new ETSNewMultiDimArrayInstanceExpression(global.generatedEs2panda._UpdateETSNewMultiDimArrayInstanceExpression1(global.context, passNode(original), passNode(other))) + } + get typeReference(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._ETSNewMultiDimArrayInstanceExpressionTypeReference(global.context, this.peer)) + } + get dimensions(): readonly Expression[] { + return unpackNodeArray(global.generatedEs2panda._ETSNewMultiDimArrayInstanceExpressionDimensions(global.context, this.peer)) + } + /** @deprecated */ + clearPreferredType(): this { + global.generatedEs2panda._ETSNewMultiDimArrayInstanceExpressionClearPreferredType(global.context, this.peer) + return this + } +} +export function isETSNewMultiDimArrayInstanceExpression(node: object | undefined): node is ETSNewMultiDimArrayInstanceExpression { + return node instanceof ETSNewMultiDimArrayInstanceExpression +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_ETS_NEW_MULTI_DIM_ARRAY_INSTANCE_EXPRESSION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_ETS_NEW_MULTI_DIM_ARRAY_INSTANCE_EXPRESSION, (peer: KNativePointer) => new ETSNewMultiDimArrayInstanceExpression(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSNullType.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSNullType.ts new file mode 100644 index 0000000000000000000000000000000000000000..ee9eef4431967182c65f96956345e4a65070467b --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSNullType.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { TypeNode } from "./TypeNode" +export class ETSNullType extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 62) + super(pointer) + } + static createETSNullType(): ETSNullType { + return new ETSNullType(global.generatedEs2panda._CreateETSNullType(global.context)) + } + static updateETSNullType(original?: ETSNullType): ETSNullType { + return new ETSNullType(global.generatedEs2panda._UpdateETSNullType(global.context, passNode(original))) + } +} +export function isETSNullType(node: object | undefined): node is ETSNullType { + return node instanceof ETSNullType +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_ETS_NULL_TYPE)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_ETS_NULL_TYPE, (peer: KNativePointer) => new ETSNullType(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSPackageDeclaration.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSPackageDeclaration.ts new file mode 100644 index 0000000000000000000000000000000000000000..0451b4a65bacf1948c8ba49b25f1e0d835a55f69 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSPackageDeclaration.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { Statement } from "./Statement" +export class ETSPackageDeclaration extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 69) + super(pointer) + } + static createETSPackageDeclaration(name?: Expression): ETSPackageDeclaration { + return new ETSPackageDeclaration(global.generatedEs2panda._CreateETSPackageDeclaration(global.context, passNode(name))) + } + static updateETSPackageDeclaration(original?: ETSPackageDeclaration, name?: Expression): ETSPackageDeclaration { + return new ETSPackageDeclaration(global.generatedEs2panda._UpdateETSPackageDeclaration(global.context, passNode(original), passNode(name))) + } +} +export function isETSPackageDeclaration(node: object | undefined): node is ETSPackageDeclaration { + return node instanceof ETSPackageDeclaration +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_ETS_PACKAGE_DECLARATION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_ETS_PACKAGE_DECLARATION, (peer: KNativePointer) => new ETSPackageDeclaration(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSParameterExpression.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSParameterExpression.ts new file mode 100644 index 0000000000000000000000000000000000000000..6e218bd07d6bfa55f2a5e37e4208b6087e3f92f1 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSParameterExpression.ts @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { AnnotatedExpression } from "./AnnotatedExpression" +import { AnnotationUsage } from "./AnnotationUsage" +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { Identifier } from "./Identifier" +import { SpreadElement } from "./SpreadElement" +import { TypeNode } from "./TypeNode" +export class ETSParameterExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 79) + super(pointer) + } + static createETSParameterExpression(identOrSpread: AnnotatedExpression | undefined, isOptional: boolean): ETSParameterExpression { + return new ETSParameterExpression(global.generatedEs2panda._CreateETSParameterExpression(global.context, passNode(identOrSpread), isOptional)) + } + static updateETSParameterExpression(original: ETSParameterExpression | undefined, identOrSpread: AnnotatedExpression | undefined, isOptional: boolean): ETSParameterExpression { + return new ETSParameterExpression(global.generatedEs2panda._UpdateETSParameterExpression(global.context, passNode(original), passNode(identOrSpread), isOptional)) + } + static create1ETSParameterExpression(identOrSpread?: AnnotatedExpression, initializer?: Expression): ETSParameterExpression { + return new ETSParameterExpression(global.generatedEs2panda._CreateETSParameterExpression1(global.context, passNode(identOrSpread), passNode(initializer))) + } + static update1ETSParameterExpression(original?: ETSParameterExpression, identOrSpread?: AnnotatedExpression, initializer?: Expression): ETSParameterExpression { + return new ETSParameterExpression(global.generatedEs2panda._UpdateETSParameterExpression1(global.context, passNode(original), passNode(identOrSpread), passNode(initializer))) + } + get name(): string { + return unpackString(global.generatedEs2panda._ETSParameterExpressionNameConst(global.context, this.peer)) + } + get ident(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._ETSParameterExpressionIdent(global.context, this.peer)) + } + /** @deprecated */ + setIdent(ident?: Identifier): this { + global.generatedEs2panda._ETSParameterExpressionSetIdent(global.context, this.peer, passNode(ident)) + return this + } + get restParameter(): SpreadElement | undefined { + return unpackNode(global.generatedEs2panda._ETSParameterExpressionRestParameter(global.context, this.peer)) + } + get initializer(): Expression | undefined { + return unpackNode(global.generatedEs2panda._ETSParameterExpressionInitializer(global.context, this.peer)) + } + /** @deprecated */ + setLexerSaved(s: string): this { + global.generatedEs2panda._ETSParameterExpressionSetLexerSaved(global.context, this.peer, s) + return this + } + get lexerSaved(): string { + return unpackString(global.generatedEs2panda._ETSParameterExpressionLexerSavedConst(global.context, this.peer)) + } + get typeAnnotation(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._ETSParameterExpressionTypeAnnotation(global.context, this.peer)) + } + /** @deprecated */ + setTypeAnnotation(typeNode?: TypeNode): this { + global.generatedEs2panda._ETSParameterExpressionSetTypeAnnotation(global.context, this.peer, passNode(typeNode)) + return this + } + get isOptional(): boolean { + return global.generatedEs2panda._ETSParameterExpressionIsOptionalConst(global.context, this.peer) + } + /** @deprecated */ + setOptional(value: boolean): this { + global.generatedEs2panda._ETSParameterExpressionSetOptional(global.context, this.peer, value) + return this + } + /** @deprecated */ + setInitializer(initExpr?: Expression): this { + global.generatedEs2panda._ETSParameterExpressionSetInitializer(global.context, this.peer, passNode(initExpr)) + return this + } + get isRestParameter(): boolean { + return global.generatedEs2panda._ETSParameterExpressionIsRestParameterConst(global.context, this.peer) + } + get requiredParams(): number { + return global.generatedEs2panda._ETSParameterExpressionGetRequiredParamsConst(global.context, this.peer) + } + /** @deprecated */ + setRequiredParams(value: number): this { + global.generatedEs2panda._ETSParameterExpressionSetRequiredParams(global.context, this.peer, value) + return this + } + get annotations(): readonly AnnotationUsage[] { + return unpackNodeArray(global.generatedEs2panda._ETSParameterExpressionAnnotations(global.context, this.peer)) + } + /** @deprecated */ + setAnnotations(annotations: readonly AnnotationUsage[]): this { + global.generatedEs2panda._ETSParameterExpressionSetAnnotations(global.context, this.peer, passNodeArray(annotations), annotations.length) + return this + } +} +export function isETSParameterExpression(node: object | undefined): node is ETSParameterExpression { + return node instanceof ETSParameterExpression +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_ETS_PARAMETER_EXPRESSION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_ETS_PARAMETER_EXPRESSION, (peer: KNativePointer) => new ETSParameterExpression(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSPrimitiveType.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSPrimitiveType.ts new file mode 100644 index 0000000000000000000000000000000000000000..1c44273eeafe1b8dd329a7e2059ccdfd219c4af5 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSPrimitiveType.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Es2pandaPrimitiveType } from "./../Es2pandaEnums" +import { TypeNode } from "./TypeNode" +export class ETSPrimitiveType extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 68) + super(pointer) + } + static createETSPrimitiveType(type: Es2pandaPrimitiveType): ETSPrimitiveType { + return new ETSPrimitiveType(global.generatedEs2panda._CreateETSPrimitiveType(global.context, type)) + } + static updateETSPrimitiveType(original: ETSPrimitiveType | undefined, type: Es2pandaPrimitiveType): ETSPrimitiveType { + return new ETSPrimitiveType(global.generatedEs2panda._UpdateETSPrimitiveType(global.context, passNode(original), type)) + } + get primitiveType(): Es2pandaPrimitiveType { + return global.generatedEs2panda._ETSPrimitiveTypeGetPrimitiveTypeConst(global.context, this.peer) + } +} +export function isETSPrimitiveType(node: object | undefined): node is ETSPrimitiveType { + return node instanceof ETSPrimitiveType +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_ETS_PRIMITIVE_TYPE)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_ETS_PRIMITIVE_TYPE, (peer: KNativePointer) => new ETSPrimitiveType(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSReExportDeclaration.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSReExportDeclaration.ts new file mode 100644 index 0000000000000000000000000000000000000000..a874a540fcd27b9d8c35b4cbd59451d410a751bf --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSReExportDeclaration.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { ETSImportDeclaration } from "./ETSImportDeclaration" +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Statement } from "./Statement" +export class ETSReExportDeclaration extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 57) + super(pointer) + } + get eTSImportDeclarations(): ETSImportDeclaration | undefined { + return unpackNode(global.generatedEs2panda._ETSReExportDeclarationGetETSImportDeclarations(global.context, this.peer)) + } + get programPath(): string { + return unpackString(global.generatedEs2panda._ETSReExportDeclarationGetProgramPathConst(global.context, this.peer)) + } +} +export function isETSReExportDeclaration(node: object | undefined): node is ETSReExportDeclaration { + return node instanceof ETSReExportDeclaration +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_REEXPORT_STATEMENT)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_REEXPORT_STATEMENT, (peer: KNativePointer) => new ETSReExportDeclaration(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSStringLiteralType.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSStringLiteralType.ts new file mode 100644 index 0000000000000000000000000000000000000000..42834e5db75cbac2649000147bd300695e33b7c1 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSStringLiteralType.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { TypeNode } from "./TypeNode" +export class ETSStringLiteralType extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 65) + super(pointer) + } + static createETSStringLiteralType(value: string): ETSStringLiteralType { + return new ETSStringLiteralType(global.generatedEs2panda._CreateETSStringLiteralType(global.context, value)) + } + static updateETSStringLiteralType(original: ETSStringLiteralType | undefined, value: string): ETSStringLiteralType { + return new ETSStringLiteralType(global.generatedEs2panda._UpdateETSStringLiteralType(global.context, passNode(original), value)) + } +} +export function isETSStringLiteralType(node: object | undefined): node is ETSStringLiteralType { + return node instanceof ETSStringLiteralType +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_ETS_STRING_LITERAL_TYPE)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_ETS_STRING_LITERAL_TYPE, (peer: KNativePointer) => new ETSStringLiteralType(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSStructDeclaration.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSStructDeclaration.ts new file mode 100644 index 0000000000000000000000000000000000000000..0482a8ae5cae85599dfa600b65aeb2b7a3378ee2 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSStructDeclaration.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { ClassDeclaration } from "./ClassDeclaration" +import { ClassDefinition } from "./ClassDefinition" +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +export class ETSStructDeclaration extends ClassDeclaration { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 83) + super(pointer) + } + static createETSStructDeclaration(def?: ClassDefinition): ETSStructDeclaration { + return new ETSStructDeclaration(global.generatedEs2panda._CreateETSStructDeclaration(global.context, passNode(def))) + } + static updateETSStructDeclaration(original?: ETSStructDeclaration, def?: ClassDefinition): ETSStructDeclaration { + return new ETSStructDeclaration(global.generatedEs2panda._UpdateETSStructDeclaration(global.context, passNode(original), passNode(def))) + } +} +export function isETSStructDeclaration(node: object | undefined): node is ETSStructDeclaration { + return node instanceof ETSStructDeclaration +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_STRUCT_DECLARATION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_STRUCT_DECLARATION, (peer: KNativePointer) => new ETSStructDeclaration(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSTuple.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSTuple.ts new file mode 100644 index 0000000000000000000000000000000000000000..882ff92868def9fd3f1137655cfa57624ed305be --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSTuple.ts @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { TypeNode } from "./TypeNode" +export class ETSTuple extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 80) + super(pointer) + } + static createETSTuple(): ETSTuple { + return new ETSTuple(global.generatedEs2panda._CreateETSTuple(global.context)) + } + static updateETSTuple(original?: ETSTuple): ETSTuple { + return new ETSTuple(global.generatedEs2panda._UpdateETSTuple(global.context, passNode(original))) + } + static create1ETSTuple(size: number): ETSTuple { + return new ETSTuple(global.generatedEs2panda._CreateETSTuple1(global.context, size)) + } + static update1ETSTuple(original: ETSTuple | undefined, size: number): ETSTuple { + return new ETSTuple(global.generatedEs2panda._UpdateETSTuple1(global.context, passNode(original), size)) + } + static create2ETSTuple(typeList: readonly TypeNode[]): ETSTuple { + return new ETSTuple(global.generatedEs2panda._CreateETSTuple2(global.context, passNodeArray(typeList), typeList.length)) + } + static update2ETSTuple(original: ETSTuple | undefined, typeList: readonly TypeNode[]): ETSTuple { + return new ETSTuple(global.generatedEs2panda._UpdateETSTuple2(global.context, passNode(original), passNodeArray(typeList), typeList.length)) + } + get tupleSize(): number { + return global.generatedEs2panda._ETSTupleGetTupleSizeConst(global.context, this.peer) + } + get tupleTypeAnnotationsList(): readonly TypeNode[] { + return unpackNodeArray(global.generatedEs2panda._ETSTupleGetTupleTypeAnnotationsList(global.context, this.peer)) + } + /** @deprecated */ + setTypeAnnotationsList(typeNodeList: readonly TypeNode[]): this { + global.generatedEs2panda._ETSTupleSetTypeAnnotationsList(global.context, this.peer, passNodeArray(typeNodeList), typeNodeList.length) + return this + } +} +export function isETSTuple(node: object | undefined): node is ETSTuple { + return node instanceof ETSTuple +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_ETS_TUPLE)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_ETS_TUPLE, (peer: KNativePointer) => new ETSTuple(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSTypeReference.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSTypeReference.ts new file mode 100644 index 0000000000000000000000000000000000000000..a9f5bd96639a1b084fc0965bc1eb693ee56122c1 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSTypeReference.ts @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { ETSTypeReferencePart } from "./ETSTypeReferencePart" +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Identifier } from "./Identifier" +import { TypeNode } from "./TypeNode" +export class ETSTypeReference extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 71) + super(pointer) + } + static createETSTypeReference(part?: ETSTypeReferencePart): ETSTypeReference { + return new ETSTypeReference(global.generatedEs2panda._CreateETSTypeReference(global.context, passNode(part))) + } + static updateETSTypeReference(original?: ETSTypeReference, part?: ETSTypeReferencePart): ETSTypeReference { + return new ETSTypeReference(global.generatedEs2panda._UpdateETSTypeReference(global.context, passNode(original), passNode(part))) + } + get part(): ETSTypeReferencePart | undefined { + return unpackNode(global.generatedEs2panda._ETSTypeReferencePart(global.context, this.peer)) + } + get baseName(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._ETSTypeReferenceBaseNameConst(global.context, this.peer)) + } +} +export function isETSTypeReference(node: object | undefined): node is ETSTypeReference { + return node instanceof ETSTypeReference +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_ETS_TYPE_REFERENCE)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_ETS_TYPE_REFERENCE, (peer: KNativePointer) => new ETSTypeReference(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSTypeReferencePart.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSTypeReferencePart.ts new file mode 100644 index 0000000000000000000000000000000000000000..165e86db6ee0ab3219e1753779838cf23e233377 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSTypeReferencePart.ts @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { Identifier } from "./Identifier" +import { TSTypeParameterInstantiation } from "./TSTypeParameterInstantiation" +import { TypeNode } from "./TypeNode" +export class ETSTypeReferencePart extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 72) + super(pointer) + } + static createETSTypeReferencePart(name?: Expression, typeParams?: TSTypeParameterInstantiation, prev?: ETSTypeReferencePart): ETSTypeReferencePart { + return new ETSTypeReferencePart(global.generatedEs2panda._CreateETSTypeReferencePart(global.context, passNode(name), passNode(typeParams), passNode(prev))) + } + static updateETSTypeReferencePart(original?: ETSTypeReferencePart, name?: Expression, typeParams?: TSTypeParameterInstantiation, prev?: ETSTypeReferencePart): ETSTypeReferencePart { + return new ETSTypeReferencePart(global.generatedEs2panda._UpdateETSTypeReferencePart(global.context, passNode(original), passNode(name), passNode(typeParams), passNode(prev))) + } + static update1ETSTypeReferencePart(original?: ETSTypeReferencePart, name?: Expression): ETSTypeReferencePart { + return new ETSTypeReferencePart(global.generatedEs2panda._UpdateETSTypeReferencePart1(global.context, passNode(original), passNode(name))) + } + get previous(): ETSTypeReferencePart | undefined { + return unpackNode(global.generatedEs2panda._ETSTypeReferencePartPrevious(global.context, this.peer)) + } + get name(): Expression | undefined { + return unpackNode(global.generatedEs2panda._ETSTypeReferencePartName(global.context, this.peer)) + } + get typeParams(): TSTypeParameterInstantiation | undefined { + return unpackNode(global.generatedEs2panda._ETSTypeReferencePartTypeParams(global.context, this.peer)) + } + get ident(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._ETSTypeReferencePartGetIdent(global.context, this.peer)) + } +} +export function isETSTypeReferencePart(node: object | undefined): node is ETSTypeReferencePart { + return node instanceof ETSTypeReferencePart +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_ETS_TYPE_REFERENCE_PART)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_ETS_TYPE_REFERENCE_PART, (peer: KNativePointer) => new ETSTypeReferencePart(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSUndefinedType.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSUndefinedType.ts new file mode 100644 index 0000000000000000000000000000000000000000..eb275b59f86894172c4da9d8d91fdd670341dfba --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSUndefinedType.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { TypeNode } from "./TypeNode" +export class ETSUndefinedType extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 63) + super(pointer) + } + static createETSUndefinedType(): ETSUndefinedType { + return new ETSUndefinedType(global.generatedEs2panda._CreateETSUndefinedType(global.context)) + } + static updateETSUndefinedType(original?: ETSUndefinedType): ETSUndefinedType { + return new ETSUndefinedType(global.generatedEs2panda._UpdateETSUndefinedType(global.context, passNode(original))) + } +} +export function isETSUndefinedType(node: object | undefined): node is ETSUndefinedType { + return node instanceof ETSUndefinedType +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_ETS_UNDEFINED_TYPE)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_ETS_UNDEFINED_TYPE, (peer: KNativePointer) => new ETSUndefinedType(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSUnionType.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSUnionType.ts new file mode 100644 index 0000000000000000000000000000000000000000..fd4588122c29d210ef0de5f55cc2267c1a62f38c --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSUnionType.ts @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { TypeNode } from "./TypeNode" +export class ETSUnionType extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 73) + super(pointer) + } + static createETSUnionType(types: readonly TypeNode[]): ETSUnionType { + return new ETSUnionType(global.generatedEs2panda._CreateETSUnionType(global.context, passNodeArray(types), types.length)) + } + static updateETSUnionType(original: ETSUnionType | undefined, types: readonly TypeNode[]): ETSUnionType { + return new ETSUnionType(global.generatedEs2panda._UpdateETSUnionType(global.context, passNode(original), passNodeArray(types), types.length)) + } + get types(): readonly TypeNode[] { + return unpackNodeArray(global.generatedEs2panda._ETSUnionTypeTypesConst(global.context, this.peer)) + } +} +export function isETSUnionType(node: object | undefined): node is ETSUnionType { + return node instanceof ETSUnionType +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_ETS_UNION_TYPE)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_ETS_UNION_TYPE, (peer: KNativePointer) => new ETSUnionType(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSWildcardType.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSWildcardType.ts new file mode 100644 index 0000000000000000000000000000000000000000..8832863f44d2e5d66c3f01c232613360b872a983 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ETSWildcardType.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { ETSTypeReference } from "./ETSTypeReference" +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Es2pandaModifierFlags } from "./../Es2pandaEnums" +import { TypeNode } from "./TypeNode" +export class ETSWildcardType extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 67) + super(pointer) + } + static createETSWildcardType(typeReference: ETSTypeReference | undefined, flags: Es2pandaModifierFlags): ETSWildcardType { + return new ETSWildcardType(global.generatedEs2panda._CreateETSWildcardType(global.context, passNode(typeReference), flags)) + } + static updateETSWildcardType(original: ETSWildcardType | undefined, typeReference: ETSTypeReference | undefined, flags: Es2pandaModifierFlags): ETSWildcardType { + return new ETSWildcardType(global.generatedEs2panda._UpdateETSWildcardType(global.context, passNode(original), passNode(typeReference), flags)) + } + get typeReference(): ETSTypeReference | undefined { + return unpackNode(global.generatedEs2panda._ETSWildcardTypeTypeReference(global.context, this.peer)) + } +} +export function isETSWildcardType(node: object | undefined): node is ETSWildcardType { + return node instanceof ETSWildcardType +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_ETS_WILDCARD_TYPE)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_ETS_WILDCARD_TYPE, (peer: KNativePointer) => new ETSWildcardType(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/EmptyStatement.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/EmptyStatement.ts new file mode 100644 index 0000000000000000000000000000000000000000..6031a3cbe599a3491ec4d1c92fa7825d67fea31f --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/EmptyStatement.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Statement } from "./Statement" +export class EmptyStatement extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 25) + super(pointer) + } + static createEmptyStatement(): EmptyStatement { + return new EmptyStatement(global.generatedEs2panda._CreateEmptyStatement(global.context)) + } + static updateEmptyStatement(original?: EmptyStatement): EmptyStatement { + return new EmptyStatement(global.generatedEs2panda._UpdateEmptyStatement(global.context, passNode(original))) + } +} +export function isEmptyStatement(node: object | undefined): node is EmptyStatement { + return node instanceof EmptyStatement +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_EMPTY_STATEMENT)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_EMPTY_STATEMENT, (peer: KNativePointer) => new EmptyStatement(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ErrorLogger.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ErrorLogger.ts new file mode 100644 index 0000000000000000000000000000000000000000..7c23035c96e45b877d3cf4d66d9ba98068b3608c --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ErrorLogger.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +export class ErrorLogger extends ArktsObject { + constructor(pointer: KNativePointer) { + super(pointer) + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ExportAllDeclaration.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ExportAllDeclaration.ts new file mode 100644 index 0000000000000000000000000000000000000000..9aa18b8cddf5a688a30e2066619d403a93010810 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ExportAllDeclaration.ts @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Identifier } from "./Identifier" +import { Statement } from "./Statement" +import { StringLiteral } from "./StringLiteral" +export class ExportAllDeclaration extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 26) + super(pointer) + } + static createExportAllDeclaration(source?: StringLiteral, exported?: Identifier): ExportAllDeclaration { + return new ExportAllDeclaration(global.generatedEs2panda._CreateExportAllDeclaration(global.context, passNode(source), passNode(exported))) + } + static updateExportAllDeclaration(original?: ExportAllDeclaration, source?: StringLiteral, exported?: Identifier): ExportAllDeclaration { + return new ExportAllDeclaration(global.generatedEs2panda._UpdateExportAllDeclaration(global.context, passNode(original), passNode(source), passNode(exported))) + } + get source(): StringLiteral | undefined { + return unpackNode(global.generatedEs2panda._ExportAllDeclarationSourceConst(global.context, this.peer)) + } + get exported(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._ExportAllDeclarationExportedConst(global.context, this.peer)) + } +} +export function isExportAllDeclaration(node: object | undefined): node is ExportAllDeclaration { + return node instanceof ExportAllDeclaration +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_EXPORT_ALL_DECLARATION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_EXPORT_ALL_DECLARATION, (peer: KNativePointer) => new ExportAllDeclaration(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ExportDefaultDeclaration.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ExportDefaultDeclaration.ts new file mode 100644 index 0000000000000000000000000000000000000000..ed8e0e1740494aa92af302c86053daffefdf97eb --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ExportDefaultDeclaration.ts @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Statement } from "./Statement" +export class ExportDefaultDeclaration extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 27) + super(pointer) + } + static createExportDefaultDeclaration(decl: AstNode | undefined, exportEquals: boolean): ExportDefaultDeclaration { + return new ExportDefaultDeclaration(global.generatedEs2panda._CreateExportDefaultDeclaration(global.context, passNode(decl), exportEquals)) + } + static updateExportDefaultDeclaration(original: ExportDefaultDeclaration | undefined, decl: AstNode | undefined, exportEquals: boolean): ExportDefaultDeclaration { + return new ExportDefaultDeclaration(global.generatedEs2panda._UpdateExportDefaultDeclaration(global.context, passNode(original), passNode(decl), exportEquals)) + } + get decl(): AstNode | undefined { + return unpackNode(global.generatedEs2panda._ExportDefaultDeclarationDecl(global.context, this.peer)) + } + get isExportEquals(): boolean { + return global.generatedEs2panda._ExportDefaultDeclarationIsExportEqualsConst(global.context, this.peer) + } +} +export function isExportDefaultDeclaration(node: object | undefined): node is ExportDefaultDeclaration { + return node instanceof ExportDefaultDeclaration +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_EXPORT_DEFAULT_DECLARATION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_EXPORT_DEFAULT_DECLARATION, (peer: KNativePointer) => new ExportDefaultDeclaration(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ExportNamedDeclaration.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ExportNamedDeclaration.ts new file mode 100644 index 0000000000000000000000000000000000000000..ae10e7c3555732e267634e36eb01cc782cbaabd1 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ExportNamedDeclaration.ts @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { ExportSpecifier } from "./ExportSpecifier" +import { Statement } from "./Statement" +import { StringLiteral } from "./StringLiteral" +export class ExportNamedDeclaration extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 28) + super(pointer) + } + static createExportNamedDeclaration(source: StringLiteral | undefined, specifiers: readonly ExportSpecifier[]): ExportNamedDeclaration { + return new ExportNamedDeclaration(global.generatedEs2panda._CreateExportNamedDeclaration(global.context, passNode(source), passNodeArray(specifiers), specifiers.length)) + } + static updateExportNamedDeclaration(original: ExportNamedDeclaration | undefined, source: StringLiteral | undefined, specifiers: readonly ExportSpecifier[]): ExportNamedDeclaration { + return new ExportNamedDeclaration(global.generatedEs2panda._UpdateExportNamedDeclaration(global.context, passNode(original), passNode(source), passNodeArray(specifiers), specifiers.length)) + } + static create1ExportNamedDeclaration(decl: AstNode | undefined, specifiers: readonly ExportSpecifier[]): ExportNamedDeclaration { + return new ExportNamedDeclaration(global.generatedEs2panda._CreateExportNamedDeclaration1(global.context, passNode(decl), passNodeArray(specifiers), specifiers.length)) + } + static update1ExportNamedDeclaration(original: ExportNamedDeclaration | undefined, decl: AstNode | undefined, specifiers: readonly ExportSpecifier[]): ExportNamedDeclaration { + return new ExportNamedDeclaration(global.generatedEs2panda._UpdateExportNamedDeclaration1(global.context, passNode(original), passNode(decl), passNodeArray(specifiers), specifiers.length)) + } + static create2ExportNamedDeclaration(decl?: AstNode): ExportNamedDeclaration { + return new ExportNamedDeclaration(global.generatedEs2panda._CreateExportNamedDeclaration2(global.context, passNode(decl))) + } + static update2ExportNamedDeclaration(original?: ExportNamedDeclaration, decl?: AstNode): ExportNamedDeclaration { + return new ExportNamedDeclaration(global.generatedEs2panda._UpdateExportNamedDeclaration2(global.context, passNode(original), passNode(decl))) + } + get decl(): AstNode | undefined { + return unpackNode(global.generatedEs2panda._ExportNamedDeclarationDeclConst(global.context, this.peer)) + } + get source(): StringLiteral | undefined { + return unpackNode(global.generatedEs2panda._ExportNamedDeclarationSourceConst(global.context, this.peer)) + } + get specifiers(): readonly ExportSpecifier[] { + return unpackNodeArray(global.generatedEs2panda._ExportNamedDeclarationSpecifiersConst(global.context, this.peer)) + } +} +export function isExportNamedDeclaration(node: object | undefined): node is ExportNamedDeclaration { + return node instanceof ExportNamedDeclaration +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_EXPORT_NAMED_DECLARATION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_EXPORT_NAMED_DECLARATION, (peer: KNativePointer) => new ExportNamedDeclaration(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ExportSpecifier.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ExportSpecifier.ts new file mode 100644 index 0000000000000000000000000000000000000000..f498a7c218a985b576f5c76d77b782bd0ec0c8d2 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ExportSpecifier.ts @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Identifier } from "./Identifier" +import { Statement } from "./Statement" +export class ExportSpecifier extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 29) + super(pointer) + } + static createExportSpecifier(local?: Identifier, exported?: Identifier): ExportSpecifier { + return new ExportSpecifier(global.generatedEs2panda._CreateExportSpecifier(global.context, passNode(local), passNode(exported))) + } + static updateExportSpecifier(original?: ExportSpecifier, local?: Identifier, exported?: Identifier): ExportSpecifier { + return new ExportSpecifier(global.generatedEs2panda._UpdateExportSpecifier(global.context, passNode(original), passNode(local), passNode(exported))) + } + get local(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._ExportSpecifierLocalConst(global.context, this.peer)) + } + get exported(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._ExportSpecifierExportedConst(global.context, this.peer)) + } +} +export function isExportSpecifier(node: object | undefined): node is ExportSpecifier { + return node instanceof ExportSpecifier +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_EXPORT_SPECIFIER)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_EXPORT_SPECIFIER, (peer: KNativePointer) => new ExportSpecifier(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/Expression.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/Expression.ts new file mode 100644 index 0000000000000000000000000000000000000000..7363a3fdbc1e6bc6b32d71debf6e89765f53491e --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/Expression.ts @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { AnnotatedExpression } from "./AnnotatedExpression" +import { Literal } from "./Literal" +import { TypeNode } from "./TypeNode" +import { TypedAstNode } from "./TypedAstNode" +export class Expression extends TypedAstNode { + constructor(pointer: KNativePointer) { + super(pointer) + } + get isGrouped(): boolean { + return global.generatedEs2panda._ExpressionIsGroupedConst(global.context, this.peer) + } + /** @deprecated */ + setGrouped(): this { + global.generatedEs2panda._ExpressionSetGrouped(global.context, this.peer) + return this + } + get asLiteral(): Literal | undefined { + return unpackNode(global.generatedEs2panda._ExpressionAsLiteral(global.context, this.peer)) + } + get isLiteral(): boolean { + return global.generatedEs2panda._ExpressionIsLiteralConst(global.context, this.peer) + } + get isTypeNode(): boolean { + return global.generatedEs2panda._ExpressionIsTypeNodeConst(global.context, this.peer) + } + get isAnnotatedExpression(): boolean { + return global.generatedEs2panda._ExpressionIsAnnotatedExpressionConst(global.context, this.peer) + } + get asTypeNode(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._ExpressionAsTypeNode(global.context, this.peer)) + } + get asAnnotatedExpression(): AnnotatedExpression | undefined { + return unpackNode(global.generatedEs2panda._ExpressionAsAnnotatedExpression(global.context, this.peer)) + } + get isBrokenExpression(): boolean { + return global.generatedEs2panda._ExpressionIsBrokenExpressionConst(global.context, this.peer) + } + get toString(): string { + return unpackString(global.generatedEs2panda._ExpressionToStringConst(global.context, this.peer)) + } +} +export function isExpression(node: object | undefined): node is Expression { + return node instanceof Expression +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ExpressionStatement.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ExpressionStatement.ts new file mode 100644 index 0000000000000000000000000000000000000000..e714455168c6aac83d74116ccea7e54dab21b7fa --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ExpressionStatement.ts @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { Statement } from "./Statement" +export class ExpressionStatement extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 30) + super(pointer) + } + static createExpressionStatement(expr?: Expression): ExpressionStatement { + return new ExpressionStatement(global.generatedEs2panda._CreateExpressionStatement(global.context, passNode(expr))) + } + static updateExpressionStatement(original?: ExpressionStatement, expr?: Expression): ExpressionStatement { + return new ExpressionStatement(global.generatedEs2panda._UpdateExpressionStatement(global.context, passNode(original), passNode(expr))) + } + get expression(): Expression | undefined { + return unpackNode(global.generatedEs2panda._ExpressionStatementGetExpression(global.context, this.peer)) + } + /** @deprecated */ + setExpression(expr?: Expression): this { + global.generatedEs2panda._ExpressionStatementSetExpression(global.context, this.peer, passNode(expr)) + return this + } +} +export function isExpressionStatement(node: object | undefined): node is ExpressionStatement { + return node instanceof ExpressionStatement +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_EXPRESSION_STATEMENT)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_EXPRESSION_STATEMENT, (peer: KNativePointer) => new ExpressionStatement(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ForInStatement.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ForInStatement.ts new file mode 100644 index 0000000000000000000000000000000000000000..1bf064f59317c76307ae12b064b1d55ef24a5479 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ForInStatement.ts @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { LoopStatement } from "./LoopStatement" +import { Statement } from "./Statement" +export class ForInStatement extends LoopStatement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 31) + super(pointer) + } + static createForInStatement(left?: AstNode, right?: Expression, body?: Statement): ForInStatement { + return new ForInStatement(global.generatedEs2panda._CreateForInStatement(global.context, passNode(left), passNode(right), passNode(body))) + } + static updateForInStatement(original?: ForInStatement, left?: AstNode, right?: Expression, body?: Statement): ForInStatement { + return new ForInStatement(global.generatedEs2panda._UpdateForInStatement(global.context, passNode(original), passNode(left), passNode(right), passNode(body))) + } + get left(): AstNode | undefined { + return unpackNode(global.generatedEs2panda._ForInStatementLeft(global.context, this.peer)) + } + get right(): Expression | undefined { + return unpackNode(global.generatedEs2panda._ForInStatementRight(global.context, this.peer)) + } + get body(): Statement | undefined { + return unpackNode(global.generatedEs2panda._ForInStatementBody(global.context, this.peer)) + } +} +export function isForInStatement(node: object | undefined): node is ForInStatement { + return node instanceof ForInStatement +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_FOR_IN_STATEMENT)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_FOR_IN_STATEMENT, (peer: KNativePointer) => new ForInStatement(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ForOfStatement.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ForOfStatement.ts new file mode 100644 index 0000000000000000000000000000000000000000..c953185094c922466fab60f8c0c269b384948bd8 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ForOfStatement.ts @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { LoopStatement } from "./LoopStatement" +import { Statement } from "./Statement" +export class ForOfStatement extends LoopStatement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 32) + super(pointer) + } + static createForOfStatement(left: AstNode | undefined, right: Expression | undefined, body: Statement | undefined, isAwait: boolean): ForOfStatement { + return new ForOfStatement(global.generatedEs2panda._CreateForOfStatement(global.context, passNode(left), passNode(right), passNode(body), isAwait)) + } + static updateForOfStatement(original: ForOfStatement | undefined, left: AstNode | undefined, right: Expression | undefined, body: Statement | undefined, isAwait: boolean): ForOfStatement { + return new ForOfStatement(global.generatedEs2panda._UpdateForOfStatement(global.context, passNode(original), passNode(left), passNode(right), passNode(body), isAwait)) + } + get left(): AstNode | undefined { + return unpackNode(global.generatedEs2panda._ForOfStatementLeft(global.context, this.peer)) + } + get right(): Expression | undefined { + return unpackNode(global.generatedEs2panda._ForOfStatementRight(global.context, this.peer)) + } + get body(): Statement | undefined { + return unpackNode(global.generatedEs2panda._ForOfStatementBody(global.context, this.peer)) + } + get isAwait(): boolean { + return global.generatedEs2panda._ForOfStatementIsAwaitConst(global.context, this.peer) + } +} +export function isForOfStatement(node: object | undefined): node is ForOfStatement { + return node instanceof ForOfStatement +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_FOR_OF_STATEMENT)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_FOR_OF_STATEMENT, (peer: KNativePointer) => new ForOfStatement(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ForUpdateStatement.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ForUpdateStatement.ts new file mode 100644 index 0000000000000000000000000000000000000000..566393f464701f6d83bf45d2186c33f0d7ac0c46 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ForUpdateStatement.ts @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { LoopStatement } from "./LoopStatement" +import { Statement } from "./Statement" +export class ForUpdateStatement extends LoopStatement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 33) + super(pointer) + } + static createForUpdateStatement(init?: AstNode, test?: Expression, update?: Expression, body?: Statement): ForUpdateStatement { + return new ForUpdateStatement(global.generatedEs2panda._CreateForUpdateStatement(global.context, passNode(init), passNode(test), passNode(update), passNode(body))) + } + get init(): AstNode | undefined { + return unpackNode(global.generatedEs2panda._ForUpdateStatementInit(global.context, this.peer)) + } + get test(): Expression | undefined { + return unpackNode(global.generatedEs2panda._ForUpdateStatementTest(global.context, this.peer)) + } + get update(): Expression | undefined { + return unpackNode(global.generatedEs2panda._ForUpdateStatementUpdateConst(global.context, this.peer)) + } + get body(): Statement | undefined { + return unpackNode(global.generatedEs2panda._ForUpdateStatementBody(global.context, this.peer)) + } +} +export function isForUpdateStatement(node: object | undefined): node is ForUpdateStatement { + return node instanceof ForUpdateStatement +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_FOR_UPDATE_STATEMENT)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_FOR_UPDATE_STATEMENT, (peer: KNativePointer) => new ForUpdateStatement(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/FunctionDecl.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/FunctionDecl.ts new file mode 100644 index 0000000000000000000000000000000000000000..5237e94d088ba56086a246a8a7918eafd0f78612 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/FunctionDecl.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { ScriptFunction } from "./ScriptFunction" +export class FunctionDecl extends ScriptFunction { + constructor(pointer: KNativePointer) { + super(pointer) + } +} +export function isFunctionDecl(node: object | undefined): node is FunctionDecl { + return node instanceof FunctionDecl +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/FunctionDeclaration.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/FunctionDeclaration.ts new file mode 100644 index 0000000000000000000000000000000000000000..0a297d20e5bcf3b190f9b78913453f91817bdf33 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/FunctionDeclaration.ts @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { AnnotationUsage } from "./AnnotationUsage" +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { ScriptFunction } from "./ScriptFunction" +import { Statement } from "./Statement" +export class FunctionDeclaration extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 34) + super(pointer) + } + static createFunctionDeclaration(func: ScriptFunction | undefined, annotations: readonly AnnotationUsage[], isAnonymous: boolean): FunctionDeclaration { + return new FunctionDeclaration(global.generatedEs2panda._CreateFunctionDeclaration(global.context, passNode(func), passNodeArray(annotations), annotations.length, isAnonymous)) + } + static updateFunctionDeclaration(original: FunctionDeclaration | undefined, func: ScriptFunction | undefined, annotations: readonly AnnotationUsage[], isAnonymous: boolean): FunctionDeclaration { + return new FunctionDeclaration(global.generatedEs2panda._UpdateFunctionDeclaration(global.context, passNode(original), passNode(func), passNodeArray(annotations), annotations.length, isAnonymous)) + } + static update1FunctionDeclaration(original: FunctionDeclaration | undefined, func: ScriptFunction | undefined, isAnonymous: boolean): FunctionDeclaration { + return new FunctionDeclaration(global.generatedEs2panda._UpdateFunctionDeclaration1(global.context, passNode(original), passNode(func), isAnonymous)) + } + get function(): ScriptFunction | undefined { + return unpackNode(global.generatedEs2panda._FunctionDeclarationFunction(global.context, this.peer)) + } + get isAnonymous(): boolean { + return global.generatedEs2panda._FunctionDeclarationIsAnonymousConst(global.context, this.peer) + } + get annotations(): readonly AnnotationUsage[] { + return unpackNodeArray(global.generatedEs2panda._FunctionDeclarationAnnotations(global.context, this.peer)) + } + /** @deprecated */ + setAnnotations(annotations: readonly AnnotationUsage[]): this { + global.generatedEs2panda._FunctionDeclarationSetAnnotations(global.context, this.peer, passNodeArray(annotations), annotations.length) + return this + } +} +export function isFunctionDeclaration(node: object | undefined): node is FunctionDeclaration { + return node instanceof FunctionDeclaration +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_FUNCTION_DECLARATION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_FUNCTION_DECLARATION, (peer: KNativePointer) => new FunctionDeclaration(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/FunctionExpression.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/FunctionExpression.ts new file mode 100644 index 0000000000000000000000000000000000000000..62b9e86f67b9e26b727f4dc0609f8d0cc5add73d --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/FunctionExpression.ts @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { Identifier } from "./Identifier" +import { ScriptFunction } from "./ScriptFunction" +export class FunctionExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 35) + super(pointer) + } + static create1FunctionExpression(namedExpr?: Identifier, func?: ScriptFunction): FunctionExpression { + return new FunctionExpression(global.generatedEs2panda._CreateFunctionExpression1(global.context, passNode(namedExpr), passNode(func))) + } + static updateFunctionExpression(original?: FunctionExpression, func?: ScriptFunction): FunctionExpression { + return new FunctionExpression(global.generatedEs2panda._UpdateFunctionExpression(global.context, passNode(original), passNode(func))) + } + static update1FunctionExpression(original?: FunctionExpression, namedExpr?: Identifier, func?: ScriptFunction): FunctionExpression { + return new FunctionExpression(global.generatedEs2panda._UpdateFunctionExpression1(global.context, passNode(original), passNode(namedExpr), passNode(func))) + } + get function(): ScriptFunction | undefined { + return unpackNode(global.generatedEs2panda._FunctionExpressionFunction(global.context, this.peer)) + } + get isAnonymous(): boolean { + return global.generatedEs2panda._FunctionExpressionIsAnonymousConst(global.context, this.peer) + } + get id(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._FunctionExpressionId(global.context, this.peer)) + } +} +export function isFunctionExpression(node: object | undefined): node is FunctionExpression { + return node instanceof FunctionExpression +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_FUNCTION_EXPRESSION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_FUNCTION_EXPRESSION, (peer: KNativePointer) => new FunctionExpression(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/FunctionSignature.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/FunctionSignature.ts new file mode 100644 index 0000000000000000000000000000000000000000..d95836e46faccae0f85652a274aec395d33baa67 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/FunctionSignature.ts @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +import { TSTypeParameterDeclaration } from "./TSTypeParameterDeclaration" +import { TypeNode } from "./TypeNode" +export class FunctionSignature extends ArktsObject { + constructor(pointer: KNativePointer) { + super(pointer) + } + static createFunctionSignature(typeParams: TSTypeParameterDeclaration | undefined, params: readonly Expression[], returnTypeAnnotation: TypeNode | undefined, hasReceiver: boolean): FunctionSignature { + return new FunctionSignature(global.generatedEs2panda._CreateFunctionSignature(global.context, passNode(typeParams), passNodeArray(params), params.length, passNode(returnTypeAnnotation), hasReceiver)) + } + get params(): readonly Expression[] { + return unpackNodeArray(global.generatedEs2panda._FunctionSignatureParams(global.context, this.peer)) + } + get typeParams(): TSTypeParameterDeclaration | undefined { + return unpackNode(global.generatedEs2panda._FunctionSignatureTypeParams(global.context, this.peer)) + } + get returnType(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._FunctionSignatureReturnType(global.context, this.peer)) + } + /** @deprecated */ + setReturnType(type?: TypeNode): this { + global.generatedEs2panda._FunctionSignatureSetReturnType(global.context, this.peer, passNode(type)) + return this + } + get clone(): FunctionSignature | undefined { + return new FunctionSignature(global.generatedEs2panda._FunctionSignatureClone(global.context, this.peer)) + } + get hasReceiver(): boolean { + return global.generatedEs2panda._FunctionSignatureHasReceiverConst(global.context, this.peer) + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/IRNode.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/IRNode.ts new file mode 100644 index 0000000000000000000000000000000000000000..42bbda33d02431c8afefcca0b4c2054b8703d09d --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/IRNode.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +export class IRNode extends ArktsObject { + constructor(pointer: KNativePointer) { + super(pointer) + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/Identifier.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/Identifier.ts new file mode 100644 index 0000000000000000000000000000000000000000..33053f5709f5924fa415e94e9b50ae9ac8c99634 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/Identifier.ts @@ -0,0 +1,154 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { AnnotatedExpression } from "./AnnotatedExpression" +import { Decorator } from "./Decorator" +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { TypeNode } from "./TypeNode" +import { ValidationInfo } from "./ValidationInfo" +export class Identifier extends AnnotatedExpression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 36) + super(pointer) + } + static create2Identifier(name: string, typeAnnotation?: TypeNode): Identifier { + return new Identifier(global.generatedEs2panda._CreateIdentifier2(global.context, name, passNode(typeAnnotation))) + } + static updateIdentifier(original?: Identifier): Identifier { + return new Identifier(global.generatedEs2panda._UpdateIdentifier(global.context, passNode(original))) + } + static update1Identifier(original: Identifier | undefined, name: string): Identifier { + return new Identifier(global.generatedEs2panda._UpdateIdentifier1(global.context, passNode(original), name)) + } + static update2Identifier(original: Identifier | undefined, name: string, typeAnnotation?: TypeNode): Identifier { + return new Identifier(global.generatedEs2panda._UpdateIdentifier2(global.context, passNode(original), name, passNode(typeAnnotation))) + } + get name(): string { + return unpackString(global.generatedEs2panda._IdentifierName(global.context, this.peer)) + } + /** @deprecated */ + setName(newName: string): this { + global.generatedEs2panda._IdentifierSetName(global.context, this.peer, newName) + return this + } + get decorators(): readonly Decorator[] { + return unpackNodeArray(global.generatedEs2panda._IdentifierDecoratorsConst(global.context, this.peer)) + } + get isErrorPlaceHolder(): boolean { + return global.generatedEs2panda._IdentifierIsErrorPlaceHolderConst(global.context, this.peer) + } + get isOptional(): boolean { + return global.generatedEs2panda._IdentifierIsOptionalConst(global.context, this.peer) + } + /** @deprecated */ + setOptional(optional_arg: boolean): this { + global.generatedEs2panda._IdentifierSetOptional(global.context, this.peer, optional_arg) + return this + } + get isReference(): boolean { + return global.generatedEs2panda._IdentifierIsReferenceConst(global.context, this.peer) + } + get isTdz(): boolean { + return global.generatedEs2panda._IdentifierIsTdzConst(global.context, this.peer) + } + /** @deprecated */ + setTdz(): this { + global.generatedEs2panda._IdentifierSetTdz(global.context, this.peer) + return this + } + /** @deprecated */ + setAccessor(): this { + global.generatedEs2panda._IdentifierSetAccessor(global.context, this.peer) + return this + } + get isAccessor(): boolean { + return global.generatedEs2panda._IdentifierIsAccessorConst(global.context, this.peer) + } + /** @deprecated */ + setMutator(): this { + global.generatedEs2panda._IdentifierSetMutator(global.context, this.peer) + return this + } + get isMutator(): boolean { + return global.generatedEs2panda._IdentifierIsMutatorConst(global.context, this.peer) + } + get isReceiver(): boolean { + return global.generatedEs2panda._IdentifierIsReceiverConst(global.context, this.peer) + } + get isPrivateIdent(): boolean { + return global.generatedEs2panda._IdentifierIsPrivateIdentConst(global.context, this.peer) + } + /** @deprecated */ + setPrivate(isPrivate: boolean): this { + global.generatedEs2panda._IdentifierSetPrivate(global.context, this.peer, isPrivate) + return this + } + get isIgnoreBox(): boolean { + return global.generatedEs2panda._IdentifierIsIgnoreBoxConst(global.context, this.peer) + } + /** @deprecated */ + setIgnoreBox(): this { + global.generatedEs2panda._IdentifierSetIgnoreBox(global.context, this.peer) + return this + } + get isAnnotationDecl(): boolean { + return global.generatedEs2panda._IdentifierIsAnnotationDeclConst(global.context, this.peer) + } + /** @deprecated */ + setAnnotationDecl(): this { + global.generatedEs2panda._IdentifierSetAnnotationDecl(global.context, this.peer) + return this + } + get isAnnotationUsage(): boolean { + return global.generatedEs2panda._IdentifierIsAnnotationUsageConst(global.context, this.peer) + } + /** @deprecated */ + setAnnotationUsage(): this { + global.generatedEs2panda._IdentifierSetAnnotationUsage(global.context, this.peer) + return this + } + get validateExpression(): ValidationInfo | undefined { + return new ValidationInfo(global.generatedEs2panda._IdentifierValidateExpression(global.context, this.peer)) + } + get typeAnnotation(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._IdentifierTypeAnnotationConst(global.context, this.peer)) + } + /** @deprecated */ + setTsTypeAnnotation(typeAnnotation?: TypeNode): this { + global.generatedEs2panda._IdentifierSetTsTypeAnnotation(global.context, this.peer, passNode(typeAnnotation)) + return this + } +} +export function isIdentifier(node: object | undefined): node is Identifier { + return node instanceof Identifier +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_IDENTIFIER)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_IDENTIFIER, (peer: KNativePointer) => new Identifier(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/IfStatement.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/IfStatement.ts new file mode 100644 index 0000000000000000000000000000000000000000..5aa7c2869590fb38736593da43255d9a7dbbb24c --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/IfStatement.ts @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { Statement } from "./Statement" +export class IfStatement extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 38) + super(pointer) + } + static createIfStatement(test?: Expression, consequent?: Statement, alternate?: Statement): IfStatement { + return new IfStatement(global.generatedEs2panda._CreateIfStatement(global.context, passNode(test), passNode(consequent), passNode(alternate))) + } + static updateIfStatement(original?: IfStatement, test?: Expression, consequent?: Statement, alternate?: Statement): IfStatement { + return new IfStatement(global.generatedEs2panda._UpdateIfStatement(global.context, passNode(original), passNode(test), passNode(consequent), passNode(alternate))) + } + get test(): Expression | undefined { + return unpackNode(global.generatedEs2panda._IfStatementTest(global.context, this.peer)) + } + get consequent(): Statement | undefined { + return unpackNode(global.generatedEs2panda._IfStatementConsequent(global.context, this.peer)) + } + get alternate(): Statement | undefined { + return unpackNode(global.generatedEs2panda._IfStatementAlternate(global.context, this.peer)) + } + /** @deprecated */ + setAlternate(alternate?: Statement): this { + global.generatedEs2panda._IfStatementSetAlternate(global.context, this.peer, passNode(alternate)) + return this + } +} +export function isIfStatement(node: object | undefined): node is IfStatement { + return node instanceof IfStatement +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_IF_STATEMENT)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_IF_STATEMENT, (peer: KNativePointer) => new IfStatement(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ImportDeclaration.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ImportDeclaration.ts new file mode 100644 index 0000000000000000000000000000000000000000..c8a19a90cb960de9edcb874e0465bde81b18c9ff --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ImportDeclaration.ts @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Es2pandaImportKinds } from "./../Es2pandaEnums" +import { Statement } from "./Statement" +import { StringLiteral } from "./StringLiteral" +export class ImportDeclaration extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 39) + super(pointer) + } + static createImportDeclaration(source: StringLiteral | undefined, specifiers: readonly AstNode[], importKinds: Es2pandaImportKinds): ImportDeclaration { + return new ImportDeclaration(global.generatedEs2panda._CreateImportDeclaration(global.context, passNode(source), passNodeArray(specifiers), specifiers.length, importKinds)) + } + static updateImportDeclaration(original: ImportDeclaration | undefined, source: StringLiteral | undefined, specifiers: readonly AstNode[], importKinds: Es2pandaImportKinds): ImportDeclaration { + return new ImportDeclaration(global.generatedEs2panda._UpdateImportDeclaration(global.context, passNode(original), passNode(source), passNodeArray(specifiers), specifiers.length, importKinds)) + } + get source(): StringLiteral | undefined { + return unpackNode(global.generatedEs2panda._ImportDeclarationSource(global.context, this.peer)) + } + get specifiers(): readonly AstNode[] { + return unpackNodeArray(global.generatedEs2panda._ImportDeclarationSpecifiers(global.context, this.peer)) + } + get isTypeKind(): boolean { + return global.generatedEs2panda._ImportDeclarationIsTypeKindConst(global.context, this.peer) + } +} +export function isImportDeclaration(node: object | undefined): node is ImportDeclaration { + return node instanceof ImportDeclaration +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_IMPORT_DECLARATION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_IMPORT_DECLARATION, (peer: KNativePointer) => new ImportDeclaration(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ImportDefaultSpecifier.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ImportDefaultSpecifier.ts new file mode 100644 index 0000000000000000000000000000000000000000..edffc4852d0913434835e64bddd3d37828db589e --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ImportDefaultSpecifier.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Identifier } from "./Identifier" +import { Statement } from "./Statement" +export class ImportDefaultSpecifier extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 41) + super(pointer) + } + static createImportDefaultSpecifier(local?: Identifier): ImportDefaultSpecifier { + return new ImportDefaultSpecifier(global.generatedEs2panda._CreateImportDefaultSpecifier(global.context, passNode(local))) + } + static updateImportDefaultSpecifier(original?: ImportDefaultSpecifier, local?: Identifier): ImportDefaultSpecifier { + return new ImportDefaultSpecifier(global.generatedEs2panda._UpdateImportDefaultSpecifier(global.context, passNode(original), passNode(local))) + } + get local(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._ImportDefaultSpecifierLocal(global.context, this.peer)) + } +} +export function isImportDefaultSpecifier(node: object | undefined): node is ImportDefaultSpecifier { + return node instanceof ImportDefaultSpecifier +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_IMPORT_DEFAULT_SPECIFIER)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_IMPORT_DEFAULT_SPECIFIER, (peer: KNativePointer) => new ImportDefaultSpecifier(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ImportExpression.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ImportExpression.ts new file mode 100644 index 0000000000000000000000000000000000000000..91ce65e2517cee57b63c6983055d7ac221ab6a8b --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ImportExpression.ts @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +export class ImportExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 40) + super(pointer) + } + static createImportExpression(source?: Expression): ImportExpression { + return new ImportExpression(global.generatedEs2panda._CreateImportExpression(global.context, passNode(source))) + } + static updateImportExpression(original?: ImportExpression, source?: Expression): ImportExpression { + return new ImportExpression(global.generatedEs2panda._UpdateImportExpression(global.context, passNode(original), passNode(source))) + } + get source(): Expression | undefined { + return unpackNode(global.generatedEs2panda._ImportExpressionSource(global.context, this.peer)) + } +} +export function isImportExpression(node: object | undefined): node is ImportExpression { + return node instanceof ImportExpression +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_IMPORT_EXPRESSION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_IMPORT_EXPRESSION, (peer: KNativePointer) => new ImportExpression(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ImportNamespaceSpecifier.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ImportNamespaceSpecifier.ts new file mode 100644 index 0000000000000000000000000000000000000000..a1691b6ad66be39bb9a1afd32a843b83d5347495 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ImportNamespaceSpecifier.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Identifier } from "./Identifier" +import { Statement } from "./Statement" +export class ImportNamespaceSpecifier extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 42) + super(pointer) + } + static createImportNamespaceSpecifier(local?: Identifier): ImportNamespaceSpecifier { + return new ImportNamespaceSpecifier(global.generatedEs2panda._CreateImportNamespaceSpecifier(global.context, passNode(local))) + } + static updateImportNamespaceSpecifier(original?: ImportNamespaceSpecifier, local?: Identifier): ImportNamespaceSpecifier { + return new ImportNamespaceSpecifier(global.generatedEs2panda._UpdateImportNamespaceSpecifier(global.context, passNode(original), passNode(local))) + } + get local(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._ImportNamespaceSpecifierLocal(global.context, this.peer)) + } +} +export function isImportNamespaceSpecifier(node: object | undefined): node is ImportNamespaceSpecifier { + return node instanceof ImportNamespaceSpecifier +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_IMPORT_NAMESPACE_SPECIFIER)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_IMPORT_NAMESPACE_SPECIFIER, (peer: KNativePointer) => new ImportNamespaceSpecifier(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ImportSource.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ImportSource.ts new file mode 100644 index 0000000000000000000000000000000000000000..daa8ad1f79676095d81812c69a3213e6a5d8e0be --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ImportSource.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +export class ImportSource extends ArktsObject { + constructor(pointer: KNativePointer) { + super(pointer) + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ImportSpecifier.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ImportSpecifier.ts new file mode 100644 index 0000000000000000000000000000000000000000..86c97288d07e44bf483fbd1fd77a8b4c0aba320f --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ImportSpecifier.ts @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Identifier } from "./Identifier" +import { Statement } from "./Statement" +export class ImportSpecifier extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 43) + super(pointer) + } + static createImportSpecifier(imported?: Identifier, local?: Identifier): ImportSpecifier { + return new ImportSpecifier(global.generatedEs2panda._CreateImportSpecifier(global.context, passNode(imported), passNode(local))) + } + static updateImportSpecifier(original?: ImportSpecifier, imported?: Identifier, local?: Identifier): ImportSpecifier { + return new ImportSpecifier(global.generatedEs2panda._UpdateImportSpecifier(global.context, passNode(original), passNode(imported), passNode(local))) + } + get imported(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._ImportSpecifierImported(global.context, this.peer)) + } + get local(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._ImportSpecifierLocal(global.context, this.peer)) + } + get isRemovable(): boolean { + return global.generatedEs2panda._ImportSpecifierIsRemovableConst(global.context, this.peer) + } + /** @deprecated */ + setRemovable(isRemovable: boolean): this { + global.generatedEs2panda._ImportSpecifierSetRemovable(global.context, this.peer, isRemovable) + return this + } +} +export function isImportSpecifier(node: object | undefined): node is ImportSpecifier { + return node instanceof ImportSpecifier +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_IMPORT_SPECIFIER)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_IMPORT_SPECIFIER, (peer: KNativePointer) => new ImportSpecifier(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/IndexInfo.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/IndexInfo.ts new file mode 100644 index 0000000000000000000000000000000000000000..15684de6e219e37b466f771d54826755f2daee01 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/IndexInfo.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +export class IndexInfo extends ArktsObject { + constructor(pointer: KNativePointer) { + super(pointer) + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/InterfaceDecl.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/InterfaceDecl.ts new file mode 100644 index 0000000000000000000000000000000000000000..f696de2dec7e15e3b1da0e782f9ba2eabaee1a76 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/InterfaceDecl.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TSInterfaceDeclaration } from "./TSInterfaceDeclaration" +export class InterfaceDecl extends TSInterfaceDeclaration { + constructor(pointer: KNativePointer) { + super(pointer) + } +} +export function isInterfaceDecl(node: object | undefined): node is InterfaceDecl { + return node instanceof InterfaceDecl +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/LabelPair.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/LabelPair.ts new file mode 100644 index 0000000000000000000000000000000000000000..6474aa7408e6932552009173bc0b7fa1c250b867 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/LabelPair.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +export class LabelPair extends ArktsObject { + constructor(pointer: KNativePointer) { + super(pointer) + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/LabelledStatement.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/LabelledStatement.ts new file mode 100644 index 0000000000000000000000000000000000000000..54a432e69273aad7447a47d5db9a85af07196c1c --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/LabelledStatement.ts @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Identifier } from "./Identifier" +import { Statement } from "./Statement" +export class LabelledStatement extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 44) + super(pointer) + } + static createLabelledStatement(ident?: Identifier, body?: Statement): LabelledStatement { + return new LabelledStatement(global.generatedEs2panda._CreateLabelledStatement(global.context, passNode(ident), passNode(body))) + } + static updateLabelledStatement(original?: LabelledStatement, ident?: Identifier, body?: Statement): LabelledStatement { + return new LabelledStatement(global.generatedEs2panda._UpdateLabelledStatement(global.context, passNode(original), passNode(ident), passNode(body))) + } + get body(): Statement | undefined { + return unpackNode(global.generatedEs2panda._LabelledStatementBody(global.context, this.peer)) + } + get ident(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._LabelledStatementIdent(global.context, this.peer)) + } + get referencedStatement(): AstNode | undefined { + return unpackNode(global.generatedEs2panda._LabelledStatementGetReferencedStatementConst(global.context, this.peer)) + } +} +export function isLabelledStatement(node: object | undefined): node is LabelledStatement { + return node instanceof LabelledStatement +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_LABELLED_STATEMENT)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_LABELLED_STATEMENT, (peer: KNativePointer) => new LabelledStatement(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/Literal.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/Literal.ts new file mode 100644 index 0000000000000000000000000000000000000000..3d8506a6f0f10fc7413e259534b61c2d3d3263af --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/Literal.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +export class Literal extends Expression { + constructor(pointer: KNativePointer) { + super(pointer) + } +} +export function isLiteral(node: object | undefined): node is Literal { + return node instanceof Literal +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/LoopStatement.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/LoopStatement.ts new file mode 100644 index 0000000000000000000000000000000000000000..35166569f1f57c1244887b8c7a6241a00ea8aee7 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/LoopStatement.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Statement } from "./Statement" +export class LoopStatement extends Statement { + constructor(pointer: KNativePointer) { + super(pointer) + } +} +export function isLoopStatement(node: object | undefined): node is LoopStatement { + return node instanceof LoopStatement +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/MaybeOptionalExpression.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/MaybeOptionalExpression.ts new file mode 100644 index 0000000000000000000000000000000000000000..4d7e19055d6d242b5be7bf4134825ba10a465f26 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/MaybeOptionalExpression.ts @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +export class MaybeOptionalExpression extends Expression { + constructor(pointer: KNativePointer) { + super(pointer) + } + get isOptional(): boolean { + return global.generatedEs2panda._MaybeOptionalExpressionIsOptionalConst(global.context, this.peer) + } + /** @deprecated */ + clearOptional(): this { + global.generatedEs2panda._MaybeOptionalExpressionClearOptional(global.context, this.peer) + return this + } +} +export function isMaybeOptionalExpression(node: object | undefined): node is MaybeOptionalExpression { + return node instanceof MaybeOptionalExpression +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/MemberExpression.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/MemberExpression.ts new file mode 100644 index 0000000000000000000000000000000000000000..623ceffc222b7c03d077e3544ff84d676ba36064 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/MemberExpression.ts @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { CodeGen } from "./CodeGen" +import { ETSFunctionType } from "./ETSFunctionType" +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Es2pandaMemberExpressionKind } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { MaybeOptionalExpression } from "./MaybeOptionalExpression" +import { VReg } from "./VReg" +export class MemberExpression extends MaybeOptionalExpression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 45) + super(pointer) + } + static createMemberExpression(object_arg: Expression | undefined, property: Expression | undefined, kind: Es2pandaMemberExpressionKind, computed: boolean, optional_arg: boolean): MemberExpression { + return new MemberExpression(global.generatedEs2panda._CreateMemberExpression(global.context, passNode(object_arg), passNode(property), kind, computed, optional_arg)) + } + static updateMemberExpression(original: MemberExpression | undefined, object_arg: Expression | undefined, property: Expression | undefined, kind: Es2pandaMemberExpressionKind, computed: boolean, optional_arg: boolean): MemberExpression { + return new MemberExpression(global.generatedEs2panda._UpdateMemberExpression(global.context, passNode(original), passNode(object_arg), passNode(property), kind, computed, optional_arg)) + } + get object(): Expression | undefined { + return unpackNode(global.generatedEs2panda._MemberExpressionObject(global.context, this.peer)) + } + /** @deprecated */ + setObject(object_arg?: Expression): this { + global.generatedEs2panda._MemberExpressionSetObject(global.context, this.peer, passNode(object_arg)) + return this + } + /** @deprecated */ + setProperty(prop?: Expression): this { + global.generatedEs2panda._MemberExpressionSetProperty(global.context, this.peer, passNode(prop)) + return this + } + get property(): Expression | undefined { + return unpackNode(global.generatedEs2panda._MemberExpressionProperty(global.context, this.peer)) + } + get isComputed(): boolean { + return global.generatedEs2panda._MemberExpressionIsComputedConst(global.context, this.peer) + } + get kind(): Es2pandaMemberExpressionKind { + return global.generatedEs2panda._MemberExpressionKindConst(global.context, this.peer) + } + /** @deprecated */ + addMemberKind(kind: Es2pandaMemberExpressionKind): this { + global.generatedEs2panda._MemberExpressionAddMemberKind(global.context, this.peer, kind) + return this + } + /** @deprecated */ + removeMemberKind(kind: Es2pandaMemberExpressionKind): this { + global.generatedEs2panda._MemberExpressionRemoveMemberKind(global.context, this.peer, kind) + return this + } + get extensionAccessorType(): ETSFunctionType | undefined { + return unpackNode(global.generatedEs2panda._MemberExpressionExtensionAccessorTypeConst(global.context, this.peer)) + } + get isIgnoreBox(): boolean { + return global.generatedEs2panda._MemberExpressionIsIgnoreBoxConst(global.context, this.peer) + } + /** @deprecated */ + setIgnoreBox(): this { + global.generatedEs2panda._MemberExpressionSetIgnoreBox(global.context, this.peer) + return this + } + get isPrivateReference(): boolean { + return global.generatedEs2panda._MemberExpressionIsPrivateReferenceConst(global.context, this.peer) + } + /** @deprecated */ + compileToReg(pg?: CodeGen, objReg?: VReg): this { + global.generatedEs2panda._MemberExpressionCompileToRegConst(global.context, this.peer, passNode(pg), passNode(objReg)) + return this + } + /** @deprecated */ + compileToRegs(pg?: CodeGen, object_arg?: VReg, property?: VReg): this { + global.generatedEs2panda._MemberExpressionCompileToRegsConst(global.context, this.peer, passNode(pg), passNode(object_arg), passNode(property)) + return this + } +} +export function isMemberExpression(node: object | undefined): node is MemberExpression { + return node instanceof MemberExpression +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_MEMBER_EXPRESSION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_MEMBER_EXPRESSION, (peer: KNativePointer) => new MemberExpression(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/MetaProperty.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/MetaProperty.ts new file mode 100644 index 0000000000000000000000000000000000000000..506287739f43d9f73da0ddfb4dabe4175a0a5559 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/MetaProperty.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Es2pandaMetaPropertyKind } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +export class MetaProperty extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 46) + super(pointer) + } + static createMetaProperty(kind: Es2pandaMetaPropertyKind): MetaProperty { + return new MetaProperty(global.generatedEs2panda._CreateMetaProperty(global.context, kind)) + } + static updateMetaProperty(original: MetaProperty | undefined, kind: Es2pandaMetaPropertyKind): MetaProperty { + return new MetaProperty(global.generatedEs2panda._UpdateMetaProperty(global.context, passNode(original), kind)) + } + get kind(): Es2pandaMetaPropertyKind { + return global.generatedEs2panda._MetaPropertyKindConst(global.context, this.peer) + } +} +export function isMetaProperty(node: object | undefined): node is MetaProperty { + return node instanceof MetaProperty +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_META_PROPERTY_EXPRESSION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_META_PROPERTY_EXPRESSION, (peer: KNativePointer) => new MetaProperty(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/MethodDefinition.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/MethodDefinition.ts new file mode 100644 index 0000000000000000000000000000000000000000..e2c283f34867307eeb78ae037ad855c812a62818 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/MethodDefinition.ts @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { ClassElement } from "./ClassElement" +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Es2pandaMethodDefinitionKind } from "./../Es2pandaEnums" +import { Es2pandaModifierFlags } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { ScriptFunction } from "./ScriptFunction" +export class MethodDefinition extends ClassElement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 47) + super(pointer) + } + static createMethodDefinition(kind: Es2pandaMethodDefinitionKind, key: Expression | undefined, value: Expression | undefined, modifiers: Es2pandaModifierFlags, isComputed: boolean): MethodDefinition { + return new MethodDefinition(global.generatedEs2panda._CreateMethodDefinition(global.context, kind, passNode(key), passNode(value), modifiers, isComputed)) + } + static updateMethodDefinition(original: MethodDefinition | undefined, kind: Es2pandaMethodDefinitionKind, key: Expression | undefined, value: Expression | undefined, modifiers: Es2pandaModifierFlags, isComputed: boolean): MethodDefinition { + return new MethodDefinition(global.generatedEs2panda._UpdateMethodDefinition(global.context, passNode(original), kind, passNode(key), passNode(value), modifiers, isComputed)) + } + get kind(): Es2pandaMethodDefinitionKind { + return global.generatedEs2panda._MethodDefinitionKindConst(global.context, this.peer) + } + get isConstructor(): boolean { + return global.generatedEs2panda._MethodDefinitionIsConstructorConst(global.context, this.peer) + } + get isMethod(): boolean { + return global.generatedEs2panda._MethodDefinitionIsMethodConst(global.context, this.peer) + } + get isExtensionMethod(): boolean { + return global.generatedEs2panda._MethodDefinitionIsExtensionMethodConst(global.context, this.peer) + } + get isGetter(): boolean { + return global.generatedEs2panda._MethodDefinitionIsGetterConst(global.context, this.peer) + } + get isSetter(): boolean { + return global.generatedEs2panda._MethodDefinitionIsSetterConst(global.context, this.peer) + } + get isDefaultAccessModifier(): boolean { + return global.generatedEs2panda._MethodDefinitionIsDefaultAccessModifierConst(global.context, this.peer) + } + /** @deprecated */ + setDefaultAccessModifier(isDefault: boolean): this { + global.generatedEs2panda._MethodDefinitionSetDefaultAccessModifier(global.context, this.peer, isDefault) + return this + } + get overloads(): readonly MethodDefinition[] { + return unpackNodeArray(global.generatedEs2panda._MethodDefinitionOverloadsConst(global.context, this.peer)) + } + get baseOverloadMethod(): MethodDefinition | undefined { + return unpackNode(global.generatedEs2panda._MethodDefinitionBaseOverloadMethod(global.context, this.peer)) + } + get asyncPairMethod(): MethodDefinition | undefined { + return unpackNode(global.generatedEs2panda._MethodDefinitionAsyncPairMethod(global.context, this.peer)) + } + /** @deprecated */ + setOverloads(overloads: readonly MethodDefinition[]): this { + global.generatedEs2panda._MethodDefinitionSetOverloads(global.context, this.peer, passNodeArray(overloads), overloads.length) + return this + } + /** @deprecated */ + clearOverloads(): this { + global.generatedEs2panda._MethodDefinitionClearOverloads(global.context, this.peer) + return this + } + /** @deprecated */ + addOverload(overload?: MethodDefinition): this { + global.generatedEs2panda._MethodDefinitionAddOverload(global.context, this.peer, passNode(overload)) + return this + } + /** @deprecated */ + setBaseOverloadMethod(baseOverloadMethod?: MethodDefinition): this { + global.generatedEs2panda._MethodDefinitionSetBaseOverloadMethod(global.context, this.peer, passNode(baseOverloadMethod)) + return this + } + /** @deprecated */ + setAsyncPairMethod(method?: MethodDefinition): this { + global.generatedEs2panda._MethodDefinitionSetAsyncPairMethod(global.context, this.peer, passNode(method)) + return this + } + get function(): ScriptFunction | undefined { + return unpackNode(global.generatedEs2panda._MethodDefinitionFunction(global.context, this.peer)) + } + /** @deprecated */ + initializeOverloadInfo(): this { + global.generatedEs2panda._MethodDefinitionInitializeOverloadInfo(global.context, this.peer) + return this + } +} +export function isMethodDefinition(node: object | undefined): node is MethodDefinition { + return node instanceof MethodDefinition +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_METHOD_DEFINITION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_METHOD_DEFINITION, (peer: KNativePointer) => new MethodDefinition(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/NamedType.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/NamedType.ts new file mode 100644 index 0000000000000000000000000000000000000000..2f962c1867f0cf1a743c5886deb78570bf8dbe72 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/NamedType.ts @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Identifier } from "./Identifier" +import { TSTypeParameterInstantiation } from "./TSTypeParameterInstantiation" +import { TypeNode } from "./TypeNode" +export class NamedType extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 48) + super(pointer) + } + static createNamedType(name?: Identifier): NamedType { + return new NamedType(global.generatedEs2panda._CreateNamedType(global.context, passNode(name))) + } + static updateNamedType(original?: NamedType, name?: Identifier): NamedType { + return new NamedType(global.generatedEs2panda._UpdateNamedType(global.context, passNode(original), passNode(name))) + } + get name(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._NamedTypeNameConst(global.context, this.peer)) + } + get typeParams(): TSTypeParameterInstantiation | undefined { + return unpackNode(global.generatedEs2panda._NamedTypeTypeParamsConst(global.context, this.peer)) + } + get isNullable(): boolean { + return global.generatedEs2panda._NamedTypeIsNullableConst(global.context, this.peer) + } + /** @deprecated */ + setNullable(nullable: boolean): this { + global.generatedEs2panda._NamedTypeSetNullable(global.context, this.peer, nullable) + return this + } + /** @deprecated */ + setNext(next?: NamedType): this { + global.generatedEs2panda._NamedTypeSetNext(global.context, this.peer, passNode(next)) + return this + } + /** @deprecated */ + setTypeParams(typeParams?: TSTypeParameterInstantiation): this { + global.generatedEs2panda._NamedTypeSetTypeParams(global.context, this.peer, passNode(typeParams)) + return this + } +} +export function isNamedType(node: object | undefined): node is NamedType { + return node instanceof NamedType +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_NAMED_TYPE)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_NAMED_TYPE, (peer: KNativePointer) => new NamedType(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/NewExpression.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/NewExpression.ts new file mode 100644 index 0000000000000000000000000000000000000000..0eab3ae18ef12d24e183d34630fdaa28704ea99b --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/NewExpression.ts @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +export class NewExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 49) + super(pointer) + } + static createNewExpression(callee: Expression | undefined, _arguments: readonly Expression[]): NewExpression { + return new NewExpression(global.generatedEs2panda._CreateNewExpression(global.context, passNode(callee), passNodeArray(_arguments), _arguments.length)) + } + static updateNewExpression(original: NewExpression | undefined, callee: Expression | undefined, _arguments: readonly Expression[]): NewExpression { + return new NewExpression(global.generatedEs2panda._UpdateNewExpression(global.context, passNode(original), passNode(callee), passNodeArray(_arguments), _arguments.length)) + } + get callee(): Expression | undefined { + return unpackNode(global.generatedEs2panda._NewExpressionCalleeConst(global.context, this.peer)) + } + get arguments(): readonly Expression[] { + return unpackNodeArray(global.generatedEs2panda._NewExpressionArgumentsConst(global.context, this.peer)) + } +} +export function isNewExpression(node: object | undefined): node is NewExpression { + return node instanceof NewExpression +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_NEW_EXPRESSION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_NEW_EXPRESSION, (peer: KNativePointer) => new NewExpression(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/NullLiteral.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/NullLiteral.ts new file mode 100644 index 0000000000000000000000000000000000000000..4d82ae3a881880cbdb5552fe5d75c3e34c8dc45a --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/NullLiteral.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Literal } from "./Literal" +export class NullLiteral extends Literal { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 50) + super(pointer) + } + static createNullLiteral(): NullLiteral { + return new NullLiteral(global.generatedEs2panda._CreateNullLiteral(global.context)) + } + static updateNullLiteral(original?: NullLiteral): NullLiteral { + return new NullLiteral(global.generatedEs2panda._UpdateNullLiteral(global.context, passNode(original))) + } +} +export function isNullLiteral(node: object | undefined): node is NullLiteral { + return node instanceof NullLiteral +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_NULL_LITERAL)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_NULL_LITERAL, (peer: KNativePointer) => new NullLiteral(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/NumberLiteral.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/NumberLiteral.ts new file mode 100644 index 0000000000000000000000000000000000000000..ff1adcf3247bc16559703d68a1694edda10389b0 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/NumberLiteral.ts @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Literal } from "./Literal" +export class NumberLiteral extends Literal { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 52) + super(pointer) + } + static createNumberLiteral(value: number): AstNode { + return new NumberLiteral(global.generatedEs2panda._CreateNumberLiteral(global.context, value)) + } + get str(): string { + return unpackString(global.generatedEs2panda._NumberLiteralStrConst(global.context, this.peer)) + } + static updateNumberLiteral(original: AstNode | undefined, value: number): AstNode { + return new NumberLiteral(global.generatedEs2panda._UpdateNumberLiteral(global.context, passNode(original), value)) + } + static update1NumberLiteral(original: AstNode | undefined, value: number): AstNode { + return new NumberLiteral(global.generatedEs2panda._UpdateNumberLiteral1(global.context, passNode(original), value)) + } + static update2NumberLiteral(original: AstNode | undefined, value: number): AstNode { + return new NumberLiteral(global.generatedEs2panda._UpdateNumberLiteral2(global.context, passNode(original), value)) + } + static update3NumberLiteral(original: AstNode | undefined, value: number): AstNode { + return new NumberLiteral(global.generatedEs2panda._UpdateNumberLiteral3(global.context, passNode(original), value)) + } +} +export function isNumberLiteral(node: object | undefined): node is NumberLiteral { + return node instanceof NumberLiteral +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_NUMBER_LITERAL)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_NUMBER_LITERAL, (peer: KNativePointer) => new NumberLiteral(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ObjectDescriptor.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ObjectDescriptor.ts new file mode 100644 index 0000000000000000000000000000000000000000..5faf02ea712bb72cee81e58b8f479f7c36373337 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ObjectDescriptor.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +export class ObjectDescriptor extends ArktsObject { + constructor(pointer: KNativePointer) { + super(pointer) + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ObjectExpression.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ObjectExpression.ts new file mode 100644 index 0000000000000000000000000000000000000000..2566b4494dc1be80e67145b1c9ba0c48eead3f81 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ObjectExpression.ts @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { AnnotatedExpression } from "./AnnotatedExpression" +import { Decorator } from "./Decorator" +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { TypeNode } from "./TypeNode" +import { ValidationInfo } from "./ValidationInfo" +export class ObjectExpression extends AnnotatedExpression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 160) + super(pointer) + } + static createObjectExpression(nodeType: Es2pandaAstNodeType, properties: readonly Expression[], trailingComma: boolean): ObjectExpression { + return new ObjectExpression(global.generatedEs2panda._CreateObjectExpression(global.context, nodeType, passNodeArray(properties), properties.length, trailingComma)) + } + static updateObjectExpression(original: ObjectExpression | undefined, nodeType: Es2pandaAstNodeType, properties: readonly Expression[], trailingComma: boolean): ObjectExpression { + return new ObjectExpression(global.generatedEs2panda._UpdateObjectExpression(global.context, passNode(original), nodeType, passNodeArray(properties), properties.length, trailingComma)) + } + get properties(): readonly Expression[] { + return unpackNodeArray(global.generatedEs2panda._ObjectExpressionPropertiesConst(global.context, this.peer)) + } + get isDeclaration(): boolean { + return global.generatedEs2panda._ObjectExpressionIsDeclarationConst(global.context, this.peer) + } + get isOptional(): boolean { + return global.generatedEs2panda._ObjectExpressionIsOptionalConst(global.context, this.peer) + } + get decorators(): readonly Decorator[] { + return unpackNodeArray(global.generatedEs2panda._ObjectExpressionDecoratorsConst(global.context, this.peer)) + } + get validateExpression(): ValidationInfo | undefined { + return new ValidationInfo(global.generatedEs2panda._ObjectExpressionValidateExpression(global.context, this.peer)) + } + get convertibleToObjectPattern(): boolean { + return global.generatedEs2panda._ObjectExpressionConvertibleToObjectPattern(global.context, this.peer) + } + /** @deprecated */ + setDeclaration(): this { + global.generatedEs2panda._ObjectExpressionSetDeclaration(global.context, this.peer) + return this + } + /** @deprecated */ + setOptional(optional_arg: boolean): this { + global.generatedEs2panda._ObjectExpressionSetOptional(global.context, this.peer, optional_arg) + return this + } + get typeAnnotation(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._ObjectExpressionTypeAnnotationConst(global.context, this.peer)) + } + /** @deprecated */ + setTsTypeAnnotation(typeAnnotation?: TypeNode): this { + global.generatedEs2panda._ObjectExpressionSetTsTypeAnnotation(global.context, this.peer, passNode(typeAnnotation)) + return this + } +} +export function isObjectExpression(node: object | undefined): node is ObjectExpression { + return node instanceof ObjectExpression +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_OBJECT_EXPRESSION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_OBJECT_EXPRESSION, (peer: KNativePointer) => new ObjectExpression(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/OmittedExpression.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/OmittedExpression.ts new file mode 100644 index 0000000000000000000000000000000000000000..7f351caf5ac85feee4d1f4a21397c4a8f30423f3 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/OmittedExpression.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +export class OmittedExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 53) + super(pointer) + } + static createOmittedExpression(): OmittedExpression { + return new OmittedExpression(global.generatedEs2panda._CreateOmittedExpression(global.context)) + } + static updateOmittedExpression(original?: OmittedExpression): OmittedExpression { + return new OmittedExpression(global.generatedEs2panda._UpdateOmittedExpression(global.context, passNode(original))) + } +} +export function isOmittedExpression(node: object | undefined): node is OmittedExpression { + return node instanceof OmittedExpression +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_OMITTED_EXPRESSION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_OMITTED_EXPRESSION, (peer: KNativePointer) => new OmittedExpression(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/OpaqueTypeNode.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/OpaqueTypeNode.ts new file mode 100644 index 0000000000000000000000000000000000000000..a3a2ec34c7e18a8d96b5c33b2cf7294a9c72d234 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/OpaqueTypeNode.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { TypeNode } from "./TypeNode" +export class OpaqueTypeNode extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 153) + super(pointer) + } + static create1OpaqueTypeNode(): OpaqueTypeNode { + return new OpaqueTypeNode(global.generatedEs2panda._CreateOpaqueTypeNode1(global.context)) + } + static update1OpaqueTypeNode(original?: OpaqueTypeNode): OpaqueTypeNode { + return new OpaqueTypeNode(global.generatedEs2panda._UpdateOpaqueTypeNode1(global.context, passNode(original))) + } +} +export function isOpaqueTypeNode(node: object | undefined): node is OpaqueTypeNode { + return node instanceof OpaqueTypeNode +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_OPAQUE_TYPE_NODE)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_OPAQUE_TYPE_NODE, (peer: KNativePointer) => new OpaqueTypeNode(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/OverloadInfo.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/OverloadInfo.ts new file mode 100644 index 0000000000000000000000000000000000000000..51800f06fb5ba90ea28e06494b93a7e561963945 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/OverloadInfo.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +export class OverloadInfo extends ArktsObject { + constructor(pointer: KNativePointer) { + super(pointer) + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/PrefixAssertionExpression.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/PrefixAssertionExpression.ts new file mode 100644 index 0000000000000000000000000000000000000000..d89b78c00daf35f8a12383f3b4480964f2460327 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/PrefixAssertionExpression.ts @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { TypeNode } from "./TypeNode" +export class PrefixAssertionExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 54) + super(pointer) + } + static createPrefixAssertionExpression(expr?: Expression, type?: TypeNode): PrefixAssertionExpression { + return new PrefixAssertionExpression(global.generatedEs2panda._CreatePrefixAssertionExpression(global.context, passNode(expr), passNode(type))) + } + static updatePrefixAssertionExpression(original?: PrefixAssertionExpression, expr?: Expression, type?: TypeNode): PrefixAssertionExpression { + return new PrefixAssertionExpression(global.generatedEs2panda._UpdatePrefixAssertionExpression(global.context, passNode(original), passNode(expr), passNode(type))) + } + get expr(): Expression | undefined { + return unpackNode(global.generatedEs2panda._PrefixAssertionExpressionExprConst(global.context, this.peer)) + } + get type(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._PrefixAssertionExpressionTypeConst(global.context, this.peer)) + } +} +export function isPrefixAssertionExpression(node: object | undefined): node is PrefixAssertionExpression { + return node instanceof PrefixAssertionExpression +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_PREFIX_ASSERTION_EXPRESSION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_PREFIX_ASSERTION_EXPRESSION, (peer: KNativePointer) => new PrefixAssertionExpression(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/Property.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/Property.ts new file mode 100644 index 0000000000000000000000000000000000000000..81a8924f14006a115ebbe0654df44cc859ffb493 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/Property.ts @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Es2pandaPropertyKind } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { ValidationInfo } from "./ValidationInfo" +export class Property extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 55) + super(pointer) + } + static create1Property(kind: Es2pandaPropertyKind, key: Expression | undefined, value: Expression | undefined, isMethod: boolean, isComputed: boolean): Property { + return new Property(global.generatedEs2panda._CreateProperty1(global.context, kind, passNode(key), passNode(value), isMethod, isComputed)) + } + static updateProperty(original?: Property, key?: Expression, value?: Expression): Property { + return new Property(global.generatedEs2panda._UpdateProperty(global.context, passNode(original), passNode(key), passNode(value))) + } + static update1Property(original: Property | undefined, kind: Es2pandaPropertyKind, key: Expression | undefined, value: Expression | undefined, isMethod: boolean, isComputed: boolean): Property { + return new Property(global.generatedEs2panda._UpdateProperty1(global.context, passNode(original), kind, passNode(key), passNode(value), isMethod, isComputed)) + } + get key(): Expression | undefined { + return unpackNode(global.generatedEs2panda._PropertyKey(global.context, this.peer)) + } + get value(): Expression | undefined { + return unpackNode(global.generatedEs2panda._PropertyValue(global.context, this.peer)) + } + get kind(): Es2pandaPropertyKind { + return global.generatedEs2panda._PropertyKindConst(global.context, this.peer) + } + get isMethod(): boolean { + return global.generatedEs2panda._PropertyIsMethodConst(global.context, this.peer) + } + get isShorthand(): boolean { + return global.generatedEs2panda._PropertyIsShorthandConst(global.context, this.peer) + } + get isComputed(): boolean { + return global.generatedEs2panda._PropertyIsComputedConst(global.context, this.peer) + } + get isAccessor(): boolean { + return global.generatedEs2panda._PropertyIsAccessorConst(global.context, this.peer) + } + get convertibleToPatternProperty(): boolean { + return global.generatedEs2panda._PropertyConvertibleToPatternProperty(global.context, this.peer) + } + get validateExpression(): ValidationInfo | undefined { + return new ValidationInfo(global.generatedEs2panda._PropertyValidateExpression(global.context, this.peer)) + } +} +export function isProperty(node: object | undefined): node is Property { + return node instanceof Property +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_PROPERTY)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_PROPERTY, (peer: KNativePointer) => new Property(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/RegExpLiteral.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/RegExpLiteral.ts new file mode 100644 index 0000000000000000000000000000000000000000..f475bc0ccd466d385194ed2631905210bec12f7d --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/RegExpLiteral.ts @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Es2pandaRegExpFlags } from "./../Es2pandaEnums" +import { Literal } from "./Literal" +export class RegExpLiteral extends Literal { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 56) + super(pointer) + } + static createRegExpLiteral(pattern: string, flags: Es2pandaRegExpFlags, flagsStr: string): RegExpLiteral { + return new RegExpLiteral(global.generatedEs2panda._CreateRegExpLiteral(global.context, pattern, flags, flagsStr)) + } + static updateRegExpLiteral(original: RegExpLiteral | undefined, pattern: string, flags: Es2pandaRegExpFlags, flagsStr: string): RegExpLiteral { + return new RegExpLiteral(global.generatedEs2panda._UpdateRegExpLiteral(global.context, passNode(original), pattern, flags, flagsStr)) + } + get pattern(): string { + return unpackString(global.generatedEs2panda._RegExpLiteralPatternConst(global.context, this.peer)) + } + get flags(): Es2pandaRegExpFlags { + return global.generatedEs2panda._RegExpLiteralFlagsConst(global.context, this.peer) + } +} +export function isRegExpLiteral(node: object | undefined): node is RegExpLiteral { + return node instanceof RegExpLiteral +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_REGEXP_LITERAL)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_REGEXP_LITERAL, (peer: KNativePointer) => new RegExpLiteral(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ReturnStatement.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ReturnStatement.ts new file mode 100644 index 0000000000000000000000000000000000000000..f840ab6590c8d559b995bcfc4f14e361f5c8512d --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ReturnStatement.ts @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { Statement } from "./Statement" +export class ReturnStatement extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 58) + super(pointer) + } + static create1ReturnStatement(argument?: Expression): ReturnStatement { + return new ReturnStatement(global.generatedEs2panda._CreateReturnStatement1(global.context, passNode(argument))) + } + static updateReturnStatement(original?: ReturnStatement): ReturnStatement { + return new ReturnStatement(global.generatedEs2panda._UpdateReturnStatement(global.context, passNode(original))) + } + static update1ReturnStatement(original?: ReturnStatement, argument?: Expression): ReturnStatement { + return new ReturnStatement(global.generatedEs2panda._UpdateReturnStatement1(global.context, passNode(original), passNode(argument))) + } + get argument(): Expression | undefined { + return unpackNode(global.generatedEs2panda._ReturnStatementArgument(global.context, this.peer)) + } + /** @deprecated */ + setArgument(arg?: Expression): this { + global.generatedEs2panda._ReturnStatementSetArgument(global.context, this.peer, passNode(arg)) + return this + } + get isAsyncImplReturn(): boolean { + return global.generatedEs2panda._ReturnStatementIsAsyncImplReturnConst(global.context, this.peer) + } +} +export function isReturnStatement(node: object | undefined): node is ReturnStatement { + return node instanceof ReturnStatement +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_RETURN_STATEMENT)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_RETURN_STATEMENT, (peer: KNativePointer) => new ReturnStatement(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ScopeFindResult.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ScopeFindResult.ts new file mode 100644 index 0000000000000000000000000000000000000000..68156bac293e443f84defeccb37bd2da54e0950a --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ScopeFindResult.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +export class ScopeFindResult extends ArktsObject { + constructor(pointer: KNativePointer) { + super(pointer) + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ScriptFunction.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ScriptFunction.ts new file mode 100644 index 0000000000000000000000000000000000000000..3543561a54972921671ebdce70edb3f56fd7218e --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ScriptFunction.ts @@ -0,0 +1,206 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { AnnotationUsage } from "./AnnotationUsage" +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Es2pandaModifierFlags } from "./../Es2pandaEnums" +import { Es2pandaScriptFunctionFlags } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { FunctionSignature } from "./FunctionSignature" +import { Identifier } from "./Identifier" +import { ReturnStatement } from "./ReturnStatement" +import { TSTypeParameterDeclaration } from "./TSTypeParameterDeclaration" +import { TypeNode } from "./TypeNode" +export class ScriptFunction extends AstNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 59) + super(pointer) + } + static createScriptFunction(databody: AstNode | undefined, datasignature: FunctionSignature | undefined, datafuncFlags: number, dataflags: number): ScriptFunction { + return new ScriptFunction(global.generatedEs2panda._CreateScriptFunction(global.context, passNode(databody), passNode(datasignature), datafuncFlags, dataflags)) + } + static updateScriptFunction(original: ScriptFunction | undefined, databody: AstNode | undefined, datasignature: FunctionSignature | undefined, datafuncFlags: number, dataflags: number): ScriptFunction { + return new ScriptFunction(global.generatedEs2panda._UpdateScriptFunction(global.context, passNode(original), passNode(databody), passNode(datasignature), datafuncFlags, dataflags)) + } + get id(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._ScriptFunctionId(global.context, this.peer)) + } + get params(): readonly Expression[] { + return unpackNodeArray(global.generatedEs2panda._ScriptFunctionParams(global.context, this.peer)) + } + get returnStatements(): readonly ReturnStatement[] { + return unpackNodeArray(global.generatedEs2panda._ScriptFunctionReturnStatements(global.context, this.peer)) + } + get typeParams(): TSTypeParameterDeclaration | undefined { + return unpackNode(global.generatedEs2panda._ScriptFunctionTypeParams(global.context, this.peer)) + } + get body(): AstNode | undefined { + return unpackNode(global.generatedEs2panda._ScriptFunctionBody(global.context, this.peer)) + } + /** @deprecated */ + addReturnStatement(returnStatement?: ReturnStatement): this { + global.generatedEs2panda._ScriptFunctionAddReturnStatement(global.context, this.peer, passNode(returnStatement)) + return this + } + /** @deprecated */ + setBody(body?: AstNode): this { + global.generatedEs2panda._ScriptFunctionSetBody(global.context, this.peer, passNode(body)) + return this + } + get returnTypeAnnotation(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._ScriptFunctionReturnTypeAnnotation(global.context, this.peer)) + } + /** @deprecated */ + setReturnTypeAnnotation(node?: TypeNode): this { + global.generatedEs2panda._ScriptFunctionSetReturnTypeAnnotation(global.context, this.peer, passNode(node)) + return this + } + get isEntryPoint(): boolean { + return global.generatedEs2panda._ScriptFunctionIsEntryPointConst(global.context, this.peer) + } + get isGenerator(): boolean { + return global.generatedEs2panda._ScriptFunctionIsGeneratorConst(global.context, this.peer) + } + get isAsyncFunc(): boolean { + return global.generatedEs2panda._ScriptFunctionIsAsyncFuncConst(global.context, this.peer) + } + get isAsyncImplFunc(): boolean { + return global.generatedEs2panda._ScriptFunctionIsAsyncImplFuncConst(global.context, this.peer) + } + get isArrow(): boolean { + return global.generatedEs2panda._ScriptFunctionIsArrowConst(global.context, this.peer) + } + get isOverload(): boolean { + return global.generatedEs2panda._ScriptFunctionIsOverloadConst(global.context, this.peer) + } + get isExternalOverload(): boolean { + return global.generatedEs2panda._ScriptFunctionIsExternalOverloadConst(global.context, this.peer) + } + get isConstructor(): boolean { + return global.generatedEs2panda._ScriptFunctionIsConstructorConst(global.context, this.peer) + } + get isGetter(): boolean { + return global.generatedEs2panda._ScriptFunctionIsGetterConst(global.context, this.peer) + } + get isSetter(): boolean { + return global.generatedEs2panda._ScriptFunctionIsSetterConst(global.context, this.peer) + } + get isExtensionAccessor(): boolean { + return global.generatedEs2panda._ScriptFunctionIsExtensionAccessorConst(global.context, this.peer) + } + get isMethod(): boolean { + return global.generatedEs2panda._ScriptFunctionIsMethodConst(global.context, this.peer) + } + get isProxy(): boolean { + return global.generatedEs2panda._ScriptFunctionIsProxyConst(global.context, this.peer) + } + get isStaticBlock(): boolean { + return global.generatedEs2panda._ScriptFunctionIsStaticBlockConst(global.context, this.peer) + } + get isEnum(): boolean { + return global.generatedEs2panda._ScriptFunctionIsEnumConst(global.context, this.peer) + } + get isHidden(): boolean { + return global.generatedEs2panda._ScriptFunctionIsHiddenConst(global.context, this.peer) + } + get isExternal(): boolean { + return global.generatedEs2panda._ScriptFunctionIsExternalConst(global.context, this.peer) + } + get isImplicitSuperCallNeeded(): boolean { + return global.generatedEs2panda._ScriptFunctionIsImplicitSuperCallNeededConst(global.context, this.peer) + } + get hasBody(): boolean { + return global.generatedEs2panda._ScriptFunctionHasBodyConst(global.context, this.peer) + } + get hasRestParameter(): boolean { + return global.generatedEs2panda._ScriptFunctionHasRestParameterConst(global.context, this.peer) + } + get hasReturnStatement(): boolean { + return global.generatedEs2panda._ScriptFunctionHasReturnStatementConst(global.context, this.peer) + } + get hasThrowStatement(): boolean { + return global.generatedEs2panda._ScriptFunctionHasThrowStatementConst(global.context, this.peer) + } + get isThrowing(): boolean { + return global.generatedEs2panda._ScriptFunctionIsThrowingConst(global.context, this.peer) + } + get isRethrowing(): boolean { + return global.generatedEs2panda._ScriptFunctionIsRethrowingConst(global.context, this.peer) + } + get isDynamic(): boolean { + return global.generatedEs2panda._ScriptFunctionIsDynamicConst(global.context, this.peer) + } + get isExtensionMethod(): boolean { + return global.generatedEs2panda._ScriptFunctionIsExtensionMethodConst(global.context, this.peer) + } + get flags(): Es2pandaScriptFunctionFlags { + return global.generatedEs2panda._ScriptFunctionFlagsConst(global.context, this.peer) + } + get hasReceiver(): boolean { + return global.generatedEs2panda._ScriptFunctionHasReceiverConst(global.context, this.peer) + } + /** @deprecated */ + setIdent(id: Identifier): this { + global.generatedEs2panda._ScriptFunctionSetIdent(global.context, this.peer, passNode(id)) + return this + } + /** @deprecated */ + addFlag(flags: Es2pandaScriptFunctionFlags): this { + global.generatedEs2panda._ScriptFunctionAddFlag(global.context, this.peer, flags) + return this + } + /** @deprecated */ + clearFlag(flags: Es2pandaScriptFunctionFlags): this { + global.generatedEs2panda._ScriptFunctionClearFlag(global.context, this.peer, flags) + return this + } + /** @deprecated */ + addModifier(flags: Es2pandaModifierFlags): this { + global.generatedEs2panda._ScriptFunctionAddModifier(global.context, this.peer, flags) + return this + } + get formalParamsLength(): number { + return global.generatedEs2panda._ScriptFunctionFormalParamsLengthConst(global.context, this.peer) + } + get annotations(): readonly AnnotationUsage[] { + return unpackNodeArray(global.generatedEs2panda._ScriptFunctionAnnotations(global.context, this.peer)) + } + /** @deprecated */ + setAnnotations(annotations: readonly AnnotationUsage[]): this { + global.generatedEs2panda._ScriptFunctionSetAnnotations(global.context, this.peer, passNodeArray(annotations), annotations.length) + return this + } +} +export function isScriptFunction(node: object | undefined): node is ScriptFunction { + return node instanceof ScriptFunction +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_SCRIPT_FUNCTION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_SCRIPT_FUNCTION, (peer: KNativePointer) => new ScriptFunction(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ScriptFunctionData.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ScriptFunctionData.ts new file mode 100644 index 0000000000000000000000000000000000000000..dc25dca16ac2ec3fa7371841eea08e34f7c38fd7 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ScriptFunctionData.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +export class ScriptFunctionData extends ArktsObject { + constructor(pointer: KNativePointer) { + super(pointer) + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/SequenceExpression.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/SequenceExpression.ts new file mode 100644 index 0000000000000000000000000000000000000000..7c74085e54760ecc40dbd8aa1f601d944cc8ba82 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/SequenceExpression.ts @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +export class SequenceExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 60) + super(pointer) + } + static createSequenceExpression(sequence_arg: readonly Expression[]): SequenceExpression { + return new SequenceExpression(global.generatedEs2panda._CreateSequenceExpression(global.context, passNodeArray(sequence_arg), sequence_arg.length)) + } + static updateSequenceExpression(original: SequenceExpression | undefined, sequence_arg: readonly Expression[]): SequenceExpression { + return new SequenceExpression(global.generatedEs2panda._UpdateSequenceExpression(global.context, passNode(original), passNodeArray(sequence_arg), sequence_arg.length)) + } + get sequence(): readonly Expression[] { + return unpackNodeArray(global.generatedEs2panda._SequenceExpressionSequence(global.context, this.peer)) + } +} +export function isSequenceExpression(node: object | undefined): node is SequenceExpression { + return node instanceof SequenceExpression +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_SEQUENCE_EXPRESSION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_SEQUENCE_EXPRESSION, (peer: KNativePointer) => new SequenceExpression(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/SignatureInfo.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/SignatureInfo.ts new file mode 100644 index 0000000000000000000000000000000000000000..605f112a1def12d10b83d00832e076d0b5cd71fe --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/SignatureInfo.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +export class SignatureInfo extends ArktsObject { + constructor(pointer: KNativePointer) { + super(pointer) + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/SourcePosition.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/SourcePosition.ts new file mode 100644 index 0000000000000000000000000000000000000000..69c033d8234426bd3941bf2bf251b88a1020d741 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/SourcePosition.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +export class SourcePosition extends ArktsObject { + constructor(pointer: KNativePointer) { + super(pointer) + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/SourceRange.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/SourceRange.ts new file mode 100644 index 0000000000000000000000000000000000000000..b790105c7f3eaefaa685c7d1bf233b48af30614e --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/SourceRange.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +export class SourceRange extends ArktsObject { + constructor(pointer: KNativePointer) { + super(pointer) + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/SpreadElement.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/SpreadElement.ts new file mode 100644 index 0000000000000000000000000000000000000000..3d253dd6010cc50c243a50543d7ff856fc280023 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/SpreadElement.ts @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { AnnotatedExpression } from "./AnnotatedExpression" +import { Decorator } from "./Decorator" +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { TypeNode } from "./TypeNode" +import { ValidationInfo } from "./ValidationInfo" +export class SpreadElement extends AnnotatedExpression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 162) + super(pointer) + } + static createSpreadElement(nodeType: Es2pandaAstNodeType, argument?: Expression): SpreadElement { + return new SpreadElement(global.generatedEs2panda._CreateSpreadElement(global.context, nodeType, passNode(argument))) + } + static updateSpreadElement(original: SpreadElement | undefined, nodeType: Es2pandaAstNodeType, argument?: Expression): SpreadElement { + return new SpreadElement(global.generatedEs2panda._UpdateSpreadElement(global.context, passNode(original), nodeType, passNode(argument))) + } + get argument(): Expression | undefined { + return unpackNode(global.generatedEs2panda._SpreadElementArgument(global.context, this.peer)) + } + get isOptional(): boolean { + return global.generatedEs2panda._SpreadElementIsOptionalConst(global.context, this.peer) + } + get decorators(): readonly Decorator[] { + return unpackNodeArray(global.generatedEs2panda._SpreadElementDecoratorsConst(global.context, this.peer)) + } + /** @deprecated */ + setOptional(optional_arg: boolean): this { + global.generatedEs2panda._SpreadElementSetOptional(global.context, this.peer, optional_arg) + return this + } + get validateExpression(): ValidationInfo | undefined { + return new ValidationInfo(global.generatedEs2panda._SpreadElementValidateExpression(global.context, this.peer)) + } + get typeAnnotation(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._SpreadElementTypeAnnotationConst(global.context, this.peer)) + } + /** @deprecated */ + setTsTypeAnnotation(typeAnnotation?: TypeNode): this { + global.generatedEs2panda._SpreadElementSetTsTypeAnnotation(global.context, this.peer, passNode(typeAnnotation)) + return this + } +} +export function isSpreadElement(node: object | undefined): node is SpreadElement { + return node instanceof SpreadElement +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_SPREAD_ELEMENT)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_SPREAD_ELEMENT, (peer: KNativePointer) => new SpreadElement(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/SrcDumper.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/SrcDumper.ts new file mode 100644 index 0000000000000000000000000000000000000000..f9a6e29cd318068296439d67c3c06cd48901fdd6 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/SrcDumper.ts @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +export class SrcDumper extends ArktsObject { + constructor(pointer: KNativePointer) { + super(pointer) + } + static createSrcDumper(node?: AstNode): SrcDumper { + return new SrcDumper(global.generatedEs2panda._CreateSrcDumper(global.context, passNode(node))) + } + /** @deprecated */ + add(str: string): this { + global.generatedEs2panda._SrcDumperAdd(global.context, this.peer, str) + return this + } + /** @deprecated */ + add1(i: number): this { + global.generatedEs2panda._SrcDumperAdd1(global.context, this.peer, i) + return this + } + /** @deprecated */ + add2(l: number): this { + global.generatedEs2panda._SrcDumperAdd2(global.context, this.peer, l) + return this + } + /** @deprecated */ + add3(f: number): this { + global.generatedEs2panda._SrcDumperAdd3(global.context, this.peer, f) + return this + } + /** @deprecated */ + add4(d: number): this { + global.generatedEs2panda._SrcDumperAdd4(global.context, this.peer, d) + return this + } + get str(): string { + return unpackString(global.generatedEs2panda._SrcDumperStrConst(global.context, this.peer)) + } + /** @deprecated */ + incrIndent(): this { + global.generatedEs2panda._SrcDumperIncrIndent(global.context, this.peer) + return this + } + /** @deprecated */ + decrIndent(): this { + global.generatedEs2panda._SrcDumperDecrIndent(global.context, this.peer) + return this + } + /** @deprecated */ + endl(num: number): this { + global.generatedEs2panda._SrcDumperEndl(global.context, this.peer, num) + return this + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/Statement.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/Statement.ts new file mode 100644 index 0000000000000000000000000000000000000000..c67960d87dc803d086b2aafbd85ef1433a951c9a --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/Statement.ts @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +export class Statement extends AstNode { + constructor(pointer: KNativePointer) { + super(pointer) + } +} +export function isStatement(node: object | undefined): node is Statement { + return node instanceof Statement +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/StringLiteral.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/StringLiteral.ts new file mode 100644 index 0000000000000000000000000000000000000000..3e1833a86e58cc72e5e8afac30868bf23f98a503 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/StringLiteral.ts @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Literal } from "./Literal" +export class StringLiteral extends Literal { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 61) + super(pointer) + } + static create1StringLiteral(str: string): StringLiteral { + return new StringLiteral(global.generatedEs2panda._CreateStringLiteral1(global.context, str)) + } + static updateStringLiteral(original?: StringLiteral): StringLiteral { + return new StringLiteral(global.generatedEs2panda._UpdateStringLiteral(global.context, passNode(original))) + } + static update1StringLiteral(original: StringLiteral | undefined, str: string): StringLiteral { + return new StringLiteral(global.generatedEs2panda._UpdateStringLiteral1(global.context, passNode(original), str)) + } + get str(): string { + return unpackString(global.generatedEs2panda._StringLiteralStrConst(global.context, this.peer)) + } +} +export function isStringLiteral(node: object | undefined): node is StringLiteral { + return node instanceof StringLiteral +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_STRING_LITERAL)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_STRING_LITERAL, (peer: KNativePointer) => new StringLiteral(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/SuperExpression.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/SuperExpression.ts new file mode 100644 index 0000000000000000000000000000000000000000..055d0a83f67ae0eab8550bd2e8b28df557fec5de --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/SuperExpression.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +export class SuperExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 82) + super(pointer) + } + static createSuperExpression(): SuperExpression { + return new SuperExpression(global.generatedEs2panda._CreateSuperExpression(global.context)) + } + static updateSuperExpression(original?: SuperExpression): SuperExpression { + return new SuperExpression(global.generatedEs2panda._UpdateSuperExpression(global.context, passNode(original))) + } +} +export function isSuperExpression(node: object | undefined): node is SuperExpression { + return node instanceof SuperExpression +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_SUPER_EXPRESSION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_SUPER_EXPRESSION, (peer: KNativePointer) => new SuperExpression(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/SwitchCaseStatement.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/SwitchCaseStatement.ts new file mode 100644 index 0000000000000000000000000000000000000000..2c7342133ca3bf53b0d8c2f2c5450b38307862b4 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/SwitchCaseStatement.ts @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { Statement } from "./Statement" +export class SwitchCaseStatement extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 84) + super(pointer) + } + static createSwitchCaseStatement(test: Expression | undefined, consequent: readonly Statement[]): SwitchCaseStatement { + return new SwitchCaseStatement(global.generatedEs2panda._CreateSwitchCaseStatement(global.context, passNode(test), passNodeArray(consequent), consequent.length)) + } + static updateSwitchCaseStatement(original: SwitchCaseStatement | undefined, test: Expression | undefined, consequent: readonly Statement[]): SwitchCaseStatement { + return new SwitchCaseStatement(global.generatedEs2panda._UpdateSwitchCaseStatement(global.context, passNode(original), passNode(test), passNodeArray(consequent), consequent.length)) + } + get test(): Expression | undefined { + return unpackNode(global.generatedEs2panda._SwitchCaseStatementTest(global.context, this.peer)) + } + /** @deprecated */ + setTest(test?: Expression): this { + global.generatedEs2panda._SwitchCaseStatementSetTest(global.context, this.peer, passNode(test)) + return this + } + get consequent(): readonly Statement[] { + return unpackNodeArray(global.generatedEs2panda._SwitchCaseStatementConsequentConst(global.context, this.peer)) + } +} +export function isSwitchCaseStatement(node: object | undefined): node is SwitchCaseStatement { + return node instanceof SwitchCaseStatement +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_SWITCH_CASE_STATEMENT)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_SWITCH_CASE_STATEMENT, (peer: KNativePointer) => new SwitchCaseStatement(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/SwitchStatement.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/SwitchStatement.ts new file mode 100644 index 0000000000000000000000000000000000000000..527c3ead8685273971d07c483cabfb87172c8b53 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/SwitchStatement.ts @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { Statement } from "./Statement" +import { SwitchCaseStatement } from "./SwitchCaseStatement" +export class SwitchStatement extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 85) + super(pointer) + } + static createSwitchStatement(discriminant: Expression | undefined, cases: readonly SwitchCaseStatement[]): SwitchStatement { + return new SwitchStatement(global.generatedEs2panda._CreateSwitchStatement(global.context, passNode(discriminant), passNodeArray(cases), cases.length)) + } + static updateSwitchStatement(original: SwitchStatement | undefined, discriminant: Expression | undefined, cases: readonly SwitchCaseStatement[]): SwitchStatement { + return new SwitchStatement(global.generatedEs2panda._UpdateSwitchStatement(global.context, passNode(original), passNode(discriminant), passNodeArray(cases), cases.length)) + } + get discriminant(): Expression | undefined { + return unpackNode(global.generatedEs2panda._SwitchStatementDiscriminant(global.context, this.peer)) + } + /** @deprecated */ + setDiscriminant(discriminant?: Expression): this { + global.generatedEs2panda._SwitchStatementSetDiscriminant(global.context, this.peer, passNode(discriminant)) + return this + } + get cases(): readonly SwitchCaseStatement[] { + return unpackNodeArray(global.generatedEs2panda._SwitchStatementCases(global.context, this.peer)) + } +} +export function isSwitchStatement(node: object | undefined): node is SwitchStatement { + return node instanceof SwitchStatement +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_SWITCH_STATEMENT)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_SWITCH_STATEMENT, (peer: KNativePointer) => new SwitchStatement(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSAnyKeyword.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSAnyKeyword.ts new file mode 100644 index 0000000000000000000000000000000000000000..c6102fbc6426bd027f8c7d6061afc5665012b89e --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSAnyKeyword.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { TypeNode } from "./TypeNode" +export class TSAnyKeyword extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 90) + super(pointer) + } + static createTSAnyKeyword(): TSAnyKeyword { + return new TSAnyKeyword(global.generatedEs2panda._CreateTSAnyKeyword(global.context)) + } + static updateTSAnyKeyword(original?: TSAnyKeyword): TSAnyKeyword { + return new TSAnyKeyword(global.generatedEs2panda._UpdateTSAnyKeyword(global.context, passNode(original))) + } +} +export function isTSAnyKeyword(node: object | undefined): node is TSAnyKeyword { + return node instanceof TSAnyKeyword +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_ANY_KEYWORD)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_ANY_KEYWORD, (peer: KNativePointer) => new TSAnyKeyword(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSArrayType.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSArrayType.ts new file mode 100644 index 0000000000000000000000000000000000000000..3f21d6669f718355789dfb72ac830feaf357e934 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSArrayType.ts @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { TypeNode } from "./TypeNode" +export class TSArrayType extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 101) + super(pointer) + } + static createTSArrayType(elementType?: TypeNode): TSArrayType { + return new TSArrayType(global.generatedEs2panda._CreateTSArrayType(global.context, passNode(elementType))) + } + static updateTSArrayType(original?: TSArrayType, elementType?: TypeNode): TSArrayType { + return new TSArrayType(global.generatedEs2panda._UpdateTSArrayType(global.context, passNode(original), passNode(elementType))) + } + get elementType(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._TSArrayTypeElementTypeConst(global.context, this.peer)) + } +} +export function isTSArrayType(node: object | undefined): node is TSArrayType { + return node instanceof TSArrayType +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_ARRAY_TYPE)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_ARRAY_TYPE, (peer: KNativePointer) => new TSArrayType(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSAsExpression.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSAsExpression.ts new file mode 100644 index 0000000000000000000000000000000000000000..a58416b831bb024fea15fcc67020fd8902c24868 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSAsExpression.ts @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { AnnotatedExpression } from "./AnnotatedExpression" +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { TypeNode } from "./TypeNode" +export class TSAsExpression extends AnnotatedExpression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 137) + super(pointer) + } + static createTSAsExpression(expression: Expression | undefined, typeAnnotation: TypeNode | undefined, isConst: boolean): TSAsExpression { + return new TSAsExpression(global.generatedEs2panda._CreateTSAsExpression(global.context, passNode(expression), passNode(typeAnnotation), isConst)) + } + static updateTSAsExpression(original: TSAsExpression | undefined, expression: Expression | undefined, typeAnnotation: TypeNode | undefined, isConst: boolean): TSAsExpression { + return new TSAsExpression(global.generatedEs2panda._UpdateTSAsExpression(global.context, passNode(original), passNode(expression), passNode(typeAnnotation), isConst)) + } + get expr(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSAsExpressionExpr(global.context, this.peer)) + } + /** @deprecated */ + setExpr(expr?: Expression): this { + global.generatedEs2panda._TSAsExpressionSetExpr(global.context, this.peer, passNode(expr)) + return this + } + get isConst(): boolean { + return global.generatedEs2panda._TSAsExpressionIsConstConst(global.context, this.peer) + } + /** @deprecated */ + setUncheckedCast(isUncheckedCast: boolean): this { + global.generatedEs2panda._TSAsExpressionSetUncheckedCast(global.context, this.peer, isUncheckedCast) + return this + } + get typeAnnotation(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._TSAsExpressionTypeAnnotationConst(global.context, this.peer)) + } + /** @deprecated */ + setTsTypeAnnotation(typeAnnotation?: TypeNode): this { + global.generatedEs2panda._TSAsExpressionSetTsTypeAnnotation(global.context, this.peer, passNode(typeAnnotation)) + return this + } +} +export function isTSAsExpression(node: object | undefined): node is TSAsExpression { + return node instanceof TSAsExpression +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_AS_EXPRESSION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_AS_EXPRESSION, (peer: KNativePointer) => new TSAsExpression(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSBigintKeyword.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSBigintKeyword.ts new file mode 100644 index 0000000000000000000000000000000000000000..f4197534ffe04d7b235fb99e359e7abf81d3e8e7 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSBigintKeyword.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { TypeNode } from "./TypeNode" +export class TSBigintKeyword extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 97) + super(pointer) + } + static createTSBigintKeyword(): TSBigintKeyword { + return new TSBigintKeyword(global.generatedEs2panda._CreateTSBigintKeyword(global.context)) + } + static updateTSBigintKeyword(original?: TSBigintKeyword): TSBigintKeyword { + return new TSBigintKeyword(global.generatedEs2panda._UpdateTSBigintKeyword(global.context, passNode(original))) + } +} +export function isTSBigintKeyword(node: object | undefined): node is TSBigintKeyword { + return node instanceof TSBigintKeyword +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_BIGINT_KEYWORD)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_BIGINT_KEYWORD, (peer: KNativePointer) => new TSBigintKeyword(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSBooleanKeyword.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSBooleanKeyword.ts new file mode 100644 index 0000000000000000000000000000000000000000..f401a379be1909efb6603567a3865ea0f9cda145 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSBooleanKeyword.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { TypeNode } from "./TypeNode" +export class TSBooleanKeyword extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 92) + super(pointer) + } + static createTSBooleanKeyword(): TSBooleanKeyword { + return new TSBooleanKeyword(global.generatedEs2panda._CreateTSBooleanKeyword(global.context)) + } + static updateTSBooleanKeyword(original?: TSBooleanKeyword): TSBooleanKeyword { + return new TSBooleanKeyword(global.generatedEs2panda._UpdateTSBooleanKeyword(global.context, passNode(original))) + } +} +export function isTSBooleanKeyword(node: object | undefined): node is TSBooleanKeyword { + return node instanceof TSBooleanKeyword +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_BOOLEAN_KEYWORD)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_BOOLEAN_KEYWORD, (peer: KNativePointer) => new TSBooleanKeyword(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSClassImplements.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSClassImplements.ts new file mode 100644 index 0000000000000000000000000000000000000000..76ce7ccaaaf24cc30610311c19d3d3c6cae8e9a6 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSClassImplements.ts @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { TSTypeParameterInstantiation } from "./TSTypeParameterInstantiation" +export class TSClassImplements extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 138) + super(pointer) + } + static createTSClassImplements(expression?: Expression, typeParameters?: TSTypeParameterInstantiation): TSClassImplements { + return new TSClassImplements(global.generatedEs2panda._CreateTSClassImplements(global.context, passNode(expression), passNode(typeParameters))) + } + static updateTSClassImplements(original?: TSClassImplements, expression?: Expression, typeParameters?: TSTypeParameterInstantiation): TSClassImplements { + return new TSClassImplements(global.generatedEs2panda._UpdateTSClassImplements(global.context, passNode(original), passNode(expression), passNode(typeParameters))) + } + static update1TSClassImplements(original?: TSClassImplements, expression?: Expression): TSClassImplements { + return new TSClassImplements(global.generatedEs2panda._UpdateTSClassImplements1(global.context, passNode(original), passNode(expression))) + } + get expr(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSClassImplementsExpr(global.context, this.peer)) + } + get typeParameters(): TSTypeParameterInstantiation | undefined { + return unpackNode(global.generatedEs2panda._TSClassImplementsTypeParametersConst(global.context, this.peer)) + } +} +export function isTSClassImplements(node: object | undefined): node is TSClassImplements { + return node instanceof TSClassImplements +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_CLASS_IMPLEMENTS)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_CLASS_IMPLEMENTS, (peer: KNativePointer) => new TSClassImplements(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSConditionalType.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSConditionalType.ts new file mode 100644 index 0000000000000000000000000000000000000000..7793a319567d22768425ea964f91d6ac882ee0db --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSConditionalType.ts @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { TypeNode } from "./TypeNode" +export class TSConditionalType extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 110) + super(pointer) + } + static createTSConditionalType(checkType?: Expression, extendsType?: Expression, trueType?: Expression, falseType?: Expression): TSConditionalType { + return new TSConditionalType(global.generatedEs2panda._CreateTSConditionalType(global.context, passNode(checkType), passNode(extendsType), passNode(trueType), passNode(falseType))) + } + static updateTSConditionalType(original?: TSConditionalType, checkType?: Expression, extendsType?: Expression, trueType?: Expression, falseType?: Expression): TSConditionalType { + return new TSConditionalType(global.generatedEs2panda._UpdateTSConditionalType(global.context, passNode(original), passNode(checkType), passNode(extendsType), passNode(trueType), passNode(falseType))) + } + get checkType(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSConditionalTypeCheckTypeConst(global.context, this.peer)) + } + get extendsType(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSConditionalTypeExtendsTypeConst(global.context, this.peer)) + } + get trueType(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSConditionalTypeTrueTypeConst(global.context, this.peer)) + } + get falseType(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSConditionalTypeFalseTypeConst(global.context, this.peer)) + } +} +export function isTSConditionalType(node: object | undefined): node is TSConditionalType { + return node instanceof TSConditionalType +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_CONDITIONAL_TYPE)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_CONDITIONAL_TYPE, (peer: KNativePointer) => new TSConditionalType(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSConstructorType.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSConstructorType.ts new file mode 100644 index 0000000000000000000000000000000000000000..1321491c2e87dbda48bdd9030a52fc876deb62f8 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSConstructorType.ts @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { FunctionSignature } from "./FunctionSignature" +import { TSTypeParameterDeclaration } from "./TSTypeParameterDeclaration" +import { TypeNode } from "./TypeNode" +export class TSConstructorType extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 125) + super(pointer) + } + static createTSConstructorType(signature: FunctionSignature | undefined, abstract: boolean): TSConstructorType { + return new TSConstructorType(global.generatedEs2panda._CreateTSConstructorType(global.context, passNode(signature), abstract)) + } + static updateTSConstructorType(original: TSConstructorType | undefined, signature: FunctionSignature | undefined, abstract: boolean): TSConstructorType { + return new TSConstructorType(global.generatedEs2panda._UpdateTSConstructorType(global.context, passNode(original), passNode(signature), abstract)) + } + get typeParams(): TSTypeParameterDeclaration | undefined { + return unpackNode(global.generatedEs2panda._TSConstructorTypeTypeParams(global.context, this.peer)) + } + get params(): readonly Expression[] { + return unpackNodeArray(global.generatedEs2panda._TSConstructorTypeParamsConst(global.context, this.peer)) + } + get returnType(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._TSConstructorTypeReturnType(global.context, this.peer)) + } + get abstract(): boolean { + return global.generatedEs2panda._TSConstructorTypeAbstractConst(global.context, this.peer) + } +} +export function isTSConstructorType(node: object | undefined): node is TSConstructorType { + return node instanceof TSConstructorType +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_CONSTRUCTOR_TYPE)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_CONSTRUCTOR_TYPE, (peer: KNativePointer) => new TSConstructorType(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSEnumDeclaration.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSEnumDeclaration.ts new file mode 100644 index 0000000000000000000000000000000000000000..a5044b08326939ea976dce5c4caef9575ee1dda7 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSEnumDeclaration.ts @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { ClassDefinition } from "./ClassDefinition" +import { Decorator } from "./Decorator" +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Identifier } from "./Identifier" +import { TypedStatement } from "./TypedStatement" +export class TSEnumDeclaration extends TypedStatement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 86) + super(pointer) + } + static createTSEnumDeclaration(key: Identifier | undefined, members: readonly AstNode[], isConst: boolean, isStatic: boolean, isDeclare: boolean): TSEnumDeclaration { + return new TSEnumDeclaration(global.generatedEs2panda._CreateTSEnumDeclaration(global.context, passNode(key), passNodeArray(members), members.length, isConst, isStatic, isDeclare)) + } + static updateTSEnumDeclaration(original: TSEnumDeclaration | undefined, key: Identifier | undefined, members: readonly AstNode[], isConst: boolean, isStatic: boolean, isDeclare: boolean): TSEnumDeclaration { + return new TSEnumDeclaration(global.generatedEs2panda._UpdateTSEnumDeclaration(global.context, passNode(original), passNode(key), passNodeArray(members), members.length, isConst, isStatic, isDeclare)) + } + get key(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._TSEnumDeclarationKey(global.context, this.peer)) + } + get members(): readonly AstNode[] { + return unpackNodeArray(global.generatedEs2panda._TSEnumDeclarationMembersConst(global.context, this.peer)) + } + get internalName(): string { + return unpackString(global.generatedEs2panda._TSEnumDeclarationInternalNameConst(global.context, this.peer)) + } + /** @deprecated */ + setInternalName(internalName: string): this { + global.generatedEs2panda._TSEnumDeclarationSetInternalName(global.context, this.peer, internalName) + return this + } + get boxedClass(): ClassDefinition | undefined { + return unpackNode(global.generatedEs2panda._TSEnumDeclarationBoxedClassConst(global.context, this.peer)) + } + /** @deprecated */ + setBoxedClass(wrapperClass?: ClassDefinition): this { + global.generatedEs2panda._TSEnumDeclarationSetBoxedClass(global.context, this.peer, passNode(wrapperClass)) + return this + } + get isConst(): boolean { + return global.generatedEs2panda._TSEnumDeclarationIsConstConst(global.context, this.peer) + } + get decorators(): readonly Decorator[] { + return unpackNodeArray(global.generatedEs2panda._TSEnumDeclarationDecoratorsConst(global.context, this.peer)) + } +} +export function isTSEnumDeclaration(node: object | undefined): node is TSEnumDeclaration { + return node instanceof TSEnumDeclaration +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_ENUM_DECLARATION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_ENUM_DECLARATION, (peer: KNativePointer) => new TSEnumDeclaration(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSEnumMember.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSEnumMember.ts new file mode 100644 index 0000000000000000000000000000000000000000..3facabee01f511493290fb63c6296b0ca6ec8c94 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSEnumMember.ts @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { Statement } from "./Statement" +export class TSEnumMember extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 87) + super(pointer) + } + static create1TSEnumMember(key: Expression | undefined, init: Expression | undefined, isGenerated: boolean): TSEnumMember { + return new TSEnumMember(global.generatedEs2panda._CreateTSEnumMember1(global.context, passNode(key), passNode(init), isGenerated)) + } + static updateTSEnumMember(original?: TSEnumMember, key?: Expression, init?: Expression): TSEnumMember { + return new TSEnumMember(global.generatedEs2panda._UpdateTSEnumMember(global.context, passNode(original), passNode(key), passNode(init))) + } + static update1TSEnumMember(original: TSEnumMember | undefined, key: Expression | undefined, init: Expression | undefined, isGenerated: boolean): TSEnumMember { + return new TSEnumMember(global.generatedEs2panda._UpdateTSEnumMember1(global.context, passNode(original), passNode(key), passNode(init), isGenerated)) + } + get key(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSEnumMemberKey(global.context, this.peer)) + } + get init(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSEnumMemberInit(global.context, this.peer)) + } + get isGenerated(): boolean { + return global.generatedEs2panda._TSEnumMemberIsGeneratedConst(global.context, this.peer) + } + get name(): string { + return unpackString(global.generatedEs2panda._TSEnumMemberNameConst(global.context, this.peer)) + } +} +export function isTSEnumMember(node: object | undefined): node is TSEnumMember { + return node instanceof TSEnumMember +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_ENUM_MEMBER)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_ENUM_MEMBER, (peer: KNativePointer) => new TSEnumMember(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSExternalModuleReference.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSExternalModuleReference.ts new file mode 100644 index 0000000000000000000000000000000000000000..5c4efa4b8b0a14d4121c2dacd087a714cadd609d --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSExternalModuleReference.ts @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +export class TSExternalModuleReference extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 88) + super(pointer) + } + static createTSExternalModuleReference(expr?: Expression): TSExternalModuleReference { + return new TSExternalModuleReference(global.generatedEs2panda._CreateTSExternalModuleReference(global.context, passNode(expr))) + } + static updateTSExternalModuleReference(original?: TSExternalModuleReference, expr?: Expression): TSExternalModuleReference { + return new TSExternalModuleReference(global.generatedEs2panda._UpdateTSExternalModuleReference(global.context, passNode(original), passNode(expr))) + } + get expr(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSExternalModuleReferenceExprConst(global.context, this.peer)) + } +} +export function isTSExternalModuleReference(node: object | undefined): node is TSExternalModuleReference { + return node instanceof TSExternalModuleReference +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_EXTERNAL_MODULE_REFERENCE)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_EXTERNAL_MODULE_REFERENCE, (peer: KNativePointer) => new TSExternalModuleReference(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSFunctionType.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSFunctionType.ts new file mode 100644 index 0000000000000000000000000000000000000000..c4985850f1b8858038c4d19f9001145146de776d --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSFunctionType.ts @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { FunctionSignature } from "./FunctionSignature" +import { TSTypeParameterDeclaration } from "./TSTypeParameterDeclaration" +import { TypeNode } from "./TypeNode" +export class TSFunctionType extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 124) + super(pointer) + } + static createTSFunctionType(signature?: FunctionSignature): TSFunctionType { + return new TSFunctionType(global.generatedEs2panda._CreateTSFunctionType(global.context, passNode(signature))) + } + static updateTSFunctionType(original?: TSFunctionType, signature?: FunctionSignature): TSFunctionType { + return new TSFunctionType(global.generatedEs2panda._UpdateTSFunctionType(global.context, passNode(original), passNode(signature))) + } + get typeParams(): TSTypeParameterDeclaration | undefined { + return unpackNode(global.generatedEs2panda._TSFunctionTypeTypeParams(global.context, this.peer)) + } + get params(): readonly Expression[] { + return unpackNodeArray(global.generatedEs2panda._TSFunctionTypeParamsConst(global.context, this.peer)) + } + get returnType(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._TSFunctionTypeReturnType(global.context, this.peer)) + } + /** @deprecated */ + setNullable(nullable: boolean): this { + global.generatedEs2panda._TSFunctionTypeSetNullable(global.context, this.peer, nullable) + return this + } +} +export function isTSFunctionType(node: object | undefined): node is TSFunctionType { + return node instanceof TSFunctionType +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_FUNCTION_TYPE)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_FUNCTION_TYPE, (peer: KNativePointer) => new TSFunctionType(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSImportEqualsDeclaration.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSImportEqualsDeclaration.ts new file mode 100644 index 0000000000000000000000000000000000000000..282f832fc2c0c04c731642260f2c1bd8eca3e558 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSImportEqualsDeclaration.ts @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { Identifier } from "./Identifier" +import { Statement } from "./Statement" +export class TSImportEqualsDeclaration extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 123) + super(pointer) + } + static createTSImportEqualsDeclaration(id: Identifier | undefined, moduleReference: Expression | undefined, isExport: boolean): TSImportEqualsDeclaration { + return new TSImportEqualsDeclaration(global.generatedEs2panda._CreateTSImportEqualsDeclaration(global.context, passNode(id), passNode(moduleReference), isExport)) + } + static updateTSImportEqualsDeclaration(original: TSImportEqualsDeclaration | undefined, id: Identifier | undefined, moduleReference: Expression | undefined, isExport: boolean): TSImportEqualsDeclaration { + return new TSImportEqualsDeclaration(global.generatedEs2panda._UpdateTSImportEqualsDeclaration(global.context, passNode(original), passNode(id), passNode(moduleReference), isExport)) + } + get id(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._TSImportEqualsDeclarationIdConst(global.context, this.peer)) + } + get moduleReference(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSImportEqualsDeclarationModuleReferenceConst(global.context, this.peer)) + } + get isExport(): boolean { + return global.generatedEs2panda._TSImportEqualsDeclarationIsExportConst(global.context, this.peer) + } +} +export function isTSImportEqualsDeclaration(node: object | undefined): node is TSImportEqualsDeclaration { + return node instanceof TSImportEqualsDeclaration +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_IMPORT_EQUALS_DECLARATION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_IMPORT_EQUALS_DECLARATION, (peer: KNativePointer) => new TSImportEqualsDeclaration(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSImportType.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSImportType.ts new file mode 100644 index 0000000000000000000000000000000000000000..7f240cfd5352ab6e44175f0ccaa9945b73d72c68 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSImportType.ts @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { TSTypeParameterInstantiation } from "./TSTypeParameterInstantiation" +import { TypeNode } from "./TypeNode" +export class TSImportType extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 111) + super(pointer) + } + static createTSImportType(param: Expression | undefined, typeParams: TSTypeParameterInstantiation | undefined, qualifier: Expression | undefined, isTypeof: boolean): TSImportType { + return new TSImportType(global.generatedEs2panda._CreateTSImportType(global.context, passNode(param), passNode(typeParams), passNode(qualifier), isTypeof)) + } + static updateTSImportType(original: TSImportType | undefined, param: Expression | undefined, typeParams: TSTypeParameterInstantiation | undefined, qualifier: Expression | undefined, isTypeof: boolean): TSImportType { + return new TSImportType(global.generatedEs2panda._UpdateTSImportType(global.context, passNode(original), passNode(param), passNode(typeParams), passNode(qualifier), isTypeof)) + } + get param(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSImportTypeParamConst(global.context, this.peer)) + } + get typeParams(): TSTypeParameterInstantiation | undefined { + return unpackNode(global.generatedEs2panda._TSImportTypeTypeParamsConst(global.context, this.peer)) + } + get qualifier(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSImportTypeQualifierConst(global.context, this.peer)) + } + get isTypeof(): boolean { + return global.generatedEs2panda._TSImportTypeIsTypeofConst(global.context, this.peer) + } +} +export function isTSImportType(node: object | undefined): node is TSImportType { + return node instanceof TSImportType +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_IMPORT_TYPE)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_IMPORT_TYPE, (peer: KNativePointer) => new TSImportType(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSIndexSignature.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSIndexSignature.ts new file mode 100644 index 0000000000000000000000000000000000000000..b3b2040a61e306360c3ba4acfa29d7e1da789806 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSIndexSignature.ts @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Es2pandaTSIndexSignatureKind } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { TypeNode } from "./TypeNode" +import { TypedAstNode } from "./TypedAstNode" +export class TSIndexSignature extends TypedAstNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 135) + super(pointer) + } + static createTSIndexSignature(param: Expression | undefined, typeAnnotation: TypeNode | undefined, readonly_arg: boolean): TSIndexSignature { + return new TSIndexSignature(global.generatedEs2panda._CreateTSIndexSignature(global.context, passNode(param), passNode(typeAnnotation), readonly_arg)) + } + static updateTSIndexSignature(original: TSIndexSignature | undefined, param: Expression | undefined, typeAnnotation: TypeNode | undefined, readonly_arg: boolean): TSIndexSignature { + return new TSIndexSignature(global.generatedEs2panda._UpdateTSIndexSignature(global.context, passNode(original), passNode(param), passNode(typeAnnotation), readonly_arg)) + } + get param(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSIndexSignatureParamConst(global.context, this.peer)) + } + get typeAnnotation(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._TSIndexSignatureTypeAnnotationConst(global.context, this.peer)) + } + get readonly(): boolean { + return global.generatedEs2panda._TSIndexSignatureReadonlyConst(global.context, this.peer) + } + get kind(): Es2pandaTSIndexSignatureKind { + return global.generatedEs2panda._TSIndexSignatureKindConst(global.context, this.peer) + } +} +export function isTSIndexSignature(node: object | undefined): node is TSIndexSignature { + return node instanceof TSIndexSignature +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_INDEX_SIGNATURE)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_INDEX_SIGNATURE, (peer: KNativePointer) => new TSIndexSignature(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSIndexedAccessType.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSIndexedAccessType.ts new file mode 100644 index 0000000000000000000000000000000000000000..360c2e763b070c2f54fb651c606349ab397553ff --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSIndexedAccessType.ts @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { TypeNode } from "./TypeNode" +export class TSIndexedAccessType extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 129) + super(pointer) + } + static createTSIndexedAccessType(objectType?: TypeNode, indexType?: TypeNode): TSIndexedAccessType { + return new TSIndexedAccessType(global.generatedEs2panda._CreateTSIndexedAccessType(global.context, passNode(objectType), passNode(indexType))) + } + static updateTSIndexedAccessType(original?: TSIndexedAccessType, objectType?: TypeNode, indexType?: TypeNode): TSIndexedAccessType { + return new TSIndexedAccessType(global.generatedEs2panda._UpdateTSIndexedAccessType(global.context, passNode(original), passNode(objectType), passNode(indexType))) + } + get objectType(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._TSIndexedAccessTypeObjectTypeConst(global.context, this.peer)) + } + get indexType(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._TSIndexedAccessTypeIndexTypeConst(global.context, this.peer)) + } +} +export function isTSIndexedAccessType(node: object | undefined): node is TSIndexedAccessType { + return node instanceof TSIndexedAccessType +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_INDEXED_ACCESS_TYPE)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_INDEXED_ACCESS_TYPE, (peer: KNativePointer) => new TSIndexedAccessType(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSInferType.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSInferType.ts new file mode 100644 index 0000000000000000000000000000000000000000..1642b52242bc1b801bef50633c6a8fa1c8a22dde --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSInferType.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { TSTypeParameter } from "./TSTypeParameter" +import { TypeNode } from "./TypeNode" +export class TSInferType extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 109) + super(pointer) + } + static createTSInferType(typeParam?: TSTypeParameter): TSInferType { + return new TSInferType(global.generatedEs2panda._CreateTSInferType(global.context, passNode(typeParam))) + } + static updateTSInferType(original?: TSInferType, typeParam?: TSTypeParameter): TSInferType { + return new TSInferType(global.generatedEs2panda._UpdateTSInferType(global.context, passNode(original), passNode(typeParam))) + } + get typeParam(): TSTypeParameter | undefined { + return unpackNode(global.generatedEs2panda._TSInferTypeTypeParamConst(global.context, this.peer)) + } +} +export function isTSInferType(node: object | undefined): node is TSInferType { + return node instanceof TSInferType +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_INFER_TYPE)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_INFER_TYPE, (peer: KNativePointer) => new TSInferType(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSInterfaceBody.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSInterfaceBody.ts new file mode 100644 index 0000000000000000000000000000000000000000..74e5c680c8fb90282380f0ddc59ad82ed3342fe6 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSInterfaceBody.ts @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +export class TSInterfaceBody extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 131) + super(pointer) + } + static createTSInterfaceBody(body: readonly AstNode[]): TSInterfaceBody { + return new TSInterfaceBody(global.generatedEs2panda._CreateTSInterfaceBody(global.context, passNodeArray(body), body.length)) + } + static updateTSInterfaceBody(original: TSInterfaceBody | undefined, body: readonly AstNode[]): TSInterfaceBody { + return new TSInterfaceBody(global.generatedEs2panda._UpdateTSInterfaceBody(global.context, passNode(original), passNodeArray(body), body.length)) + } + get body(): readonly AstNode[] { + return unpackNodeArray(global.generatedEs2panda._TSInterfaceBodyBody(global.context, this.peer)) + } +} +export function isTSInterfaceBody(node: object | undefined): node is TSInterfaceBody { + return node instanceof TSInterfaceBody +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_INTERFACE_BODY)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_INTERFACE_BODY, (peer: KNativePointer) => new TSInterfaceBody(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSInterfaceDeclaration.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSInterfaceDeclaration.ts new file mode 100644 index 0000000000000000000000000000000000000000..bfa80ac52d80528d58c0d12cf242ad1b3e848a38 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSInterfaceDeclaration.ts @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { AnnotationUsage } from "./AnnotationUsage" +import { ClassDeclaration } from "./ClassDeclaration" +import { Decorator } from "./Decorator" +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Identifier } from "./Identifier" +import { TSInterfaceBody } from "./TSInterfaceBody" +import { TSInterfaceHeritage } from "./TSInterfaceHeritage" +import { TSTypeParameterDeclaration } from "./TSTypeParameterDeclaration" +import { TypedStatement } from "./TypedStatement" +export class TSInterfaceDeclaration extends TypedStatement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 130) + super(pointer) + } + static createTSInterfaceDeclaration(_extends: readonly TSInterfaceHeritage[], id: AstNode | undefined, typeParams: AstNode | undefined, body: AstNode | undefined, isStatic: boolean, isExternal: boolean): TSInterfaceDeclaration { + return new TSInterfaceDeclaration(global.generatedEs2panda._CreateTSInterfaceDeclaration(global.context, passNodeArray(_extends), _extends.length, passNode(id), passNode(typeParams), passNode(body), isStatic, isExternal)) + } + static updateTSInterfaceDeclaration(original: TSInterfaceDeclaration | undefined, _extends: readonly TSInterfaceHeritage[], id: AstNode | undefined, typeParams: AstNode | undefined, body: AstNode | undefined, isStatic: boolean, isExternal: boolean): TSInterfaceDeclaration { + return new TSInterfaceDeclaration(global.generatedEs2panda._UpdateTSInterfaceDeclaration(global.context, passNode(original), passNodeArray(_extends), _extends.length, passNode(id), passNode(typeParams), passNode(body), isStatic, isExternal)) + } + get body(): TSInterfaceBody | undefined { + return unpackNode(global.generatedEs2panda._TSInterfaceDeclarationBody(global.context, this.peer)) + } + get id(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._TSInterfaceDeclarationId(global.context, this.peer)) + } + get internalName(): string { + return unpackString(global.generatedEs2panda._TSInterfaceDeclarationInternalNameConst(global.context, this.peer)) + } + /** @deprecated */ + setInternalName(internalName: string): this { + global.generatedEs2panda._TSInterfaceDeclarationSetInternalName(global.context, this.peer, internalName) + return this + } + get isStatic(): boolean { + return global.generatedEs2panda._TSInterfaceDeclarationIsStaticConst(global.context, this.peer) + } + get isFromExternal(): boolean { + return global.generatedEs2panda._TSInterfaceDeclarationIsFromExternalConst(global.context, this.peer) + } + get typeParams(): TSTypeParameterDeclaration | undefined { + return unpackNode(global.generatedEs2panda._TSInterfaceDeclarationTypeParams(global.context, this.peer)) + } + get extends(): readonly TSInterfaceHeritage[] { + return unpackNodeArray(global.generatedEs2panda._TSInterfaceDeclarationExtends(global.context, this.peer)) + } + get decorators(): readonly Decorator[] { + return unpackNodeArray(global.generatedEs2panda._TSInterfaceDeclarationDecoratorsConst(global.context, this.peer)) + } + get anonClass(): ClassDeclaration | undefined { + return unpackNode(global.generatedEs2panda._TSInterfaceDeclarationGetAnonClass(global.context, this.peer)) + } + /** @deprecated */ + setAnonClass(anonClass?: ClassDeclaration): this { + global.generatedEs2panda._TSInterfaceDeclarationSetAnonClass(global.context, this.peer, passNode(anonClass)) + return this + } + get annotations(): readonly AnnotationUsage[] { + return unpackNodeArray(global.generatedEs2panda._TSInterfaceDeclarationAnnotations(global.context, this.peer)) + } + /** @deprecated */ + setAnnotations(annotations: readonly AnnotationUsage[]): this { + global.generatedEs2panda._TSInterfaceDeclarationSetAnnotations(global.context, this.peer, passNodeArray(annotations), annotations.length) + return this + } +} +export function isTSInterfaceDeclaration(node: object | undefined): node is TSInterfaceDeclaration { + return node instanceof TSInterfaceDeclaration +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_INTERFACE_DECLARATION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_INTERFACE_DECLARATION, (peer: KNativePointer) => new TSInterfaceDeclaration(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSInterfaceHeritage.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSInterfaceHeritage.ts new file mode 100644 index 0000000000000000000000000000000000000000..41ae5ee2ee6e4f889a0a1be3b6ca16238668430b --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSInterfaceHeritage.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { TypeNode } from "./TypeNode" +export class TSInterfaceHeritage extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 132) + super(pointer) + } + static createTSInterfaceHeritage(expr?: TypeNode): TSInterfaceHeritage { + return new TSInterfaceHeritage(global.generatedEs2panda._CreateTSInterfaceHeritage(global.context, passNode(expr))) + } + static updateTSInterfaceHeritage(original?: TSInterfaceHeritage, expr?: TypeNode): TSInterfaceHeritage { + return new TSInterfaceHeritage(global.generatedEs2panda._UpdateTSInterfaceHeritage(global.context, passNode(original), passNode(expr))) + } + get expr(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._TSInterfaceHeritageExpr(global.context, this.peer)) + } +} +export function isTSInterfaceHeritage(node: object | undefined): node is TSInterfaceHeritage { + return node instanceof TSInterfaceHeritage +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_INTERFACE_HERITAGE)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_INTERFACE_HERITAGE, (peer: KNativePointer) => new TSInterfaceHeritage(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSIntersectionType.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSIntersectionType.ts new file mode 100644 index 0000000000000000000000000000000000000000..7e5b7c0766357672719fa4ad829a3a9cb09a8676 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSIntersectionType.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { TypeNode } from "./TypeNode" +export class TSIntersectionType extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 112) + super(pointer) + } + static createTSIntersectionType(types: readonly Expression[]): TSIntersectionType { + return new TSIntersectionType(global.generatedEs2panda._CreateTSIntersectionType(global.context, passNodeArray(types), types.length)) + } + static updateTSIntersectionType(original: TSIntersectionType | undefined, types: readonly Expression[]): TSIntersectionType { + return new TSIntersectionType(global.generatedEs2panda._UpdateTSIntersectionType(global.context, passNode(original), passNodeArray(types), types.length)) + } + get types(): readonly Expression[] { + return unpackNodeArray(global.generatedEs2panda._TSIntersectionTypeTypesConst(global.context, this.peer)) + } +} +export function isTSIntersectionType(node: object | undefined): node is TSIntersectionType { + return node instanceof TSIntersectionType +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_INTERSECTION_TYPE)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_INTERSECTION_TYPE, (peer: KNativePointer) => new TSIntersectionType(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSLiteralType.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSLiteralType.ts new file mode 100644 index 0000000000000000000000000000000000000000..ca345e4e00784d3da5a66bd5b25328ca880ca56b --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSLiteralType.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { TypeNode } from "./TypeNode" +export class TSLiteralType extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 108) + super(pointer) + } + static createTSLiteralType(literal?: Expression): TSLiteralType { + return new TSLiteralType(global.generatedEs2panda._CreateTSLiteralType(global.context, passNode(literal))) + } + static updateTSLiteralType(original?: TSLiteralType, literal?: Expression): TSLiteralType { + return new TSLiteralType(global.generatedEs2panda._UpdateTSLiteralType(global.context, passNode(original), passNode(literal))) + } + get literal(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSLiteralTypeLiteralConst(global.context, this.peer)) + } +} +export function isTSLiteralType(node: object | undefined): node is TSLiteralType { + return node instanceof TSLiteralType +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_LITERAL_TYPE)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_LITERAL_TYPE, (peer: KNativePointer) => new TSLiteralType(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSMappedType.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSMappedType.ts new file mode 100644 index 0000000000000000000000000000000000000000..c8cd77decc8ed1bc499b35a2560dd9e86e513686 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSMappedType.ts @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Es2pandaMappedOption } from "./../Es2pandaEnums" +import { TSTypeParameter } from "./TSTypeParameter" +import { TypeNode } from "./TypeNode" +export class TSMappedType extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 113) + super(pointer) + } + static createTSMappedType(typeParameter: TSTypeParameter | undefined, typeAnnotation: TypeNode | undefined, readonly_arg: Es2pandaMappedOption, optional_arg: Es2pandaMappedOption): TSMappedType { + return new TSMappedType(global.generatedEs2panda._CreateTSMappedType(global.context, passNode(typeParameter), passNode(typeAnnotation), readonly_arg, optional_arg)) + } + static updateTSMappedType(original: TSMappedType | undefined, typeParameter: TSTypeParameter | undefined, typeAnnotation: TypeNode | undefined, readonly_arg: Es2pandaMappedOption, optional_arg: Es2pandaMappedOption): TSMappedType { + return new TSMappedType(global.generatedEs2panda._UpdateTSMappedType(global.context, passNode(original), passNode(typeParameter), passNode(typeAnnotation), readonly_arg, optional_arg)) + } + get typeParameter(): TSTypeParameter | undefined { + return unpackNode(global.generatedEs2panda._TSMappedTypeTypeParameter(global.context, this.peer)) + } + get typeAnnotation(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._TSMappedTypeTypeAnnotation(global.context, this.peer)) + } + get readonly(): Es2pandaMappedOption { + return global.generatedEs2panda._TSMappedTypeReadonly(global.context, this.peer) + } + get optional(): Es2pandaMappedOption { + return global.generatedEs2panda._TSMappedTypeOptional(global.context, this.peer) + } +} +export function isTSMappedType(node: object | undefined): node is TSMappedType { + return node instanceof TSMappedType +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_MAPPED_TYPE)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_MAPPED_TYPE, (peer: KNativePointer) => new TSMappedType(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSMethodSignature.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSMethodSignature.ts new file mode 100644 index 0000000000000000000000000000000000000000..1188cd18e89c6dfae808302b2fa40845d4f77160 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSMethodSignature.ts @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { FunctionSignature } from "./FunctionSignature" +import { TSTypeParameterDeclaration } from "./TSTypeParameterDeclaration" +import { TypeNode } from "./TypeNode" +export class TSMethodSignature extends AstNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 105) + super(pointer) + } + static createTSMethodSignature(key: Expression | undefined, signature: FunctionSignature | undefined, computed: boolean, optional_arg: boolean): TSMethodSignature { + return new TSMethodSignature(global.generatedEs2panda._CreateTSMethodSignature(global.context, passNode(key), passNode(signature), computed, optional_arg)) + } + static updateTSMethodSignature(original: TSMethodSignature | undefined, key: Expression | undefined, signature: FunctionSignature | undefined, computed: boolean, optional_arg: boolean): TSMethodSignature { + return new TSMethodSignature(global.generatedEs2panda._UpdateTSMethodSignature(global.context, passNode(original), passNode(key), passNode(signature), computed, optional_arg)) + } + get key(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSMethodSignatureKey(global.context, this.peer)) + } + get typeParams(): TSTypeParameterDeclaration | undefined { + return unpackNode(global.generatedEs2panda._TSMethodSignatureTypeParams(global.context, this.peer)) + } + get params(): readonly Expression[] { + return unpackNodeArray(global.generatedEs2panda._TSMethodSignatureParamsConst(global.context, this.peer)) + } + get returnTypeAnnotation(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._TSMethodSignatureReturnTypeAnnotation(global.context, this.peer)) + } + get computed(): boolean { + return global.generatedEs2panda._TSMethodSignatureComputedConst(global.context, this.peer) + } + get optional(): boolean { + return global.generatedEs2panda._TSMethodSignatureOptionalConst(global.context, this.peer) + } +} +export function isTSMethodSignature(node: object | undefined): node is TSMethodSignature { + return node instanceof TSMethodSignature +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_METHOD_SIGNATURE)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_METHOD_SIGNATURE, (peer: KNativePointer) => new TSMethodSignature(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSModuleBlock.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSModuleBlock.ts new file mode 100644 index 0000000000000000000000000000000000000000..1e1c58111f413c88fefa4cdd001d8fb134f500c9 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSModuleBlock.ts @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Statement } from "./Statement" +export class TSModuleBlock extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 114) + super(pointer) + } + static createTSModuleBlock(statements: readonly Statement[]): TSModuleBlock { + return new TSModuleBlock(global.generatedEs2panda._CreateTSModuleBlock(global.context, passNodeArray(statements), statements.length)) + } + static updateTSModuleBlock(original: TSModuleBlock | undefined, statements: readonly Statement[]): TSModuleBlock { + return new TSModuleBlock(global.generatedEs2panda._UpdateTSModuleBlock(global.context, passNode(original), passNodeArray(statements), statements.length)) + } + get statements(): readonly Statement[] { + return unpackNodeArray(global.generatedEs2panda._TSModuleBlockStatementsConst(global.context, this.peer)) + } +} +export function isTSModuleBlock(node: object | undefined): node is TSModuleBlock { + return node instanceof TSModuleBlock +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_MODULE_BLOCK)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_MODULE_BLOCK, (peer: KNativePointer) => new TSModuleBlock(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSModuleDeclaration.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSModuleDeclaration.ts new file mode 100644 index 0000000000000000000000000000000000000000..58cc7ccd05da0f7cf8180b75f00035a5b6882cc9 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSModuleDeclaration.ts @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { Statement } from "./Statement" +export class TSModuleDeclaration extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 122) + super(pointer) + } + static createTSModuleDeclaration(name: Expression | undefined, body: Statement | undefined, declare: boolean, _global: boolean): TSModuleDeclaration { + return new TSModuleDeclaration(global.generatedEs2panda._CreateTSModuleDeclaration(global.context, passNode(name), passNode(body), declare, _global)) + } + static updateTSModuleDeclaration(original: TSModuleDeclaration | undefined, name: Expression | undefined, body: Statement | undefined, declare: boolean, _global: boolean): TSModuleDeclaration { + return new TSModuleDeclaration(global.generatedEs2panda._UpdateTSModuleDeclaration(global.context, passNode(original), passNode(name), passNode(body), declare, _global)) + } + get name(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSModuleDeclarationNameConst(global.context, this.peer)) + } + get body(): Statement | undefined { + return unpackNode(global.generatedEs2panda._TSModuleDeclarationBodyConst(global.context, this.peer)) + } + get global(): boolean { + return global.generatedEs2panda._TSModuleDeclarationGlobalConst(global.context, this.peer) + } + get isExternalOrAmbient(): boolean { + return global.generatedEs2panda._TSModuleDeclarationIsExternalOrAmbientConst(global.context, this.peer) + } +} +export function isTSModuleDeclaration(node: object | undefined): node is TSModuleDeclaration { + return node instanceof TSModuleDeclaration +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_MODULE_DECLARATION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_MODULE_DECLARATION, (peer: KNativePointer) => new TSModuleDeclaration(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSNamedTupleMember.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSNamedTupleMember.ts new file mode 100644 index 0000000000000000000000000000000000000000..29c3e25d9450088d83733d85bbc0d75dc455deae --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSNamedTupleMember.ts @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { TypeNode } from "./TypeNode" +export class TSNamedTupleMember extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 134) + super(pointer) + } + static createTSNamedTupleMember(label: Expression | undefined, elementType: TypeNode | undefined, optional_arg: boolean): TSNamedTupleMember { + return new TSNamedTupleMember(global.generatedEs2panda._CreateTSNamedTupleMember(global.context, passNode(label), passNode(elementType), optional_arg)) + } + static updateTSNamedTupleMember(original: TSNamedTupleMember | undefined, label: Expression | undefined, elementType: TypeNode | undefined, optional_arg: boolean): TSNamedTupleMember { + return new TSNamedTupleMember(global.generatedEs2panda._UpdateTSNamedTupleMember(global.context, passNode(original), passNode(label), passNode(elementType), optional_arg)) + } + get label(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSNamedTupleMemberLabelConst(global.context, this.peer)) + } + get elementType(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._TSNamedTupleMemberElementType(global.context, this.peer)) + } + get isOptional(): boolean { + return global.generatedEs2panda._TSNamedTupleMemberIsOptionalConst(global.context, this.peer) + } +} +export function isTSNamedTupleMember(node: object | undefined): node is TSNamedTupleMember { + return node instanceof TSNamedTupleMember +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_NAMED_TUPLE_MEMBER)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_NAMED_TUPLE_MEMBER, (peer: KNativePointer) => new TSNamedTupleMember(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSNeverKeyword.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSNeverKeyword.ts new file mode 100644 index 0000000000000000000000000000000000000000..5ab05cb6527dbc3d9c237c3bd46bd5139d03ed04 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSNeverKeyword.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { TypeNode } from "./TypeNode" +export class TSNeverKeyword extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 98) + super(pointer) + } + static createTSNeverKeyword(): TSNeverKeyword { + return new TSNeverKeyword(global.generatedEs2panda._CreateTSNeverKeyword(global.context)) + } + static updateTSNeverKeyword(original?: TSNeverKeyword): TSNeverKeyword { + return new TSNeverKeyword(global.generatedEs2panda._UpdateTSNeverKeyword(global.context, passNode(original))) + } +} +export function isTSNeverKeyword(node: object | undefined): node is TSNeverKeyword { + return node instanceof TSNeverKeyword +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_NEVER_KEYWORD)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_NEVER_KEYWORD, (peer: KNativePointer) => new TSNeverKeyword(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSNonNullExpression.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSNonNullExpression.ts new file mode 100644 index 0000000000000000000000000000000000000000..38c775419d574f095f2e5535dfe6ee97c91aa7eb --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSNonNullExpression.ts @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +export class TSNonNullExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 99) + super(pointer) + } + static createTSNonNullExpression(expr?: Expression): TSNonNullExpression { + return new TSNonNullExpression(global.generatedEs2panda._CreateTSNonNullExpression(global.context, passNode(expr))) + } + static updateTSNonNullExpression(original?: TSNonNullExpression, expr?: Expression): TSNonNullExpression { + return new TSNonNullExpression(global.generatedEs2panda._UpdateTSNonNullExpression(global.context, passNode(original), passNode(expr))) + } + get expr(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSNonNullExpressionExpr(global.context, this.peer)) + } + /** @deprecated */ + setExpr(expr?: Expression): this { + global.generatedEs2panda._TSNonNullExpressionSetExpr(global.context, this.peer, passNode(expr)) + return this + } +} +export function isTSNonNullExpression(node: object | undefined): node is TSNonNullExpression { + return node instanceof TSNonNullExpression +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_NON_NULL_EXPRESSION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_NON_NULL_EXPRESSION, (peer: KNativePointer) => new TSNonNullExpression(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSNullKeyword.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSNullKeyword.ts new file mode 100644 index 0000000000000000000000000000000000000000..974d5e3b07c76f7bad3d8f6939c9fb8d0668b20e --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSNullKeyword.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { TypeNode } from "./TypeNode" +export class TSNullKeyword extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 100) + super(pointer) + } + static createTSNullKeyword(): TSNullKeyword { + return new TSNullKeyword(global.generatedEs2panda._CreateTSNullKeyword(global.context)) + } + static updateTSNullKeyword(original?: TSNullKeyword): TSNullKeyword { + return new TSNullKeyword(global.generatedEs2panda._UpdateTSNullKeyword(global.context, passNode(original))) + } +} +export function isTSNullKeyword(node: object | undefined): node is TSNullKeyword { + return node instanceof TSNullKeyword +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_NULL_KEYWORD)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_NULL_KEYWORD, (peer: KNativePointer) => new TSNullKeyword(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSNumberKeyword.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSNumberKeyword.ts new file mode 100644 index 0000000000000000000000000000000000000000..051bf39808bdc40cf2c1d16d5802b14ee298ea22 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSNumberKeyword.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { TypeNode } from "./TypeNode" +export class TSNumberKeyword extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 89) + super(pointer) + } + static createTSNumberKeyword(): TSNumberKeyword { + return new TSNumberKeyword(global.generatedEs2panda._CreateTSNumberKeyword(global.context)) + } + static updateTSNumberKeyword(original?: TSNumberKeyword): TSNumberKeyword { + return new TSNumberKeyword(global.generatedEs2panda._UpdateTSNumberKeyword(global.context, passNode(original))) + } +} +export function isTSNumberKeyword(node: object | undefined): node is TSNumberKeyword { + return node instanceof TSNumberKeyword +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_NUMBER_KEYWORD)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_NUMBER_KEYWORD, (peer: KNativePointer) => new TSNumberKeyword(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSObjectKeyword.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSObjectKeyword.ts new file mode 100644 index 0000000000000000000000000000000000000000..a2c378cbde0d3038da9630a5fbb03172719206f9 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSObjectKeyword.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { TypeNode } from "./TypeNode" +export class TSObjectKeyword extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 96) + super(pointer) + } + static createTSObjectKeyword(): TSObjectKeyword { + return new TSObjectKeyword(global.generatedEs2panda._CreateTSObjectKeyword(global.context)) + } + static updateTSObjectKeyword(original?: TSObjectKeyword): TSObjectKeyword { + return new TSObjectKeyword(global.generatedEs2panda._UpdateTSObjectKeyword(global.context, passNode(original))) + } +} +export function isTSObjectKeyword(node: object | undefined): node is TSObjectKeyword { + return node instanceof TSObjectKeyword +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_OBJECT_KEYWORD)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_OBJECT_KEYWORD, (peer: KNativePointer) => new TSObjectKeyword(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSParameterProperty.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSParameterProperty.ts new file mode 100644 index 0000000000000000000000000000000000000000..dcab958228ef6cd06cfcd328b7fbb6f03ee97e04 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSParameterProperty.ts @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAccessibilityOption } from "./../Es2pandaEnums" +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +export class TSParameterProperty extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 121) + super(pointer) + } + static createTSParameterProperty(accessibility: Es2pandaAccessibilityOption, parameter: Expression | undefined, readonly_arg: boolean, isStatic: boolean, isExport: boolean): TSParameterProperty { + return new TSParameterProperty(global.generatedEs2panda._CreateTSParameterProperty(global.context, accessibility, passNode(parameter), readonly_arg, isStatic, isExport)) + } + static updateTSParameterProperty(original: TSParameterProperty | undefined, accessibility: Es2pandaAccessibilityOption, parameter: Expression | undefined, readonly_arg: boolean, isStatic: boolean, isExport: boolean): TSParameterProperty { + return new TSParameterProperty(global.generatedEs2panda._UpdateTSParameterProperty(global.context, passNode(original), accessibility, passNode(parameter), readonly_arg, isStatic, isExport)) + } + get accessibility(): Es2pandaAccessibilityOption { + return global.generatedEs2panda._TSParameterPropertyAccessibilityConst(global.context, this.peer) + } + get readonly(): boolean { + return global.generatedEs2panda._TSParameterPropertyReadonlyConst(global.context, this.peer) + } + get isStatic(): boolean { + return global.generatedEs2panda._TSParameterPropertyIsStaticConst(global.context, this.peer) + } + get isExport(): boolean { + return global.generatedEs2panda._TSParameterPropertyIsExportConst(global.context, this.peer) + } + get parameter(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSParameterPropertyParameterConst(global.context, this.peer)) + } +} +export function isTSParameterProperty(node: object | undefined): node is TSParameterProperty { + return node instanceof TSParameterProperty +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_PARAMETER_PROPERTY)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_PARAMETER_PROPERTY, (peer: KNativePointer) => new TSParameterProperty(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSParenthesizedType.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSParenthesizedType.ts new file mode 100644 index 0000000000000000000000000000000000000000..320d4ec1a9a15ca7a2443f258af5a25efab2da53 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSParenthesizedType.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { TypeNode } from "./TypeNode" +export class TSParenthesizedType extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 107) + super(pointer) + } + static createTSParenthesizedType(type?: TypeNode): TSParenthesizedType { + return new TSParenthesizedType(global.generatedEs2panda._CreateTSParenthesizedType(global.context, passNode(type))) + } + static updateTSParenthesizedType(original?: TSParenthesizedType, type?: TypeNode): TSParenthesizedType { + return new TSParenthesizedType(global.generatedEs2panda._UpdateTSParenthesizedType(global.context, passNode(original), passNode(type))) + } + get type(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSParenthesizedTypeTypeConst(global.context, this.peer)) + } +} +export function isTSParenthesizedType(node: object | undefined): node is TSParenthesizedType { + return node instanceof TSParenthesizedType +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_PARENT_TYPE)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_PARENT_TYPE, (peer: KNativePointer) => new TSParenthesizedType(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSPropertySignature.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSPropertySignature.ts new file mode 100644 index 0000000000000000000000000000000000000000..f33c6510d8d50cbdd0dbdeecba7288c87b405f2e --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSPropertySignature.ts @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { AnnotatedAstNode } from "./AnnotatedAstNode" +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { TypeNode } from "./TypeNode" +export class TSPropertySignature extends AnnotatedAstNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 104) + super(pointer) + } + static createTSPropertySignature(key: Expression | undefined, typeAnnotation: TypeNode | undefined, computed: boolean, optional_arg: boolean, readonly_arg: boolean): TSPropertySignature { + return new TSPropertySignature(global.generatedEs2panda._CreateTSPropertySignature(global.context, passNode(key), passNode(typeAnnotation), computed, optional_arg, readonly_arg)) + } + static updateTSPropertySignature(original: TSPropertySignature | undefined, key: Expression | undefined, typeAnnotation: TypeNode | undefined, computed: boolean, optional_arg: boolean, readonly_arg: boolean): TSPropertySignature { + return new TSPropertySignature(global.generatedEs2panda._UpdateTSPropertySignature(global.context, passNode(original), passNode(key), passNode(typeAnnotation), computed, optional_arg, readonly_arg)) + } + get key(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSPropertySignatureKey(global.context, this.peer)) + } + get computed(): boolean { + return global.generatedEs2panda._TSPropertySignatureComputedConst(global.context, this.peer) + } + get optional(): boolean { + return global.generatedEs2panda._TSPropertySignatureOptionalConst(global.context, this.peer) + } + get readonly(): boolean { + return global.generatedEs2panda._TSPropertySignatureReadonlyConst(global.context, this.peer) + } + get typeAnnotation(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._TSPropertySignatureTypeAnnotationConst(global.context, this.peer)) + } + /** @deprecated */ + setTsTypeAnnotation(typeAnnotation?: TypeNode): this { + global.generatedEs2panda._TSPropertySignatureSetTsTypeAnnotation(global.context, this.peer, passNode(typeAnnotation)) + return this + } +} +export function isTSPropertySignature(node: object | undefined): node is TSPropertySignature { + return node instanceof TSPropertySignature +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_PROPERTY_SIGNATURE)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_PROPERTY_SIGNATURE, (peer: KNativePointer) => new TSPropertySignature(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSQualifiedName.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSQualifiedName.ts new file mode 100644 index 0000000000000000000000000000000000000000..027cdb9ad0f32f147064ad96fb4aa027dc526079 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSQualifiedName.ts @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { Identifier } from "./Identifier" +export class TSQualifiedName extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 128) + super(pointer) + } + static createTSQualifiedName(left?: Expression, right?: Identifier): TSQualifiedName { + return new TSQualifiedName(global.generatedEs2panda._CreateTSQualifiedName(global.context, passNode(left), passNode(right))) + } + static updateTSQualifiedName(original?: TSQualifiedName, left?: Expression, right?: Identifier): TSQualifiedName { + return new TSQualifiedName(global.generatedEs2panda._UpdateTSQualifiedName(global.context, passNode(original), passNode(left), passNode(right))) + } + get left(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSQualifiedNameLeft(global.context, this.peer)) + } + get right(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._TSQualifiedNameRight(global.context, this.peer)) + } + get name(): string { + return unpackString(global.generatedEs2panda._TSQualifiedNameNameConst(global.context, this.peer)) + } + get resolveLeftMostQualifiedName(): TSQualifiedName | undefined { + return unpackNode(global.generatedEs2panda._TSQualifiedNameResolveLeftMostQualifiedName(global.context, this.peer)) + } +} +export function isTSQualifiedName(node: object | undefined): node is TSQualifiedName { + return node instanceof TSQualifiedName +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_QUALIFIED_NAME)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_QUALIFIED_NAME, (peer: KNativePointer) => new TSQualifiedName(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSSignatureDeclaration.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSSignatureDeclaration.ts new file mode 100644 index 0000000000000000000000000000000000000000..db97f1538094cf46d4d86e8bcec7110a2d299973 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSSignatureDeclaration.ts @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Es2pandaTSSignatureDeclarationKind } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { FunctionSignature } from "./FunctionSignature" +import { TSTypeParameterDeclaration } from "./TSTypeParameterDeclaration" +import { TypeNode } from "./TypeNode" +import { TypedAstNode } from "./TypedAstNode" +export class TSSignatureDeclaration extends TypedAstNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 106) + super(pointer) + } + static createTSSignatureDeclaration(kind: Es2pandaTSSignatureDeclarationKind, signature?: FunctionSignature): TSSignatureDeclaration { + return new TSSignatureDeclaration(global.generatedEs2panda._CreateTSSignatureDeclaration(global.context, kind, passNode(signature))) + } + static updateTSSignatureDeclaration(original: TSSignatureDeclaration | undefined, kind: Es2pandaTSSignatureDeclarationKind, signature?: FunctionSignature): TSSignatureDeclaration { + return new TSSignatureDeclaration(global.generatedEs2panda._UpdateTSSignatureDeclaration(global.context, passNode(original), kind, passNode(signature))) + } + get typeParams(): TSTypeParameterDeclaration | undefined { + return unpackNode(global.generatedEs2panda._TSSignatureDeclarationTypeParams(global.context, this.peer)) + } + get params(): readonly Expression[] { + return unpackNodeArray(global.generatedEs2panda._TSSignatureDeclarationParamsConst(global.context, this.peer)) + } + get returnTypeAnnotation(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._TSSignatureDeclarationReturnTypeAnnotation(global.context, this.peer)) + } + get kind(): Es2pandaTSSignatureDeclarationKind { + return global.generatedEs2panda._TSSignatureDeclarationKindConst(global.context, this.peer) + } +} +export function isTSSignatureDeclaration(node: object | undefined): node is TSSignatureDeclaration { + return node instanceof TSSignatureDeclaration +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_SIGNATURE_DECLARATION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_SIGNATURE_DECLARATION, (peer: KNativePointer) => new TSSignatureDeclaration(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSStringKeyword.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSStringKeyword.ts new file mode 100644 index 0000000000000000000000000000000000000000..4d7c5d2d7c5887d74aab523ba3898fa2cd1046b3 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSStringKeyword.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { TypeNode } from "./TypeNode" +export class TSStringKeyword extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 91) + super(pointer) + } + static createTSStringKeyword(): TSStringKeyword { + return new TSStringKeyword(global.generatedEs2panda._CreateTSStringKeyword(global.context)) + } + static updateTSStringKeyword(original?: TSStringKeyword): TSStringKeyword { + return new TSStringKeyword(global.generatedEs2panda._UpdateTSStringKeyword(global.context, passNode(original))) + } +} +export function isTSStringKeyword(node: object | undefined): node is TSStringKeyword { + return node instanceof TSStringKeyword +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_STRING_KEYWORD)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_STRING_KEYWORD, (peer: KNativePointer) => new TSStringKeyword(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSThisType.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSThisType.ts new file mode 100644 index 0000000000000000000000000000000000000000..9d872f160bcde99ce620457901dd8f8aa8e32081 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSThisType.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { TypeNode } from "./TypeNode" +export class TSThisType extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 115) + super(pointer) + } + static createTSThisType(): TSThisType { + return new TSThisType(global.generatedEs2panda._CreateTSThisType(global.context)) + } + static updateTSThisType(original?: TSThisType): TSThisType { + return new TSThisType(global.generatedEs2panda._UpdateTSThisType(global.context, passNode(original))) + } +} +export function isTSThisType(node: object | undefined): node is TSThisType { + return node instanceof TSThisType +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_THIS_TYPE)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_THIS_TYPE, (peer: KNativePointer) => new TSThisType(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSTupleType.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSTupleType.ts new file mode 100644 index 0000000000000000000000000000000000000000..0073d6aefed0502f775979441a5b858ed0e7b369 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSTupleType.ts @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { TypeNode } from "./TypeNode" +export class TSTupleType extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 133) + super(pointer) + } + static createTSTupleType(elementTypes: readonly TypeNode[]): TSTupleType { + return new TSTupleType(global.generatedEs2panda._CreateTSTupleType(global.context, passNodeArray(elementTypes), elementTypes.length)) + } + static updateTSTupleType(original: TSTupleType | undefined, elementTypes: readonly TypeNode[]): TSTupleType { + return new TSTupleType(global.generatedEs2panda._UpdateTSTupleType(global.context, passNode(original), passNodeArray(elementTypes), elementTypes.length)) + } + get elementType(): readonly TypeNode[] { + return unpackNodeArray(global.generatedEs2panda._TSTupleTypeElementTypeConst(global.context, this.peer)) + } +} +export function isTSTupleType(node: object | undefined): node is TSTupleType { + return node instanceof TSTupleType +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_TUPLE_TYPE)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_TUPLE_TYPE, (peer: KNativePointer) => new TSTupleType(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSTypeAliasDeclaration.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSTypeAliasDeclaration.ts new file mode 100644 index 0000000000000000000000000000000000000000..bd715e14cbfc9c91206915ed93f73c3d2248252b --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSTypeAliasDeclaration.ts @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { AnnotatedStatement } from "./AnnotatedStatement" +import { AnnotationUsage } from "./AnnotationUsage" +import { Decorator } from "./Decorator" +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Identifier } from "./Identifier" +import { TSTypeParameterDeclaration } from "./TSTypeParameterDeclaration" +import { TypeNode } from "./TypeNode" +export class TSTypeAliasDeclaration extends AnnotatedStatement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 126) + super(pointer) + } + static createTSTypeAliasDeclaration(id?: Identifier, typeParams?: TSTypeParameterDeclaration, typeAnnotation?: TypeNode): TSTypeAliasDeclaration { + return new TSTypeAliasDeclaration(global.generatedEs2panda._CreateTSTypeAliasDeclaration(global.context, passNode(id), passNode(typeParams), passNode(typeAnnotation))) + } + static updateTSTypeAliasDeclaration(original?: TSTypeAliasDeclaration, id?: Identifier, typeParams?: TSTypeParameterDeclaration, typeAnnotation?: TypeNode): TSTypeAliasDeclaration { + return new TSTypeAliasDeclaration(global.generatedEs2panda._UpdateTSTypeAliasDeclaration(global.context, passNode(original), passNode(id), passNode(typeParams), passNode(typeAnnotation))) + } + static update1TSTypeAliasDeclaration(original?: TSTypeAliasDeclaration, id?: Identifier): TSTypeAliasDeclaration { + return new TSTypeAliasDeclaration(global.generatedEs2panda._UpdateTSTypeAliasDeclaration1(global.context, passNode(original), passNode(id))) + } + get id(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._TSTypeAliasDeclarationId(global.context, this.peer)) + } + get typeParams(): TSTypeParameterDeclaration | undefined { + return unpackNode(global.generatedEs2panda._TSTypeAliasDeclarationTypeParamsConst(global.context, this.peer)) + } + get decorators(): readonly Decorator[] { + return unpackNodeArray(global.generatedEs2panda._TSTypeAliasDeclarationDecoratorsConst(global.context, this.peer)) + } + /** @deprecated */ + setTypeParameters(typeParams?: TSTypeParameterDeclaration): this { + global.generatedEs2panda._TSTypeAliasDeclarationSetTypeParameters(global.context, this.peer, passNode(typeParams)) + return this + } + get annotations(): readonly AnnotationUsage[] { + return unpackNodeArray(global.generatedEs2panda._TSTypeAliasDeclarationAnnotations(global.context, this.peer)) + } + /** @deprecated */ + setAnnotations(annotations: readonly AnnotationUsage[]): this { + global.generatedEs2panda._TSTypeAliasDeclarationSetAnnotations(global.context, this.peer, passNodeArray(annotations), annotations.length) + return this + } + get typeAnnotation(): TypeNode { + return unpackNonNullableNode(global.generatedEs2panda._TSTypeAliasDeclarationTypeAnnotationConst(global.context, this.peer)) + } + /** @deprecated */ + setTsTypeAnnotation(typeAnnotation?: TypeNode): this { + global.generatedEs2panda._TSTypeAliasDeclarationSetTsTypeAnnotation(global.context, this.peer, passNode(typeAnnotation)) + return this + } +} +export function isTSTypeAliasDeclaration(node: object | undefined): node is TSTypeAliasDeclaration { + return node instanceof TSTypeAliasDeclaration +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_TYPE_ALIAS_DECLARATION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_TYPE_ALIAS_DECLARATION, (peer: KNativePointer) => new TSTypeAliasDeclaration(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSTypeAssertion.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSTypeAssertion.ts new file mode 100644 index 0000000000000000000000000000000000000000..860ceb12bd96b0d91c1346675c6d6b0f1ce70829 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSTypeAssertion.ts @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { AnnotatedExpression } from "./AnnotatedExpression" +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { TypeNode } from "./TypeNode" +export class TSTypeAssertion extends AnnotatedExpression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 139) + super(pointer) + } + static createTSTypeAssertion(typeAnnotation?: TypeNode, expression?: Expression): TSTypeAssertion { + return new TSTypeAssertion(global.generatedEs2panda._CreateTSTypeAssertion(global.context, passNode(typeAnnotation), passNode(expression))) + } + static updateTSTypeAssertion(original?: TSTypeAssertion, typeAnnotation?: TypeNode, expression?: Expression): TSTypeAssertion { + return new TSTypeAssertion(global.generatedEs2panda._UpdateTSTypeAssertion(global.context, passNode(original), passNode(typeAnnotation), passNode(expression))) + } + get expression(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSTypeAssertionGetExpressionConst(global.context, this.peer)) + } + get typeAnnotation(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._TSTypeAssertionTypeAnnotationConst(global.context, this.peer)) + } + /** @deprecated */ + setTsTypeAnnotation(typeAnnotation?: TypeNode): this { + global.generatedEs2panda._TSTypeAssertionSetTsTypeAnnotation(global.context, this.peer, passNode(typeAnnotation)) + return this + } +} +export function isTSTypeAssertion(node: object | undefined): node is TSTypeAssertion { + return node instanceof TSTypeAssertion +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_TYPE_ASSERTION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_TYPE_ASSERTION, (peer: KNativePointer) => new TSTypeAssertion(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSTypeLiteral.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSTypeLiteral.ts new file mode 100644 index 0000000000000000000000000000000000000000..3b0ad66de84bfb65c2498e3afcc93a40f258f5e8 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSTypeLiteral.ts @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { TypeNode } from "./TypeNode" +export class TSTypeLiteral extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 103) + super(pointer) + } + static createTSTypeLiteral(members: readonly AstNode[]): TSTypeLiteral { + return new TSTypeLiteral(global.generatedEs2panda._CreateTSTypeLiteral(global.context, passNodeArray(members), members.length)) + } + static updateTSTypeLiteral(original: TSTypeLiteral | undefined, members: readonly AstNode[]): TSTypeLiteral { + return new TSTypeLiteral(global.generatedEs2panda._UpdateTSTypeLiteral(global.context, passNode(original), passNodeArray(members), members.length)) + } + get members(): readonly AstNode[] { + return unpackNodeArray(global.generatedEs2panda._TSTypeLiteralMembersConst(global.context, this.peer)) + } +} +export function isTSTypeLiteral(node: object | undefined): node is TSTypeLiteral { + return node instanceof TSTypeLiteral +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_TYPE_LITERAL)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_TYPE_LITERAL, (peer: KNativePointer) => new TSTypeLiteral(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSTypeOperator.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSTypeOperator.ts new file mode 100644 index 0000000000000000000000000000000000000000..9c6ef04db44b21e4d88509301423e142036bf02a --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSTypeOperator.ts @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Es2pandaTSOperatorType } from "./../Es2pandaEnums" +import { TypeNode } from "./TypeNode" +export class TSTypeOperator extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 116) + super(pointer) + } + static createTSTypeOperator(type: TypeNode | undefined, operatorType: Es2pandaTSOperatorType): TSTypeOperator { + return new TSTypeOperator(global.generatedEs2panda._CreateTSTypeOperator(global.context, passNode(type), operatorType)) + } + static updateTSTypeOperator(original: TSTypeOperator | undefined, type: TypeNode | undefined, operatorType: Es2pandaTSOperatorType): TSTypeOperator { + return new TSTypeOperator(global.generatedEs2panda._UpdateTSTypeOperator(global.context, passNode(original), passNode(type), operatorType)) + } + get type(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._TSTypeOperatorTypeConst(global.context, this.peer)) + } + get isReadonly(): boolean { + return global.generatedEs2panda._TSTypeOperatorIsReadonlyConst(global.context, this.peer) + } + get isKeyof(): boolean { + return global.generatedEs2panda._TSTypeOperatorIsKeyofConst(global.context, this.peer) + } + get isUnique(): boolean { + return global.generatedEs2panda._TSTypeOperatorIsUniqueConst(global.context, this.peer) + } +} +export function isTSTypeOperator(node: object | undefined): node is TSTypeOperator { + return node instanceof TSTypeOperator +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_TYPE_OPERATOR)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_TYPE_OPERATOR, (peer: KNativePointer) => new TSTypeOperator(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSTypeParameter.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSTypeParameter.ts new file mode 100644 index 0000000000000000000000000000000000000000..9ae3f309fd845cef1204cbe2d7293bbf0bb80bb7 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSTypeParameter.ts @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { AnnotationUsage } from "./AnnotationUsage" +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Es2pandaModifierFlags } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { Identifier } from "./Identifier" +import { TypeNode } from "./TypeNode" +export class TSTypeParameter extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 117) + super(pointer) + } + static create1TSTypeParameter(name: Identifier | undefined, constraint: TypeNode | undefined, defaultType: TypeNode | undefined, flags: Es2pandaModifierFlags): TSTypeParameter { + return new TSTypeParameter(global.generatedEs2panda._CreateTSTypeParameter1(global.context, passNode(name), passNode(constraint), passNode(defaultType), flags)) + } + static updateTSTypeParameter(original?: TSTypeParameter, name?: Identifier, constraint?: TypeNode, defaultType?: TypeNode): TSTypeParameter { + return new TSTypeParameter(global.generatedEs2panda._UpdateTSTypeParameter(global.context, passNode(original), passNode(name), passNode(constraint), passNode(defaultType))) + } + static update1TSTypeParameter(original: TSTypeParameter | undefined, name: Identifier | undefined, constraint: TypeNode | undefined, defaultType: TypeNode | undefined, flags: Es2pandaModifierFlags): TSTypeParameter { + return new TSTypeParameter(global.generatedEs2panda._UpdateTSTypeParameter1(global.context, passNode(original), passNode(name), passNode(constraint), passNode(defaultType), flags)) + } + get name(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._TSTypeParameterName(global.context, this.peer)) + } + get constraint(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._TSTypeParameterConstraint(global.context, this.peer)) + } + /** @deprecated */ + setConstraint(constraint?: TypeNode): this { + global.generatedEs2panda._TSTypeParameterSetConstraint(global.context, this.peer, passNode(constraint)) + return this + } + get defaultType(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._TSTypeParameterDefaultTypeConst(global.context, this.peer)) + } + /** @deprecated */ + setDefaultType(defaultType?: TypeNode): this { + global.generatedEs2panda._TSTypeParameterSetDefaultType(global.context, this.peer, passNode(defaultType)) + return this + } + get annotations(): readonly AnnotationUsage[] { + return unpackNodeArray(global.generatedEs2panda._TSTypeParameterAnnotations(global.context, this.peer)) + } + /** @deprecated */ + setAnnotations(annotations: readonly AnnotationUsage[]): this { + global.generatedEs2panda._TSTypeParameterSetAnnotations(global.context, this.peer, passNodeArray(annotations), annotations.length) + return this + } +} +export function isTSTypeParameter(node: object | undefined): node is TSTypeParameter { + return node instanceof TSTypeParameter +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_TYPE_PARAMETER)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_TYPE_PARAMETER, (peer: KNativePointer) => new TSTypeParameter(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSTypeParameterDeclaration.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSTypeParameterDeclaration.ts new file mode 100644 index 0000000000000000000000000000000000000000..303fd99e77e3cb7221bb7ecf435147c0ca8ed4ae --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSTypeParameterDeclaration.ts @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { TSTypeParameter } from "./TSTypeParameter" +export class TSTypeParameterDeclaration extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 118) + super(pointer) + } + static createTSTypeParameterDeclaration(params: readonly TSTypeParameter[], requiredParams: number): TSTypeParameterDeclaration { + return new TSTypeParameterDeclaration(global.generatedEs2panda._CreateTSTypeParameterDeclaration(global.context, passNodeArray(params), params.length, requiredParams)) + } + static updateTSTypeParameterDeclaration(original: TSTypeParameterDeclaration | undefined, params: readonly TSTypeParameter[], requiredParams: number): TSTypeParameterDeclaration { + return new TSTypeParameterDeclaration(global.generatedEs2panda._UpdateTSTypeParameterDeclaration(global.context, passNode(original), passNodeArray(params), params.length, requiredParams)) + } + get params(): readonly TSTypeParameter[] { + return unpackNodeArray(global.generatedEs2panda._TSTypeParameterDeclarationParamsConst(global.context, this.peer)) + } + /** @deprecated */ + addParam(param?: TSTypeParameter): this { + global.generatedEs2panda._TSTypeParameterDeclarationAddParam(global.context, this.peer, passNode(param)) + return this + } + get requiredParams(): number { + return global.generatedEs2panda._TSTypeParameterDeclarationRequiredParamsConst(global.context, this.peer) + } +} +export function isTSTypeParameterDeclaration(node: object | undefined): node is TSTypeParameterDeclaration { + return node instanceof TSTypeParameterDeclaration +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_TYPE_PARAMETER_DECLARATION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_TYPE_PARAMETER_DECLARATION, (peer: KNativePointer) => new TSTypeParameterDeclaration(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSTypeParameterInstantiation.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSTypeParameterInstantiation.ts new file mode 100644 index 0000000000000000000000000000000000000000..3367228d6c3f0f796963b6d4cc4178480eab5150 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSTypeParameterInstantiation.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { TypeNode } from "./TypeNode" +export class TSTypeParameterInstantiation extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 119) + super(pointer) + } + static createTSTypeParameterInstantiation(params: readonly TypeNode[]): TSTypeParameterInstantiation { + return new TSTypeParameterInstantiation(global.generatedEs2panda._CreateTSTypeParameterInstantiation(global.context, passNodeArray(params), params.length)) + } + static updateTSTypeParameterInstantiation(original: TSTypeParameterInstantiation | undefined, params: readonly TypeNode[]): TSTypeParameterInstantiation { + return new TSTypeParameterInstantiation(global.generatedEs2panda._UpdateTSTypeParameterInstantiation(global.context, passNode(original), passNodeArray(params), params.length)) + } + get params(): readonly TypeNode[] { + return unpackNodeArray(global.generatedEs2panda._TSTypeParameterInstantiationParamsConst(global.context, this.peer)) + } +} +export function isTSTypeParameterInstantiation(node: object | undefined): node is TSTypeParameterInstantiation { + return node instanceof TSTypeParameterInstantiation +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_TYPE_PARAMETER_INSTANTIATION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_TYPE_PARAMETER_INSTANTIATION, (peer: KNativePointer) => new TSTypeParameterInstantiation(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSTypePredicate.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSTypePredicate.ts new file mode 100644 index 0000000000000000000000000000000000000000..6ca2b888a98d514aa9f2e62e3ff02270dc2b2a15 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSTypePredicate.ts @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { TypeNode } from "./TypeNode" +export class TSTypePredicate extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 120) + super(pointer) + } + static createTSTypePredicate(parameterName: Expression | undefined, typeAnnotation: TypeNode | undefined, asserts: boolean): TSTypePredicate { + return new TSTypePredicate(global.generatedEs2panda._CreateTSTypePredicate(global.context, passNode(parameterName), passNode(typeAnnotation), asserts)) + } + static updateTSTypePredicate(original: TSTypePredicate | undefined, parameterName: Expression | undefined, typeAnnotation: TypeNode | undefined, asserts: boolean): TSTypePredicate { + return new TSTypePredicate(global.generatedEs2panda._UpdateTSTypePredicate(global.context, passNode(original), passNode(parameterName), passNode(typeAnnotation), asserts)) + } + get parameterName(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSTypePredicateParameterNameConst(global.context, this.peer)) + } + get typeAnnotation(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._TSTypePredicateTypeAnnotationConst(global.context, this.peer)) + } + get asserts(): boolean { + return global.generatedEs2panda._TSTypePredicateAssertsConst(global.context, this.peer) + } +} +export function isTSTypePredicate(node: object | undefined): node is TSTypePredicate { + return node instanceof TSTypePredicate +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_TYPE_PREDICATE)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_TYPE_PREDICATE, (peer: KNativePointer) => new TSTypePredicate(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSTypeQuery.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSTypeQuery.ts new file mode 100644 index 0000000000000000000000000000000000000000..7a4e3957596c5204b70470ddb90ce87d2328718d --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSTypeQuery.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { TypeNode } from "./TypeNode" +export class TSTypeQuery extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 136) + super(pointer) + } + static createTSTypeQuery(exprName?: Expression): TSTypeQuery { + return new TSTypeQuery(global.generatedEs2panda._CreateTSTypeQuery(global.context, passNode(exprName))) + } + static updateTSTypeQuery(original?: TSTypeQuery, exprName?: Expression): TSTypeQuery { + return new TSTypeQuery(global.generatedEs2panda._UpdateTSTypeQuery(global.context, passNode(original), passNode(exprName))) + } + get exprName(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSTypeQueryExprNameConst(global.context, this.peer)) + } +} +export function isTSTypeQuery(node: object | undefined): node is TSTypeQuery { + return node instanceof TSTypeQuery +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_TYPE_QUERY)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_TYPE_QUERY, (peer: KNativePointer) => new TSTypeQuery(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSTypeReference.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSTypeReference.ts new file mode 100644 index 0000000000000000000000000000000000000000..f8ec939454a90e6753867e53053f6ba2b884b867 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSTypeReference.ts @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { Identifier } from "./Identifier" +import { TSTypeParameterInstantiation } from "./TSTypeParameterInstantiation" +import { TypeNode } from "./TypeNode" +export class TSTypeReference extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 127) + super(pointer) + } + static createTSTypeReference(typeName?: Expression, typeParams?: TSTypeParameterInstantiation): TSTypeReference { + return new TSTypeReference(global.generatedEs2panda._CreateTSTypeReference(global.context, passNode(typeName), passNode(typeParams))) + } + static updateTSTypeReference(original?: TSTypeReference, typeName?: Expression, typeParams?: TSTypeParameterInstantiation): TSTypeReference { + return new TSTypeReference(global.generatedEs2panda._UpdateTSTypeReference(global.context, passNode(original), passNode(typeName), passNode(typeParams))) + } + get typeParams(): TSTypeParameterInstantiation | undefined { + return unpackNode(global.generatedEs2panda._TSTypeReferenceTypeParamsConst(global.context, this.peer)) + } + get typeName(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSTypeReferenceTypeNameConst(global.context, this.peer)) + } + get baseName(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._TSTypeReferenceBaseNameConst(global.context, this.peer)) + } +} +export function isTSTypeReference(node: object | undefined): node is TSTypeReference { + return node instanceof TSTypeReference +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_TYPE_REFERENCE)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_TYPE_REFERENCE, (peer: KNativePointer) => new TSTypeReference(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSUndefinedKeyword.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSUndefinedKeyword.ts new file mode 100644 index 0000000000000000000000000000000000000000..a7538f5a660437b27e675f4a0d58021d341d854e --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSUndefinedKeyword.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { TypeNode } from "./TypeNode" +export class TSUndefinedKeyword extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 94) + super(pointer) + } + static createTSUndefinedKeyword(): TSUndefinedKeyword { + return new TSUndefinedKeyword(global.generatedEs2panda._CreateTSUndefinedKeyword(global.context)) + } + static updateTSUndefinedKeyword(original?: TSUndefinedKeyword): TSUndefinedKeyword { + return new TSUndefinedKeyword(global.generatedEs2panda._UpdateTSUndefinedKeyword(global.context, passNode(original))) + } +} +export function isTSUndefinedKeyword(node: object | undefined): node is TSUndefinedKeyword { + return node instanceof TSUndefinedKeyword +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_UNDEFINED_KEYWORD)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_UNDEFINED_KEYWORD, (peer: KNativePointer) => new TSUndefinedKeyword(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSUnionType.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSUnionType.ts new file mode 100644 index 0000000000000000000000000000000000000000..19ed0624fdb6fb95bd8c2175b902962a7028df11 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSUnionType.ts @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { TypeNode } from "./TypeNode" +export class TSUnionType extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 102) + super(pointer) + } + static createTSUnionType(types: readonly TypeNode[]): TSUnionType { + return new TSUnionType(global.generatedEs2panda._CreateTSUnionType(global.context, passNodeArray(types), types.length)) + } + static updateTSUnionType(original: TSUnionType | undefined, types: readonly TypeNode[]): TSUnionType { + return new TSUnionType(global.generatedEs2panda._UpdateTSUnionType(global.context, passNode(original), passNodeArray(types), types.length)) + } + get types(): readonly TypeNode[] { + return unpackNodeArray(global.generatedEs2panda._TSUnionTypeTypesConst(global.context, this.peer)) + } +} +export function isTSUnionType(node: object | undefined): node is TSUnionType { + return node instanceof TSUnionType +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_UNION_TYPE)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_UNION_TYPE, (peer: KNativePointer) => new TSUnionType(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSUnknownKeyword.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSUnknownKeyword.ts new file mode 100644 index 0000000000000000000000000000000000000000..05439e0cebc6a2de165d36ec0a19184b9fe892fc --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSUnknownKeyword.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { TypeNode } from "./TypeNode" +export class TSUnknownKeyword extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 95) + super(pointer) + } + static createTSUnknownKeyword(): TSUnknownKeyword { + return new TSUnknownKeyword(global.generatedEs2panda._CreateTSUnknownKeyword(global.context)) + } + static updateTSUnknownKeyword(original?: TSUnknownKeyword): TSUnknownKeyword { + return new TSUnknownKeyword(global.generatedEs2panda._UpdateTSUnknownKeyword(global.context, passNode(original))) + } +} +export function isTSUnknownKeyword(node: object | undefined): node is TSUnknownKeyword { + return node instanceof TSUnknownKeyword +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_UNKNOWN_KEYWORD)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_UNKNOWN_KEYWORD, (peer: KNativePointer) => new TSUnknownKeyword(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSVoidKeyword.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSVoidKeyword.ts new file mode 100644 index 0000000000000000000000000000000000000000..cef192f23c662e7ccd1b393173c7fcb760dc7d12 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TSVoidKeyword.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { TypeNode } from "./TypeNode" +export class TSVoidKeyword extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 93) + super(pointer) + } + static createTSVoidKeyword(): TSVoidKeyword { + return new TSVoidKeyword(global.generatedEs2panda._CreateTSVoidKeyword(global.context)) + } + static updateTSVoidKeyword(original?: TSVoidKeyword): TSVoidKeyword { + return new TSVoidKeyword(global.generatedEs2panda._UpdateTSVoidKeyword(global.context, passNode(original))) + } +} +export function isTSVoidKeyword(node: object | undefined): node is TSVoidKeyword { + return node instanceof TSVoidKeyword +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TS_VOID_KEYWORD)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TS_VOID_KEYWORD, (peer: KNativePointer) => new TSVoidKeyword(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TaggedTemplateExpression.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TaggedTemplateExpression.ts new file mode 100644 index 0000000000000000000000000000000000000000..e27c7a75f1e55eb6ab14d48cebf4bbd80a1735e7 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TaggedTemplateExpression.ts @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { TSTypeParameterInstantiation } from "./TSTypeParameterInstantiation" +import { TemplateLiteral } from "./TemplateLiteral" +export class TaggedTemplateExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 140) + super(pointer) + } + static createTaggedTemplateExpression(tag?: Expression, quasi?: TemplateLiteral, typeParams?: TSTypeParameterInstantiation): TaggedTemplateExpression { + return new TaggedTemplateExpression(global.generatedEs2panda._CreateTaggedTemplateExpression(global.context, passNode(tag), passNode(quasi), passNode(typeParams))) + } + static updateTaggedTemplateExpression(original?: TaggedTemplateExpression, tag?: Expression, quasi?: TemplateLiteral, typeParams?: TSTypeParameterInstantiation): TaggedTemplateExpression { + return new TaggedTemplateExpression(global.generatedEs2panda._UpdateTaggedTemplateExpression(global.context, passNode(original), passNode(tag), passNode(quasi), passNode(typeParams))) + } + get tag(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TaggedTemplateExpressionTagConst(global.context, this.peer)) + } + get quasi(): TemplateLiteral | undefined { + return unpackNode(global.generatedEs2panda._TaggedTemplateExpressionQuasiConst(global.context, this.peer)) + } + get typeParams(): TSTypeParameterInstantiation | undefined { + return unpackNode(global.generatedEs2panda._TaggedTemplateExpressionTypeParamsConst(global.context, this.peer)) + } +} +export function isTaggedTemplateExpression(node: object | undefined): node is TaggedTemplateExpression { + return node instanceof TaggedTemplateExpression +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TAGGED_TEMPLATE_EXPRESSION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TAGGED_TEMPLATE_EXPRESSION, (peer: KNativePointer) => new TaggedTemplateExpression(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TemplateElement.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TemplateElement.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc939e479c285152e0010defaaedcaba277b81f9 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TemplateElement.ts @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +export class TemplateElement extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 141) + super(pointer) + } + static create1TemplateElement(raw: string, cooked: string): TemplateElement { + return new TemplateElement(global.generatedEs2panda._CreateTemplateElement1(global.context, raw, cooked)) + } + static updateTemplateElement(original?: TemplateElement): TemplateElement { + return new TemplateElement(global.generatedEs2panda._UpdateTemplateElement(global.context, passNode(original))) + } + static update1TemplateElement(original: TemplateElement | undefined, raw: string, cooked: string): TemplateElement { + return new TemplateElement(global.generatedEs2panda._UpdateTemplateElement1(global.context, passNode(original), raw, cooked)) + } + get raw(): string { + return unpackString(global.generatedEs2panda._TemplateElementRawConst(global.context, this.peer)) + } + get cooked(): string { + return unpackString(global.generatedEs2panda._TemplateElementCookedConst(global.context, this.peer)) + } +} +export function isTemplateElement(node: object | undefined): node is TemplateElement { + return node instanceof TemplateElement +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TEMPLATE_ELEMENT)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TEMPLATE_ELEMENT, (peer: KNativePointer) => new TemplateElement(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TemplateLiteral.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TemplateLiteral.ts new file mode 100644 index 0000000000000000000000000000000000000000..3ed0b07ba0c713bbd6b40538f5108ccbc0c6d900 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TemplateLiteral.ts @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { TemplateElement } from "./TemplateElement" +export class TemplateLiteral extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 142) + super(pointer) + } + static createTemplateLiteral(quasis: readonly TemplateElement[], expressions: readonly Expression[], multilineString: string): TemplateLiteral { + return new TemplateLiteral(global.generatedEs2panda._CreateTemplateLiteral(global.context, passNodeArray(quasis), quasis.length, passNodeArray(expressions), expressions.length, multilineString)) + } + static updateTemplateLiteral(original: TemplateLiteral | undefined, quasis: readonly TemplateElement[], expressions: readonly Expression[], multilineString: string): TemplateLiteral { + return new TemplateLiteral(global.generatedEs2panda._UpdateTemplateLiteral(global.context, passNode(original), passNodeArray(quasis), quasis.length, passNodeArray(expressions), expressions.length, multilineString)) + } + get quasis(): readonly TemplateElement[] { + return unpackNodeArray(global.generatedEs2panda._TemplateLiteralQuasisConst(global.context, this.peer)) + } + get expressions(): readonly Expression[] { + return unpackNodeArray(global.generatedEs2panda._TemplateLiteralExpressionsConst(global.context, this.peer)) + } + get multilineString(): string { + return unpackString(global.generatedEs2panda._TemplateLiteralGetMultilineStringConst(global.context, this.peer)) + } +} +export function isTemplateLiteral(node: object | undefined): node is TemplateLiteral { + return node instanceof TemplateLiteral +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TEMPLATE_LITERAL)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TEMPLATE_LITERAL, (peer: KNativePointer) => new TemplateLiteral(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ThisExpression.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ThisExpression.ts new file mode 100644 index 0000000000000000000000000000000000000000..1c54681676dd76124b247bf4570d37f9c0b186b7 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ThisExpression.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +export class ThisExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 143) + super(pointer) + } + static createThisExpression(): ThisExpression { + return new ThisExpression(global.generatedEs2panda._CreateThisExpression(global.context)) + } + static updateThisExpression(original?: ThisExpression): ThisExpression { + return new ThisExpression(global.generatedEs2panda._UpdateThisExpression(global.context, passNode(original))) + } +} +export function isThisExpression(node: object | undefined): node is ThisExpression { + return node instanceof ThisExpression +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_THIS_EXPRESSION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_THIS_EXPRESSION, (peer: KNativePointer) => new ThisExpression(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ThrowStatement.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ThrowStatement.ts new file mode 100644 index 0000000000000000000000000000000000000000..1d5f2df9dd7acefd9ee4015013be83d10ef2e8e4 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ThrowStatement.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { Statement } from "./Statement" +export class ThrowStatement extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 145) + super(pointer) + } + static createThrowStatement(argument?: Expression): ThrowStatement { + return new ThrowStatement(global.generatedEs2panda._CreateThrowStatement(global.context, passNode(argument))) + } + static updateThrowStatement(original?: ThrowStatement, argument?: Expression): ThrowStatement { + return new ThrowStatement(global.generatedEs2panda._UpdateThrowStatement(global.context, passNode(original), passNode(argument))) + } + get argument(): Expression | undefined { + return unpackNode(global.generatedEs2panda._ThrowStatementArgumentConst(global.context, this.peer)) + } +} +export function isThrowStatement(node: object | undefined): node is ThrowStatement { + return node instanceof ThrowStatement +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_THROW_STATEMENT)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_THROW_STATEMENT, (peer: KNativePointer) => new ThrowStatement(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TryStatement.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TryStatement.ts new file mode 100644 index 0000000000000000000000000000000000000000..709c3cd50a942dba950cab3970fbafc56aa26640 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TryStatement.ts @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { BlockStatement } from "./BlockStatement" +import { CatchClause } from "./CatchClause" +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { LabelPair } from "./LabelPair" +import { Statement } from "./Statement" +export class TryStatement extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 146) + super(pointer) + } + static createTryStatement(block: BlockStatement | undefined, catchClauses: readonly CatchClause[], finalizer: BlockStatement | undefined, finalizerInsertionsLabelPair: readonly LabelPair[], finalizerInsertionsStatement: readonly Statement[]): TryStatement { + return new TryStatement(global.generatedEs2panda._CreateTryStatement(global.context, passNode(block), passNodeArray(catchClauses), catchClauses.length, passNode(finalizer), passNodeArray(finalizerInsertionsLabelPair), finalizerInsertionsLabelPair.length, passNodeArray(finalizerInsertionsStatement), finalizerInsertionsStatement.length)) + } + static updateTryStatement(original: TryStatement | undefined, block: BlockStatement | undefined, catchClauses: readonly CatchClause[], finalizer: BlockStatement | undefined, finalizerInsertionsLabelPair: readonly LabelPair[], finalizerInsertionsStatement: readonly Statement[]): TryStatement { + return new TryStatement(global.generatedEs2panda._UpdateTryStatement(global.context, passNode(original), passNode(block), passNodeArray(catchClauses), catchClauses.length, passNode(finalizer), passNodeArray(finalizerInsertionsLabelPair), finalizerInsertionsLabelPair.length, passNodeArray(finalizerInsertionsStatement), finalizerInsertionsStatement.length)) + } + static update1TryStatement(original?: TryStatement, other?: TryStatement): TryStatement { + return new TryStatement(global.generatedEs2panda._UpdateTryStatement1(global.context, passNode(original), passNode(other))) + } + get finallyBlock(): BlockStatement | undefined { + return unpackNode(global.generatedEs2panda._TryStatementFinallyBlockConst(global.context, this.peer)) + } + get block(): BlockStatement | undefined { + return unpackNode(global.generatedEs2panda._TryStatementBlockConst(global.context, this.peer)) + } + get hasFinalizer(): boolean { + return global.generatedEs2panda._TryStatementHasFinalizerConst(global.context, this.peer) + } + get hasDefaultCatchClause(): boolean { + return global.generatedEs2panda._TryStatementHasDefaultCatchClauseConst(global.context, this.peer) + } + get catchClauses(): readonly CatchClause[] { + return unpackNodeArray(global.generatedEs2panda._TryStatementCatchClausesConst(global.context, this.peer)) + } + get finallyCanCompleteNormally(): boolean { + return global.generatedEs2panda._TryStatementFinallyCanCompleteNormallyConst(global.context, this.peer) + } + /** @deprecated */ + setFinallyCanCompleteNormally(finallyCanCompleteNormally: boolean): this { + global.generatedEs2panda._TryStatementSetFinallyCanCompleteNormally(global.context, this.peer, finallyCanCompleteNormally) + return this + } +} +export function isTryStatement(node: object | undefined): node is TryStatement { + return node instanceof TryStatement +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TRY_STATEMENT)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TRY_STATEMENT, (peer: KNativePointer) => new TryStatement(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TypeNode.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TypeNode.ts new file mode 100644 index 0000000000000000000000000000000000000000..00cb419cc4bf3dfd9d6fa6140cfa2960b18ed669 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TypeNode.ts @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { AnnotationUsage } from "./AnnotationUsage" +import { Expression } from "./Expression" +export class TypeNode extends Expression { + constructor(pointer: KNativePointer) { + super(pointer) + } + get annotations(): readonly AnnotationUsage[] { + return unpackNodeArray(global.generatedEs2panda._TypeNodeAnnotations(global.context, this.peer)) + } + /** @deprecated */ + setAnnotations(annotations: readonly AnnotationUsage[]): this { + global.generatedEs2panda._TypeNodeSetAnnotations(global.context, this.peer, passNodeArray(annotations), annotations.length) + return this + } +} +export function isTypeNode(node: object | undefined): node is TypeNode { + return node instanceof TypeNode +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TypedAstNode.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TypedAstNode.ts new file mode 100644 index 0000000000000000000000000000000000000000..33f6d04380f4c5264a2c518c51928ffb32df1fa2 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TypedAstNode.ts @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +export class TypedAstNode extends AstNode { + constructor(pointer: KNativePointer) { + super(pointer) + } +} +export function isTypedAstNode(node: object | undefined): node is TypedAstNode { + return node instanceof TypedAstNode +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TypedStatement.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TypedStatement.ts new file mode 100644 index 0000000000000000000000000000000000000000..1814a6ac6275d583ae818644edc198e275eeb5f6 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TypedStatement.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Statement } from "./Statement" +export class TypedStatement extends Statement { + constructor(pointer: KNativePointer) { + super(pointer) + } +} +export function isTypedStatement(node: object | undefined): node is TypedStatement { + return node instanceof TypedStatement +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TypeofExpression.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TypeofExpression.ts new file mode 100644 index 0000000000000000000000000000000000000000..043703df3518b0aa72ce3c9200edc4e044b092a5 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/TypeofExpression.ts @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +export class TypeofExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 144) + super(pointer) + } + static createTypeofExpression(argument?: Expression): TypeofExpression { + return new TypeofExpression(global.generatedEs2panda._CreateTypeofExpression(global.context, passNode(argument))) + } + static updateTypeofExpression(original?: TypeofExpression, argument?: Expression): TypeofExpression { + return new TypeofExpression(global.generatedEs2panda._UpdateTypeofExpression(global.context, passNode(original), passNode(argument))) + } + get argument(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TypeofExpressionArgumentConst(global.context, this.peer)) + } +} +export function isTypeofExpression(node: object | undefined): node is TypeofExpression { + return node instanceof TypeofExpression +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_TYPEOF_EXPRESSION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_TYPEOF_EXPRESSION, (peer: KNativePointer) => new TypeofExpression(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/UnaryExpression.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/UnaryExpression.ts new file mode 100644 index 0000000000000000000000000000000000000000..8092f46937609da2f606abd687a9e342c9124ab3 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/UnaryExpression.ts @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Es2pandaTokenType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +export class UnaryExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 147) + super(pointer) + } + static createUnaryExpression(argument: Expression | undefined, unaryOperator: Es2pandaTokenType): UnaryExpression { + return new UnaryExpression(global.generatedEs2panda._CreateUnaryExpression(global.context, passNode(argument), unaryOperator)) + } + static updateUnaryExpression(original: UnaryExpression | undefined, argument: Expression | undefined, unaryOperator: Es2pandaTokenType): UnaryExpression { + return new UnaryExpression(global.generatedEs2panda._UpdateUnaryExpression(global.context, passNode(original), passNode(argument), unaryOperator)) + } + get operatorType(): Es2pandaTokenType { + return global.generatedEs2panda._UnaryExpressionOperatorTypeConst(global.context, this.peer) + } + get argument(): Expression | undefined { + return unpackNode(global.generatedEs2panda._UnaryExpressionArgument(global.context, this.peer)) + } +} +export function isUnaryExpression(node: object | undefined): node is UnaryExpression { + return node instanceof UnaryExpression +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_UNARY_EXPRESSION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_UNARY_EXPRESSION, (peer: KNativePointer) => new UnaryExpression(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/UndefinedLiteral.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/UndefinedLiteral.ts new file mode 100644 index 0000000000000000000000000000000000000000..500b9e0f6f1e53d404a29430c773590b4995502a --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/UndefinedLiteral.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Literal } from "./Literal" +export class UndefinedLiteral extends Literal { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 51) + super(pointer) + } + static createUndefinedLiteral(): UndefinedLiteral { + return new UndefinedLiteral(global.generatedEs2panda._CreateUndefinedLiteral(global.context)) + } + static updateUndefinedLiteral(original?: UndefinedLiteral): UndefinedLiteral { + return new UndefinedLiteral(global.generatedEs2panda._UpdateUndefinedLiteral(global.context, passNode(original))) + } +} +export function isUndefinedLiteral(node: object | undefined): node is UndefinedLiteral { + return node instanceof UndefinedLiteral +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_UNDEFINED_LITERAL)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_UNDEFINED_LITERAL, (peer: KNativePointer) => new UndefinedLiteral(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/UpdateExpression.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/UpdateExpression.ts new file mode 100644 index 0000000000000000000000000000000000000000..7ae3efd104ad530c7fecdc168f932e35e8301dc4 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/UpdateExpression.ts @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Es2pandaTokenType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +export class UpdateExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 148) + super(pointer) + } + static createUpdateExpression(argument: Expression | undefined, updateOperator: Es2pandaTokenType, isPrefix: boolean): UpdateExpression { + return new UpdateExpression(global.generatedEs2panda._CreateUpdateExpression(global.context, passNode(argument), updateOperator, isPrefix)) + } + static updateUpdateExpression(original: UpdateExpression | undefined, argument: Expression | undefined, updateOperator: Es2pandaTokenType, isPrefix: boolean): UpdateExpression { + return new UpdateExpression(global.generatedEs2panda._UpdateUpdateExpression(global.context, passNode(original), passNode(argument), updateOperator, isPrefix)) + } + get operatorType(): Es2pandaTokenType { + return global.generatedEs2panda._UpdateExpressionOperatorTypeConst(global.context, this.peer) + } + get argument(): Expression | undefined { + return unpackNode(global.generatedEs2panda._UpdateExpressionArgument(global.context, this.peer)) + } + get isPrefix(): boolean { + return global.generatedEs2panda._UpdateExpressionIsPrefixConst(global.context, this.peer) + } +} +export function isUpdateExpression(node: object | undefined): node is UpdateExpression { + return node instanceof UpdateExpression +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_UPDATE_EXPRESSION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_UPDATE_EXPRESSION, (peer: KNativePointer) => new UpdateExpression(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/VReg.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/VReg.ts new file mode 100644 index 0000000000000000000000000000000000000000..11a43a241da9a5e05b19d4101e9cb633176718e3 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/VReg.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +export class VReg extends ArktsObject { + constructor(pointer: KNativePointer) { + super(pointer) + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ValidationInfo.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ValidationInfo.ts new file mode 100644 index 0000000000000000000000000000000000000000..7f85236cadb154c193512e29a0bff94110939312 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/ValidationInfo.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { SourcePosition } from "./SourcePosition" +export class ValidationInfo extends ArktsObject { + constructor(pointer: KNativePointer) { + super(pointer) + } + static create1ValidationInfo(m: string, p?: SourcePosition): ValidationInfo { + return new ValidationInfo(global.generatedEs2panda._CreateValidationInfo1(global.context, m, passNode(p))) + } + get fail(): boolean { + return global.generatedEs2panda._ValidationInfoFailConst(global.context, this.peer) + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/VariableDeclaration.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/VariableDeclaration.ts new file mode 100644 index 0000000000000000000000000000000000000000..a4fc03e4343d5f032b18de0e291412a8d9ee730a --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/VariableDeclaration.ts @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { AnnotationUsage } from "./AnnotationUsage" +import { Decorator } from "./Decorator" +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Es2pandaVariableDeclarationKind } from "./../Es2pandaEnums" +import { Statement } from "./Statement" +import { VariableDeclarator } from "./VariableDeclarator" +export class VariableDeclaration extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 149) + super(pointer) + } + static createVariableDeclaration(kind: Es2pandaVariableDeclarationKind, declarators: readonly VariableDeclarator[]): VariableDeclaration { + return new VariableDeclaration(global.generatedEs2panda._CreateVariableDeclaration(global.context, kind, passNodeArray(declarators), declarators.length)) + } + static updateVariableDeclaration(original: VariableDeclaration | undefined, kind: Es2pandaVariableDeclarationKind, declarators: readonly VariableDeclarator[]): VariableDeclaration { + return new VariableDeclaration(global.generatedEs2panda._UpdateVariableDeclaration(global.context, passNode(original), kind, passNodeArray(declarators), declarators.length)) + } + get declarators(): readonly VariableDeclarator[] { + return unpackNodeArray(global.generatedEs2panda._VariableDeclarationDeclaratorsConst(global.context, this.peer)) + } + get kind(): Es2pandaVariableDeclarationKind { + return global.generatedEs2panda._VariableDeclarationKindConst(global.context, this.peer) + } + get decorators(): readonly Decorator[] { + return unpackNodeArray(global.generatedEs2panda._VariableDeclarationDecoratorsConst(global.context, this.peer)) + } + get annotations(): readonly AnnotationUsage[] { + return unpackNodeArray(global.generatedEs2panda._VariableDeclarationAnnotations(global.context, this.peer)) + } + /** @deprecated */ + setAnnotations(annotations: readonly AnnotationUsage[]): this { + global.generatedEs2panda._VariableDeclarationSetAnnotations(global.context, this.peer, passNodeArray(annotations), annotations.length) + return this + } +} +export function isVariableDeclaration(node: object | undefined): node is VariableDeclaration { + return node instanceof VariableDeclaration +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_VARIABLE_DECLARATION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_VARIABLE_DECLARATION, (peer: KNativePointer) => new VariableDeclaration(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/VariableDeclarator.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/VariableDeclarator.ts new file mode 100644 index 0000000000000000000000000000000000000000..3513e86a88164ee93789fb4efbb3526da66020f4 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/VariableDeclarator.ts @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Es2pandaVariableDeclaratorFlag } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { TypedStatement } from "./TypedStatement" +export class VariableDeclarator extends TypedStatement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 150) + super(pointer) + } + static create1VariableDeclarator(flag: Es2pandaVariableDeclaratorFlag, ident?: Expression, init?: Expression): VariableDeclarator { + return new VariableDeclarator(global.generatedEs2panda._CreateVariableDeclarator1(global.context, flag, passNode(ident), passNode(init))) + } + static updateVariableDeclarator(original: VariableDeclarator | undefined, flag: Es2pandaVariableDeclaratorFlag, ident?: Expression): VariableDeclarator { + return new VariableDeclarator(global.generatedEs2panda._UpdateVariableDeclarator(global.context, passNode(original), flag, passNode(ident))) + } + static update1VariableDeclarator(original: VariableDeclarator | undefined, flag: Es2pandaVariableDeclaratorFlag, ident?: Expression, init?: Expression): VariableDeclarator { + return new VariableDeclarator(global.generatedEs2panda._UpdateVariableDeclarator1(global.context, passNode(original), flag, passNode(ident), passNode(init))) + } + get init(): Expression | undefined { + return unpackNode(global.generatedEs2panda._VariableDeclaratorInit(global.context, this.peer)) + } + /** @deprecated */ + setInit(init?: Expression): this { + global.generatedEs2panda._VariableDeclaratorSetInit(global.context, this.peer, passNode(init)) + return this + } + get id(): Expression | undefined { + return unpackNode(global.generatedEs2panda._VariableDeclaratorId(global.context, this.peer)) + } + get flag(): Es2pandaVariableDeclaratorFlag { + return global.generatedEs2panda._VariableDeclaratorFlag(global.context, this.peer) + } +} +export function isVariableDeclarator(node: object | undefined): node is VariableDeclarator { + return node instanceof VariableDeclarator +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_VARIABLE_DECLARATOR)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_VARIABLE_DECLARATOR, (peer: KNativePointer) => new VariableDeclarator(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/VerificationContext.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/VerificationContext.ts new file mode 100644 index 0000000000000000000000000000000000000000..c11ea7a0611398c4e67d94642605521e3ad3b5df --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/VerificationContext.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +export class VerificationContext extends ArktsObject { + constructor(pointer: KNativePointer) { + super(pointer) + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/VerifierMessage.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/VerifierMessage.ts new file mode 100644 index 0000000000000000000000000000000000000000..49c5c76a940e0bd6257ca6b0f5fc1d1c7e41d2da --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/VerifierMessage.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +export class VerifierMessage extends ArktsObject { + constructor(pointer: KNativePointer) { + super(pointer) + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/WhileStatement.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/WhileStatement.ts new file mode 100644 index 0000000000000000000000000000000000000000..fd37a8499630326a9ee38e0362a9157e777898f2 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/WhileStatement.ts @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { LoopStatement } from "./LoopStatement" +import { Statement } from "./Statement" +export class WhileStatement extends LoopStatement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 151) + super(pointer) + } + static createWhileStatement(test?: Expression, body?: Statement): WhileStatement { + return new WhileStatement(global.generatedEs2panda._CreateWhileStatement(global.context, passNode(test), passNode(body))) + } + static updateWhileStatement(original?: WhileStatement, test?: Expression, body?: Statement): WhileStatement { + return new WhileStatement(global.generatedEs2panda._UpdateWhileStatement(global.context, passNode(original), passNode(test), passNode(body))) + } + get test(): Expression | undefined { + return unpackNode(global.generatedEs2panda._WhileStatementTest(global.context, this.peer)) + } + get body(): Statement | undefined { + return unpackNode(global.generatedEs2panda._WhileStatementBody(global.context, this.peer)) + } +} +export function isWhileStatement(node: object | undefined): node is WhileStatement { + return node instanceof WhileStatement +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_WHILE_STATEMENT)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_WHILE_STATEMENT, (peer: KNativePointer) => new WhileStatement(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/YieldExpression.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/YieldExpression.ts new file mode 100644 index 0000000000000000000000000000000000000000..111a2739c2f541e99311fcbc62469d172a875718 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/generated/peers/YieldExpression.ts @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaAstNodeType } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +export class YieldExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 152) + super(pointer) + } + static createYieldExpression(argument: Expression | undefined, isDelegate: boolean): YieldExpression { + return new YieldExpression(global.generatedEs2panda._CreateYieldExpression(global.context, passNode(argument), isDelegate)) + } + static updateYieldExpression(original: YieldExpression | undefined, argument: Expression | undefined, isDelegate: boolean): YieldExpression { + return new YieldExpression(global.generatedEs2panda._UpdateYieldExpression(global.context, passNode(original), passNode(argument), isDelegate)) + } + get hasDelegate(): boolean { + return global.generatedEs2panda._YieldExpressionHasDelegateConst(global.context, this.peer) + } + get argument(): Expression | undefined { + return unpackNode(global.generatedEs2panda._YieldExpressionArgumentConst(global.context, this.peer)) + } +} +export function isYieldExpression(node: object | undefined): node is YieldExpression { + return node instanceof YieldExpression +} +if (!nodeByType.has(Es2pandaAstNodeType.AST_NODE_TYPE_YIELD_EXPRESSION)) { + nodeByType.set(Es2pandaAstNodeType.AST_NODE_TYPE_YIELD_EXPRESSION, (peer: KNativePointer) => new YieldExpression(peer)) +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/index.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..840594be45dcfc38d2c2db2072a5ac4372103f27 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/index.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export * from "./utils" +export * from "./reexport-for-generated" +export * from "./generated/Es2pandaEnums" +export * from "./generated" + +export * from "./arkts-api/utilities/private" +export * from "./arkts-api/utilities/public" +export * from "./arkts-api/factory/nodeFactory" +export * from "./arkts-api/visitor" +export * from "./arkts-api/AbstractVisitor" + +export * from "./arkts-api/peers/AstNode" +export * from "./arkts-api/peers/Config" +export * from "./arkts-api/peers/Context" +export * from "./arkts-api/peers/Program" +export * from "./arkts-api/peers/ImportPathManager" +export { global as arktsGlobal } from "./arkts-api/static/global" diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/reexport-for-generated.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/reexport-for-generated.ts new file mode 100644 index 0000000000000000000000000000000000000000..e79fa93835019eeb848c7e7f17cb139d211bf087 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/reexport-for-generated.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export { KNativePointer } from "@koalaui/interop" +export { AstNode } from "./arkts-api/peers/AstNode" +export { ArktsObject, isSameNativeObject } from "./arkts-api/peers/ArktsObject" +export { NodeCache } from "./arkts-api/node-cache" +export { + passNode, + unpackNonNullableNode, + unpackNodeArray, + passNodeArray, + unpackNode, + unpackNonNullableObject, + unpackString, + unpackObject, + assertValidPeer, + updateNodeByNode +} from "./arkts-api/utilities/private" +export { nodeByType } from "./arkts-api/class-by-peer" +export { global } from "./arkts-api/static/global" +export { Es2pandaMemberExpressionKind } from "./generated/Es2pandaEnums" diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/ts-api/factory/nodeFactory.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/ts-api/factory/nodeFactory.ts new file mode 100644 index 0000000000000000000000000000000000000000..7424783a2fe44b9bf8dd4bf586955ad94cb1fce7 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/ts-api/factory/nodeFactory.ts @@ -0,0 +1,1390 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { throwError } from "../../utils" +import * as ts from "@koalaui/ets-tsc" +import * as arkts from "../../arkts-api" + +import { + passNode, + passNodeArray, + passToken, + passModifiersToScriptFunction, + passModifiers, + passIdentifier, + passTypeParams, + passVariableDeclarationKind, +} from "../utilities/private" +import { + SyntaxKind, + NodeFlags, +} from "../static/enums" +import { + Es2pandaContextState, + Es2pandaPrimitiveType, + Es2pandaMethodDefinitionKind, + Es2pandaModifierFlags, + Es2pandaScriptFunctionFlags, + Es2pandaMemberExpressionKind, + Es2pandaClassDefinitionModifiers, + Es2pandaVariableDeclarationKind, + Es2pandaVariableDeclaratorFlag, +} from "../../arkts-api" +import { + // ts types: + Modifier, + BinaryOperatorToken, + + Node, + Token, + Identifier, + StringLiteral, + FunctionDeclaration, + Block, + KeywordTypeNode, + PropertyAccessExpression, + ParameterDeclaration, + ReturnStatement, + IfStatement, + ExpressionStatement, + CallExpression, + ArrowFunction, + TypeReferenceNode, + BinaryExpression, + FunctionTypeNode, + TypeNode, + Expression, + Statement, + SourceFile, + ClassElement, + MethodDeclaration, + ConstructorDeclaration, + TypeParameterDeclaration, + NumericLiteral, + ClassDeclaration, + VariableDeclaration, + VariableDeclarationList, + VariableStatement, + UnionTypeNode, + SuperExpression, + ParenthesizedExpression, + ImportDeclaration, + ImportClause, + ImportSpecifier, +} from "../types" + +// TODO: add flags and base +export function createNodeFactory() { + return { + createSourceFile, + updateSourceFile, + createIdentifier, + createStringLiteral, + createNumericLiteral, + createFunctionDeclaration, + updateFunctionDeclaration, + createParameterDeclaration, + updateParameterDeclaration, + createETSTypeReferenceNode, + updateTypeReferenceNode, + createKeywordTypeNode, + createBlock, + updateBlock, + createExpressionStatement, + updateExpressionStatement, + createReturnStatement, + updateReturnStatement, + createPropertyAccessExpression, + updatePropertyAccessExpression, + createCallExpression, + updateCallExpression, + createIfStatement, + updateIfStatement, + createToken, + createBinaryExpression, + updateBinaryExpression, + createArrowFunction, + updateArrowFunction, + createFunctionTypeNode, + updateFunctionTypeNode, + createMethodDeclaration, + updateMethodDeclaration, + createConstructorDeclaration, + updateConstructorDeclaration, + createTypeParameterDeclaration, + updateTypeParameterDeclaration, + createClassDeclaration, + updateClassDeclaration, + createVariableDeclarationList, + updateVariableDeclarationList, + createVariableStatement, + updateVariableStatement, + createVariableDeclaration, + updateVariableDeclaration, + createETSUnionTypeNode, + updateETSUnionTypeNode, + createSuper, + updateSuper, + createParenthesizedExpression, + updateParenthesizedExpression, + // createImportDeclaration, + createImportSpecifier, + } + + // @api + // function createSourceFile( + // statements: readonly Statement[], + // endOfFileToken: EndOfFileToken, + // flags: NodeFlags, + // ): SourceFile; + function createSourceFile(source: string, state: Es2pandaContextState = Es2pandaContextState.ES2PANDA_STATE_PARSED): SourceFile { + const node = arkts.EtsScript.createFromSource(source, state) + return new SourceFile(node) + } + + // TODO: fix (now doesn't create a new node) + // @api + // updateSourceFile( + // node: SourceFile, + // statements: readonly Statement[], + // isDeclarationFile?: boolean, + // referencedFiles?: readonly FileReference[], + // typeReferences?: readonly FileReference[], + // hasNoDefaultLib?: boolean, + // libReferences?: readonly FileReference[] + // ): SourceFile; + function updateSourceFile( + node: SourceFile, + statements: readonly Statement[] + ): SourceFile { + return new SourceFile( + arkts.EtsScript.updateByStatements( + node.node, + passNodeArray(statements) + ) + ) + } + + // @api + // createIdentifier( + // text: string + // ): Identifier; + function createIdentifier( + text: string, + typeAnnotation?: TypeNode | undefined + ): Identifier { + return new Identifier( + arkts.factory.createIdentifier( + text, + passNode(typeAnnotation) + ) + ) + } + + // @api + // createStringLiteral( + // text: string, + // isSingleQuote?: boolean + // ): StringLiteral; + function createStringLiteral( + str: string + ): StringLiteral { + return new StringLiteral( + arkts.factory.createStringLiteral( + str + ) + ) + } + + // @api + // createNumericLiteral( + // value: string | number, + // numericLiteralFlags: TokenFlags = TokenFlags.None + // ): NumericLiteral { + function createNumericLiteral( + value: number + ): NumericLiteral { + return new NumericLiteral( + arkts.factory.createNumberLiteral( + value + ) + ) + } + + // @api + // createVariableDeclarationList( + // declarations: readonly VariableDeclaration[], + // flags = NodeFlags.None + // ): VariableDeclarationList + function createVariableDeclarationList( + declarations: readonly VariableDeclaration[], + flags: NodeFlags = NodeFlags.None + ): VariableDeclarationList { + return new VariableDeclarationList( + arkts.factory.createVariableDeclaration( + passModifiers([]), + passVariableDeclarationKind(flags), + passNodeArray(declarations) + ) + ) + } + + // @api + // updateVariableDeclarationList( + // node: VariableDeclarationList, + // declarations: readonly VariableDeclaration[] + // ): VariableDeclarationList + function updateVariableDeclarationList( + node: VariableDeclarationList, + declarations: readonly VariableDeclaration[] + ): VariableDeclarationList { + return new VariableDeclarationList( + arkts.factory.updateVariableDeclaration( + node.node, + passModifiers([]), + passVariableDeclarationKind(node.flags), + passNodeArray(declarations) + ) + ) + } + + // @api + // createVariableStatement( + // modifiers: readonly ModifierLike[] | undefined, + // declarationList: VariableDeclarationList | readonly VariableDeclaration[] + // ): VariableStatement + function createVariableStatement( + modifiers: readonly Modifier[] | undefined, + declarationList: VariableDeclarationList | readonly VariableDeclaration[] + ): VariableStatement { + const node: arkts.VariableDeclaration = (declarationList instanceof VariableDeclarationList) ? declarationList.node : createVariableDeclarationList(declarationList, undefined).node + return new VariableStatement( + arkts.factory.createVariableDeclaration( + passModifiers(modifiers), + node.declarationKind, + node.declarators + ) + ) + } + + // @api + // updateVariableStatement( + // node: VariableStatement, + // modifiers: readonly ModifierLike[] | undefined, + // declarationList: VariableDeclarationList + // ): VariableStatement + function updateVariableStatement( + node: VariableStatement, + modifiers: readonly Modifier[] | undefined, + declarationList: VariableDeclarationList + ): VariableStatement { + return new VariableStatement( + arkts.factory.updateVariableDeclaration( + node.node, + passModifiers(modifiers), + declarationList.node.declarationKind, + declarationList.node.declarators + ) + ) + } + + // @api + // createVariableDeclaration( + // name: string | BindingName, + // exclamationToken: ExclamationToken | undefined, + // type: TypeNode | undefined, + // initializer: Expression | undefined + // ): VariableDeclaration + function createVariableDeclaration( + name: string | Identifier, + exclamationToken: undefined, + type: TypeNode | undefined, + initializer: Expression | undefined + ): VariableDeclaration { + return new VariableDeclaration( + arkts.factory.createVariableDeclarator( + // TODO: maybe incorrect + Es2pandaVariableDeclaratorFlag.VARIABLE_DECLARATOR_FLAG_UNKNOWN, + passIdentifier(name, type), + passNode(initializer) + ) + ) + } + + // @api + // function updateVariableDeclaration( + // node: VariableDeclaration, + // name: BindingName, + // exclamationToken: ExclamationToken | undefined, + // type: TypeNode | undefined, + // initializer: Expression | undefined + // ): VariableDeclaration + function updateVariableDeclaration( + node: VariableDeclaration, + name: Identifier, + exclamationToken: undefined, + type: TypeNode | undefined, + initializer: Expression | undefined + ): VariableDeclaration { + return new VariableDeclaration( + arkts.factory.updateVariableDeclarator( + node.node, + // TODO: maybe incorrect + Es2pandaVariableDeclaratorFlag.VARIABLE_DECLARATOR_FLAG_UNKNOWN, + passIdentifier(name, type), + passNode(initializer) + ) + ) + } + + // @api + // createFunctionDeclaration( + // modifiers: readonly ModifierLike[] | undefined, + // asteriskToken: AsteriskToken | undefined, + // name: string | Identifier | undefined, + // typeParameters: readonly TypeParameterDeclaration[] | undefined, + // parameters: readonly ParameterDeclaration[], + // type: TypeNode | undefined, + // body: Block | undefined + // ): FunctionDeclaration; + function createFunctionDeclaration( + modifiers: readonly Modifier[] | undefined, + asteriskToken: undefined, + name: string | Identifier | undefined, + typeParameters: readonly TypeParameterDeclaration[] | undefined, + parameters: readonly ParameterDeclaration[], + type: TypeNode | undefined, + body: Block | undefined + ): FunctionDeclaration { + return new FunctionDeclaration( + arkts.factory.createFunctionDeclaration( + arkts.factory.createScriptFunction( + body?.node, + arkts.FunctionSignature.create( + passTypeParams(typeParameters), + passNodeArray(parameters), + type?.node + ), + 0, + passModifiers(modifiers) | Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC | Es2pandaModifierFlags.MODIFIER_FLAGS_STATIC, + body === undefined, + passIdentifier(name) + ), + false + ) + ) + } + + // @api + // updateFunctionDeclaration( + // node: FunctionDeclaration, + // modifiers: readonly ModifierLike[] | undefined, + // asteriskToken: AsteriskToken | undefined, + // name: Identifier | undefined, + // typeParameters: readonly TypeParameterDeclaration[] | undefined, + // parameters: readonly ParameterDeclaration[], + // type: TypeNode | undefined, + // body: Block | undefined + // ): FunctionDeclaration; + function updateFunctionDeclaration( + node: FunctionDeclaration, + modifiers: readonly Modifier[] | undefined, + asteriskToken: undefined, + name: Identifier | undefined, + typeParameters: readonly TypeParameterDeclaration[] | undefined, + parameters: readonly ParameterDeclaration[], + type: TypeNode | undefined, + body: Block | undefined + ): FunctionDeclaration { + return new FunctionDeclaration( + arkts.factory.updateFunctionDeclaration( + node.node, + arkts.factory.updateScriptFunction( + node.node.scriptFunction, + body?.node, + arkts.FunctionSignature.create( + passTypeParams(typeParameters), + passNodeArray(parameters), + type?.node + ), + 0, + passModifiers(modifiers) | Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC | Es2pandaModifierFlags.MODIFIER_FLAGS_STATIC, + body === undefined, + passIdentifier(name) + ), + false + ) + ) + } + + // @api + // createParameterDeclaration( + // modifiers: readonly ModifierLike[] | undefined, + // dotDotDotToken: DotDotDotToken | undefined, + // name: string | BindingName, + // questionToken?: QuestionToken, + // type?: TypeNode, + // initializer?: Expression + // ): ParameterDeclaration; + function createParameterDeclaration( + modifiers: readonly Modifier[] | undefined, + dotDotDotToken: undefined, + name: string | Identifier, + questionToken?: undefined, + type?: TypeNode, + initializer?: Expression + ): ParameterDeclaration { + return new ParameterDeclaration( + arkts.factory.createParameterDeclaration( + arkts.factory.createIdentifier( + (name instanceof Identifier) ? name.node.name : name, + type?.node + ), + initializer?.node + ) + ) + } + + // @api + // function updateParameterDeclaration( + // node: ParameterDeclaration, + // modifiers: readonly ModifierLike[] | undefined, + // dotDotDotToken: DotDotDotToken | undefined, + // name: string | BindingName, + // questionToken: QuestionToken | undefined, + // type: TypeNode | undefined, + // initializer: Expression | undefined, + // ): ParameterDeclaration + function updateParameterDeclaration( + node: ParameterDeclaration, + modifiers: readonly Modifier[] | undefined, + dotDotDotToken: undefined, + name: string | Identifier, + questionToken?: undefined, + type?: TypeNode, + initializer?: Expression + ): ParameterDeclaration { + return new ParameterDeclaration( + arkts.factory.updateParameterDeclaration( + node.node, + arkts.factory.createIdentifier( + (name instanceof Identifier) ? name.node.name : name, + type?.node + ), + initializer?.node + ) + ) + } + + // @api + // createTypeParameterDeclaration( + // modifiers: readonly Modifier[] | undefined, + // name: string | Identifier, + // constraint?: TypeNode, + // defaultType?: TypeNode + // ): TypeParameterDeclaration; + function createTypeParameterDeclaration( + modifiers: readonly Modifier[] | undefined, + name: string | Identifier, + constraint?: TypeNode, + defaultType?: TypeNode + ): TypeParameterDeclaration { + return new TypeParameterDeclaration( + arkts.factory.createTypeParameter( + passIdentifier(name), + constraint?.node, + defaultType?.node, + passModifiers(modifiers) + ) + ) + } + + // @api + // function updateTypeParameterDeclaration( + // node: TypeParameterDeclaration, + // modifiers: readonly Modifier[] | undefined, + // name: Identifier, + // constraint: TypeNode | undefined, + // defaultType: TypeNode | undefined + // ): TypeParameterDeclaration + function updateTypeParameterDeclaration( + node: TypeParameterDeclaration, + modifiers: readonly Modifier[] | undefined, + name: string | Identifier, + constraint?: TypeNode, + defaultType?: TypeNode + ): TypeParameterDeclaration { + return new TypeParameterDeclaration( + arkts.factory.updateTypeParameter( + node.node, + passIdentifier(name), + constraint?.node, + defaultType?.node, + passModifiers(modifiers) + ) + ) + } + + // @api + // createETSUnionTypeNode( + // types: readonly TypeNode[] + // ): UnionTypeNode + function createETSUnionTypeNode( + types: readonly TypeNode[] + ): UnionTypeNode { + return new UnionTypeNode( + arkts.factory.createETSUnionType( + passNodeArray(types) + ) + ) + } + + // @api + // function updateETSUnionTypeNode( + // node: UnionTypeNode, + // types: NodeArray + // ): UnionTypeNode + function updateETSUnionTypeNode( + node: UnionTypeNode, + types: readonly TypeNode[] + ): UnionTypeNode { + return new UnionTypeNode( + arkts.factory.updateETSUnionType( + node.node, + passNodeArray(types) + ) + ) + + } + + // @api + // createETSTypeReferenceNode( + // typeName: string | EntityName, + // typeArguments?: readonly TypeNode[] + // ): TypeReferenceNode; + function createETSTypeReferenceNode( + typeName: Identifier, + typeArguments?: undefined + ): TypeReferenceNode { + return new TypeReferenceNode( + arkts.factory.createETSTypeReferenceFromId( + typeName.node + ) + ) + } + + // @api + // function updateTypeReferenceNode( + // node: TypeReferenceNode, + // typeName: EntityName, + // typeArguments: NodeArray | undefined + // ): TypeReferenceNode + function updateTypeReferenceNode( + node: TypeReferenceNode, + typeName: Identifier, + typeArguments?: undefined + ): TypeReferenceNode { + return new TypeReferenceNode( + arkts.factory.updateTypeReferenceFromId( + node.node, + typeName.node + ) + ) + } + + // @api + // createKeywordTypeNode( + // kind: TKind + // ): KeywordTypeNode; + function createKeywordTypeNode( + TKind: ts.KeywordTypeSyntaxKind + ): KeywordTypeNode { + function createKeywordTypeNodeFromString( + keyword: string + ): KeywordTypeNode { + return new KeywordTypeNode( + arkts.factory.createETSTypeReferenceFromId( + arkts.factory.createIdentifier( + keyword + ) + ) + ) + } + + function createKeywordTypeNodeFromKind( + kind: number + ): KeywordTypeNode { + return new KeywordTypeNode( + arkts.factory.createPrimitiveType( + kind + ) + ) + } + + const keywords = new Map([ + [ts.SyntaxKind.NumberKeyword, createKeywordTypeNodeFromString("number")], + [ts.SyntaxKind.StringKeyword, createKeywordTypeNodeFromString("string")], + [ts.SyntaxKind.AnyKeyword, createKeywordTypeNodeFromString("any")], + [ts.SyntaxKind.VoidKeyword, createKeywordTypeNodeFromKind(8)], + ]) + return keywords.get(TKind) ?? throwError('unsupported keyword') + } + + // @api + // createBlock( + // statements: readonly Statement[], + // multiLine?: boolean + // ): Block; + function createBlock( + statements: readonly Statement[], + multiline?: boolean + ): Block { + return new Block( + arkts.factory.createBlock( + passNodeArray(statements) + ) + ) + } + + // @api + // updateBlock( + // node: Block, + // statements: readonly Statement[] + // ): Block; + function updateBlock( + node: Block, + statements: readonly Statement[] + ): Block { + return new Block( + arkts.factory.updateBlock( + node.node, + passNodeArray(statements) + ) + ) + } + + // @api + // createExpressionStatement( + // expression: Expression + // ): ExpressionStatement; + function createExpressionStatement( + expression: Expression + ): ExpressionStatement { + return new ExpressionStatement( + arkts.factory.createExpressionStatement( + expression.node + ) + ) + } + + // @api + // updateExpressionStatement( + // node: ExpressionStatement, + // expression: Expression + // ): ExpressionStatement; + function updateExpressionStatement( + node: ExpressionStatement, + expression: Expression + ): ExpressionStatement { + return new ExpressionStatement( + arkts.factory.updateExpressionStatement( + node.node, + expression.node + ) + ) + } + + // @api + // createReturnStatement( + // expression?: Expression + // ): ReturnStatement; + function createReturnStatement( + expression: Expression + ): ReturnStatement { + return new ReturnStatement( + arkts.factory.createReturnStatement( + expression.node + ) + ) + } + + // @api + // function updateReturnStatement( + // node: ReturnStatement, + // expression: Expression | undefined + // ): ReturnStatement + function updateReturnStatement( + node: ReturnStatement, + expression: Expression + ): ReturnStatement { + return new ReturnStatement( + arkts.factory.updateReturnStatement( + node.node, + expression.node + ) + ) + } + + // @api + // createPropertyAccessExpression( + // expression: Expression, + // name: string | MemberName + // ): PropertyAccessExpression; + function createPropertyAccessExpression( + expression: Expression, + name: string | Identifier + ): PropertyAccessExpression { + return new PropertyAccessExpression( + arkts.factory.createMemberExpression( + expression.node, + passIdentifier(name), + Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + false, + false + ) + ) + } + + // @api + // updatePropertyAccessExpression( + // node: PropertyAccessExpression, + // expression: Expression, + // name: MemberName + // ): PropertyAccessExpression; + function updatePropertyAccessExpression( + node: PropertyAccessExpression, + expression: Expression, + name: Identifier + ): PropertyAccessExpression { + return new PropertyAccessExpression( + arkts.factory.updateMemberExpression( + node.node, + expression.node, + passIdentifier(name), + Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + false, + false + ) + ) + } + + // @api + // createCallExpression( + // expression: Expression, + // typeArguments: readonly TypeNode[] | undefined, + // argumentsArray: readonly Expression[] | undefined + // ): CallExpression; + function createCallExpression( + expression: Expression, + typeArguments: readonly TypeNode[] | undefined, + argumentsArray: readonly Expression[] | undefined + ): CallExpression { + return new CallExpression( + arkts.factory.createCallExpression( + expression.node, + (typeArguments !== undefined) ? + arkts.factory.createTypeParameterDeclaration(passNodeArray(typeArguments)) : undefined, + passNodeArray(argumentsArray) + ) + ) + } + + // @api + // updateCallExpression( + // node: CallExpression, + // expression: Expression, + // typeArguments: readonly TypeNode[] | undefined, + // argumentsArray: readonly Expression[] + // ): CallExpression; + function updateCallExpression( + node: CallExpression, + expression: Expression, + typeArguments: readonly TypeNode[] | undefined, + argumentsArray: readonly Expression[] | undefined + ): CallExpression { + return new CallExpression( + arkts.factory.updateCallExpression( + node.node, + expression.node, + (typeArguments !== undefined) ? + arkts.factory.createTypeParameterDeclaration(passNodeArray(typeArguments)) : undefined, + passNodeArray(argumentsArray) + ) + ) + } + + // @api + // createIfStatement( + // expression: Expression, + // thenStatement: Statement, + // elseStatement?: Statement + // ): IfStatement; + function createIfStatement( + expression: Expression, + thenStatement: Statement, + elseStatement?: undefined + ): IfStatement { + return new IfStatement( + arkts.factory.createIfStatement( + passNode(expression), + passNode(thenStatement), + passNode(elseStatement), + ) + ) + } + + // @api + // updateIfStatement( + // expression: Expression, + // thenStatement: Statement, + // elseStatement: Statement | undefined + // ): IfStatement; + function updateIfStatement( + node: IfStatement, + expression: Expression, + thenStatement: Statement, + elseStatement?: undefined + ): IfStatement { + return new IfStatement( + arkts.factory.updateIfStatement( + node.node, + passNode(expression), + passNode(thenStatement), + passNode(elseStatement), + ) + ) + } + + // TODO: rewrite maybe + // @api + // createToken( + // token: SyntaxKind._ + // ): _; + function createToken( + token: TKind + ) { + return new Token(token) + } + + // @api + // createBinaryExpression( + // left: Expression, + // operator: BinaryOperator | BinaryOperatorToken, + // right: Expression + // ): BinaryExpression; + function createBinaryExpression( + left: Expression, + operator: BinaryOperatorToken, + right: Expression + ): BinaryExpression { + return new BinaryExpression( + arkts.factory.createBinaryExpression( + passNode(left), + passToken(operator), + passNode(right), + ) + ) + } + + // @api + // function updateBinaryExpression( + // node: BinaryExpression, + // left: Expression, + // operator: BinaryOperatorToken, + // right: Expression + // ): BinaryExpression + function updateBinaryExpression( + node: BinaryExpression, + left: Expression, + operator: BinaryOperatorToken, + right: Expression + ): BinaryExpression { + return new BinaryExpression( + arkts.factory.updateBinaryExpression( + node.node, + passNode(left), + passToken(operator), + passNode(right), + ) + ) + } + + // @api + // createArrowFunction( + // modifiers: readonly Modifier[] | undefined, + // typeParameters: readonly TypeParameterDeclaration[] | undefined, + // parameters: readonly ParameterDeclaration[], + // type: TypeNode | undefined, + // equalsGreaterThanToken: EqualsGreaterThanToken | undefined, + // body: ConciseBody + // ): ArrowFunction; + function createArrowFunction( + modifiers: readonly Modifier[] | undefined, + typeParameters: readonly TypeParameterDeclaration[] | undefined, + parameters: readonly ParameterDeclaration[], + type: TypeNode | undefined, + equalsGreaterThanToken: Token | undefined, + body: Block + ) { + return new ArrowFunction( + arkts.factory.createArrowFunction( + arkts.factory.createScriptFunction( + passNode(body), + arkts.FunctionSignature.create( + passTypeParams(typeParameters), + passNodeArray(parameters), + passNode(type) + ), + passModifiersToScriptFunction(modifiers) | Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_ARROW, + passModifiers(modifiers) | Es2pandaModifierFlags.MODIFIER_FLAGS_NONE, + false, + undefined + ) + ) + ) + } + + // @api + // function updateArrowFunction( + // node: ArrowFunction, + // modifiers: readonly Modifier[] | undefined, + // typeParameters: readonly TypeParameterDeclaration[] | undefined, + // parameters: readonly ParameterDeclaration[], + // type: TypeNode | undefined, + // equalsGreaterThanToken: EqualsGreaterThanToken, + // body: ConciseBody, + // ): ArrowFunction + function updateArrowFunction( + node: ArrowFunction, + modifiers: readonly Modifier[] | undefined, + typeParameters: readonly TypeParameterDeclaration[] | undefined, + parameters: readonly ParameterDeclaration[], + type: undefined, + equalsGreaterThanToken: Token | undefined, + body: Block, + ): ArrowFunction { + return new ArrowFunction( + arkts.factory.updateArrowFunction( + node.node, + arkts.factory.updateScriptFunction( + node.node.scriptFunction, + passNode(body), + arkts.FunctionSignature.create( + passTypeParams(typeParameters), + passNodeArray(parameters), + passNode(type) + ), + passModifiersToScriptFunction(modifiers) | Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_ARROW, + passModifiers(modifiers) | Es2pandaModifierFlags.MODIFIER_FLAGS_NONE, + false, + undefined + ) + ) + ) + } + + // @api + // function createClassDeclaration( + // modifiers: readonly ModifierLike[] | undefined, + // name: string | Identifier | undefined, + // typeParameters: readonly TypeParameterDeclaration[] | undefined, + // heritageClauses: readonly HeritageClause[] | undefined, + // members: readonly ClassElement[], + // ): ClassDeclaration + function createClassDeclaration( + modifiers: readonly Modifier[] | undefined, + name: string | Identifier | undefined, + typeParameters: readonly TypeParameterDeclaration[] | undefined, + heritageClauses: readonly TypeParameterDeclaration[] | undefined, + members: readonly ClassElement[] + ): ClassDeclaration { + return new ClassDeclaration( + arkts.factory.createClassDeclaration( + arkts.factory.createClassDefinition( + passIdentifier(name), + passNodeArray(members), + // passModifiers(modifiers) | es2panda_ModifierFlags.MODIFIER_FLAGS_PUBLIC | es2panda_ModifierFlags.MODIFIER_FLAGS_STATIC, + Es2pandaModifierFlags.MODIFIER_FLAGS_NONE, + // TODO: pass through modifiers + Es2pandaClassDefinitionModifiers.CLASS_DEFINITION_MODIFIERS_NONE, + passTypeParams(typeParameters), + undefined + ) + ) + ) + } + + // @api + // updateClassDeclaration( + // node: ClassDeclaration, + // modifiers: readonly ModifierLike[] | undefined, + // name: Identifier | undefined, + // typeParameters: readonly TypeParameterDeclaration[] | undefined, + // heritageClauses: readonly HeritageClause[] | undefined, + // members: readonly ClassElement[] + // ): ClassDeclaration; + function updateClassDeclaration( + node: ClassDeclaration, + modifiers: readonly Modifier[] | undefined, + name: Identifier | undefined, + typeParameters: readonly TypeParameterDeclaration[] | undefined, + heritageClauses: undefined, + members: readonly ClassElement[] + ): ClassDeclaration { + return new ClassDeclaration( + arkts.factory.updateClassDeclaration( + node.node, + arkts.factory.updateClassDefinition( + node.node.definition, + passIdentifier(name), + passNodeArray(members), + // passModifiers(modifiers) | es2panda_ModifierFlags.MODIFIER_FLAGS_PUBLIC | es2panda_ModifierFlags.MODIFIER_FLAGS_STATIC, + Es2pandaModifierFlags.MODIFIER_FLAGS_NONE, + // TODO: pass through modifiers + Es2pandaClassDefinitionModifiers.CLASS_DEFINITION_MODIFIERS_NONE, + passTypeParams(typeParameters) + ) + ) + ) + } + + // @api + // tsc: createFunctionTypeNode( + // typeParameters: readonly TypeParameterDeclaration[] | undefined, + // parameters: readonly ParameterDeclaration[], + // type: TypeNode + // ): FunctionTypeNode; + function createFunctionTypeNode( + typeParameters: readonly TypeParameterDeclaration[] | undefined, + parameters: readonly ParameterDeclaration[], + type: TypeNode + ): FunctionTypeNode { + return new FunctionTypeNode( + arkts.factory.createFunctionType( + arkts.FunctionSignature.create( + passTypeParams(typeParameters), + passNodeArray(parameters), + passNode(type) + ), + Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_NONE + ) + ) + } + + // @api + // function updateFunctionTypeNode( + // node: FunctionTypeNode, + // typeParameters: NodeArray | undefined, + // parameters: NodeArray, + // type: TypeNode, + // ): FunctionTypeNode + function updateFunctionTypeNode( + node: FunctionTypeNode, + typeParameters: readonly TypeParameterDeclaration[] | undefined, + parameters: readonly ParameterDeclaration[], + type: TypeNode + ): FunctionTypeNode { + return new FunctionTypeNode( + arkts.factory.updateFunctionType( + node.node, + arkts.FunctionSignature.create( + passTypeParams(typeParameters), + passNodeArray(parameters), + passNode(type) + ), + Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_NONE + ) + ) + } + + // TODO: fix modifiers + // @api + // createMethodDeclaration( + // modifiers: readonly ModifierLike[] | undefined, + // asteriskToken: AsteriskToken | undefined, + // name: string | PropertyName, + // questionToken: QuestionToken | undefined, + // typeParameters: readonly TypeParameterDeclaration[] | undefined, + // parameters: readonly ParameterDeclaration[], + // type: TypeNode | undefined, + // body: Block | undefined + // ): MethodDeclaration; + function createMethodDeclaration( + modifiers: readonly Modifier[] | undefined, + asteriskToken: undefined, + name: string | Identifier, + questionToken: undefined, + typeParameters: readonly TypeParameterDeclaration[] | undefined, + parameters: readonly ParameterDeclaration[], + type: TypeNode | undefined, + body: Block | undefined + ): MethodDeclaration { + const _name = passIdentifier(name) + return new MethodDeclaration( + arkts.factory.createMethodDefinition( + Es2pandaMethodDefinitionKind.METHOD_DEFINITION_KIND_METHOD, + _name, + arkts.factory.createFunctionExpression( + arkts.factory.createScriptFunction( + passNode(body), + arkts.FunctionSignature.create( + passTypeParams(typeParameters), + passNodeArray(parameters), + passNode(type) + ), + 0, + passModifiers(modifiers) | Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC || Es2pandaModifierFlags.MODIFIER_FLAGS_STATIC, + false, + _name + ) + ), + passModifiers(modifiers), + false + ) + ) + } + + // @api + // tsc: updateMethodDeclaration( + // node: MethodDeclaration, + // modifiers: readonly ModifierLike[] | undefined, + // asteriskToken: AsteriskToken | undefined, + // name: PropertyName, + // questionToken: QuestionToken | undefined, + // typeParameters: readonly TypeParameterDeclaration[] | undefined, + // parameters: readonly ParameterDeclaration[], + // type: TypeNode | undefined, + // body: Block | undefined + // ): MethodDeclaration; + function updateMethodDeclaration( + node: MethodDeclaration, + modifiers: readonly Modifier[] | undefined, + asteriskToken: undefined, + name: Identifier, + questionToken: undefined, + typeParameters: readonly TypeParameterDeclaration[] | undefined, + parameters: readonly ParameterDeclaration[], + type: undefined, + body: Block | undefined + ): MethodDeclaration { + const _name = passIdentifier(name) + return new MethodDeclaration( + arkts.factory.updateMethodDefinition( + node.node, + Es2pandaMethodDefinitionKind.METHOD_DEFINITION_KIND_METHOD, + _name, + arkts.factory.createFunctionExpression( + // TODO: maybe fix + arkts.factory.updateScriptFunction( + node.node.scriptFunction, + passNode(body), + arkts.FunctionSignature.create( + passTypeParams(typeParameters), + passNodeArray(parameters), + passNode(type) + ), + 0, + passModifiers(modifiers) | Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC || Es2pandaModifierFlags.MODIFIER_FLAGS_STATIC, + false, + _name + ) + ), + passModifiers(modifiers), + false + ) + ) + } + + // @api + // createConstructorDeclaration( + // modifiers: readonly ModifierLike[] | undefined, + // parameters: readonly ParameterDeclaration[], + // body: Block | undefined + // ): ConstructorDeclaration; + function createConstructorDeclaration( + modifiers: readonly Modifier[] | undefined, + parameters: readonly ParameterDeclaration[], + body: Block | undefined + ): ConstructorDeclaration { + const _name = arkts.factory.createIdentifier( + "constructor" + ) + return new ConstructorDeclaration( + arkts.factory.createMethodDefinition( + Es2pandaMethodDefinitionKind.METHOD_DEFINITION_KIND_CONSTRUCTOR, + _name, + arkts.factory.createFunctionExpression( + arkts.factory.createScriptFunction( + passNode(body), + arkts.FunctionSignature.create( + undefined, + passNodeArray(parameters), + // TODO: change to void maybe + undefined + ), + passModifiersToScriptFunction(modifiers) | Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_CONSTRUCTOR, + passModifiers(modifiers) | Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC | Es2pandaModifierFlags.MODIFIER_FLAGS_CONSTRUCTOR, + false, + _name + ) + ), + passModifiers(modifiers) | Es2pandaModifierFlags.MODIFIER_FLAGS_CONSTRUCTOR, + false + ) + ) + } + + // @api + // function updateConstructorDeclaration( + // node: ConstructorDeclaration, + // modifiers: readonly ModifierLike[] | undefined, + // parameters: readonly ParameterDeclaration[], + // body: Block | undefined, + // ): ConstructorDeclaration + function updateConstructorDeclaration( + node: ConstructorDeclaration, + modifiers: readonly Modifier[] | undefined, + parameters: readonly ParameterDeclaration[], + body: Block | undefined + ): ConstructorDeclaration { + const _name = arkts.factory.updateIdentifier( + node.node.name, + "constructor" + ) + return new ConstructorDeclaration( + arkts.factory.updateMethodDefinition( + node.node, + Es2pandaMethodDefinitionKind.METHOD_DEFINITION_KIND_CONSTRUCTOR, + _name, + arkts.factory.createFunctionExpression( + // TODO: maybe fix + arkts.factory.updateScriptFunction( + node.node.scriptFunction, + passNode(body), + arkts.FunctionSignature.create( + undefined, + passNodeArray(parameters), + // TODO: change to void maybe + undefined + ), + passModifiersToScriptFunction(modifiers) | Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_CONSTRUCTOR, + passModifiers(modifiers) | Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC | Es2pandaModifierFlags.MODIFIER_FLAGS_CONSTRUCTOR, + false, + _name + ) + ), + passModifiers(modifiers) | Es2pandaModifierFlags.MODIFIER_FLAGS_CONSTRUCTOR, + false + ) + ) + + } + + // @api + // tsc: createSuper( + // ): SuperExpression; + function createSuper( + ): SuperExpression { + return new SuperExpression( + arkts.factory.createSuperExpression() + ) + } + + // @api + // tsc: updateSuper( + // node: SuperExpression + // ): SuperExpression; + function updateSuper( + node: SuperExpression + ): SuperExpression { + return new SuperExpression( + arkts.factory.updateSuperExpression( + node.node, + ) + ) + } + + // @api + // tsc: createParenthesizedExpression( + // expression: Expression + // ): ParenthesizedExpression; + function createParenthesizedExpression( + expression: Expression + ): ParenthesizedExpression { + return expression + // TODO: + // return new ParenthesizedExpression( + // expression + // ) + } + + // @api + // tsc: updateParenthesizedExpression( + // node: ParenthesizedExpression, + // expression: Expression + // ): ParenthesizedExpression; + function updateParenthesizedExpression( + node: ParenthesizedExpression, + expression: Expression + ): ParenthesizedExpression { + return expression + // TODO: + // return new ParenthesizedExpression( + // expression + // ) + } + + // // @api + // // createImportDeclaration( + // // decorators: readonly Decorator[] | undefined, + // // modifiers: readonly Modifier[] | undefined, + // // importClause: ImportClause | undefined, + // // moduleSpecifier: Expression, + // // assertClause?: AssertClause + // // ): ImportDeclaration; + // function createImportDeclaration( + // decorators: undefined, + // modifiers: readonly Modifier[] | undefined, + // importClause: ImportClause | undefined, + // moduleSpecifier: StringLiteral, + // assertClause?: undefined + // ): ImportDeclaration { + // return new ImportDeclaration( + // arkts.EtsImportDeclaration.create( + // undefined, + // arkts.ImportSource.create(moduleSpecifier.node), + + // ) + // ) + // } + + // @api + // createImportSpecifier( + // isTypeOnly: boolean, + // propertyName: Identifier | undefined, + // name: Identifier + // ): ImportSpecifier; + function createImportSpecifier( + isTypeOnly: boolean, + propertyName: Identifier | undefined, + name: Identifier + ): ImportSpecifier { + return new ImportSpecifier( + name.node + ) + } +} + +export const factory = createNodeFactory(); diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/ts-api/factory/nodeTests.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/ts-api/factory/nodeTests.ts new file mode 100644 index 0000000000000000000000000000000000000000..74114702a7448916f482ba9b588e5a2b49dfad5b --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/ts-api/factory/nodeTests.ts @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { SyntaxKind, } from "@koalaui/ets-tsc" + +import { + ArrowFunction, + Block, + CallExpression, + ClassDeclaration, + ExpressionStatement, + FunctionDeclaration, + FunctionExpression, + FunctionTypeNode, + GetAccessorDeclaration, + Identifier, + MethodDeclaration, + MethodSignature, + Node, + ParameterDeclaration, + PropertyAccessExpression, + PropertyDeclaration, + PropertySignature, + SetAccessorDeclaration, + SourceFile, + VariableDeclaration, + VariableDeclarationList, + VariableStatement, +} from "../types" + +export function isIdentifier(node: Node): node is Identifier { + return node.kind === SyntaxKind.Identifier +} + +export function isCallExpression(node: Node): node is CallExpression { + return node.kind === SyntaxKind.CallExpression +} + +export function isPropertyAccessExpression(node: Node): node is PropertyAccessExpression { + return node.kind === SyntaxKind.PropertyAccessExpression +} + +export function isFunctionDeclaration(node: Node): node is FunctionDeclaration { + return node.kind === SyntaxKind.FunctionDeclaration +} + +export function isMethodDeclaration(node: Node): node is MethodDeclaration { + return node.kind === SyntaxKind.MethodDeclaration +} + +export function isSourceFile(node: Node): node is SourceFile { + return node.kind === SyntaxKind.SourceFile +} + +export function isExpressionStatement(node: Node): node is ExpressionStatement { + return node.kind === SyntaxKind.ExpressionStatement +} + +export function isArrowFunction(node: Node): node is ArrowFunction { + return node.kind === SyntaxKind.ArrowFunction +} + +export function isClassDeclaration(node: Node): node is ClassDeclaration { + return node.kind === SyntaxKind.ClassDeclaration +} + +export function isBlock(node: Node): node is Block { + return node.kind === SyntaxKind.Block +} + +export function isFunctionExpression(node: Node): node is FunctionExpression { + return node.kind === SyntaxKind.FunctionExpression +} + +export function isParameter(node: Node): node is ParameterDeclaration { + return node.kind === SyntaxKind.Parameter +} + +export function isVariableDeclaration(node: Node): node is VariableDeclaration { + return node.kind === SyntaxKind.VariableDeclaration +} + +export function isVariableDeclarationList(node: Node): node is VariableDeclarationList { + return node.kind === SyntaxKind.VariableDeclarationList +} + +export function isPropertyDeclaration(node: Node): node is PropertyDeclaration { + return node.kind === SyntaxKind.PropertyDeclaration +} + +export function isPropertySignature(node: Node): node is PropertySignature { + return node.kind === SyntaxKind.PropertySignature +} + +export function isFunctionTypeNode(node: Node): node is FunctionTypeNode { + return node.kind === SyntaxKind.FunctionType +} + +export function isMethodSignature(node: Node): node is MethodSignature { + return node.kind === SyntaxKind.MethodSignature +} + +export function isGetAccessorDeclaration(node: Node): node is GetAccessorDeclaration { + return node.kind === SyntaxKind.GetAccessor +} + +export function isSetAccessorDeclaration(node: Node): node is SetAccessorDeclaration { + return node.kind === SyntaxKind.SetAccessor +} + +export function isVariableStatement(node: Node): node is VariableStatement { + return node.kind === SyntaxKind.VariableStatement +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/ts-api/index.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/ts-api/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..354f0b841e5753177c68d7a28ba09e28063dafc1 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/ts-api/index.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// TODO: remove private export +export * from "./utilities/private" +export * from "./utilities/public" +export * from "./types" +export * from "./factory/nodeFactory" +export * from "./factory/nodeTests" +export { + visitEachChild, +} from "./visitor/visitor" +export { + SyntaxKind, + NodeFlags, +} from "./static/enums" + +// from ArkTS api +export * from "../arkts-api/static/global" +export { + Es2pandaContextState as ContextState, + Es2pandaPrimitiveType as Es2pandaPrimitiveType, +} from "../arkts-api" diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/ts-api/static/enums.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/ts-api/static/enums.ts new file mode 100644 index 0000000000000000000000000000000000000000..78dc895df7ecda4ff446e39b9edd61d465cd5eec --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/ts-api/static/enums.ts @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export { SyntaxKind } from "@koalaui/ets-tsc" +export { TokenSyntaxKind } from "@koalaui/ets-tsc" +export { NodeFlags } from "@koalaui/ets-tsc" diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/ts-api/types.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/ts-api/types.ts new file mode 100644 index 0000000000000000000000000000000000000000..cb263beaad5a40bebcc2c2845100ecbe8ed4dcff --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/ts-api/types.ts @@ -0,0 +1,935 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as ts from "@koalaui/ets-tsc" +import * as arkts from "../arkts-api" + +import { throwError } from "../utils" +import { + passModifiers, + todo, + unpackModifiers, + unpackNode, + unpackNodeArray, + unpackVariableDeclarationKind, +} from "./utilities/private" +import { SyntaxKind } from "./static/enums" + +// TODO: write implementation +export interface TransformationContext {} + +// TODO: write implementation +export interface Program {} + +// TODO: remove U type param +export type NodeArray, U extends arkts.AstNode | undefined = arkts.AstNode | undefined> = ts.NodeArray + +export abstract class Node implements ts.Node { + constructor(node: T) { + this.node = node + } + + readonly node: T + + // TODO: remove any + get parent(): any { + if (this.node === undefined) { + throwError('trying to get parent of undefined _node') + } + return unpackNode(this.node.parent) + } + + set parent(node: Node) { + if (this.node === undefined) { + throwError('trying to set parent of undefined') + } + if (node.node === undefined) { + throwError('trying to set parent to undefined') + } + this.node.parent = node.node + } + + set modifiers(flags: readonly Modifier[] | undefined) { + if (this.node === undefined) { + throwError('trying to set modifiers of undefined') + } + this.node.modifiers = passModifiers(flags) + } + + get modifiers(): NodeArray { + return unpackModifiers(this.node?.modifiers) + } + + abstract kind: SyntaxKind + + // TODO: + forEachChild(cbNode: (node: ts.Node) => T | undefined, cbNodeArray?: ((nodes: ts.NodeArray) => T | undefined) | undefined): T | undefined { throw new Error("Method not implemented.") } + getSourceFile(): ts.SourceFile { throw new Error("Method not implemented.") } + getChildCount(sourceFile?: ts.SourceFile | undefined): number { throw new Error("Method not implemented.") } + getChildAt(index: number, sourceFile?: ts.SourceFile | undefined): ts.Node { throw new Error("Method not implemented.") } + getChildren(sourceFile?: ts.SourceFile | undefined): ts.Node[] { throw new Error("Method not implemented.") } + + getStart(sourceFile?: ts.SourceFile | undefined, includeJsDocComment?: boolean | undefined): number { throw new Error("Method not implemented.") } + getFullStart(): number { throw new Error("Method not implemented.") } + getEnd(): number { throw new Error("Method not implemented.") } + getWidth(sourceFile?: ts.SourceFileLike | undefined): number { throw new Error("Method not implemented.") } + getFullWidth(): number { throw new Error("Method not implemented.") } + getLeadingTriviaWidth(sourceFile?: ts.SourceFile | undefined): number { throw new Error("Method not implemented.") } + getFullText(sourceFile?: ts.SourceFile | undefined): string { throw new Error("Method not implemented.") } + getText(sourceFile?: ts.SourceFile | undefined): string { throw new Error("Method not implemented.") } + getFirstToken(sourceFile?: ts.SourceFile | undefined): ts.Node | undefined { throw new Error("Method not implemented.") } + getLastToken(sourceFile?: ts.SourceFile | undefined): ts.Node | undefined { throw new Error("Method not implemented.") } + + get symbol(): ts.Symbol { return todo() } + get flags(): ts.NodeFlags { return todo() } + get pos(): number { return todo() } + get end(): number { return todo() } +} + +// TODO: add all tokens +export type BinaryOperator = + | ts.SyntaxKind.PlusToken + | ts.SyntaxKind.MinusToken + + | ts.SyntaxKind.AsteriskToken + +export type BinaryOperatorToken = Token; + +// TODO: rethink maybe (temporary solution) +export class Token extends Node { + constructor(kind: TKind) { + super(undefined) + this.kind = kind + } + + readonly kind: TKind; +} + +export type ModifierSyntaxKind = + // | SyntaxKind.ConstructorKeyword + | SyntaxKind.AbstractKeyword + | SyntaxKind.AccessorKeyword + | SyntaxKind.AsyncKeyword + | SyntaxKind.ConstKeyword + | SyntaxKind.DeclareKeyword + | SyntaxKind.DefaultKeyword + | SyntaxKind.ExportKeyword + | SyntaxKind.InKeyword + | SyntaxKind.PrivateKeyword + | SyntaxKind.ProtectedKeyword + | SyntaxKind.PublicKeyword + | SyntaxKind.ReadonlyKeyword + | SyntaxKind.OutKeyword + | SyntaxKind.OverrideKeyword + | SyntaxKind.StaticKeyword; + +export class Modifier extends Node { + constructor(kind: ModifierSyntaxKind) { + super(undefined) + this.kind = kind + } + + public toString(): string { + return `${this.kind}` + } + + kind: ModifierSyntaxKind +} + +export abstract class Expression extends Node implements ts.Expression { + // TODO: support minimal interface + _expressionBrand: any +} + +export class FunctionDeclaration extends Node implements ts.FunctionDeclaration, FunctionLikeDeclarationBase { + constructor(node: arkts.FunctionDeclaration) { + super(node) + this.name = unpackNode(node.name) + this.body = unpackNode(node.body) + this.typeParameters = unpackNodeArray(node.typeParamsDecl?.parameters) + this.type = unpackNode(node.returnType) + this.parameters = unpackNodeArray(node.parameters) + } + + readonly name?: Identifier | undefined + readonly body?: Block | undefined + readonly typeParameters?: NodeArray | undefined + readonly type?: TypeNode | undefined + readonly parameters: NodeArray + readonly kind: ts.SyntaxKind.FunctionDeclaration = ts.SyntaxKind.FunctionDeclaration + + // brands + _functionLikeDeclarationBrand: any + _declarationBrand: any + _statementBrand: any +} + +export class FunctionExpression extends Node implements ts.FunctionExpression, FunctionLikeDeclarationBase { + constructor(node: arkts.FunctionExpression) { + super(node) + this.name = unpackNode(node.scriptFunction.ident) + if (node.scriptFunction.body === undefined) { + throwError('body expected to be not undefined') + } + this.body = unpackNode(node.scriptFunction.body) + this.parameters = unpackNodeArray(node.scriptFunction.parameters) + } + + readonly name?: Identifier + readonly body: Block + readonly parameters: NodeArray + readonly kind: ts.SyntaxKind.FunctionExpression = ts.SyntaxKind.FunctionExpression + + // brands + _primaryExpressionBrand: any + _memberExpressionBrand: any + _leftHandSideExpressionBrand: any + _updateExpressionBrand: any + _unaryExpressionBrand: any + _expressionBrand: any + _functionLikeDeclarationBrand: any + _declarationBrand: any +} + +export class Identifier extends Node implements ts.Identifier, Expression { + constructor(node: arkts.Identifier) { + super(node) + this.text = node.name + } + + readonly text: string + readonly kind: ts.SyntaxKind.Identifier = ts.SyntaxKind.Identifier + + // TODO: + get escapedText(): ts.__String { return todo() } + + // brands + _primaryExpressionBrand: any + _memberExpressionBrand: any + _leftHandSideExpressionBrand: any + _updateExpressionBrand: any + _unaryExpressionBrand: any + _expressionBrand: any + _declarationBrand: any +} + +export class PrivateIdentifier extends Node implements ts.PrivateIdentifier, Expression { + constructor(node: arkts.Identifier) { + super(node) + this.text = node.name + if (!node.isPrivate) { + throwError('identifier expected to be private') + } + } + + readonly text: string + readonly kind: ts.SyntaxKind.PrivateIdentifier = ts.SyntaxKind.PrivateIdentifier + + // TODO: + get escapedText(): ts.__String { return todo() } + + // brands + _primaryExpressionBrand: any + _memberExpressionBrand: any + _leftHandSideExpressionBrand: any + _updateExpressionBrand: any + _unaryExpressionBrand: any + _expressionBrand: any + _declarationBrand: any +} + +export abstract class Statement extends Node implements ts.Statement { + // brands + _statementBrand: any +} + +export class Block extends Node implements ts.Block { + constructor(node: arkts.BlockStatement) { + super(node) + this.statements = unpackNodeArray(node.statements) + } + + readonly statements: NodeArray + readonly kind: ts.SyntaxKind.Block = ts.SyntaxKind.Block + + // brands + _statementBrand: any +} + +export class SourceFile extends Node implements ts.SourceFile { + constructor(node: arkts.EtsScript) { + super(node) + + this.statements = unpackNodeArray(this.node.statements) + } + + readonly statements: NodeArray + readonly kind: ts.SyntaxKind.SourceFile = ts.SyntaxKind.SourceFile + + // TODO: + getLineAndCharacterOfPosition(pos: number): ts.LineAndCharacter { throw new Error("Method not implemented.") } + getLineEndOfPosition(pos: number): number { throw new Error("Method not implemented.") } + getLineStarts(): readonly number[] { throw new Error("Method not implemented.") } + getPositionOfLineAndCharacter(line: number, character: number): number { throw new Error("Method not implemented.") } + update(newText: string, textChangeRange: ts.TextChangeRange): ts.SourceFile { throw new Error("Method not implemented.") } + get endOfFileToken(): ts.Token { return todo() } + get fileName(): string { return todo() } + get text() { return todo() } + get amdDependencies(): readonly ts.AmdDependency[] { return todo() } + get referencedFiles(): readonly ts.FileReference[] { return todo() } + get typeReferenceDirectives(): readonly ts.FileReference[] { return todo() } + get libReferenceDirectives(): readonly ts.FileReference[] { return todo() } + get languageVariant(): ts.LanguageVariant { return todo() } + get isDeclarationFile(): boolean { return todo() } + get hasNoDefaultLib(): boolean { return todo() } + get languageVersion(): ts.ScriptTarget { return todo() } + + // brands + _declarationBrand: any +} + +export abstract class LeftHandSideExpression extends Node implements ts.LeftHandSideExpression, Expression { + // brands + _leftHandSideExpressionBrand: any + _updateExpressionBrand: any + _unaryExpressionBrand: any + _expressionBrand: any +} + +export class ExpressionStatement extends Node implements ts.ExpressionStatement, Statement { + constructor(node: arkts.ExpressionStatement) { + super(node) + this.expression = unpackNode(this.node.expression) + } + + readonly expression: Expression + readonly kind: ts.SyntaxKind.ExpressionStatement = ts.SyntaxKind.ExpressionStatement + + // brands + _statementBrand: any +} + +export class CallExpression extends Node implements ts.CallExpression, LeftHandSideExpression { + constructor(node: arkts.CallExpression) { + super(node) + this.expression = unpackNode(node.expression) + this.arguments = unpackNodeArray(node.arguments) + } + + readonly expression: LeftHandSideExpression + readonly arguments: NodeArray + readonly kind: ts.SyntaxKind.CallExpression = ts.SyntaxKind.CallExpression + + // brands + _leftHandSideExpressionBrand: any + _updateExpressionBrand: any + _unaryExpressionBrand: any + _expressionBrand: any + _declarationBrand: any +} + +export class PropertyAccessExpression extends Node implements ts.PropertyAccessExpression, Expression { + constructor(node: arkts.MemberExpression) { + super(node) + this.expression = unpackNode(node.object) + this.name = unpackNode(node.property) + } + + readonly expression: LeftHandSideExpression + readonly name: Identifier + readonly kind: ts.SyntaxKind.PropertyAccessExpression = ts.SyntaxKind.PropertyAccessExpression + + // brands + _memberExpressionBrand: any + _leftHandSideExpressionBrand: any + _updateExpressionBrand: any + _unaryExpressionBrand: any + _expressionBrand: any + _declarationBrand: any +} + +export class StringLiteral extends Node implements ts.StringLiteral { + constructor(node: arkts.StringLiteral) { + super(node) + + this.text = node.str + } + + readonly text: string + readonly kind: ts.SyntaxKind.StringLiteral = ts.SyntaxKind.StringLiteral + + // brands + _literalExpressionBrand: any + _primaryExpressionBrand: any + _memberExpressionBrand: any + _leftHandSideExpressionBrand: any + _updateExpressionBrand: any + _unaryExpressionBrand: any + _expressionBrand: any + _declarationBrand: any +} + +export class ClassDeclaration extends Node implements ts.ClassDeclaration { + constructor(node: arkts.ClassDeclaration) { + super(node) + this.name = unpackNode(node.definition.name) + this.members = unpackNodeArray(node.definition.members) + this.typeParameters = unpackNodeArray(node.definition.typeParamsDecl?.parameters) + } + + readonly name: Identifier + readonly members: NodeArray + readonly typeParameters?: NodeArray + readonly kind: ts.SyntaxKind.ClassDeclaration = ts.SyntaxKind.ClassDeclaration + + // brands + _declarationBrand: any + _statementBrand: any +} + +export abstract class ClassElement extends Node implements ts.ClassElement { + // brands + _declarationBrand: any + _classElementBrand: any +} + +export type MemberName = Identifier | PrivateIdentifier; + +// TODO: support +// export type PropertyName = Identifier | StringLiteral | NumericLiteral | ts.ComputedPropertyName | PrivateIdentifier; +export type PropertyName = Identifier | StringLiteral | NumericLiteral | PrivateIdentifier; + +// TODO: support +export type DeclarationName = + | PropertyName + // | JsxAttributeName + // | StringLiteralLike + // | ElementAccessExpression + // | BindingPattern + // | EntityNameExpression; + +export interface Declaration extends Node {} + +export abstract class NamedDeclaration extends Node implements ts.NamedDeclaration, Declaration { + readonly name?: DeclarationName; + + // brands + _declarationBrand: any +} + +export type SignatureDeclaration = ts.CallSignatureDeclaration | ts.ConstructSignatureDeclaration | MethodSignature | ts.IndexSignatureDeclaration | FunctionTypeNode | ts.ConstructorTypeNode | ts.JSDocFunctionType | FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | ts.AccessorDeclaration | FunctionExpression | ArrowFunction; + +export interface SignatureDeclarationBase extends NamedDeclaration {} + +export type VariableLikeDeclaration = ts.VariableDeclaration | ParameterDeclaration | ts.BindingElement | PropertyDeclaration | ts.PropertyAssignment | PropertySignature | ts.JsxAttribute | ts.ShorthandPropertyAssignment | ts.EnumMember | ts.JSDocPropertyTag | ts.JSDocParameterTag; + +export interface FunctionLikeDeclarationBase extends SignatureDeclarationBase { + // brands + _functionLikeDeclarationBrand: any; +} + +// TODO: support +// export type FunctionLikeDeclaration = FunctionDeclaration | MethodDeclaration | ts.GetAccessorDeclaration | ts.SetAccessorDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction; +export type FunctionLikeDeclaration = FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction; + +export class MethodSignature extends Node implements ts.MethodSignature, SignatureDeclarationBase { + constructor(node: arkts.AstNode) { + super(node) + } + + // readonly name: PropertyName + // readonly parameters: NodeArray + readonly kind: ts.SyntaxKind.MethodSignature = ts.SyntaxKind.MethodSignature + + // TODO: + name: any + parameters: any + + // brands + _declarationBrand: any + _typeElementBrand: any +} + +// export class MethodDeclaration extends Node implements ts.MethodDeclaration, FunctionLikeDeclarationBase, ClassElement { +export class MethodDeclaration extends Node implements ts.MethodDeclaration, ClassElement { + constructor(node: arkts.MethodDefinition) { + super(node) + this.name = unpackNode(node.name) + this.parameters = unpackNodeArray(node.scriptFunction.parameters) + this.body = unpackNode(node.scriptFunction.body) + } + + // tsc: readonly name?: PropertyName + readonly name: Identifier + readonly parameters: NodeArray + // tsc: readonly body?: FunctionBody | undefined + readonly body?: Block | undefined + readonly kind: ts.SyntaxKind.MethodDeclaration = ts.SyntaxKind.MethodDeclaration + + // brands + _functionLikeDeclarationBrand: any + _classElementBrand: any + _objectLiteralBrand: any + _declarationBrand: any +} + +// export class ConstructorDeclaration extends Node implements ts.ConstructorDeclaration, FunctionLikeDeclarationBase, ClassElement { +export class ConstructorDeclaration extends Node implements ts.ConstructorDeclaration, ClassElement { + constructor(node: arkts.MethodDefinition) { + super(node) + this.name = unpackNode(node.name) + this.parameters = unpackNodeArray(node.scriptFunction.parameters) + this.body = unpackNode(node.scriptFunction.body) + } + + // ts: readonly name?: PropertyName + readonly name: Identifier + readonly parameters: NodeArray + // ts: readonly body?: FunctionBody | undefined + readonly body?: Block + readonly kind: ts.SyntaxKind.Constructor = ts.SyntaxKind.Constructor + + // brands + _functionLikeDeclarationBrand: any + _classElementBrand: any + _objectLiteralBrand: any + _declarationBrand: any +} + +// TODO: specify arkts.AstNode type +export class PropertySignature extends Node implements ts.TypeElement { + constructor(node: arkts.AstNode) { + super(node) + } + + readonly name?: PropertyName + readonly kind: ts.SyntaxKind.PropertySignature = ts.SyntaxKind.PropertySignature + + // brands + _typeElementBrand: any + _declarationBrand: any +} + +// TODO: specify arkts.AstNode type +export class PropertyDeclaration extends Node implements ts.PropertyDeclaration, ClassElement { + constructor(node: arkts.AstNode) { + super(node) + } + + readonly kind: ts.SyntaxKind.PropertyDeclaration = ts.SyntaxKind.PropertyDeclaration + + // TODO: + name: any + + // brands + _classElementBrand: any + _declarationBrand: any +} + +// TODO: specify arkts.AstNode type +export class GetAccessorDeclaration extends Node implements ts.GetAccessorDeclaration, FunctionLikeDeclarationBase, ClassElement { + constructor(node: arkts.AstNode) { + super(node) + } + + // readonly name: PropertyName + // readonly parameters: NodeArray + readonly kind: ts.SyntaxKind.GetAccessor = ts.SyntaxKind.GetAccessor + + // TODO: + name: any + parameters: any + + // brands + _functionLikeDeclarationBrand: any + _declarationBrand: any + _classElementBrand: any + _typeElementBrand: any + _objectLiteralBrand: any +} + +// TODO: specify arkts.AstNode type +export class SetAccessorDeclaration extends Node implements ts.SetAccessorDeclaration, FunctionLikeDeclarationBase, ClassElement { + constructor(node: arkts.AstNode) { + super(node) + } + + // readonly name: PropertyName + // readonly parameters: NodeArray + readonly kind: ts.SyntaxKind.SetAccessor = ts.SyntaxKind.SetAccessor + + // TODO: + name: any + parameters: any + + // brands + _functionLikeDeclarationBrand: any + _declarationBrand: any + _classElementBrand: any + _typeElementBrand: any + _objectLiteralBrand: any +} + +export class ParameterDeclaration extends Node implements ts.ParameterDeclaration, NamedDeclaration { + constructor(node: arkts.ETSParameterExpression) { + super(node) + } + + readonly kind: ts.SyntaxKind.Parameter = ts.SyntaxKind.Parameter + + // TODO: + name: any + + // brands + _declarationBrand: any +} + +export type BindingName = Identifier | ts.BindingPattern; + +export class VariableStatement extends Node implements ts.VariableStatement { + constructor(node: arkts.VariableDeclaration) { + super(node) + this.declarationList = new VariableDeclarationList(node) + } + + readonly declarationList: VariableDeclarationList + readonly kind: ts.SyntaxKind.VariableStatement = ts.SyntaxKind.VariableStatement + + // brands + _statementBrand: any +} + +export class VariableDeclarationList extends Node implements ts.VariableDeclarationList { + constructor(node: arkts.VariableDeclaration) { + super(node) + this.declarations = unpackNodeArray(node.declarators) + } + + readonly declarations: NodeArray + get flags(): ts.NodeFlags { return unpackVariableDeclarationKind(this.node.declarationKind) } + readonly kind: ts.SyntaxKind.VariableDeclarationList = ts.SyntaxKind.VariableDeclarationList +} + +export class VariableDeclaration extends Node implements ts.VariableDeclaration, NamedDeclaration { + constructor(node: arkts.VariableDeclarator) { + super(node) + this.name = unpackNode(node.name) + } + + readonly name: Identifier + readonly kind: ts.SyntaxKind.VariableDeclaration = ts.SyntaxKind.VariableDeclaration + + // brands + _declarationBrand: any +} + +export class TypeParameterDeclaration extends Node implements ts.TypeParameterDeclaration { + constructor(node: arkts.TSTypeParameter) { + super(node) + this.name = unpackNode(node.name) + } + + readonly name: Identifier + readonly kind: ts.SyntaxKind.TypeParameter = ts.SyntaxKind.TypeParameter + + // brands + _declarationBrand: any +} + +export abstract class TypeNode extends Node implements ts.TypeNode { + // brands + _typeNodeBrand: any +} + +export class KeywordTypeNode extends Node implements ts.KeywordTypeNode, TypeNode { + constructor(node: arkts.ETSPrimitiveType | arkts.ETSTypeReference) { + super(node) + } + + readonly kind: ts.KeywordTypeSyntaxKind = ts.SyntaxKind.UnknownKeyword + + // brands + _typeNodeBrand: any +} + +export class TypeReferenceNode extends Node implements ts.TypeReferenceNode, TypeNode { + constructor(node: arkts.AstNode) { + super(node) + } + + readonly kind: ts.SyntaxKind.TypeReference = ts.SyntaxKind.TypeReference + + // TODO: + typeName: any + + // brands + _typeNodeBrand: any +} + +export class FunctionTypeNode extends Node implements ts.FunctionTypeNode, TypeNode, SignatureDeclarationBase { + constructor(node: arkts.AstNode) { + super(node) + } + + readonly name?: DeclarationName + readonly kind: ts.SyntaxKind.FunctionType = ts.SyntaxKind.FunctionType + + // TODO: support minimal interface + parameters: any + type: any + + // brands + _typeNodeBrand: any + _declarationBrand: any +} + +export class UnionTypeNode extends Node implements ts.UnionTypeNode, TypeNode { + constructor(node: arkts.ETSUnionType) { + super(node) + this.types = unpackNodeArray(node.types) + } + + readonly types: NodeArray + readonly kind: ts.SyntaxKind.UnionType = ts.SyntaxKind.UnionType + + // brands + _typeNodeBrand: any +} + +export class ReturnStatement extends Node implements ts.ReturnStatement, Statement { + constructor(node: arkts.ReturnStatement) { + super(node) + this.expression = unpackNode(node.argument) + } + + readonly expression: Expression | undefined + readonly kind: ts.SyntaxKind.ReturnStatement = ts.SyntaxKind.ReturnStatement + + // brands + _statementBrand: any +} + +export class IfStatement extends Node implements ts.IfStatement { + constructor(node: arkts.IfStatement) { + super(node) + } + + readonly kind: ts.SyntaxKind.IfStatement = ts.SyntaxKind.IfStatement + + // TODO: + thenStatement: any + expression: any + + // brands + _statementBrand: any +} + +export class BinaryExpression extends Node implements ts.BinaryExpression { + constructor(node: arkts.BinaryExpression) { + super(node) + } + + readonly kind: ts.SyntaxKind.BinaryExpression = ts.SyntaxKind.BinaryExpression + + // TODO: + left: any + right: any + operatorToken: any + + // brands + _expressionBrand: any + _declarationBrand: any +} + +export class AssignmentExpression extends Node implements ts.AssignmentExpression { + constructor(node: arkts.AssignmentExpression) { + super(node) + } + + readonly kind: ts.SyntaxKind.BinaryExpression = ts.SyntaxKind.BinaryExpression + + // TODO: + right: any + left: any + operatorToken: any + + // brands + _expressionBrand: any + _declarationBrand: any +} + +export class ArrowFunction extends Node implements ts.ArrowFunction { + constructor(node: arkts.ArrowFunctionExpression) { + super(node) + if (node.scriptFunction.body === undefined) { + throwError('node.scriptFunction.body not expected to be undefined') + } + this.body = unpackNode(node.scriptFunction.body) + this.parameters = unpackNodeArray(node.scriptFunction.parameters) + } + + get name(): never { return throwError(`name doesn't exist for ArrowFunction`) } + readonly body: Block + readonly parameters: NodeArray + readonly kind: ts.SyntaxKind.ArrowFunction = ts.SyntaxKind.ArrowFunction + + // TODO: + equalsGreaterThanToken: any + + // brands + _expressionBrand: any + _functionLikeDeclarationBrand: any + _declarationBrand: any +} + +export class NumericLiteral extends Node implements ts.NumericLiteral, Declaration { + constructor(node: arkts.NumberLiteral) { + super(node) + + this.text = `${node.value}` + } + + readonly text: string + readonly kind: ts.SyntaxKind.NumericLiteral = ts.SyntaxKind.NumericLiteral + + // brands + _literalExpressionBrand: any + _declarationBrand: any + _primaryExpressionBrand: any + _memberExpressionBrand: any + _leftHandSideExpressionBrand: any + _updateExpressionBrand: any + _unaryExpressionBrand: any + _expressionBrand: any +} + +export class SuperExpression extends Node implements ts.SuperExpression { + constructor(node: arkts.SuperExpression) { + super(node) + } + + readonly kind: ts.SyntaxKind.SuperKeyword = ts.SyntaxKind.SuperKeyword + + // brands + _primaryExpressionBrand: any + _memberExpressionBrand: any + _leftHandSideExpressionBrand: any + _updateExpressionBrand: any + _unaryExpressionBrand: any + _expressionBrand: any +} + +export class HeritageClause extends Node implements ts.HeritageClause { + constructor(node: arkts.SuperExpression) { + super(node) + } + + readonly kind: ts.SyntaxKind.HeritageClause = ts.SyntaxKind.HeritageClause + // token: ts.SyntaxKind.ExtendsKeyword | ts.SyntaxKind.ImplementsKeyword + // types: ts.NodeArray + + // TODO: + token: any + types: any +} + + +// TODO: there is no ParenthesizedExpression in ArkTS, +// so for temporary solution we're just gonna ignore this type of nodes +// and replace it with Expression underneath +export type ParenthesizedExpression = Expression +// export class ParenthesizedExpression extends Node implements ts.ParenthesizedExpression { +// constructor(expression: Expression) { +// super(undefined) +// this.expression = expression +// } + +// readonly expression: Expression +// readonly kind: ts.SyntaxKind.ParenthesizedExpression = ts.SyntaxKind.ParenthesizedExpression + +// // brands +// _primaryExpressionBrand: any +// _memberExpressionBrand: any +// _leftHandSideExpressionBrand: any +// _updateExpressionBrand: any +// _unaryExpressionBrand: any +// _expressionBrand: any +// } + +// TODO: +export class ImportDeclaration extends Node implements ts.ImportDeclaration { + constructor(node: arkts.UnsupportedNode) { + super(node) + } + + readonly kind: ts.SyntaxKind.ImportDeclaration = ts.SyntaxKind.ImportDeclaration + + // TODO: + moduleSpecifier: any + + // brands + _statementBrand: any +} + +// TODO: +export class ImportClause extends Node implements ts.ImportClause { + constructor(node: arkts.UnsupportedNode) { + super(node) + } + + readonly kind: ts.SyntaxKind.ImportClause = ts.SyntaxKind.ImportClause + + // TODO: + isTypeOnly: any + + // brands + _declarationBrand: any +} + +// TODO: +export class NamedImports extends Node implements ts.NamedImports { + constructor(node: arkts.UnsupportedNode) { + super(node) + } + + readonly kind: ts.SyntaxKind.NamedImports = ts.SyntaxKind.NamedImports + + // TODO: + elements: any +} + +export class ImportSpecifier extends Node implements ts.ImportSpecifier { + constructor(node: arkts.Identifier) { + super(node) + this.name = unpackNode(this.node) + } + + readonly name: Identifier + readonly kind: ts.SyntaxKind.ImportSpecifier = ts.SyntaxKind.ImportSpecifier + + // TODO: + isTypeOnly: any + + // brands + _declarationBrand: any +} + +export class UnsupportedNode extends Node implements ts.Node { + constructor(node: arkts.AstNode) { + super(node) + } + + readonly kind: ts.SyntaxKind = SyntaxKind.Unknown +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/ts-api/utilities/private.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/ts-api/utilities/private.ts new file mode 100644 index 0000000000000000000000000000000000000000..718fd97680ae404646185a3954afc8f606cbaf7e --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/ts-api/utilities/private.ts @@ -0,0 +1,289 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { throwError } from "../../utils" + +import * as ts from "../" +import * as arkts from "../../arkts-api" + +import { KInt } from "@koalaui/interop" +import { + SyntaxKind, + TokenSyntaxKind, + NodeFlags, +} from "../static/enums" +import { + Es2pandaAstNodeType, + Es2pandaModifierFlags, + Es2pandaScriptFunctionFlags, + Es2pandaTokenType, + Es2pandaVariableDeclarationKind, +} from "../../arkts-api" + +export function todo(): any { + throwError("Not yet implemented") +} + +type kindTypes = + | { new (node: arkts.AstNode): ts.Node } + | { new (node: arkts.Identifier): ts.Identifier } + | { new (node: arkts.EtsScript): ts.SourceFile } + | { new (node: arkts.StringLiteral): ts.StringLiteral } + | { new (node: arkts.NumberLiteral): ts.NumericLiteral } + | { new (node: arkts.ExpressionStatement): ts.ExpressionStatement } + | { new (node: arkts.FunctionDeclaration): ts.FunctionDeclaration } + | { new (node: arkts.ReturnStatement): ts.ReturnStatement } + | { new (node: arkts.ETSParameterExpression): ts.ParameterDeclaration } + | { new (node: arkts.CallExpression): ts.CallExpression } + | { new (node: arkts.BlockStatement): ts.Block } + | { new (node: arkts.TSTypeParameter): ts.TypeParameterDeclaration} + | { new (node: arkts.MemberExpression): ts.PropertyAccessExpression} + | { new (node: arkts.IfStatement): ts.IfStatement} + | { new (node: arkts.ETSTypeReference): ts.TypeReferenceNode } + | { new (node: arkts.ETSPrimitiveType | arkts.ETSTypeReference): ts.KeywordTypeNode } + | { new (node: arkts.BinaryExpression): ts.BinaryExpression } + | { new (node: arkts.ETSUnionType): ts.UnionTypeNode } + | { new (node: arkts.ArrowFunctionExpression): ts.ArrowFunction } + | { new (node: arkts.ClassDeclaration): ts.ClassDeclaration } + | { new (node: arkts.MethodDefinition): ts.MethodDeclaration } + | { new (node: arkts.VariableDeclarator): ts.VariableDeclaration } + | { new (node: arkts.VariableDeclaration): ts.VariableStatement } + +export function classByEtsNode(node: arkts.AstNode) { + const types = + new Map([ + [Es2pandaAstNodeType.AST_NODE_TYPE_ETS_MODULE, ts.SourceFile], + [Es2pandaAstNodeType.AST_NODE_TYPE_IDENTIFIER, ts.Identifier], + [Es2pandaAstNodeType.AST_NODE_TYPE_STRING_LITERAL, ts.StringLiteral], + [Es2pandaAstNodeType.AST_NODE_TYPE_NUMBER_LITERAL, ts.NumericLiteral], + [Es2pandaAstNodeType.AST_NODE_TYPE_EXPRESSION_STATEMENT, ts.ExpressionStatement], + [Es2pandaAstNodeType.AST_NODE_TYPE_FUNCTION_DECLARATION, ts.FunctionDeclaration], + [Es2pandaAstNodeType.AST_NODE_TYPE_RETURN_STATEMENT, ts.ReturnStatement], + [Es2pandaAstNodeType.AST_NODE_TYPE_ETS_PARAMETER_EXPRESSION, ts.ParameterDeclaration], + [Es2pandaAstNodeType.AST_NODE_TYPE_CALL_EXPRESSION, ts.CallExpression], + [Es2pandaAstNodeType.AST_NODE_TYPE_BLOCK_STATEMENT, ts.Block], + [Es2pandaAstNodeType.AST_NODE_TYPE_ETS_TYPE_REFERENCE, ts.TypeReferenceNode], + [Es2pandaAstNodeType.AST_NODE_TYPE_TS_TYPE_PARAMETER, ts.TypeParameterDeclaration], + [Es2pandaAstNodeType.AST_NODE_TYPE_MEMBER_EXPRESSION, ts.PropertyAccessExpression], + [Es2pandaAstNodeType.AST_NODE_TYPE_IF_STATEMENT, ts.IfStatement], + [Es2pandaAstNodeType.AST_NODE_TYPE_ETS_PRIMITIVE_TYPE, ts.KeywordTypeNode], + [Es2pandaAstNodeType.AST_NODE_TYPE_BINARY_EXPRESSION, ts.BinaryExpression], + [Es2pandaAstNodeType.AST_NODE_TYPE_ETS_UNION_TYPE, ts.UnionTypeNode], + [Es2pandaAstNodeType.AST_NODE_TYPE_ARROW_FUNCTION_EXPRESSION, ts.ArrowFunction], + [Es2pandaAstNodeType.AST_NODE_TYPE_CLASS_DECLARATION, ts.ClassDeclaration], + [Es2pandaAstNodeType.AST_NODE_TYPE_METHOD_DEFINITION, ts.MethodDeclaration], + [Es2pandaAstNodeType.AST_NODE_TYPE_VARIABLE_DECLARATION, ts.VariableStatement], + [Es2pandaAstNodeType.AST_NODE_TYPE_VARIABLE_DECLARATOR, ts.VariableDeclaration], + [Es2pandaAstNodeType.AST_NODE_TYPE_SUPER_EXPRESSION, ts.SuperExpression], + + [Es2pandaAstNodeType.AST_NODE_TYPE_CLASS_STATIC_BLOCK, ts.UnsupportedNode], + [Es2pandaAstNodeType.AST_NODE_TYPE_CLASS_PROPERTY, ts.UnsupportedNode], + [Es2pandaAstNodeType.AST_NODE_TYPE_ETS_IMPORT_DECLARATION, ts.UnsupportedNode], + ]) + + return types.get(node.type) ?? throwError(`UNSUPPORTED NODE (ts): ${Es2pandaAstNodeType[node.type]}`) +} + +// TODO: add checks for casts in functions below + +export function unpackNode >(node: U): T +export function unpackNode >(node: U): T | undefined +export function unpackNode >(node: U): T | undefined { + if (node === undefined) { + return undefined + } + return (new (classByEtsNode(node))(node as any)) as T +} + +export function passNode(node: ts.Node): T +export function passNode(node: ts.Node | undefined): T | undefined +export function passNode(node: ts.Node | undefined): T | undefined { + if (node === undefined) { + return undefined + } + return (node.node as T) ?? throwError('trying to pass non-compatible node') +} + +export function unpackNodeArray >(nodes: readonly U[]): ts.NodeArray +export function unpackNodeArray >(nodes: readonly U[] | undefined): ts.NodeArray | undefined +export function unpackNodeArray >(nodes: readonly U[] | undefined): ts.NodeArray | undefined { + return nodes?.map((node: U) => unpackNode(node)) as ReadonlyArray > as ts.NodeArray +} + +export function passNodeArray(nodes: readonly ts.Node[]): T[] +export function passNodeArray(nodes: readonly ts.Node[] | undefined): T[] | undefined +export function passNodeArray(nodes: readonly ts.Node[] | undefined): T[] | undefined { + return nodes?.map((node: ts.Node) => passNode(node)) +} + +export function passIdentifier(node: ts.Identifier | string, typeAnnotation?: ts.TypeNode): arkts.Identifier +export function passIdentifier(node: ts.Identifier | string | undefined, typeAnnotation?: ts.TypeNode): arkts.Identifier | undefined +export function passIdentifier(node: ts.Identifier | string | undefined, typeAnnotation?: ts.TypeNode): arkts.Identifier | undefined { + if (node === undefined) { + return undefined + } + if (node instanceof ts.Identifier) { + if (typeAnnotation === undefined) { + return node.node + } + return arkts.Identifier.create( + node.node.name, + passNode(typeAnnotation) + ) + } + return arkts.Identifier.create( + node, + passNode(typeAnnotation) + ) +} + +// TODO: support optional params +export function passTypeParams(params: readonly ts.TypeParameterDeclaration[] | undefined): arkts.TSTypeParameterDeclaration | undefined { + if (params === undefined) { + return undefined + } + return arkts.factory.createTypeParameterDeclaration( + passNodeArray(params) + ) +} + +export function unpackModifiers(modifiers: KInt | undefined): ts.NodeArray { + const translation = new Map([ + // [Es2pandaModifierFlags.MODIFIER_FLAGS_NONE, SyntaxKind.UnknownKeyword], + // [Es2pandaModifierFlags.MODIFIER_FLAGS_CONSTRUCTOR, SyntaxKind.ConstructorKeyword], + + [Es2pandaModifierFlags.MODIFIER_FLAGS_ABSTRACT, SyntaxKind.AbstractKeyword], + // TODO: unsupported + // [Es2pandaModifierFlags. , SyntaxKind.AccessorKeyword], + [Es2pandaModifierFlags.MODIFIER_FLAGS_ASYNC, SyntaxKind.AsyncKeyword], + [Es2pandaModifierFlags.MODIFIER_FLAGS_CONST, SyntaxKind.ConstKeyword], + [Es2pandaModifierFlags.MODIFIER_FLAGS_DECLARE, SyntaxKind.DeclareKeyword], + // TODO: choose one + // [Es2pandaModifierFlags.MODIFIER_FLAGS_DEFAULT_EXPORT, SyntaxKind.DefaultClause], + // [Es2pandaModifierFlags.MODIFIER_FLAGS_DEFAULT_EXPORT, SyntaxKind.DefaultKeyword], + [Es2pandaModifierFlags.MODIFIER_FLAGS_EXPORT, SyntaxKind.ExportKeyword], + [Es2pandaModifierFlags.MODIFIER_FLAGS_IN, SyntaxKind.InKeyword], + [Es2pandaModifierFlags.MODIFIER_FLAGS_PRIVATE, SyntaxKind.PrivateKeyword], + [Es2pandaModifierFlags.MODIFIER_FLAGS_PROTECTED, SyntaxKind.ProtectedKeyword], + [Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC, SyntaxKind.PublicKeyword], + [Es2pandaModifierFlags.MODIFIER_FLAGS_OUT, SyntaxKind.OutKeyword], + [Es2pandaModifierFlags.MODIFIER_FLAGS_OVERRIDE, SyntaxKind.OverrideKeyword], + [Es2pandaModifierFlags.MODIFIER_FLAGS_READONLY, SyntaxKind.ReadonlyKeyword], + [Es2pandaModifierFlags.MODIFIER_FLAGS_STATIC, SyntaxKind.StaticKeyword], + ]) + + const bits = function*(flags: KInt) { + let bit: KInt = 1 + while (flags >= bit) { + if ((flags & bit) > 0) { + yield bit + } + bit <<= 1 + } + } + if (modifiers === undefined) { + return [] as ReadonlyArray as ts.NodeArray + } + let mods: ts.Modifier[] = [] + for (const bit of bits(modifiers)) { + mods.push(new ts.Modifier(translation.get(bit) ?? throwError(`Unsupported modifier: ${bit}`))) + } + return mods as ReadonlyArray as ts.NodeArray +} + +export function passModifiers(modifiers: ReadonlyArray | undefined): KInt { + const translation = new Map([ + // [SyntaxKind.UnknownKeyword, Es2pandaModifierFlags.MODIFIER_FLAGS_NONE], + // [SyntaxKind.ConstructorKeyword, Es2pandaModifierFlags.MODIFIER_FLAGS_CONSTRUCTOR], + + [SyntaxKind.AbstractKeyword, Es2pandaModifierFlags.MODIFIER_FLAGS_ABSTRACT], + // TODO: unsupported + // [SyntaxKind.AccessorKeyword, Es2pandaModifierFlags.], + [SyntaxKind.AsyncKeyword, Es2pandaModifierFlags.MODIFIER_FLAGS_ASYNC], + [SyntaxKind.ConstKeyword, Es2pandaModifierFlags.MODIFIER_FLAGS_CONST], + [SyntaxKind.DeclareKeyword, Es2pandaModifierFlags.MODIFIER_FLAGS_DECLARE], + [SyntaxKind.DefaultKeyword, Es2pandaModifierFlags.MODIFIER_FLAGS_DEFAULT_EXPORT], + [SyntaxKind.ExportKeyword, Es2pandaModifierFlags.MODIFIER_FLAGS_EXPORT], + [SyntaxKind.InKeyword, Es2pandaModifierFlags.MODIFIER_FLAGS_IN], + [SyntaxKind.PrivateKeyword, Es2pandaModifierFlags.MODIFIER_FLAGS_PRIVATE], + [SyntaxKind.ProtectedKeyword, Es2pandaModifierFlags.MODIFIER_FLAGS_PROTECTED], + [SyntaxKind.PublicKeyword, Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC], + [SyntaxKind.OutKeyword, Es2pandaModifierFlags.MODIFIER_FLAGS_OUT], + [SyntaxKind.OverrideKeyword, Es2pandaModifierFlags.MODIFIER_FLAGS_OVERRIDE], + [SyntaxKind.ReadonlyKeyword, Es2pandaModifierFlags.MODIFIER_FLAGS_READONLY], + [SyntaxKind.StaticKeyword, Es2pandaModifierFlags.MODIFIER_FLAGS_STATIC], + ]) + + if (modifiers === undefined) { + return Es2pandaModifierFlags.MODIFIER_FLAGS_NONE + } + return modifiers + .map((mod: ts.Modifier | undefined | Es2pandaModifierFlags) => { + if (mod === undefined) { + return Es2pandaModifierFlags.MODIFIER_FLAGS_NONE + } + if (typeof mod === 'object') { + return translation.get(mod.kind) ?? throwError(`Unsupported modifier: ${mod.kind}`) + } + return mod + }) + .reduce( + (prev, curr) => (prev | curr), + Es2pandaModifierFlags.MODIFIER_FLAGS_NONE + ) +} + +export function passToken(token: ts.Token): KInt { + const translation = new Map([ + [SyntaxKind.PlusToken, Es2pandaTokenType.TOKEN_TYPE_PUNCTUATOR_PLUS], + [SyntaxKind.MinusToken, Es2pandaTokenType.TOKEN_TYPE_PUNCTUATOR_MINUS], + [SyntaxKind.AsteriskToken, Es2pandaTokenType.TOKEN_TYPE_PUNCTUATOR_MULTIPLY], + ]) + + return translation.get(token.kind) ?? throwError('unsupported token') +} + +export function passModifiersToScriptFunction(modifiers: readonly ts.Modifier[] | undefined): KInt { + const translation = new Map([ + [SyntaxKind.StaticKeyword, Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_STATIC_BLOCK], + [SyntaxKind.AsyncKeyword, Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_ASYNC], + [SyntaxKind.PublicKeyword, Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_NONE], + ]) + + return modifiers?.reduce( + (prev, curr) => prev | (translation.get(curr.kind) ?? throwError(`Unsupported ScriptFunction flag: ${curr.kind}`)), + Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_NONE + ) ?? Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_NONE +} + +export function passVariableDeclarationKind(flags: NodeFlags): Es2pandaVariableDeclarationKind { + const translation = new Map([ + [NodeFlags.Const, Es2pandaVariableDeclarationKind.VARIABLE_DECLARATION_KIND_CONST], + [NodeFlags.Let, Es2pandaVariableDeclarationKind.VARIABLE_DECLARATION_KIND_LET], + [NodeFlags.None, Es2pandaVariableDeclarationKind.VARIABLE_DECLARATION_KIND_VAR], + ]) + + return translation.get(flags) ?? throwError('unsupported VariableDeclarationKind') +} + +export function unpackVariableDeclarationKind(kind: Es2pandaVariableDeclarationKind): NodeFlags { + const translation = new Map([ + [Es2pandaVariableDeclarationKind.VARIABLE_DECLARATION_KIND_CONST, NodeFlags.Const], + [Es2pandaVariableDeclarationKind.VARIABLE_DECLARATION_KIND_LET, NodeFlags.Let], + [Es2pandaVariableDeclarationKind.VARIABLE_DECLARATION_KIND_VAR, NodeFlags.None], + ]) + + return translation.get(kind) ?? throwError('unsupported VariableDeclarationKind') +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/ts-api/utilities/public.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/ts-api/utilities/public.ts new file mode 100644 index 0000000000000000000000000000000000000000..85d666f55fd8bb293c1d92f5385681b06ba95a69 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/ts-api/utilities/public.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { global } from "../../arkts-api/static/global" +import { throwError } from "../../utils" +import * as ts from "../." +import { KNativePointer, nullptr } from "@koalaui/interop" +import { unpackNonNullableNode } from "../../arkts-api" + +export { proceedToState, startChecker } from "../../arkts-api" + +// TODO: like in arkts utils +export function getDecl(node: ts.Node): ts.Node | undefined { + if (node.node === undefined) { + throwError('there is no arkts pair of ts node (unable to getDecl)') + } + let decl: KNativePointer = node.node.peer + decl = global.es2panda._AstNodeVariableConst(global.context, decl) + if (decl === nullptr) { + return undefined + } + decl = global.es2panda._VariableDeclaration(global.context, decl) + if (decl === nullptr) { + return undefined + } + decl = global.es2panda._DeclNode(global.context, decl) + if (decl === nullptr) { + return undefined + } + return ts.unpackNode(unpackNonNullableNode(decl)) +} + +// TODO: like in arkts utils +export function getOriginalNode(node: ts.Node): ts.Node { + if (node.node === undefined) { + // TODO: fix this + throwError('there is no arkts pair of ts node (unable to getOriginalNode)') + } + if (node.node.originalPeer === nullptr) { + return node + } + return ts.unpackNode(unpackNonNullableNode(node.node.originalPeer)) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/ts-api/visitor/visitor.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/ts-api/visitor/visitor.ts new file mode 100644 index 0000000000000000000000000000000000000000..76c81da9b11bec5e594dda2e2a4fc076caa7758e --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/ts-api/visitor/visitor.ts @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { throwError } from "../../utils" + +import * as ts from "../." +import { factory } from "../factory/nodeFactory" +import { SyntaxKind } from "../static/enums" + +type Visitor = (node: ts.Node) => ts.Node + +// TODO: rethink (remove as) +function nodeVisitor(node: T, visitor: Visitor): T { + if (node === undefined) { + return node + } + return visitor(node) as T +} + +// TODO: rethink (remove as) +function nodesVisitor | undefined>(nodes: TIn, visitor: Visitor): T[] | TIn { + if (nodes === undefined) { + return nodes + } + return nodes.map(node => visitor(node) as T) +} + +type VisitEachChildFunction = (node: T, visitor: Visitor) => T + +// TODO: add more nodes +type HasChildren = + | ts.SourceFile + | ts.FunctionDeclaration + | ts.ExpressionStatement + | ts.CallExpression + | ts.PropertyAccessExpression + | ts.ClassDeclaration + | ts.MethodDeclaration + | ts.Block + | ts.VariableStatement + | ts.VariableDeclarationList + +type VisitEachChildTable = { [TNode in HasChildren as TNode["kind"]]: VisitEachChildFunction } + +// TODO: add more nodes +const visitEachChildTable: VisitEachChildTable = { + [SyntaxKind.SourceFile]: function (node: ts.SourceFile, visitor: Visitor) { + return factory.updateSourceFile( + node, + nodesVisitor(node.statements, visitor) + ) + }, + [SyntaxKind.FunctionDeclaration]: function (node: ts.FunctionDeclaration, visitor: Visitor) { + return factory.updateFunctionDeclaration( + node, + node.modifiers, + undefined, + nodeVisitor(node.name, visitor), + nodesVisitor(node.typeParameters, visitor), + nodesVisitor(node.parameters, visitor), + nodeVisitor(node.type, visitor), + nodeVisitor(node.body, visitor), + ) + }, + [SyntaxKind.ExpressionStatement]: function (node: ts.ExpressionStatement, visitor: Visitor) { + return factory.updateExpressionStatement( + node, + nodeVisitor(node.expression, visitor) + ) + }, + [SyntaxKind.CallExpression]: function (node: ts.CallExpression, visitor: Visitor) { + return factory.updateCallExpression( + node, + nodeVisitor(node.expression, visitor), + undefined, + nodesVisitor(node.arguments, visitor) + ) + }, + [SyntaxKind.PropertyAccessExpression]: function (node: ts.PropertyAccessExpression, visitor: Visitor) { + return factory.updatePropertyAccessExpression( + node, + nodeVisitor(node.expression, visitor), + nodeVisitor(node.name, visitor) + ) + }, + [SyntaxKind.ClassDeclaration]: function (node: ts.ClassDeclaration, visitor: Visitor) { + return factory.updateClassDeclaration( + node, + undefined, + nodeVisitor(node.name, visitor), + undefined, + undefined, + nodesVisitor(node.members, visitor) + ) + }, + [SyntaxKind.MethodDeclaration]: function (node: ts.MethodDeclaration, visitor: Visitor) { + return factory.updateMethodDeclaration( + node, + undefined, + undefined, + nodeVisitor(node.name, visitor), + undefined, + undefined, + nodesVisitor(node.parameters, visitor), + undefined, + nodeVisitor(node.body, visitor), + ) + }, + [SyntaxKind.Block]: function (node: ts.Block, visitor: Visitor) { + return factory.updateBlock( + node, + nodesVisitor(node.statements, visitor), + ) + }, + [SyntaxKind.VariableStatement]: function (node: ts.VariableStatement, visitor: Visitor) { + return factory.updateVariableStatement( + node, + undefined, + nodeVisitor(node.declarationList, visitor), + ) + }, + [SyntaxKind.VariableDeclarationList]: function (node: ts.VariableDeclarationList, visitor: Visitor) { + return factory.updateVariableDeclarationList( + node, + nodesVisitor(node.declarations, visitor), + ) + }, +} + +function nodeHasChildren(node: ts.Node): node is HasChildren { + return node.kind in visitEachChildTable +} + +export function visitEachChild( + node: T, + visitor: Visitor +): T { + const visitFunc = (visitEachChildTable as Record | undefined>)[node.kind]; + if (nodeHasChildren(node) && visitFunc === undefined) { + throwError('Unsupported node kind: ' + node.kind) + } + return (visitFunc === undefined) ? node : visitFunc(node, visitor); +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/utils.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/utils.ts new file mode 100644 index 0000000000000000000000000000000000000000..7d436606669fece920bcfd4997409af6eb38e5dc --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/src/utils.ts @@ -0,0 +1,387 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export function throwError(error: string): never { + throw new Error(error) +} + +export function withWarning(value: T, message: string): T { + // console.warn(message) + return value +} + +export function isNumber(value: any): value is number { + return typeof value === `number` +} + +function replacePercentOutsideStrings(code: string): string { + const stringPattern = /("[^"]*"|'[^']*'|`[^`]*`)/g; + const percentPattern = /(?(); + strings.forEach((string) => { + const placeholder = `__STRING_PLACEHOLDER_${placeholderCounter++}__`; + placeholderMap.set(placeholder, string); + code = code.replace(string, placeholder); + }); + + code = code.replace(percentPattern, '_'); + + placeholderMap.forEach((originalString, placeholder) => { + code = code.replace(new RegExp(placeholder, 'g'), originalString); + }); + + return code; +} + +function replaceIllegalHashes(code: string): string { + const stringPattern = /("[^"]*"|'[^']*'|`[^`]*`)/g; + const strings = code.match(stringPattern) || []; + + let placeholderCounter = 0; + const placeholderMap = new Map(); + strings.forEach((string) => { + const placeholder = `__STRING_PLACEHOLDER_${placeholderCounter++}__`; + placeholderMap.set(placeholder, string); + code = code.replace(string, placeholder); + }); + + code = code.replace(/#/g, '_'); + + placeholderMap.forEach((originalString, placeholder) => { + code = code.replace(new RegExp(placeholder, 'g'), originalString); + }); + + return code; +} + +function replaceGensymWrappers(code: string): string { + const indices = [...code.matchAll(/\({let/g)].map(it => it.index) + const replacements: string[][] = [] + for (var i of indices) { + if (!i) { + continue + } + var j = i + 1, depth = 1 + while (j < code.length) { + if (code[j] == '(') { + depth++ + } + if (code[j] == ')') { + depth-- + } + if (depth == 0) { + break + } + j++ + } + + if (j == code.length) { + continue + } + + const base = code.substring(i, j + 1) + if (base.match(/\({let/)?.length! > 1) { // don't touch if contains nested constructions + continue + } + const fixed = base.replaceAll(/^\({let ([_%a-zA-Z0-9]+?) = (?!\({let)([\s\S]*?);\n([\s\S]*?)}\)$/g, + (match, name: string, val: string, expr: string) => { + let rightExpr = expr.slice(expr.lastIndexOf(name) + name.length, -1) + if (rightExpr[0] != '.') { + rightExpr = `.${rightExpr}` + } + return `(${val}?${rightExpr})` + } + ) + replacements.push([base, fixed]) + } + for (var [b, f] of replacements) { + code = code.replace(b, f) + } + return code +} + + +function addExports(code: string): string { + const exportAstNodes = ["let", "const", "class", "abstract class", "@Entry() @Component() final class", "@Component() final class", "interface", "@interface", "type", "enum", "final class", "function", + "declare interface", + "@Retention({policy:\"SOURCE\"}) @interface", "@memo() function", "@memo_entry() function", "@memo_intrinsic() function", + ] + exportAstNodes.forEach((astNodeText) => { + code = code.replaceAll(`\n${astNodeText}`, `\nexport ${astNodeText}`) + } + ) + // TODO this is a temporary workaround and should be replaced with a proper import/export handling in future + code = code.replaceAll(/\n(@memo\(\) @BuilderLambda\(\{value:"\w+"\}\)) function/g, '\n$1 export function') + const fix = [ + ["export @memo() function", "@memo() export function"], + ["export @memo_entry() function", "@memo_entry() export function"], + ["export @memo_intrinsic() function", "@memo_intrinsic() export function"], + ["export class OhosRouter", "export default class OhosRouter"] + ] + for (var [f, t] of fix) { + code = code.replaceAll(f, t) + } + return code.replaceAll("\nexport function main()", "\nfunction main()") +} + +function removeAbstractFromInterfaces(code: string): string { + const interfaces = [...code.matchAll(/interface([\s\S]*?){([\s\S]*?)\n}\n/g)].map(it => it[0]) + interfaces.forEach((content) => { + const newContent = content.replaceAll('abstract ', '') + code = code.replaceAll(content, newContent) + }) + return code +} + +function removeInvalidLambdaTyping(code: string): string { + const knownTypes = ['boolean', 'int64', 'void'] + return code.replaceAll(/\(([^\n\(\)]*?)\): ([\S]*?) => {/g, (match, p1, p2) => { + if (knownTypes.includes(p2)) { + return match + } + return `(${p1}) => {` + }) +} + +function returnOptionalParams(code: string): string { + const reduce = (line: string): string => { + if (line.includes("constructor")) { + return line + } + for (var i = 0; i < line.length; i++) { + if (line[i] == '(') { + let ignore = false + for (var k = i; k >= 0; k--) { + if (line[k].match(/[a-zA-Z<>_0-9]/)) { + break + } + if (line[k] == ':') { + ignore = true + } + } + if (ignore) { + continue + } + const initi = i + let j = i + 1, depth = 1 + let parts: string[] = [] + while (j < line.length) { + if (line[j] == '(') { + depth++ + } + if (line[j] == ')') { + depth-- + if (depth == 0) { + parts.push(line.substring(i + 1, j)) + break + } + } + if (line[j] == ',' && depth == 1) { + parts.push(line.substring(i + 1, j)) + i = j + 1 + } + j++ + } + if (depth == 0 && parts.length && parts.every(it => it.includes(": ") && !it.includes("? "))) { + let k = parts.length - 1 + while (k >= 0) { + if (parts[k].endsWith(" | undefined")) { + let w = parts[k].substring(0, parts[k].length - " | undefined".length) + let i = w.indexOf(':') + if (w[i - 1] != '?') { + parts[k] = w.substring(0, i) + "?" + w.substring(i) + } + } else { + break + } + k-- + } + if (k != parts.length - 1) { + let nline = line.substring(0, initi + 1) + parts.join(', ') + line.substring(j) + return nline + } + } + i = initi + } + } + return line + } + return code.split('\n').map((line) => { + let nline = reduce(line) + while (nline != line) { + line = nline + nline = reduce(line) + } + return line + }).join('\n') +} + +function fixPropertyLines(code: string): string { + /* + + for some properties the following construction is generated: + + private readonly name = false; + + public name(name) { // for readonly properties "setter" is also generated + (this).name = name = false; // sometimes there is a typing here + return; + } + + public name() { + return (this).name; + } + + this function wraps this back to `readonly name = false;` + + */ + return code.replaceAll(/(private|public)(.*)?(.*?)\n((.*?)\n){9}/g, (match, p1, p2, p3) => { + return `public ${p2} ${p3}` + }) +} + +function fixDuplicateSettersInInterfaces(code: string): string { + /* + + sometimes interfaces contains duplicate setters, this functions fixes it + + */ + code = code.replaceAll(/\n(.*)interface(.*){\n([\s\S]*?)\n}\n/g, (match, modifiers, p1, p2: string) => { + const keep = p2.split('\n').filter((it) => !it.trimStart().startsWith(`set`)) + const setters = [...new Set(p2.split('\n').filter((it) => it.trimStart().startsWith(`set`)))] + return `\n${modifiers}interface${p1}{\n${keep.join('\n')}\n${setters.join('\n')}\n}\n` + }) + code = code.replaceAll(/\n (.*)interface(.*){\n([\s\S]*?)\n }\n/g, (match, modifiers, p1, p2: string) => { + const keep = p2.split('\n').filter((it) => !it.trimStart().startsWith(`set`)) + const setters = [...new Set(p2.split('\n').filter((it) => it.trimStart().startsWith(`set`)))] + return `\n ${modifiers}interface${p1}{\n${keep.join('\n')}\n${setters.join('\n')}\n }\n` + }) + return code +} + +function excludePartialInterfaces(code: string): string { + return code.replaceAll(/interface (.*)\$partial<>([\s\S]*?)}/g, '') +} + +function fixNamespace(code: string) { + /* + namespaces become abstract classes, and enums become final classes + enum in namespace -> class in class -> not supported + + we have only one such place, so fix manually + */ + code = code.replaceAll(` export abstract class Profiler { + public static _$initializerBlockInit$_() {} + + public static _$init$_() {}`, ` export namespace Profiler {`) + + code = code.replaceAll(/public static ((?:un)?registerVsyncCallback)/g, "export function $1") + + return code.replaceAll(/export abstract class GestureControl {((.*)\n){4}/g, "export namespace GestureControl {") +} + +function fixEnums(code: string) { + const lines = code.split('\n') + const enums = [] + for (let i = 0; i + 1 < lines.length; i++) { + if (lines[i].trimStart().startsWith(`export final class`) + && lines[i + 1].trimStart().startsWith(`private readonly _ordinal`) + ) { + const name = lines[i].split(' ')[3] + enums.push(name) + } + } + enums.forEach((name) => { + const regexp = new RegExp(`${name}\\.(\\w+)(.)`, `g`) + code = code.replaceAll(regexp, (match, p1, p2) => { + if (!p1.startsWith('_') && p2 == ":") { // this colon is for switch case, not for type + return `${name}.${p1}.valueOf()${p2}` + } + return match + }) + const idents = [...code.matchAll(new RegExp(`(\\w+?)([\\W])(\\w+?): ${name}`, `g`))].filter(it => it[1] != "readonly" && it[1] != "_get").map(it => it[3]) + // work manually with a couple of cases not to write one more bracket parser + if (code.includes(`const eventKind = (deserializer.readInt32() as CallbackEventKind);`)) { + // this is for file arkui/src/generated/peers/CallbacksChecker.ts + idents.push(`eventKind`) + code = code.replace(`const eventKind = (deserializer.readInt32() as CallbackEventKind);`, `const eventKind = CallbackEventKind.fromValue(deserializer.readInt32());`) + } + if (code.includes(`switch ((type as EventType))`)) { + // this is for file arkui/src/Application.ts + code = code.replace(`switch ((type as EventType))`, `switch (type)`) + } + idents.forEach((id) => { + code = code.replaceAll(`${id} as int32`, `${id}.valueOf()`) + code = code.replaceAll(`switch (${id})`, `switch (${id}.valueOf())`) + }) + }) + return code +} + +function fixSwitchCase(code: string) { + const lines = code.split('\n') + // assume good formatting on start, return also good formatting (spaces on line beginnings) + const spacesStack = [] + for (var i = 1; i < lines.length; i++) { + if (lines[i].trimStart().startsWith('case ') || lines[i].trimStart().startsWith('default:')) { + if (lines[i - 1].trimStart().startsWith('switch')) { + spacesStack.push(lines[i - 1].indexOf('s')) + lines[i] = lines[i] + ` {` + } else { + const indent = ` `.repeat(spacesStack[spacesStack.length - 1] + 2) + lines[i] = indent + `}\n` + indent + lines[i].trimStart() + ` {` + } + } + else if (spacesStack.length && lines[i].trimStart().startsWith('}') && lines[i].indexOf('}') <= spacesStack[spacesStack.length - 1]) { + lines[i] = ` `.repeat(spacesStack[spacesStack.length - 1]) + `} ` + lines[i].trimStart() + spacesStack.pop() + } + } + return lines.join('\n') +} + +/* + TODO: + The lowerings insert %% and other special symbols into names of temporary variables. + Until we keep feeding ast dumps back to the parser this function is needed. + */ +export function filterSource(text: string): string { + //console.error("====") + // console.error(text.split('\n').map((it, index) => `${`${index + 1}`.padStart(4)} |${it}`).join('\n')) + const dumperUnwrappers = [ + fixNamespace, + fixEnums, + fixDuplicateSettersInInterfaces, + removeAbstractFromInterfaces, + addExports, + replaceGensymWrappers, // nested + replaceGensymWrappers, // nested + replaceGensymWrappers, + replaceIllegalHashes, + replacePercentOutsideStrings, + excludePartialInterfaces, + (code: string) => code.replaceAll("", "_cctor_"), + (code: string) => code.replaceAll("public constructor() {}", ""), + (code: string) => code.replaceAll("@Module()", ""), + fixPropertyLines, + fixSwitchCase, + ] + // console.error("====") + // console.error(dumperUnwrappers.reduceRight((code, f) => f(code), text).split('\n').map((it, index) => `${`${index + 1}`.padStart(4)} |${it}`).join('\n')) + return dumperUnwrappers.reduceRight((code, f) => f(code), text) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/tools/issue_gen.mjs b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/tools/issue_gen.mjs new file mode 100644 index 0000000000000000000000000000000000000000..86c18af199c346083a4f18e76f639c240fbaa2de --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/tools/issue_gen.mjs @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as fs from 'fs' +import * as path from 'path' + +process.chdir(path.resolve('./')) + +const issue_src = fs.readFileSync('../playground/src/playground.cc', { encoding: 'utf8', flag: 'r' }) + +const component_src = +` +### Component + +Plugin API + +` + +const revision_src = +` +### Revision + +"@panda/sdk": "1.5.0-dev.9184" + +` + +const reproduction_src = +` +### Reproduction + +\`\`\` +${issue_src} +\`\`\` + +` + +// TODO: +const log = `` + +const log_src = +` +### Log + +\`\`\` +${log} +\`\`\` +` + +console.log( + component_src + + revision_src + + reproduction_src + + log_src +) diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/tsconfig.host.json b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/tsconfig.host.json new file mode 100644 index 0000000000000000000000000000000000000000..73e04374e272aef15efa9265a13b154c18adbeca --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/tsconfig.host.json @@ -0,0 +1,12 @@ +{ + "extends": "@koalaui/build-common/tsconfig.json", + "compilerOptions": { + "outDir": "build", + "baseUrl": ".", + "rootDir": "./src-host", + "module": "esnext" + }, + "include": [ + "./src-host/**/*.ts" + ] +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/tsconfig.json b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/tsconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..40575c88c1de110c80a91c586c0c6252d33fbc0c --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/tsconfig.json @@ -0,0 +1,15 @@ +{ + "extends": "@koalaui/build-common/tsconfig.json", + "compilerOptions": { + "outDir": "build", + "baseUrl": ".", + "rootDir": "./src", + "module": "esnext" + }, + "include": [ + "./src/**/*.ts" + ], + "exclude": [ + "./src/ts-api/**/*.ts" + ] +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/tsconfig.plugin.json b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/tsconfig.plugin.json new file mode 100644 index 0000000000000000000000000000000000000000..b984e32b04420e5823c5b0ce024c019aefedcb8d --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/libarkts/tsconfig.plugin.json @@ -0,0 +1,12 @@ +{ + "extends": "@koalaui/build-common/tsconfig.json", + "compilerOptions": { + "outDir": "build/plugins", + "baseUrl": ".", + "rootDir": "./plugins", + "module": "esnext" + }, + "include": [ + "./plugins/src/**/*.ts" + ] +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/annotate-test-executable.json b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/annotate-test-executable.json new file mode 100644 index 0000000000000000000000000000000000000000..6ee97e0a80810d6e23b5784787e941fe7f928804 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/annotate-test-executable.json @@ -0,0 +1,5 @@ +{ + "inputDir": "./test/executable", + "outputDir": "./test/ets", + "include": ["./test/executable/**/*.ts"] +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/demo/demo/demo.ets b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/demo/demo/demo.ets new file mode 100644 index 0000000000000000000000000000000000000000..3da27bb38d5253b948ea39397b44abae18bcae4c --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/demo/demo/demo.ets @@ -0,0 +1,71 @@ +import { IncrementalNode, + NodeAttach, mutableState, contextLocalValue, ReadonlyTreeNode, + memoRoot, updateStateManager, +} from "@koalaui/runtime" + +import { memo } from "@koalaui/runtime/annotations" + +const CONTEXT_ROOT_SCOPE = "ohos.koala.context.root.scope" // not exported due to restart +class StringerNode extends IncrementalNode { + constructor(kind: int = 1) { + super(kind) + } + data: string | undefined = undefined +} + +@memo +function Stringer( + arg: string, + @memo + content?: () => void +): void { + NodeAttach(() => + new StringerNode(), (node: StringerNode): void => { + node.data = arg + console.log("I am recomputing with arg: ", arg) + content?.() + }) +} + +const state = mutableState(17) + +@memo +function demo(node: StringerNode): void { + Stringer("First", () => { + console.log("Content of the first") + Stringer(`Second ${state.value}`, () => { + console.log("Content of the second") + Stringer("Third") + }) + Stringer("Fourth", () => { + console.log("Content of the 4th") + Stringer("5th") + }) + }) + + // This is to dump the complete managed incremental scope tree + const scope = contextLocalValue(CONTEXT_ROOT_SCOPE) + console.log(scope?.toHierarchy()) +} + +function main() { + console.log(state.value) + + // memoRoot is the entry point here. + // It initializes the incremental runtime and computes the first frame. + // Have a look at its implementation. + console.log("\nBuild first frame") + const root = memoRoot(new StringerNode(0), demo) + console.log(root.value.toHierarchy()) // dump ui subtree + + console.log("\nBuild second frame") + updateStateManager() // Compute next frame. + console.log(root.value.toHierarchy()) + + state.value = 19 + + console.log("\nBuild third frame") + updateStateManager() // Compute the next frame. + console.log(root.value.toHierarchy()) + console.log("-----END-----") +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/demo/package.json b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/demo/package.json new file mode 100644 index 0000000000000000000000000000000000000000..c5a1ae3486b830c2971012efc10dff046d5cd83b --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/demo/package.json @@ -0,0 +1,12 @@ +{ + "scripts": { + "clean": "rimraf build", + "compile": "fast-arktsc --config ui2abcconfig.json --compiler ../../../incremental/tools/panda/arkts/ui2abc --link-name ./build/demo.abc --file-option --restart-stages && ninja ${NINJA_OPTIONS} -f build/abc/build.ninja", + "run": "../../../incremental/tools/panda/arkts/ark ./build/demo.abc --ark-boot-files ../../../incremental/runtime/build/incremental.abc --ark-entry-point @demo.demo.ETSGLOBAL::main", + "disasm": "$(find build -name '*.abc' -exec ../../../incremental/tools/panda/arkts/arkdisasm {} \\;)" + }, + "devDependencies": { + "@koalaui/ets-tsc": "4.9.5-r5", + "@koalaui/fast-arktsc": "1.5.15" + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/demo/ui2abcconfig.json b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/demo/ui2abcconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..b66f95b9509fca3f47339c35cd31c06672873b7b --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/demo/ui2abcconfig.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + "package": "@demo", + "outDir": "build/abc", + "baseUrl": "./demo", + "paths": { + "@koalaui/compat": [ "../../../../incremental/compat/src/arkts" ], + "#platform": [ "../../../../incremental/compat/src/arkts" ], + "@koalaui/common": [ "../../../../incremental/common/src" ], + "@koalaui/runtime": [ "../../../../incremental/runtime/ets" ], + "@koalaui/runtime/annotations": [ "../../../../incremental/runtime/annotations" ] + }, + "plugins": [ + { + "transform": "..", + "stage": "checked", + "name": "memo" + } + ] + }, + "include": ["./demo/demo.ets"], + "dependencies": { + "@koalaui/runtime": [ + "../../../incremental/runtime/ui2abcconfig.json" + ] + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/mocharc.diagnostics.json b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/mocharc.diagnostics.json new file mode 100644 index 0000000000000000000000000000000000000000..afa05ed4d79dabb20402b0c3e893e96e51c42113 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/mocharc.diagnostics.json @@ -0,0 +1,6 @@ +{ + "ui": "tdd", + "spec": "./test/diagnostics/diagnostics.test.ts", + "extension": ["ts"], + "require": ["../../incremental/test-utils/scripts/register"] +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/package.json b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/package.json new file mode 100644 index 0000000000000000000000000000000000000000..b67895abe40026bb2cd11c7284197d83a6aea587 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/package.json @@ -0,0 +1,37 @@ +{ + "name": "@koalaui/memo-plugin", + "main": "lib/MemoTransformer.js", + "scripts": { + "clean": "rimraf build", + "compile": "rollup -c", + + "runtime:clean": "npm run all:clean --prefix ../../incremental", + "runtime:prepare": "npm run build:incremental:inc:ui2abc --prefix ../../incremental/runtime", + "compile:libarkts": "npm run compile --prefix ../libarkts", + "demo:clean": "npm run clean --prefix demo", + "demo:run": "npm run compile:libarkts && npm run compile && npm run compile --prefix demo && npm run run --prefix demo", + "test": "npm run compile:libarkts && npm run compile && npm run test --prefix test", + "demo:disasm": "npm run disasm --prefix demo", + + "compile:deps:harness": "cd ../../incremental/harness && npm run build:harness", + "compile:deps": "npm run compile:libarkts && npm run compile && npm run compile:deps:harness && npm run runtime:prepare", + + "compile:annotate": "npm run compile --prefix ../annotate", + "executable:annotate:test": "npm run compile:annotate && node ../annotate annotate-test-executable.json", + "executable:ui2abc:fast-arktsc": "fast-arktsc --config ./test/arktsconfig-executable.json --compiler ../../incremental/tools/panda/arkts/ui2abc --link-name ./build/test/test.abc --file-option --restart-stages", + "executable:ui2abc:ninja": "cd build && ninja", + "executable:ui2abc": "npm run executable:ui2abc:fast-arktsc && npm run executable:ui2abc:ninja", + "executable:abc": "bash ../../incremental/tools/panda/arkts/ark ./build/test/test.abc --ark-boot-files ./build/test/test.abc:../../incremental/runtime/build/incremental.abc:../../incremental/harness/build/harness.abc --ark-entry-point @test.ets.basic.test.ETSGLOBAL::main", + "executable": "npm run compile:deps && npm run executable:annotate:test && npm run executable:ui2abc && npm run executable:abc", + + "diagnostics": "mocha --config mocharc.diagnostics.json", + "test:diagnostics": "npm run compile && npm run diagnostics", + "test:all": "npm run test && npm run executable && npm run diagnostics", + "recheck:ui2abc:fast-arktsc": "fast-arktsc --config ./recheck-bringup/ui2abcconfig.json --compiler ../../incremental/tools/panda/arkts/ui2abc --link-name ./build/recheck-bringup/memo-hello-world.abc --file-option", + "recheck:ui2abc:ninja": "cd build/recheck-bringup && ninja", + "recheck:ui2abc": "npm run recheck:ui2abc:fast-arktsc && npm run recheck:ui2abc:ninja" + }, + "devDependencies": { + "@koalaui/harness": "1.5.15+devel" + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/input/ets/memo-hello-world.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/input/ets/memo-hello-world.ts new file mode 100644 index 0000000000000000000000000000000000000000..2c34a5b7255c5ecb4bd6050521575fd09ee4bcd5 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/input/ets/memo-hello-world.ts @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { memo as memo, memo_intrinsic as memo_intrinsic, memo_entry as memo_entry, memo_stable as memo_stable, memo_skip as memo_skip } from "@koalaui/runtime/annotations"; + +import { __memo_context_type as __memo_context_type, __memo_id_type as __memo_id_type } from "@koalaui/runtime"; + +@memo +function foo(): number { + console.log('hello') + return 4 +} + +@memo_entry +function main() { + foo() +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/animation/AnimatedState.ets b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/animation/AnimatedState.ets new file mode 100644 index 0000000000000000000000000000000000000000..470d228f345a576414cadc88fe34d9eed5070ce2 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/animation/AnimatedState.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { int64 } from "../common" +import { TimeAnimation } from "./TimeAnimation" +import { MutableState, State } from "../states/State" +export declare interface AnimatedState extends State { + animation: TimeAnimation + readonly running: boolean + paused: boolean +} +export declare function animatedState(animation: TimeAnimation, startNow: boolean = false, timeProvider?: () => int64): AnimatedState +export declare interface MutableAnimatedState extends MutableState { + animation: TimeAnimation + readonly running: boolean +} +export declare function mutableAnimatedState(initial: Value, animationProvider: ImplicitAnimationProvider): MutableAnimatedState +export type ImplicitAnimationProvider = (from: Value, to: Value) => TimeAnimation +export declare interface StateAnimator { + parameter: Parameter + readonly value: Value + onValueChange(action: (newValue: Value) => void): void +} +export declare function stateAnimator(parameter: P, animationProvider: ParametrizedAnimationProvider): StateAnimator +export type ParametrizedAnimationProvider = (parameter: P, value: V | undefined) => TimeAnimation diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/animation/AnimationRange.ets b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/animation/AnimationRange.ets new file mode 100644 index 0000000000000000000000000000000000000000..236cd721e187ff34fc10d889c67c950d81fce58d --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/animation/AnimationRange.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { float64 } from "../common" +export type AnimationRange = (value: float64) => Value +export declare function ArrayAnimationRange(from: ReadonlyArray, to: ReadonlyArray, compute: (array: ReadonlyArray) => Value): AnimationRange +export declare function NumberAnimationRange(from: float64, to: float64): AnimationRange diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/animation/Easing.ets b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/animation/Easing.ets new file mode 100644 index 0000000000000000000000000000000000000000..bc0a01b25938d66a8c826fd653af9a488fd18ebf --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/animation/Easing.ets @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { float64, uint32 } from "../common" +export type EasingCurve = (value: float64) => float64 +export declare class Easing { + static readonly Linear: EasingCurve + static readonly LinearReversed: EasingCurve + static readonly EaseInSine: EasingCurve + static readonly EaseOutSine: EasingCurve + static readonly EaseInOutSine: EasingCurve + static readonly Ease: EasingCurve + static readonly EaseIn: EasingCurve + static readonly EaseOut: EasingCurve + static readonly EaseInOut: EasingCurve + static readonly ViscousFluid: EasingCurve + static readonly Bubble: EasingCurve + static inverted(easing: EasingCurve): EasingCurve + static reversed(easing: EasingCurve): EasingCurve + static restarted(easing: EasingCurve): EasingCurve + static repeated(easing: EasingCurve, count: uint32): EasingCurve + static joined(...easing: EasingCurve[]): EasingCurve + static thereAndBackAgain(easing: EasingCurve): EasingCurve + static cubicBezier(p1x: float64, p1y: float64, p2x: float64, p2y: float64): EasingCurve + static steps(stops: uint32, jump: EasingStepJump = EasingStepJump.None): EasingCurve + static viscousFluid(v0: float64 = 1, f: float64 = 3): EasingCurve +} +export enum EasingStepJump { + Start, + End, + None, + Both, +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/animation/EasingSupport.ets b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/animation/EasingSupport.ets new file mode 100644 index 0000000000000000000000000000000000000000..51e86c58af08c7e570ab71f1ed51ebafaa371cfb --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/animation/EasingSupport.ets @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { float64, uint32 } from "../common" +export declare class EasingSupport { + x: Float64Array + y: Float64Array + constructor(size: uint32, xSupplier: (value: float64) => float64, ySupplier: (value: float64) => float64) + convert(value: float64): float64 + static newCubicBezier(p1x: float64, p1y: float64, p2x: float64, p2y: float64, size: uint32 = 1024): EasingSupport +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/animation/GlobalTimer.ets b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/animation/GlobalTimer.ets new file mode 100644 index 0000000000000000000000000000000000000000..446dd5c9a7b90d1365d48ecf6fa3795912b13880 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/animation/GlobalTimer.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { int64 } from "../common" +import { GlobalStateManager } from "../states/GlobalStateManager" +import { MutableState, StateContext } from "../states/State" +export declare function getAnimationTimer(context: StateContext = GlobalStateManager.instance): MutableState | undefined +export declare function createAnimationTimer(context: StateContext, initial: int64 = 0): MutableState diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/animation/TimeAnimation.ets b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/animation/TimeAnimation.ets new file mode 100644 index 0000000000000000000000000000000000000000..6a12831828205392a4971f59869ecfe85212ee6e --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/animation/TimeAnimation.ets @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { float64, int32, int64, uint32 } from "../common" +import { AnimationRange } from "./AnimationRange" +import { EasingCurve } from "./Easing" +export declare const DEFAULT_ANIMATION_DURATION: uint32 +export declare interface TimeAnimation { + readonly running: boolean + getValue(time: int64): Value + onStart(time: int64): void + onPause(time: int64): void +} +export declare interface AnimationSpec { + readonly duration: uint32 + readonly delay: uint32 + readonly easing: EasingCurve + readonly onEdge: OnEdge + readonly onPause: OnPause + readonly iterations: int32 | undefined + readonly onStart: (() => void) | undefined + readonly onEnd: (() => void) | undefined + readonly onReset: (() => void) | undefined +} +export declare class OnEdge { + static Nothing: OnEdge + static Reverse: OnEdge + static Restart: OnEdge + constructor(name: string) +} +export declare class OnPause { + static Nothing: OnPause + static Reset: OnPause + static Fade: OnPause + constructor(name: string) +} +export declare function constAnimation(value: Value): TimeAnimation +export declare function timeAnimation(compute: (time: int64) => Value, initialTime: int64 = 0): TimeAnimation +export declare function smoothAnimation(period: uint32, from: float64 = 0.0, to: float64 = 1.0): TimeAnimation +export declare function blinkAnimation(period: uint32, initialValue: boolean = false): TimeAnimation +export declare function countAnimation(period: uint32, initialCount: int64 = 0): TimeAnimation +export declare function periodicAnimation(period: uint32, compute: (count: int64) => Value, initialCount: int64 = 0): TimeAnimation +export declare function periodicAnimationWithDelay(delay: uint32, period: uint32, compute: (count: int64) => Value, initialCount: int64 = 0): TimeAnimation +export declare function frameAnimation(frameTime: ReadonlyArray, compute: (index: int64) => Value): TimeAnimation +export declare function numberAnimation(spec: Partial, to: float64 = 1.0, from: float64 = 0.0): TimeAnimation +export declare function animation(spec: Partial, compute: AnimationRange, initialState: float64 = 0): TimeAnimation +export declare function transition(duration: uint32, easing: EasingCurve, compute: AnimationRange, initialState: int64 = 0): TimeAnimation +export declare function linearTransition(duration: uint32, compute: AnimationRange, initialState: int64 = 0): TimeAnimation \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/animation/memo.ets b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/animation/memo.ets new file mode 100644 index 0000000000000000000000000000000000000000..1ed38006d8ddd1f5345e51b071ae7b7256116ef2 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/animation/memo.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { memo } from "../annotations" +import { float64, int64, uint32 } from "../common" +import { AnimatedState, ImplicitAnimationProvider, MutableAnimatedState, ParametrizedAnimationProvider, StateAnimator, animatedState, mutableAnimatedState, stateAnimator } from "./AnimatedState" +import { AnimationRange } from "./AnimationRange" +import { Easing, EasingCurve } from "./Easing" +import { AnimationSpec, TimeAnimation } from "./TimeAnimation" +@memo export declare function sampledValue(sampleRate: uint32, generator: (tick: int64) => V): V +@memo export declare function rememberAnimatedState(animation: () => TimeAnimation, startNow: boolean = false): AnimatedState +@memo export declare function rememberNumberTransition(on: boolean, duration: uint32, easing: EasingCurve = Easing.Linear, to: float64 = 1.0, from: float64 = 0.0): AnimatedState +@memo export declare function rememberTransition(on: boolean, duration: uint32, easing: EasingCurve, compute: AnimationRange, initial: boolean = on): AnimatedState +@memo export declare function rememberMutableAnimatedState(initial: Value, animationProvider: ImplicitAnimationProvider): MutableAnimatedState +@memo export declare function rememberMutableAnimatedStateNumber(initial: float64, animationSpec: Partial): MutableAnimatedState +@memo export declare function rememberAnimator(parameter: P, animationProvider: ParametrizedAnimationProvider): StateAnimator \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/annotations.ets b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/annotations.ets new file mode 100644 index 0000000000000000000000000000000000000000..11ec0d271740e75a4bebeed250f19ba9402b16ae --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/annotations.ets @@ -0,0 +1,15 @@ + +@Retention({policy: "SOURCE"}) +export @interface memo {} + +@Retention({policy: "SOURCE"}) +export @interface memo_intrinsic {} + +@Retention({policy: "SOURCE"}) +export @interface memo_entry {} + +@Retention({policy: "SOURCE"}) +export @interface memo_stable {} + +@Retention({policy: "SOURCE"}) +export @interface memo_skip {} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/common.ets b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/common.ets new file mode 100644 index 0000000000000000000000000000000000000000..5110a388237c5d43a739573aaeed4ec2a7f3a73f --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/common.ets @@ -0,0 +1,5 @@ +export type KoalaCallsiteKey = int +export type int32 = int +export type uint32 = int +export type int64 = long +export type float64 = double diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/index.ets b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..a057aae34879253ac1a618cf77faf5de60339c99 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/index.ets @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export { + AnimatedState, + ImplicitAnimationProvider, + MutableAnimatedState, + ParametrizedAnimationProvider, + StateAnimator, + animatedState, + mutableAnimatedState, + stateAnimator, +} from "./animation/AnimatedState" +export { + AnimationRange, + ArrayAnimationRange, + NumberAnimationRange, +} from "./animation/AnimationRange" +export { + Easing, + EasingCurve, + EasingStepJump, +} from "./animation/Easing" +export { + createAnimationTimer, + getAnimationTimer, +} from "./animation/GlobalTimer" +export { + rememberAnimatedState, + rememberAnimator, + rememberMutableAnimatedState, + rememberMutableAnimatedStateNumber, + rememberNumberTransition, + rememberTransition, + sampledValue, +} from "./animation/memo" +export { + AnimationSpec, + OnEdge, + OnPause, + TimeAnimation, + animation, + blinkAnimation, + constAnimation, + countAnimation, + frameAnimation, + linearTransition, + numberAnimation, + periodicAnimation, + periodicAnimationWithDelay, + smoothAnimation, + timeAnimation, + transition, +} from "./animation/TimeAnimation" + +export { + memoBind, + memoBind2, + memoPartialBind2_1, + memoPartialBind3_2, + MemoCallbackContext, +} from "./memo/bind" +export { + OnChange, + RunEffect, +} from "./memo/changeListener" +export { + contextLocal, + contextLocalScope, + contextLocalValue, +} from "./memo/contextLocal" +export { + memoRoot, + memoEntry, + memoEntry1, + memoEntry2, +} from "./memo/entry" +export { + DataNode, + NodeAttach, + contextNode, +} from "./memo/node" +export { + memoize, + memoLifecycle, + once, + remember, + rememberArrayState, + rememberComputableState, + rememberComputableValue, + rememberControlledScope, + rememberDisposable, + rememberMutableAsyncState, + rememberMutableState, +} from "./memo/remember" +export { + Repeat, + RepeatByArray, + RepeatRange, + RepeatWithKey, +} from "./memo/repeat" +export { + TestNode, + testRoot, + testTick, + testUpdate, +} from "./memo/testing" + +export { + Disposable, + disposeContent, + disposeContentBackward, + disposeContentForward, +} from "./states/Disposable" +export { + GlobalStateManager, + arrayState, + callScheduledCallbacks, + mutableState, + scheduleCallback, + updateStateManager, +} from "./states/GlobalStateManager" +export { + ArrayState, + CONTEXT_ROOT_NODE, + CONTEXT_ROOT_SCOPE, + ComputableState, + ControlledScope, + Equivalent, + MutableState, + State, + StateContext, + StateManager, + ValueTracker, +} from "./states/State" +export { + __context, + __id, + __key, + __memo_context_type, + __memo_id_type, + __memo_transformed, + __memo_transformed_before, + __memo_transformed_after, +} from "./internals" + +export { IncrementalNode } from "./tree/IncrementalNode" +export { PrimeNumbers } from "./tree/PrimeNumbers" +export { ReadonlyTreeNode } from "./tree/ReadonlyTreeNode" +export { TreeNode } from "./tree/TreeNode" +export { TreePath } from "./tree/TreePath" + +export { memo, memo_intrinsic, memo_entry, memo_stable, memo_skip } from "./annotations" diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/internals.ets b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/internals.ets new file mode 100644 index 0000000000000000000000000000000000000000..b8f3ff6a2f551b9e2bd973353b3b586511c28192 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/internals.ets @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { KoalaCallsiteKey } from "./common" +import { StateContext } from "./states/State" +export type __memo_context_type = StateContext +export type __memo_id_type = KoalaCallsiteKey +export type __memo_transformed_before = string +export type __memo_transformed_after = number +export type __memo_transformed = __memo_transformed_before +export declare function __context(): StateContext +export declare function __id(): KoalaCallsiteKey +export declare function __key(): KoalaCallsiteKey diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/memo/bind.ets b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/memo/bind.ets new file mode 100644 index 0000000000000000000000000000000000000000..65d660d389df8348db3d64d6a1857e42ff8b71ca --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/memo/bind.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { memo } from "../annotations" +import { KoalaCallsiteKey } from "../common" +import { StateContext } from "../states/State" +export declare class MemoCallbackContext { + readonly context: StateContext + readonly id: KoalaCallsiteKey + constructor(context: StateContext, id: KoalaCallsiteKey) + @memo static Make(): MemoCallbackContext + call(@memo callback: (args: Int32Array) => number, args: Int32Array): number +} +export declare function memoBind(@memo item: (arg: T) => void, value: T): @memo () => void +export declare function memoBind2(@memo item: (arg1: T1, arg2: T2) => void, value1: T1, value2: T2): @memo () => void +export declare function memoPartialBind2_1(@memo item: (arg1: T1, arg2: T2) => void, value1: T1): @memo (arg2: T2) => void +export declare function memoPartialBind3_2(@memo item: (arg1: T1, arg2: T2, arg3: T3) => void, value1: T1): @memo (arg2: T2, arg3: T3) => void diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/memo/changeListener.ets b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/memo/changeListener.ets new file mode 100644 index 0000000000000000000000000000000000000000..bcaa2a50c47b344a787a2c5d694dcc818ab14a3c --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/memo/changeListener.ets @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { memo_intrinsic } from "../annotations" +@memo_intrinsic export declare function OnChange(value: Value, listener: (value: Value) => void): void +@memo_intrinsic export declare function RunEffect(value: Value, effect: (value: Value) => void): void diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/memo/contextLocal.ets b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/memo/contextLocal.ets new file mode 100644 index 0000000000000000000000000000000000000000..5cfb10ee7d897ea385e7948b24889d8a6482d536 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/memo/contextLocal.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { memo, memo_intrinsic } from "../annotations" +import { State } from "../states/State" +@memo_intrinsic export declare function contextLocal(name: string): State | undefined +@memo_intrinsic export declare function contextLocalValue(name: string): Value +@memo_intrinsic export declare function contextLocalScope(name: string, value: Value, @memo content: () => void): void diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/memo/entry.ets b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/memo/entry.ets new file mode 100644 index 0000000000000000000000000000000000000000..2b7d437692caabd2befdeee696267a31a0b580b1 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/memo/entry.ets @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { memo, memo_entry } from "../annotations" +import { KoalaCallsiteKey } from "../common" +import { ComputableState, StateContext } from "../states/State" +import { IncrementalNode } from "../tree/IncrementalNode" +export declare function memoRoot(node: Node, @memo update: (node: Node) => void): ComputableState +export declare function memoRoot(node: Node, update: (__memo_context: StateContext, __memo_id: KoalaCallsiteKey, node: Node) => void): ComputableState +@memo_entry export declare function memoEntry(__memo_context: StateContext, __memo_id: KoalaCallsiteKey, @memo entry: () => R): R +@memo_entry export declare function memoEntry(__memo_context: StateContext, __memo_id: KoalaCallsiteKey, entry: (__memo_context: StateContext, __memo_id: KoalaCallsiteKey) => R): R +@memo_entry export declare function memoEntry1(__memo_context: StateContext, __memo_id: KoalaCallsiteKey, @memo entry: (arg: T) => R, arg: T): R +@memo_entry export declare function memoEntry1(__memo_context: StateContext, __memo_id: KoalaCallsiteKey, entry: (__memo_context: StateContext, __memo_id: KoalaCallsiteKey, arg: T) => R, arg: T): R +@memo_entry export declare function memoEntry2(__memo_context: StateContext, __memo_id: KoalaCallsiteKey, @memo entry: (arg1: T1, arg2: T2) => R, arg1: T1, arg2: T2): R +@memo_entry export declare function memoEntry2(__memo_context: StateContext, __memo_id: KoalaCallsiteKey, entry: (__memo_context: StateContext, __memo_id: KoalaCallsiteKey, arg1: T1, arg2: T2) => R, arg1: T1, arg2: T2): R diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/memo/node.ets b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/memo/node.ets new file mode 100644 index 0000000000000000000000000000000000000000..4e425cc51f4f84ce6511ba42f2e84b3e6c7b95b0 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/memo/node.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { memo, memo_intrinsic } from "../annotations" +import { uint32, KoalaCallsiteKey } from "../common" +import { IncrementalNode } from "../tree/IncrementalNode" +import { StateContext } from "../states/State" +@memo_intrinsic export declare function NodeAttach(create: () => Node, @memo update: (node: Node) => void): void +@memo_intrinsic export declare function contextNode(kind: uint32 = 1, name?: string): T +export declare function NodeAttach(__memo_context: StateContext, __memo_id: KoalaCallsiteKey, create: () => Node, update: (__memo_context: StateContext, __memo_id: KoalaCallsiteKey, node: Node) => void): void +export declare function contextNode(__memo_context: StateContext, __memo_id: KoalaCallsiteKey, kind: uint32 = 1, name?: string): T +export declare class DataNode extends IncrementalNode { + data: Data | undefined + constructor(kind: uint32 = 1) + static attach(kind: uint32, data: Data, onDataChange?: () => void): void + static extract(kind: uint32, node: IncrementalNode): Data | undefined +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/memo/remember.ets b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/memo/remember.ets new file mode 100644 index 0000000000000000000000000000000000000000..3476df08bbba4fd0579b0da1675421894d97720d --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/memo/remember.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { memo, memo_skip, memo_intrinsic } from "../annotations" +import { ArrayState, ControlledScope, MutableState } from "../states/State" +@memo_intrinsic export declare function memoize(compute: () => Value): Value +@memo_intrinsic export declare function memoLifecycle(onAttach: () => void, onDetach: () => void): void +@memo_intrinsic export declare function once(callback: () => void): void +@memo_intrinsic export declare function remember(compute: () => Value): Value +@memo_intrinsic export declare function rememberDisposable(compute: () => Value, cleanup: (value: Value | undefined) => void): Value +@memo_intrinsic export declare function rememberMutableState(initial: (() => Value) | Value): MutableState +@memo_intrinsic export declare function rememberArrayState(initial?: () => ReadonlyArray): ArrayState +@memo export declare function rememberMutableAsyncState(compute: () => Promise, initial?: Value, onError?: (error: Error) => void): MutableState +@memo export declare function rememberComputableState(key: Key, @memo_skip compute: (key: Key) => Promise, initial?: Value, onError?: (error: Error) => void): MutableState +@memo export declare function rememberComputableValue(key: Key, @memo_skip compute: (key: Key) => Promise, initial?: Value, onError?: (e: Error) => void): Value | undefined +@memo_intrinsic export declare function rememberControlledScope(invalidate: () => void): ControlledScope diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/memo/repeat.ets b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/memo/repeat.ets new file mode 100644 index 0000000000000000000000000000000000000000..d12ad9abf369e186f0a5c7e5ee4d0ce112823a0d --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/memo/repeat.ets @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { memo } from "../annotations" +import { KoalaCallsiteKey, int32 } from "../common" +import { StateContext } from "../states/State" +@memo export declare function Repeat(count: int32, @memo action: (index: int32) => void): void +export declare function Repeat(__memo_context: StateContext, __memo_id: KoalaCallsiteKey, count: int32, action: (__memo_context: StateContext, __memo_id: KoalaCallsiteKey, index: int32) => void): void +@memo export declare function RepeatWithKey(count: int32, key: (index: int32) => KoalaCallsiteKey, @memo action: (index: int32) => void): void +export declare function RepeatWithKey(__memo_context: StateContext, __memo_id: KoalaCallsiteKey, count: int32, key: (index: int32) => KoalaCallsiteKey, action: (__memo_context: StateContext, __memo_id: KoalaCallsiteKey, index: int32) => void): void +@memo export declare function RepeatByArray(array: ReadonlyArray, key: (element: T, index: int32) => KoalaCallsiteKey, @memo action: (element: T, index: int32) => void): void +export declare function RepeatByArray(__memo_context: StateContext, __memo_id: KoalaCallsiteKey, array: ReadonlyArray, key: (element: T, index: int32) => KoalaCallsiteKey, action: (__memo_context: StateContext, __memo_id: KoalaCallsiteKey, element: T, index: int32) => void): void +@memo export declare function RepeatRange(start: int32, end: int32, element: (index: int32) => T, key: (element: T, index: int32) => KoalaCallsiteKey, @memo action: (element: T, index: int32) => void): void +export declare function RepeatRange(__memo_context: StateContext, __memo_id: KoalaCallsiteKey, start: int32, end: int32, element: (index: int32) => T, key: (element: T, index: int32) => KoalaCallsiteKey, action: (__memo_context: StateContext, __memo_id: KoalaCallsiteKey, element: T, index: int32) => void): void diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/memo/testing.ets b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/memo/testing.ets new file mode 100644 index 0000000000000000000000000000000000000000..57d9b70b6f17a99d2cc1f1ee50e19385dc1e4858 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/memo/testing.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { memo, memo_intrinsic } from "../annotations" +import { uint32, KoalaCallsiteKey } from "../common" +import { GlobalStateManager } from "../states/GlobalStateManager" +import { ComputableState, State, StateContext, StateManager } from "../states/State" +import { IncrementalNode } from "../tree/IncrementalNode" +export declare class TestNode extends IncrementalNode { + content: string + constructor(kind: uint32 = 1) + toString(): string + static create(@memo content: (node: TestNode) => void): ComputableState + static create(content: (__memo_context: StateContext, __memo_id: KoalaCallsiteKey, node: TestNode) => void): ComputableState + @memo_intrinsic static attach(content: (node: TestNode) => void): void + @memo_intrinsic static attach(content: (__memo_context: StateContext, __memo_id: KoalaCallsiteKey, node: TestNode) => void): void +} +export declare function testRoot(@memo content: (node: TestNode) => void): State +export declare function testRoot(content: (__memo_context: StateContext, __memo_id: KoalaCallsiteKey, node: TestNode) => void): State +export declare function testUpdate(withCallbacks: boolean = true, manager: StateManager = GlobalStateManager.instance): uint32 +export declare function testTick(root: State, withCallbacks: boolean = true): void diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/states/Dependency.ets b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/states/Dependency.ets new file mode 100644 index 0000000000000000000000000000000000000000..af0c9d5a159aede246a088cc8eee18501652b944 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/states/Dependency.ets @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export declare interface Dependency { + readonly obsolete: boolean + invalidate(): void +} +export declare class Dependencies { + frame: int + dependencies: Set | undefined + latest: Dependency | undefined + get empty(): boolean + register(dependency?: Dependency): void + updateDependencies(invalidate: boolean): void +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/states/Disposable.ets b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/states/Disposable.ets new file mode 100644 index 0000000000000000000000000000000000000000..59d045a473691c62aeadea59676ecf8e40d6f8dd --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/states/Disposable.ets @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export declare interface Disposable { + readonly disposed: boolean + dispose(): void +} +export declare function disposeContentForward(array: ReadonlyArray): void +export declare function disposeContentBackward(array: ReadonlyArray): void +export declare function disposeContent(it: IterableIterator): void diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/states/GlobalStateManager.ets b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/states/GlobalStateManager.ets new file mode 100644 index 0000000000000000000000000000000000000000..9fa16240793b295d55157d1539d3198dfab531ff --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/states/GlobalStateManager.ets @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ArrayState, Equivalent, MutableState, StateManager, ValueTracker } from "./State" +export declare class GlobalStateManager { + static current: StateManager | undefined + static get instance(): StateManager + static reset(): void +} +export declare function updateStateManager(manager: StateManager = GlobalStateManager.instance): void +export declare function callScheduledCallbacks(manager: StateManager = GlobalStateManager.instance): void +export declare function scheduleCallback(callback?: () => void, manager: StateManager = GlobalStateManager.instance): void +export declare function mutableState(value: T, equivalent?: Equivalent, tracker?: ValueTracker): MutableState +export declare function arrayState(array?: ReadonlyArray, equivalent?: Equivalent): ArrayState diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/states/Journal.ets b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/states/Journal.ets new file mode 100644 index 0000000000000000000000000000000000000000..8ff179ffb680d11173e8f33ca854171c4c641765 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/states/Journal.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AtomicRef } from "../common" +export interface Changes { + getChange(state: Object): AtomicRef | undefined + clear(): void +} +export declare class Journal implements Changes { + readonly current: AtomicRef + setMarker(): void + addChange(state: Object, value: Value): void + getChanges(): Changes | undefined + getChange(state: Object): AtomicRef | undefined + clear(): void + getCachedArray(state: Object, array: Array): Array +} +declare class Chunk { + readonly previous: AtomicRef + readonly map: Map + get(state: Object): AtomicRef | undefined +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/states/State.ets b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/states/State.ets new file mode 100644 index 0000000000000000000000000000000000000000..0277e11149a378b715392c12e4360c15c8702d0e --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/states/State.ets @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { int32, KoalaCallsiteKey, uint32 } from "../common" +import { Disposable } from "./Disposable" +import { IncrementalNode } from "../tree/IncrementalNode" +export declare const CONTEXT_ROOT_SCOPE: string +export declare const CONTEXT_ROOT_NODE: string +export type Equivalent = (oldV: Value, newV: Value) => boolean +export declare function createStateManager(): StateManager +export declare interface StateManager extends StateContext { + syncChanges(): void + isUpdateNeeded(): boolean + updateSnapshot(): uint32 + updatableNode(node: Node, update: (context: StateContext) => void, cleanup?: () => void): ComputableState + scheduleCallback(callback: () => void): void + callCallbacks(): void + frozen: boolean + reset(): void +} +export declare interface State { + readonly modified: boolean + readonly value: Value +} +export declare interface MutableState extends Disposable, State { + value: Value +} +export declare interface ArrayState extends State> { + length: number + at(index: number): Item + get(index: number): Item + set(index: number, item: Item): void + copyWithin(target: number, start: number, end?: number): Array + fill(value: Item, start?: number, end?: number): Array + pop(): Item | undefined + push(...items: Item[]): number + reverse(): Array + shift(): Item | undefined + sort(comparator?: (a: Item, b: Item) => number): Array + splice(start: number, deleteCount: number | undefined, ...items: Item[]): Array + unshift(...items: Item[]): number +} +export declare interface ComputableState extends Disposable, State { + readonly recomputeNeeded: boolean +} +export declare interface StateContext { + readonly node: IncrementalNode | undefined + attach(id: KoalaCallsiteKey, create: () => Node, update: () => void, cleanup?: () => void): void + compute(id: KoalaCallsiteKey, compute: () => Value, cleanup?: (value: Value | undefined) => void, once?: boolean): Value + computableState(compute: (context: StateContext) => Value, cleanup?: (context: StateContext, value: Value | undefined) => void): ComputableState + mutableState(initial: Value, global?: boolean, equivalent?: Equivalent, tracker?: ValueTracker): MutableState + arrayState(initial?: ReadonlyArray, global?: boolean, equivalent?: Equivalent): ArrayState + namedState(name: string, create: () => Value, global?: boolean, equivalent?: Equivalent, tracker?: ValueTracker): MutableState + stateBy(name: string, global?: boolean): MutableState | undefined + valueBy(name: string, global?: boolean): Value + scope(id: KoalaCallsiteKey, paramCount?: int32, create?: () => IncrementalNode, compute?: () => Value, cleanup?: (value: Value | undefined) => void, once?: boolean): InternalScope + controlledScope(id: KoalaCallsiteKey, invalidate: () => void): ControlledScope +} +export declare interface ValueTracker { + onCreate(value: Value): Value + onUpdate(value: Value): Value +} +export declare interface InternalScope { + readonly unchanged: boolean + readonly cached: Value + recache(newValue?: Value): Value + param(index: int32, value: V, equivalent?: Equivalent, name?: string, contextLocal?: boolean): State +} +export declare interface ControlledScope { + enter(): void + leave(): void +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/tree/IncrementalNode.ets b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/tree/IncrementalNode.ets new file mode 100644 index 0000000000000000000000000000000000000000..7e70a5c64f929261ac589475d61889bb49a50f64 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/tree/IncrementalNode.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { uint32 } from "../common" +import { Disposable } from "../states/Disposable" +import { ReadonlyTreeNode } from "./ReadonlyTreeNode" +export declare class IncrementalNode implements Disposable, ReadonlyTreeNode { + _disposed: boolean + _child: IncrementalNode | undefined + _prev: IncrementalNode | undefined + _next: IncrementalNode | undefined + _parent: IncrementalNode | undefined + _incremental: IncrementalNode | undefined + protected onChildInserted: ((node: IncrementalNode) => void) | undefined + protected onChildRemoved: ((node: IncrementalNode) => void) | undefined + readonly kind: uint32 + constructor(kind: uint32 = 1) + isKind(kind: uint32): boolean + get disposed(): boolean + dispose(): void + get parent(): IncrementalNode | undefined + toString(): string + toHierarchy(): string + get firstChild(): IncrementalNode | undefined + get nextSibling(): IncrementalNode | undefined + get previousSibling(): IncrementalNode | undefined + incrementalUpdateSkip(count: uint32): void + incrementalUpdateDone(parent?: IncrementalNode): void +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/tree/PrimeNumbers.ets b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/tree/PrimeNumbers.ets new file mode 100644 index 0000000000000000000000000000000000000000..d5994c577d651db34a50fa114dd3fcb01eee0e6a --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/tree/PrimeNumbers.ets @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { uint32 } from "../common" +export declare const PrimeNumbers: ReadonlyArray \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/tree/ReadonlyTreeNode.ets b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/tree/ReadonlyTreeNode.ets new file mode 100644 index 0000000000000000000000000000000000000000..7c7d9f52f3be133480b08e379ad67ae35c9ed8d9 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/tree/ReadonlyTreeNode.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export declare interface ReadonlyTreeNode { + readonly parent: ReadonlyTreeNode | undefined + toHierarchy(): string +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/tree/TreeNode.ets b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/tree/TreeNode.ets new file mode 100644 index 0000000000000000000000000000000000000000..56a72359cb2f3b6e89a0d37f6b238b2c7c2f81ac --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/tree/TreeNode.ets @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { float64, int32, uint32 } from "../common" +import { Disposable } from "../states/Disposable" +import { ReadonlyTreeNode } from "./ReadonlyTreeNode" +export declare class TreeNode implements Disposable, ReadonlyTreeNode { + myIndex: int32 + myParent: TreeNode | undefined + myChildren: Array + myIndicesValid: boolean + myDisposed: boolean + readonly kind: uint32 + protected onChildInserted: ((node: TreeNode, index: int32) => void) | undefined + protected onChildRemoved: ((node: TreeNode, index: int32) => void) | undefined + constructor(kind: uint32 = 1) + get disposed(): boolean + dispose(): void + get parent(): TreeNode | undefined + get depth(): uint32 + get childrenCount(): uint32 + get children(): ReadonlyArray + get index(): int32 + isKind(kind: uint32): boolean + find(valueOf: (node: TreeNode, index: int32) => V | undefined): V | undefined + forEach(action: (node: TreeNode, index: float64) => void): void + every(predicate: (node: TreeNode, index: float64) => boolean): boolean + some(predicate: (node: TreeNode, index: float64) => boolean): boolean + childAt(index: int32): TreeNode | undefined + appendChild(node: TreeNode): boolean + insertChildAt(index: int32, node: TreeNode): boolean + appendChildren(...nodes: TreeNode[]): boolean + insertChildrenAt(index: int32, ...nodes: TreeNode[]): boolean + removeChildAt(index: int32): TreeNode | undefined + removeChildrenAt(index: int32, count?: uint32): Array + removeChild(node: TreeNode): boolean + removeFromParent(): void + removeNodes(index: int32, count: uint32): Array + insertNodeAt(index: int32, node: TreeNode): void + insertable(node: TreeNode): boolean + accessible(index: int32, count: uint32 = 1): boolean + toString(): string + toHierarchy(): string + collectNodes(): Array + collectParentsTo(array: Array): void + collectChildrenTo(array: Array, deep: boolean = false): void +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/tree/TreePath.ets b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/tree/TreePath.ets new file mode 100644 index 0000000000000000000000000000000000000000..55be5f191c5d76c670c31a419c46f4a489e36028 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/tree/TreePath.ets @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { uint32 } from "../common" +export declare class TreePath { + readonly node: Node + readonly parent: TreePath | undefined + constructor(node: Node, parent?: TreePath) + child(node: Node): TreePath + get root(): TreePath + get depth(): uint32 + toString(): string +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/tree/TreeUpdater.ets b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/tree/TreeUpdater.ets new file mode 100644 index 0000000000000000000000000000000000000000..a54302e816507b06527db1668563ce468196e6ab --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/runtime-api/tree/TreeUpdater.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { int32, uint32 } from "../common" +import { TreePath } from "./TreePath" +export declare class TreeUpdater { + current: TreePath + readonly reverse: boolean + constructor(root: Node, reverse: boolean = false) + get path(): TreePath + get node(): Node + down(node: Node): void + up(): void + clear(): void + insert(index: int32, node: Node): void + remove(index: int32, amount: uint32): void + move(indexFrom: int32, indexTo: int32, amount: uint32): void +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/ui2abcconfig.json b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/ui2abcconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..3dfc8a6d3f413df19a11c6690622781e6334dc4d --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/recheck-bringup/ui2abcconfig.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + "package": "@recheck-bringup", + "outDir": "../build/recheck-bringup", + "baseUrl": ".", + "paths": { + "@koalaui/common": ["../../../incremental/common/src"], + "@koalaui/compat": ["../../../incremental/compat/src/arkts"], + "@koalaui/harness": ["../../../incremental/harness/src/arkts"], + "@koalaui/runtime": ["./runtime-api"], + "@koalaui/runtime/annotations": ["./runtime-api"] + }, + "plugins": [ + { + "transform": "@koalaui/memo-plugin", + "stage": "checked", + "name": "memo" + } + ] + }, + "include": [ + "./input/ets/memo-hello-world.ts" + ], + "dependencies": { + "@koalaui/runtime": ["../../../incremental/runtime/ui2abcconfig.json"] + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/rollup.config.mjs b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/rollup.config.mjs new file mode 100644 index 0000000000000000000000000000000000000000..a232e4ff118ff2e914252bd2890e88aabbea0dd4 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/rollup.config.mjs @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import nodeResolve from "@rollup/plugin-node-resolve"; +import typescript from "@rollup/plugin-typescript"; +import commonjs from '@rollup/plugin-commonjs' + +const ENABLE_SOURCE_MAPS = true; // Enable for debugging + +/** @type {import("rollup").RollupOptions} */ +export default { + input: "./src/MemoTransformer.ts", + output: { + file: "./lib/MemoTransformer.js", + format: "commonjs", + plugins: [ + // terser() + ], + banner: [ + "#!/usr/bin/env node", + APACHE_LICENSE_HEADER() + ].join("\n"), + }, + external: ["@koalaui/libarkts"], + plugins: [ + commonjs(), + typescript({ + outputToFilesystem: false, + module: "esnext", + sourceMap: ENABLE_SOURCE_MAPS, + declarationMap: false, + declaration: false, + composite: false, + }), + nodeResolve({ + extensions: [".js", ".mjs", ".cjs", ".ts", ".cts", ".mts"] + }) + ], +} + +function APACHE_LICENSE_HEADER() { + return ` +/** +* @license +* Copyright (c) ${new Date().getUTCFullYear()} Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +` +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/src/AnalysisVisitor.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/src/AnalysisVisitor.ts new file mode 100644 index 0000000000000000000000000000000000000000..9eb1d75fa88f7b902c9ef9d3036116e303899bf8 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/src/AnalysisVisitor.ts @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as arkts from "@koalaui/libarkts" +import { getDeclResolveGensym, getMemoFunctionKind, MemoFunctionKind } from "./utils" +import { getParams, isMemoAnnotatable, isMemoizable } from "./api-utils" + +class AnalysisVisitorOptions { + applyMemo?: MemoFunctionKind +} + +export class AnalysisVisitor extends arkts.AbstractVisitor { + // TODO: migrate to wrappers instead of pointers + constructor( + public scriptFunctions: Map, + public ETSFunctionTypes: Map, + ) { + super() + } + + visitor(node: arkts.BlockStatement, options?: AnalysisVisitorOptions): arkts.BlockStatement + visitor(node: arkts.CallExpression, options?: AnalysisVisitorOptions): arkts.CallExpression + visitor(node: arkts.Expression, options?: AnalysisVisitorOptions): arkts.Expression + visitor(node: arkts.AstNode, options?: AnalysisVisitorOptions): arkts.AstNode { + if (arkts.isScriptFunction(node)) { + const kind = options?.applyMemo ? options?.applyMemo : getMemoFunctionKind(node) + this.scriptFunctions.set(node.originalPeer, kind) + return this.visitEachChild(node, { applyMemo: false }) + } + if (arkts.isETSFunctionType(node)) { + const kind = options?.applyMemo ? options?.applyMemo : getMemoFunctionKind(node) + this.ETSFunctionTypes.set(node.originalPeer, kind) + return this.visitEachChild(node, { applyMemo: false }) + } + + if (isMemoAnnotatable(node)) { + return this.visitEachChild(node, { applyMemo: options?.applyMemo ? options?.applyMemo : getMemoFunctionKind(node) }) + } + + if (arkts.isCallExpression(node)) { + const expr = node.callee + const decl = getDeclResolveGensym(expr!) + if (!isMemoizable(decl)) { + return node + } + const params = getParams(decl) + return arkts.factory.updateCallExpression( + node, + this.visitor(node.callee!, options), + node.arguments.map((arg, index) => this.visitor(arg, { applyMemo: params[index] ? getMemoFunctionKind(params[index]) : undefined })), + node.typeParams ? this.visitor(node.typeParams, options) as arkts.TSTypeParameterInstantiation : undefined, + node.isOptional, + node.hasTrailingComma, + node.trailingBlock ? this.visitor(node.trailingBlock, options) : undefined, + ) + } + + return this.visitEachChild(node, options) + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/src/DiagnosticVisitor.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/src/DiagnosticVisitor.ts new file mode 100644 index 0000000000000000000000000000000000000000..599cd2faa211ad9373650f99b2c2c7e3179cd15b --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/src/DiagnosticVisitor.ts @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as arkts from "@koalaui/libarkts" +import { getDeclResolveGensym, MemoFunctionKind } from "./utils" +import { getName, isMemo, isMemoizable, Memoizable } from "./api-utils" + +type ScopeInfo = { + name?: string, + isMemo: boolean +} + +export class DiagnosticVisitor extends arkts.AbstractVisitor { + constructor( + public scriptFunctions: Map, + ) { + super() + } + + private scopes: ScopeInfo[] = [] + + enter(node: arkts.AstNode) { + if (arkts.isScriptFunction(node)) { + const name = node.id?.name + const isMemo = this.scriptFunctions.get(node.originalPeer) != MemoFunctionKind.NONE + this.scopes.push({ name , isMemo }) + } + return this + } + + exit(node: arkts.AstNode) { + if (arkts.isScriptFunction(node)) { + this.scopes.pop() + } + return this + } + + checkMemoCall(decl: Memoizable) { + if (this.scopes[this.scopes.length - 1].isMemo === false) { + if (this.scopes[this.scopes.length - 1].name) { + console.error(`Attempt to call @memo-method ${getName(decl)} from non-@memo-method ${this.scopes[this.scopes.length - 1].name}`) + throw "Invalid @memo usage" + } else { + console.error(`Attempt to call @memo-method ${getName(decl)} from anonymous non-@memo-method`) + throw "Invalid @memo usage" + } + } + return this + } + + visitor(beforeChildren: arkts.AstNode): arkts.AstNode { + this.enter(beforeChildren) + const node = this.visitEachChild(beforeChildren) + this.exit(beforeChildren) + + if (arkts.isCallExpression(node)) { + const expr = node.callee + const decl = getDeclResolveGensym(expr!) + if (isMemoizable(decl) && isMemo(decl)) { + this.checkMemoCall(decl) + } + } + return node + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/src/FunctionTransformer.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/src/FunctionTransformer.ts new file mode 100644 index 0000000000000000000000000000000000000000..759fffbcd5e01252440acb7a85a929f53aa9b724 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/src/FunctionTransformer.ts @@ -0,0 +1,311 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as arkts from "@koalaui/libarkts" +import { factory } from "./MemoFactory" +import { + MemoFunctionKind, + PositionalIdTracker, + RuntimeNames, + getDeclResolveGensym, + hasMemoStableAnnotation, + isTrackableParam, + isVoidType, + shouldWrap, +} from "./utils" +import { ParameterTransformer, ParamInfo } from "./ParameterTransformer" +import { ReturnTransformer } from "./ReturnTranformer" +import { InternalsTransformer } from "./InternalsTransformer" +import { SignatureTransformer } from "./SignatureTransformer" +import { + castParameters, + getName, + getParams, + isMemo, + isMemoizable, +} from "./api-utils" + +function needThisRewrite(hasReceiver: boolean, isStatic: boolean, stableThis: boolean) { + return hasReceiver && !isStatic && !stableThis +} + +function isVoidReturn(returnTypeAnnotation: arkts.TypeNode | undefined) { + return !returnTypeAnnotation || isVoidType(returnTypeAnnotation) +} + +function mayAddLastReturn(node: arkts.BlockStatement): boolean { + return node.statements.length == 0 || ( + !arkts.isReturnStatement(node.statements[node.statements.length - 1]) && + !arkts.isThrowStatement(node.statements[node.statements.length - 1]) + ) +} + +function dropUntrackableParameters(parameters: readonly arkts.ETSParameterExpression[]) { + return parameters.filter((it, index) => isTrackableParam(it, index + 1 == parameters.length)) +} + +function getMemoParameterIdentifiers(parameters: readonly arkts.ETSParameterExpression[]) { + return [ + ...dropUntrackableParameters(parameters).map(it => { + return { ident: it.ident!, param: it } + }) + ] +} + +function fixGensymParams(params: ParamInfo[], body: arkts.BlockStatement) { + var gensymParamsCount = 0; + for (var i = 0; i < params.length; i++) { + if (params[i].ident.name.startsWith(RuntimeNames.GENSYM)) { + if (gensymParamsCount >= body.statements.length) { + throw new Error(`Expected ${params[i].ident.name} replacement to original parameter`) + } + const declaration = body.statements[gensymParamsCount] + if (!arkts.isVariableDeclaration(declaration)) { + throw new Error(`Expected ${params[i].ident.name} replacement to original parameter`) + } + if (!arkts.isIdentifier(declaration.declarators[0].id)) { + throw new Error(`Expected ${params[i].ident.name} replacement to original parameter`) + } + params[i].ident = declaration.declarators[0].id + gensymParamsCount++ + } + } + return gensymParamsCount +} + +function updateFunctionBody( + node: arkts.BlockStatement, + parameters: readonly arkts.ETSParameterExpression[], + returnTypeAnnotation: arkts.TypeNode | undefined, + hasReceiver: boolean, + isStatic: boolean, + stableThis: boolean, + hash: arkts.NumberLiteral | arkts.StringLiteral, + addLogging: boolean, +): [ + arkts.BlockStatement, + ParamInfo[], + arkts.VariableDeclaration | undefined, + arkts.ReturnStatement | arkts.BlockStatement | undefined, +] { + const shouldCreateMemoThisParam = needThisRewrite(hasReceiver, isStatic, stableThis) + const parameterIdentifiers = getMemoParameterIdentifiers(parameters) + const gensymParamsCount = fixGensymParams(parameterIdentifiers, node) + const parameterNames = [...(shouldCreateMemoThisParam ? [RuntimeNames.THIS.valueOf()] : []), ...parameterIdentifiers.map(it => it.ident.name)] + const scopeDeclaration = factory.createScopeDeclaration( + stableThis ? arkts.factory.createETSPrimitiveType(arkts.Es2pandaPrimitiveType.PRIMITIVE_TYPE_VOID) : returnTypeAnnotation, + hash, parameterNames.length + ) + const memoParametersDeclaration = parameterNames.length ? factory.createMemoParameterDeclaration(parameterNames) : undefined + const syntheticReturnStatement = factory.createSyntheticReturnStatement(isVoidReturn(returnTypeAnnotation), stableThis) + const unchangedCheck = factory.createIfStatementWithSyntheticReturnStatement(syntheticReturnStatement) + return [ + arkts.factory.updateBlockStatement( + node, + [ + ...node.statements.slice(0, gensymParamsCount), + scopeDeclaration, + ...(memoParametersDeclaration ? [memoParametersDeclaration] : []), + ...(addLogging ? [factory.createMemoParameterModifiedLogging(parameterNames)] : []), + ...(addLogging ? [factory.createUnchangedLogging()] : []), + unchangedCheck, + ...node.statements.slice(gensymParamsCount), + ...(mayAddLastReturn(node) ? [arkts.factory.createReturnStatement(undefined)] : []), + ] + ), + parameterIdentifiers, + memoParametersDeclaration, + syntheticReturnStatement, + ] +} + +class FunctionTransformerOptions { + receiverContext?: boolean +} + +export class FunctionTransformer extends arkts.AbstractVisitor { + constructor( + public scriptFunctions: Map, + public typeAliases: Map, + private positionalIdTracker: PositionalIdTracker, + private signatureTransformer: SignatureTransformer, + private internalsTransformer: InternalsTransformer, + private parameterTransformer: ParameterTransformer, + private returnTransformer: ReturnTransformer, + private addLogging: boolean, + ) { + super() + } + + private stable: number = 0 + + public modified: boolean = false + + enter(node: arkts.AstNode) { + if (arkts.isClassDefinition(node)) { + if (hasMemoStableAnnotation(node)) { + this.stable++ + } + } + return this + } + + exit(node: arkts.AstNode) { + if (arkts.isClassDefinition(node)) { + if (hasMemoStableAnnotation(node)) { + this.stable-- + } + } + return this + } + + fixObjectArg(arg: arkts.Expression, param: arkts.ETSParameterExpression) { + if (param.typeAnnotation && arkts.isObjectExpression(arg)) { + return arkts.factory.createTSAsExpression( + arg, + param.typeAnnotation, + false + ) + } + return arg + } + + updateScriptFunction( + scriptFunction: arkts.ScriptFunction, + hasReceiver: boolean, + name: string = "", + ): arkts.ScriptFunction { + if (!scriptFunction.body || !arkts.isBlockStatement(scriptFunction.body)) { + return scriptFunction + } + const afterInternalsTransformer = this.internalsTransformer.visitor(scriptFunction.body) as arkts.BlockStatement + const kind = this.scriptFunctions.get(scriptFunction.originalPeer) ?? MemoFunctionKind.NONE + if (kind == MemoFunctionKind.INTRINSIC || kind == MemoFunctionKind.ENTRY) { + return arkts.factory.updateScriptFunction( + scriptFunction, + afterInternalsTransformer, + scriptFunction.typeParams, + scriptFunction.params, + scriptFunction.returnTypeAnnotation, + false, + scriptFunction.flags, + scriptFunction.modifierFlags, + scriptFunction.id, + scriptFunction.annotations, + ) + } + + const isStatic = (scriptFunction.modifierFlags & arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_STATIC) != 0 + const isStableThis = this.stable > 0 + const [body, parameterIdentifiers, memoParametersDeclaration, syntheticReturnStatement] = updateFunctionBody( + afterInternalsTransformer, + castParameters(scriptFunction.params), + scriptFunction.returnTypeAnnotation, + hasReceiver, + isStatic, + isStableThis, + this.positionalIdTracker.id(name), + this.addLogging + ) + const afterParameterTransformer = this.parameterTransformer + .withThis(needThisRewrite(hasReceiver, isStatic, isStableThis)) + .withParameters(parameterIdentifiers) + .skip(memoParametersDeclaration) + .visitor(body) + const afterReturnTransformer = this.returnTransformer + .skip(syntheticReturnStatement) + .rewriteThis(isStableThis) + .visitor(afterParameterTransformer) + return arkts.factory.updateScriptFunction( + scriptFunction, + afterReturnTransformer, + scriptFunction.typeParams, + scriptFunction.params, + scriptFunction.returnTypeAnnotation, + false, + scriptFunction.flags, + scriptFunction.modifierFlags, + scriptFunction.id, + scriptFunction.annotations, + ) + } + + transformScriptFunction(node: arkts.ScriptFunction, options?: FunctionTransformerOptions): arkts.ScriptFunction { + const kind = this.scriptFunctions.get(node.originalPeer) ?? MemoFunctionKind.NONE // can it actually be undefined? + if (kind === MemoFunctionKind.NONE) { + return this.signatureTransformer.visitor(node) + } + this.modified = true + return this.signatureTransformer.visitor( + this.updateScriptFunction( + node, + node.hasReceiver || (options?.receiverContext == true), + node.id?.name, + ) + ) + } + + transformCallExpression(node: arkts.CallExpression, options?: FunctionTransformerOptions): arkts.CallExpression { + const expr = node.callee + const decl = getDeclResolveGensym(expr!) + if (decl === undefined) { + return node + } + if (!isMemoizable(decl) || !isMemo(decl)) { + return node + } + + const params = getParams(decl) + const updatedArguments = node.arguments.map((it, index) => { + if (shouldWrap(params[index], index + 1 == params.length, it)) { + return factory.createComputeExpression(this.positionalIdTracker.id(getName(decl)), this.fixObjectArg(it, params[index])) + } + return this.fixObjectArg(it, params[index]) + }) + this.modified = true + return arkts.factory.updateCallExpression( + node, + node.callee, + [...factory.createHiddenArguments(this.positionalIdTracker.id(getName(decl))), ...updatedArguments], + node.typeParams, + node.isOptional, + node.hasTrailingComma, + node.trailingBlock, + ) + } + + transformETSFunctionType(node: arkts.ETSFunctionType, options?: FunctionTransformerOptions): arkts.ETSFunctionType { + return this.signatureTransformer.visitor(node) + } + + visitor(beforeChildren: arkts.AstNode, options?: FunctionTransformerOptions): arkts.AstNode { + this.enter(beforeChildren) + const node = this.visitEachChild(beforeChildren, { + receiverContext: + (options?.receiverContext || arkts.isMethodDefinition(beforeChildren)) && !arkts.isScriptFunction(beforeChildren) + }) + this.exit(beforeChildren) + if (arkts.isScriptFunction(node)) { + return this.transformScriptFunction(node, options) + } + if (arkts.isCallExpression(node)) { + return this.transformCallExpression(node, options) + } + if (arkts.isETSFunctionType(node)) { + return this.transformETSFunctionType(node, options) + } + return node + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/src/InternalsTransformer.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/src/InternalsTransformer.ts new file mode 100644 index 0000000000000000000000000000000000000000..8bbd08762c5db10fef708f0efece7a1f20580bad --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/src/InternalsTransformer.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as arkts from "@koalaui/libarkts" +import { RuntimeNames } from "./utils" + +export class InternalsTransformer extends arkts.AbstractVisitor { + + visitor(beforeChildren: arkts.AstNode): arkts.AstNode { + const node = this.visitEachChild(beforeChildren) + if (arkts.isCallExpression(node)) { + if (arkts.isIdentifier(node.callee)) { + if (node.callee.name == RuntimeNames.__CONTEXT) { + return arkts.factory.createIdentifier( + RuntimeNames.CONTEXT, + undefined + ) + } + if (node.callee.name == RuntimeNames.__ID) { + return arkts.factory.createIdentifier( + RuntimeNames.ID, + undefined + ) + } + } + } + return node + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/src/MemoFactory.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/src/MemoFactory.ts new file mode 100644 index 0000000000000000000000000000000000000000..7bf0851689c71f25bcb289bd68da2d8659417e36 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/src/MemoFactory.ts @@ -0,0 +1,326 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as arkts from "@koalaui/libarkts" +import { DebugNames, RuntimeNames } from "./utils" + +export class factory { + // Importing + static createContextTypeImportSpecifier(): arkts.ImportSpecifier { + return arkts.factory.createImportSpecifier( + arkts.factory.createIdentifier(RuntimeNames.CONTEXT_TYPE, undefined), + arkts.factory.createIdentifier(RuntimeNames.CONTEXT_TYPE, undefined), + ) + } + static createIdTypeImportSpecifier(): arkts.ImportSpecifier { + return arkts.factory.createImportSpecifier( + arkts.factory.createIdentifier(RuntimeNames.ID_TYPE, undefined), + arkts.factory.createIdentifier(RuntimeNames.ID_TYPE, undefined), + ) + } + static createContextTypesImportDeclaration(path?: string): arkts.ETSImportDeclaration { + return arkts.factory.createETSImportDeclaration( + arkts.factory.createStringLiteral(path ?? RuntimeNames.CONTEXT_TYPE_DEFAULT_IMPORT), + [factory.createContextTypeImportSpecifier(), factory.createIdTypeImportSpecifier()], + arkts.Es2pandaImportKinds.IMPORT_KINDS_ALL, + arkts.global.compilerContext.program, + arkts.Es2pandaImportFlags.IMPORT_FLAGS_DEFAULT_IMPORT + ) + } + + // Parameters + static createContextParameter(): arkts.ETSParameterExpression { + return arkts.factory.createETSParameterExpression( + arkts.factory.createIdentifier( + RuntimeNames.CONTEXT, + arkts.factory.createETSTypeReference( + arkts.factory.createETSTypeReferencePart( + arkts.factory.createIdentifier(RuntimeNames.CONTEXT_TYPE, undefined), + undefined, + undefined ) + ) + ), + false + ) + } + static createIdParameter(): arkts.ETSParameterExpression { + return arkts.factory.createETSParameterExpression( + arkts.factory.createIdentifier(RuntimeNames.ID, + arkts.factory.createETSTypeReference( + arkts.factory.createETSTypeReferencePart( + arkts.factory.createIdentifier(RuntimeNames.ID_TYPE, undefined), + undefined, + undefined + ) + ) + ), + false + ) + } + static createHiddenParameters(): arkts.ETSParameterExpression[] { + return [factory.createContextParameter(), factory.createIdParameter()] + } + + // Arguments + static createContextArgument(): arkts.Expression { + return arkts.factory.createIdentifier(RuntimeNames.CONTEXT, undefined) + } + static createIdArgument(hash: arkts.NumberLiteral | arkts.StringLiteral): arkts.Expression { + return arkts.factory.createBinaryExpression( + arkts.factory.createIdentifier(RuntimeNames.ID, undefined), + hash, + arkts.Es2pandaTokenType.TOKEN_TYPE_PUNCTUATOR_PLUS, + ) + } + static createHiddenArguments(hash: arkts.NumberLiteral | arkts.StringLiteral): arkts.Expression[] { + return [factory.createContextArgument(), factory.createIdArgument(hash)] + } + + // Memo parameters + static createMemoParameterIdentifier(name: string): arkts.Identifier { + return arkts.factory.createIdentifier(`${RuntimeNames.PARAMETER}_${name}`, undefined) + } + static createMemoParameterDeclarator(id: number, name: string): arkts.VariableDeclarator { + return arkts.factory.createVariableDeclarator( + arkts.Es2pandaVariableDeclaratorFlag.VARIABLE_DECLARATOR_FLAG_CONST, + factory.createMemoParameterIdentifier(name), + arkts.factory.createCallExpression( + arkts.factory.createMemberExpression( + arkts.factory.createIdentifier(RuntimeNames.SCOPE, undefined), + arkts.factory.createIdentifier(RuntimeNames.INTERNAL_PARAMETER_STATE, undefined), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + false, + false + ), + [ + arkts.factory.createNumberLiteral(id), + arkts.factory.createIdentifier(name, undefined), + ], + undefined, + ) + ) + } + static createMemoParameterDeclaration(parameters: string[]): arkts.VariableDeclaration { + return arkts.factory.createVariableDeclaration( + arkts.Es2pandaVariableDeclarationKind.VARIABLE_DECLARATION_KIND_CONST, + parameters.map((name, id) => { return factory.createMemoParameterDeclarator(id, name) }), + ) + } + static createMemoParameterModifiedLogging(parameters: string[]): arkts.CallExpression { + return arkts.factory.createCallExpression( + arkts.factory.createMemberExpression( + arkts.factory.createIdentifier(DebugNames.CONSOLE, undefined), + arkts.factory.createIdentifier(DebugNames.LOG, undefined), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_NONE, + false, + false, + ), + [ + arkts.factory.createStringLiteral(DebugNames.BANNER_PARAMETER), + ...parameters.flatMap((name) => { return [ + arkts.factory.createStringLiteral(`( ${name} modified:`), + arkts.factory.createMemberExpression( + factory.createMemoParameterIdentifier(name), + arkts.factory.createIdentifier("modified", undefined), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_GETTER, + false, + false + ), + arkts.factory.createStringLiteral(`)`), + ] }) + ], + undefined, + ) + } + static createMemoParameterAccess(name: string): arkts.MemberExpression { + return arkts.factory.createMemberExpression( + factory.createMemoParameterIdentifier(name), + arkts.factory.createIdentifier(RuntimeNames.VALUE, undefined), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_GETTER, + false, + false, + ) + } + static createMemoParameterAccessCall(name: string, passArgs?: arkts.Expression[]): arkts.CallExpression { + const updatedArgs = passArgs ? passArgs : [] + return arkts.factory.createCallExpression( + arkts.factory.createMemberExpression( + factory.createMemoParameterIdentifier(name), + arkts.factory.createIdentifier(RuntimeNames.VALUE, undefined), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_GETTER, + false, + false, + ), + [...updatedArgs], + undefined, + ) + } + + // Recache + static createScopeDeclaration(returnTypeAnnotation: arkts.TypeNode | undefined, hash: arkts.NumberLiteral | arkts.StringLiteral, cnt: number): arkts.VariableDeclaration { + return arkts.factory.createVariableDeclaration( + arkts.Es2pandaVariableDeclarationKind.VARIABLE_DECLARATION_KIND_CONST, + [ + arkts.factory.createVariableDeclarator( + arkts.Es2pandaVariableDeclaratorFlag.VARIABLE_DECLARATOR_FLAG_CONST, + arkts.factory.createIdentifier(RuntimeNames.SCOPE, undefined), + arkts.factory.createCallExpression( + arkts.factory.createMemberExpression( + arkts.factory.createIdentifier(RuntimeNames.CONTEXT, undefined), + arkts.factory.createIdentifier(RuntimeNames.INTERNAL_SCOPE, undefined), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + false, + false + ), + [ + factory.createIdArgument(hash), + arkts.factory.createNumberLiteral(cnt) + ], + arkts.factory.createTSTypeParameterInstantiation( + returnTypeAnnotation + ? [returnTypeAnnotation] + : [arkts.factory.createETSPrimitiveType(arkts.Es2pandaPrimitiveType.PRIMITIVE_TYPE_VOID)], + ), + ) + ) + ] + ) + } + static createRecacheCall(arg?: arkts.Expression): arkts.CallExpression { + return arkts.factory.createCallExpression( + arkts.factory.createMemberExpression( + arkts.factory.createIdentifier(RuntimeNames.SCOPE, undefined), + arkts.factory.createIdentifier(RuntimeNames.INTERNAL_VALUE_NEW, undefined), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + false, + false + ), + arg ? [arg] : [], + undefined, + ) + } + static createReturnThis(): arkts.BlockStatement { + return arkts.factory.createBlockStatement([ + factory.createRecacheCall(), + arkts.factory.createReturnStatement( + arkts.factory.createThisExpression() + ) + ]) + } + static createSyntheticReturnStatement(isVoidReturn: boolean, stableThis: boolean): arkts.ReturnStatement | arkts.BlockStatement { + if (isVoidReturn) { + return arkts.factory.createBlockStatement([ + arkts.factory.createMemberExpression( + arkts.factory.createIdentifier(RuntimeNames.SCOPE, undefined), + arkts.factory.createIdentifier(RuntimeNames.INTERNAL_VALUE, undefined), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_NONE, + false, + false, + ), + arkts.factory.createReturnStatement(undefined) + ]) + } + if (stableThis) { + return arkts.factory.createBlockStatement([ + arkts.factory.createMemberExpression( + arkts.factory.createIdentifier(RuntimeNames.SCOPE, undefined), + arkts.factory.createIdentifier(RuntimeNames.INTERNAL_VALUE, undefined), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_NONE, + false, + false, + ), + arkts.factory.createReturnStatement( + arkts.factory.createThisExpression() + ) + ]) + } + return arkts.factory.createReturnStatement( + arkts.factory.createMemberExpression( + arkts.factory.createIdentifier(RuntimeNames.SCOPE, undefined), + arkts.factory.createIdentifier(RuntimeNames.INTERNAL_VALUE, undefined), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_NONE, + false, + false, + ), + ) + } + static createIfStatementWithSyntheticReturnStatement(syntheticReturnStatement: arkts.ReturnStatement | arkts.BlockStatement): arkts.IfStatement { + return arkts.factory.createIfStatement( + arkts.factory.createMemberExpression( + arkts.factory.createIdentifier(RuntimeNames.SCOPE, undefined), + arkts.factory.createIdentifier(RuntimeNames.INTERNAL_VALUE_OK, undefined), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_GETTER, + false, + false, + ), + syntheticReturnStatement, + undefined, + ) + } + static createUnchangedLogging() { + return arkts.factory.createCallExpression( + arkts.factory.createMemberExpression( + arkts.factory.createIdentifier(DebugNames.CONSOLE, undefined), + arkts.factory.createIdentifier(DebugNames.LOG, undefined), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_NONE, + false, + false, + ), + [ + arkts.factory.createStringLiteral(DebugNames.BANNER_UNCHANGED), + arkts.factory.createMemberExpression( + arkts.factory.createIdentifier(RuntimeNames.SCOPE, undefined), + arkts.factory.createIdentifier(RuntimeNames.INTERNAL_VALUE_OK, undefined), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_GETTER, + false, + false + ) + ], + undefined, + ) + } + + // Compute + static createLambdaWrapper(node: arkts.Expression): arkts.ArrowFunctionExpression { + return arkts.factory.createArrowFunctionExpression( + arkts.factory.createScriptFunction( + arkts.factory.createBlockStatement([ + arkts.factory.createReturnStatement(node) + ]), + undefined, + [], + undefined, + false, + arkts.Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_ARROW, + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_NONE, + undefined, + undefined, + ) + ) + } + static createComputeExpression(hash: arkts.NumberLiteral | arkts.StringLiteral, node: arkts.Expression): arkts.CallExpression { + return arkts.factory.createCallExpression( + arkts.factory.createMemberExpression( + arkts.factory.createIdentifier(RuntimeNames.CONTEXT, undefined), + arkts.factory.createIdentifier(RuntimeNames.COMPUTE, undefined), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + false, + false + ), + [factory.createIdArgument(hash), factory.createLambdaWrapper(node)], + undefined, + ) + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/src/MemoTransformer.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/src/MemoTransformer.ts new file mode 100644 index 0000000000000000000000000000000000000000..7e6321a8a2829844a7ae0acab99733c3d91efd75 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/src/MemoTransformer.ts @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as arkts from "@koalaui/libarkts" +import { factory } from "./MemoFactory" +import { AnalysisVisitor } from "./AnalysisVisitor" +import { FunctionTransformer } from "./FunctionTransformer" +import { dumpAstToFile, MemoFunctionKind, PositionalIdTracker } from "./utils" +import { InternalsTransformer } from "./InternalsTransformer" +import { ParameterTransformer } from "./ParameterTransformer" +import { ReturnTransformer } from "./ReturnTranformer" +import { SignatureTransformer } from "./SignatureTransformer" +import { DiagnosticVisitor } from "./DiagnosticVisitor" + +export interface TransformerOptions { + trace?: boolean, + contextImport?: string, + stableForTests?: boolean, + keepTransformed?: string, + manuallyDisableInsertingImport?: boolean, + addLogging?: boolean, +} + +export default function memoTransformer( + userPluginOptions?: TransformerOptions +) { + return (node: arkts.AstNode) => { + if (!arkts.isETSModule(node)) { + throw new Error(`expected ETSModule got ${node.constructor.name}`) + } + const scriptFunctions = new Map() + const ETSFunctionTypes = new Map() + const analysisVisitor = new AnalysisVisitor(scriptFunctions, ETSFunctionTypes) + const diagnosticVisitor = new DiagnosticVisitor(scriptFunctions) + const positionalIdTracker = new PositionalIdTracker(`${arkts.getPackageName()}.${arkts.getFilePathFromPackageRoot()}`, userPluginOptions?.stableForTests) + const signatureTransformer = new SignatureTransformer(scriptFunctions, ETSFunctionTypes) + const internalsTransformer = new InternalsTransformer() + const parameterTransformer = new ParameterTransformer(positionalIdTracker) + const returnTransformer = new ReturnTransformer() + + analysisVisitor.visitor(node) + diagnosticVisitor.visitor(node) + + const functionTransformer = new FunctionTransformer( + scriptFunctions, + ETSFunctionTypes, + positionalIdTracker, + signatureTransformer, + internalsTransformer, + parameterTransformer, + returnTransformer, + userPluginOptions?.addLogging ?? false + ) + let result = functionTransformer.visitor(node) + if (userPluginOptions?.manuallyDisableInsertingImport != true) { + if ((functionTransformer.modified || signatureTransformer.modified)) { + result = arkts.updateETSModuleByStatements( + node, + [ + ...node.getChildren().filter(it => arkts.isETSImportDeclaration(it)), + factory.createContextTypesImportDeclaration(userPluginOptions?.contextImport), + ...node.getChildren().filter(it => !arkts.isETSImportDeclaration(it)), + ] + ) + } + } + if (userPluginOptions?.keepTransformed) { + dumpAstToFile(result, userPluginOptions.keepTransformed) + } + return result + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/src/ParameterTransformer.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/src/ParameterTransformer.ts new file mode 100644 index 0000000000000000000000000000000000000000..2ba0c7b83d43b3740801ef7075d277dad65945a2 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/src/ParameterTransformer.ts @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as arkts from "@koalaui/libarkts" +import { factory } from "./MemoFactory" +import { KPointer } from "@koalaui/interop" +import { isMemoParametersDeclaration, PositionalIdTracker, RuntimeNames } from "./utils" + +export type ParamInfo = { + ident: arkts.Identifier, + param: arkts.ETSParameterExpression +} + +export class ParameterTransformer extends arkts.AbstractVisitor { + private rewriteIdentifiers?: Map arkts.MemberExpression | arkts.Identifier> + private rewriteCalls?: Map arkts.CallExpression> + private rewriteThis?: boolean + private skipNode?: arkts.VariableDeclaration + + constructor(private positionalIdTracker: PositionalIdTracker) { + super() + } + + withThis(flag: boolean): ParameterTransformer { + this.rewriteThis = flag + return this + } + + withParameters(parameters: ParamInfo[]): ParameterTransformer { + this.rewriteCalls = new Map(parameters.filter(it => + it.param.typeAnnotation && (arkts.isETSFunctionType(it.param.typeAnnotation) || arkts.isETSUnionType(it.param.typeAnnotation))).map(it => { + return [it.param.ident!.name.startsWith(RuntimeNames.GENSYM) ? it.ident.originalPeer : it.param.originalPeer, (passArgs: arkts.Expression[]) => { + return factory.createMemoParameterAccessCall(it.ident.name, passArgs) + }] + }) + ) + this.rewriteIdentifiers = new Map(parameters.map(it => { + return [it.param.ident!.name.startsWith(RuntimeNames.GENSYM) ? it.ident.originalPeer : it.param.originalPeer, () => { + return factory.createMemoParameterAccess(it.ident.name) + }] + }) + ) + return this + } + + skip(memoParametersDeclaration?: arkts.VariableDeclaration): ParameterTransformer { + this.skipNode = memoParametersDeclaration + return this + } + + visitor(beforeChildren: arkts.AstNode): arkts.AstNode { + // TODO: temporary checking skip nodes by comparison with expected skip nodes + // Should be fixed when update procedure implemented properly + if (/* beforeChildren === this.skipNode */ isMemoParametersDeclaration(beforeChildren)) { + return beforeChildren + } + if (arkts.isVariableDeclaration(beforeChildren) && this.rewriteIdentifiers?.has(beforeChildren.declarators[0].id!.originalPeer)) { + return beforeChildren + } + if (arkts.isCallExpression(beforeChildren)) { + if (arkts.isIdentifier(beforeChildren.callee)) { + const decl = arkts.getPeerDecl(beforeChildren.callee.originalPeer) // TODO: here should be getDeclResolveGensym, but it would result in code not passing filterSource + if (decl && this.rewriteCalls?.has(decl.originalPeer)) { + return this.rewriteCalls.get(decl.originalPeer)!( + beforeChildren.arguments.map((it) => this.visitor(it) as arkts.Expression) // TODO: remove as + ) + } + } + } + const node = this.visitEachChild(beforeChildren) + if (arkts.isIdentifier(node)) { + const decl = arkts.getPeerDecl(node.originalPeer) // TODO: here should be getDeclResolveGensym, but it would result in code not passing filterSource + if (decl && this.rewriteIdentifiers?.has(decl.originalPeer)) { + return this.rewriteIdentifiers.get(decl.originalPeer)!() + } + } + if (arkts.isThisExpression(node) && this.rewriteThis) { + return factory.createMemoParameterAccess(RuntimeNames.THIS) + } + return node + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/src/ReturnTranformer.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/src/ReturnTranformer.ts new file mode 100644 index 0000000000000000000000000000000000000000..1c0aa7f34101165fec960dff5ad773f13136f508 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/src/ReturnTranformer.ts @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as arkts from "@koalaui/libarkts" +import { factory } from "./MemoFactory" +import { isSyntheticReturnStatement } from "./utils" + +export class ReturnTransformer extends arkts.AbstractVisitor { + private skipNode?: arkts.ReturnStatement | arkts.BlockStatement + private stableThis: boolean = false + + skip(syntheticReturnStatement?: arkts.ReturnStatement | arkts.BlockStatement): ReturnTransformer { + this.skipNode = syntheticReturnStatement + return this + } + + rewriteThis(stableThis: boolean): ReturnTransformer { + this.stableThis = stableThis + return this + } + + visitor(beforeChildren: arkts.AstNode): arkts.AstNode { + // TODO: temporary checking skip nodes by comparison with expected skip nodes + // Should be fixed when update procedure implemented properly + if (/* beforeChildren === this.skipNode */ isSyntheticReturnStatement(beforeChildren)) { + return beforeChildren + } + if (arkts.isScriptFunction(beforeChildren)) { + return beforeChildren + } + const node = this.visitEachChild(beforeChildren) + if (arkts.isReturnStatement(node)) { + if (this.stableThis && node.argument && arkts.isThisExpression(node.argument)) { + return factory.createReturnThis() + } + if (node.argument == undefined) { + return arkts.factory.createBlockStatement([ + factory.createRecacheCall(), + node + ]) + } + return arkts.factory.updateReturnStatement(node, factory.createRecacheCall(node.argument)) + } + return node + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/src/SignatureTransformer.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/src/SignatureTransformer.ts new file mode 100644 index 0000000000000000000000000000000000000000..e55f091f0fa5eb989893e9b1e6a64c30e52c4a4b --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/src/SignatureTransformer.ts @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as arkts from "@koalaui/libarkts" +import { factory } from "./MemoFactory" +import { MemoFunctionKind } from "./utils" + +export class SignatureTransformer extends arkts.AbstractVisitor { + public modified = false + + constructor( + public scriptFunctions: Map, + public ETSFunctionTypes: Map, + ) { + super() + } + + visitor(node: arkts.ScriptFunction): arkts.ScriptFunction + visitor(node: arkts.ETSFunctionType): arkts.ETSFunctionType + visitor(node: arkts.AstNode): arkts.AstNode { + if (arkts.isScriptFunction(node)) { + const memo = this.scriptFunctions.get(node.originalPeer) + const shouldTransform = memo == MemoFunctionKind.MEMO || memo == MemoFunctionKind.INTRINSIC + if (shouldTransform) { + this.modified = true + } + return arkts.factory.updateScriptFunction( + node, + node.body, + node.typeParams, + [...(shouldTransform ? factory.createHiddenParameters() : []), ...node.params], + node.returnTypeAnnotation + ? node.returnTypeAnnotation + : shouldTransform + ? arkts.factory.createETSPrimitiveType(arkts.Es2pandaPrimitiveType.PRIMITIVE_TYPE_VOID) + : undefined, + node.hasReceiver, + node.flags, + node.modifierFlags, + node.id, + node.annotations + ) + } + if (arkts.isETSFunctionType(node)) { + const memo = this.ETSFunctionTypes.get(node.originalPeer) + if (memo) { + this.modified = true + } + return arkts.factory.updateETSFunctionType( + node, + undefined, + [...(memo ? factory.createHiddenParameters() : []), ...node.params], + node.returnType, + false, + arkts.Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_ARROW, + node.annotations, + ) + } + + return this.visitEachChild(node) + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/src/api-utils.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/src/api-utils.ts new file mode 100644 index 0000000000000000000000000000000000000000..3a3558998e734b452e19004e3d6deec5bf8253d1 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/src/api-utils.ts @@ -0,0 +1,234 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as arkts from "@koalaui/libarkts" +import { getDeclResolveGensym, getMemoFunctionKind, MemoFunctionKind } from "./utils" + +/** + * Type of node which can be returned by getDecl and correspond to node which can have memo annotation + * + * @see getDecl + * @see getDeclResolveGensym + * @see MemoAnnotatable + */ +export type Memoizable = + arkts.MethodDefinition + | arkts.ETSParameterExpression + | arkts.Identifier + | arkts.ClassProperty + +/** + * Type of expression node which can have functional memo annotation + */ +export type MemoAnnotatableExpression = + arkts.ScriptFunction + | arkts.ArrowFunctionExpression + | arkts.ETSParameterExpression + | arkts.VariableDeclaration + | arkts.ClassProperty + | arkts.TSTypeAliasDeclaration + +/** + * Type of type node which can have functonal memo annotation + */ +export type MemoAnnotatableType = + arkts.ETSFunctionType + | arkts.ETSUnionType + +/** + * Type of node which can have functional memo annotation + */ +export type MemoAnnotatable = MemoAnnotatableExpression | MemoAnnotatableType + +/** + * Type of node which can have @memo_stable annotation + */ +export type MemoStableAnnotatable = arkts.ClassDefinition + +/** + * Type of node which can have @memo_skip annotation + */ +export type MemoSkipAnnotatable = arkts.ETSParameterExpression + +export function isMemoizable(node: arkts.AstNode | undefined): node is Memoizable { + return arkts.isMethodDefinition(node) + || arkts.isETSParameterExpression(node) + || arkts.isIdentifier(node) + || arkts.isClassProperty(node) +} + +export function isMemoAnnotatableExpression(node: arkts.AstNode | undefined): node is MemoAnnotatableExpression { + return arkts.isScriptFunction(node) + || arkts.isETSParameterExpression(node) + || arkts.isArrowFunctionExpression(node) + || arkts.isVariableDeclaration(node) + || arkts.isClassProperty(node) + || arkts.isTSTypeAliasDeclaration(node) +} + +export function isMemoAnnotatableType(node: arkts.AstNode | undefined): node is MemoAnnotatableType { + return arkts.isETSFunctionType(node) || arkts.isETSUnionType(node) +} + +export function isMemoAnnotatable(node: arkts.AstNode | undefined): node is MemoAnnotatable { + return isMemoAnnotatableExpression(node) || isMemoAnnotatableType(node) +} + +export function getName(node: Memoizable): string { + if (arkts.isMethodDefinition(node)) { + return node.id!.name + } + if (arkts.isETSParameterExpression(node)) { + return node.ident!.name + } + if (arkts.isIdentifier(node)) { + return node.name + } + if (arkts.isClassProperty(node)) { + return node.id!.name + } + assertIsNever(node) +} + +// TODO: this should use info from AnalysisVisitor, not obtain it from the node +// but this require AnalysisVisitor to be run on all sources +export function isMemo(node: Memoizable) { + if (arkts.isMethodDefinition(node)) { + const kind = getMemoFunctionKind(node.function!) + if (kind == MemoFunctionKind.MEMO || kind == MemoFunctionKind.INTRINSIC) { + return true + } + } + if (arkts.isETSParameterExpression(node)) { + const kind = getMemoFunctionKind(node) + if (kind == MemoFunctionKind.MEMO || kind == MemoFunctionKind.INTRINSIC) { + return true + } + if (arkts.isETSTypeReference(node.typeAnnotation)) { + const name = node.typeAnnotation.part?.name + if (name) { + const decl = getDeclResolveGensym(name) + if (arkts.isTSTypeAliasDeclaration(decl)) { + const kind = isMemoAnnotatableType(decl.typeAnnotation) && getMemoFunctionKind(decl.typeAnnotation) + if (kind == MemoFunctionKind.MEMO || kind == MemoFunctionKind.INTRINSIC) { + return true + } + const kind2 = getMemoFunctionKind(decl) + if (kind2 == MemoFunctionKind.MEMO || kind2 == MemoFunctionKind.INTRINSIC) { + return true + } + } + } + } + } + if (arkts.isIdentifier(node)) { + if (arkts.isVariableDeclarator(node.parent) && arkts.isArrowFunctionExpression(node.parent.init)) { + const kind = getMemoFunctionKind(node.parent.init) + if (kind == MemoFunctionKind.MEMO || kind == MemoFunctionKind.INTRINSIC) { + return true + } + } + if (arkts.isVariableDeclarator(node.parent) && arkts.isVariableDeclaration(node.parent.parent)) { + const kind = getMemoFunctionKind(node.parent.parent) + if (kind == MemoFunctionKind.MEMO || kind == MemoFunctionKind.INTRINSIC) { + return true + } + } + } + if (arkts.isClassProperty(node)) { + const kind = getMemoFunctionKind(node) + if (kind == MemoFunctionKind.MEMO || kind == MemoFunctionKind.INTRINSIC) { + return true + } + } + return false +} + +/** + * es2panda API is weird here + * + * @deprecated + */ +export function castParameters(params: readonly arkts.Expression[]): readonly arkts.ETSParameterExpression[] { + return params as readonly arkts.ETSParameterExpression[] +} + +export function correctObjectExpression(node: arkts.AstNode | undefined): boolean { + return arkts.isObjectExpression(node) || (arkts.isTSAsExpression(node) && correctObjectExpression(node.expr)) +} + +export function correctFunctionParamType(type: arkts.TypeNode): boolean { + if (arkts.isETSFunctionType(type)) { + return true + } + if (arkts.isETSUnionType(type)) { + const nonUndefined: arkts.TypeNode[] = type.types.filter((it) => { + return !arkts.isETSUndefinedType(it) + }) + if (nonUndefined.length != 1) { + return false + } + if (arkts.isETSFunctionType(nonUndefined[0])) { + return true + } + } + return false +} + +function assertIsNever(isNever: never): never { + throw new Error("Unreachable") +} + +/** + * This function is used to check whether some parameters of decl call should be rewritten + * + * For expressions that cannot accept @memo parameters it returns [] + */ +export function getParams(decl: Memoizable) { + if (arkts.isMethodDefinition(decl)) { + return castParameters(decl.function!.params) + } + if (arkts.isETSParameterExpression(decl)) { + if (arkts.isETSFunctionType(decl.typeAnnotation)) { + return castParameters(decl.typeAnnotation.params) + } + if (arkts.isETSUnionType(decl.typeAnnotation)) { + const nonUndefined: arkts.TypeNode[] = decl.typeAnnotation.types.filter((it) => { + return !arkts.isETSUndefinedType(it) + }) + if (nonUndefined.length != 1) { + return [] + } + if (arkts.isETSFunctionType(nonUndefined[0])) { + return castParameters(nonUndefined[0].params) + } + return [] + } + return [] + } + if (arkts.isIdentifier(decl)) { + if (arkts.isVariableDeclarator(decl.parent) && arkts.isArrowFunctionExpression(decl.parent.init)) { + return castParameters(decl.parent.init.function!.params) + } + return [] + } + if (arkts.isClassProperty(decl)) { + if (arkts.isArrowFunctionExpression(decl.value)) { + return castParameters(decl.value.function!.params) + } + return [] + } + assertIsNever(decl) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/src/utils.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/src/utils.ts new file mode 100644 index 0000000000000000000000000000000000000000..dd3abd50a4a8e65159a78913e2d62ac95d162085 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/src/utils.ts @@ -0,0 +1,257 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { UniqueId } from "@koalaui/common" +import * as arkts from "@koalaui/libarkts" +import * as fs from "node:fs" +import * as path from "node:path" +import { correctFunctionParamType, correctObjectExpression, MemoAnnotatable, MemoSkipAnnotatable, MemoStableAnnotatable } from "./api-utils" + +export enum RuntimeNames { + __CONTEXT = "__context", + __ID = "__id", + ANNOTATION = "memo", + ANNOTATION_ENTRY = "memo_entry", + ANNOTATION_INTRINSIC = "memo_intrinsic", + ANNOTATION_SKIP = "memo_skip", + ANNOTATION_STABLE = "memo_stable", + COMPUTE = "compute", + CONTENT = "content", + CONTEXT = "__memo_context", + CONTEXT_TYPE = "__memo_context_type", + CONTEXT_TYPE_DEFAULT_IMPORT = "@koalaui/runtime", + GENSYM = "gensym%%_", + ID = "__memo_id", + ID_TYPE = "__memo_id_type", + INTERNAL_PARAMETER_STATE = "param", + INTERNAL_SCOPE = "scope", + INTERNAL_VALUE = "cached", + INTERNAL_VALUE_NEW = "recache", + INTERNAL_VALUE_OK = "unchanged", + PARAMETER = "__memo_parameter", + SCOPE = "__memo_scope", + THIS = "this", + VALUE = "value", +} + +export enum DebugNames { + BANNER_PARAMETER = "[MEMO PARAMETER DEBUG]", + BANNER_UNCHANGED = "[MEMO UNCHANGED DEBUG]", + CONSOLE = "console", + LOG = "log", +} + +function baseName(path: string): string { + return path.replace(/^.*\/(.*)$/, "$1") +} + +export class PositionalIdTracker { + // Global for the whole program. + static callCount: number = 0 + + // Set `stable` to true if you want to have more predictable values. + // For example for tests. + // Don't use it in production! + constructor(public filename: string, public stableForTests: boolean = false) { + if (stableForTests) PositionalIdTracker.callCount = 0 + } + + sha1Id(callName: string, fileName: string): string { + const uniqId = new UniqueId() + uniqId.addString("memo call uniqid") + uniqId.addString(fileName) + uniqId.addString(callName) + uniqId.addI32(PositionalIdTracker.callCount++) + return uniqId.compute().substring(0, 7) + } + + stringId(callName: string, fileName: string): string { + if (this.stableForTests) { + return `id_${callName}_${fileName}` + } + return `${PositionalIdTracker.callCount++}_${callName}_${fileName}` + } + + id(callName: string = ""): arkts.NumberLiteral | arkts.StringLiteral { + + const fileName = this.stableForTests ? + baseName(this.filename) : + this.filename + + const positionId = (this.stableForTests) ? + this.stringId(callName, fileName) : + this.sha1Id(callName, fileName) + + + return this.stableForTests + ? arkts.factory.createStringLiteral(positionId) + : arkts.factory.createNumberLiteral(parseInt(positionId, 16)) + } +} + +export enum MemoFunctionKind { + NONE = 0, + MEMO = 1, + INTRINSIC = 2, + ENTRY = 4, +} + +function hasMemoAnnotation(node: MemoAnnotatable) { + return node.annotations.some((it) => + it.expr !== undefined && arkts.isIdentifier(it.expr) && it.expr.name === RuntimeNames.ANNOTATION + ) +} + +function hasMemoEntryAnnotation(node: MemoAnnotatable) { + return node.annotations.some((it) => + it.expr !== undefined && arkts.isIdentifier(it.expr) && it.expr.name === RuntimeNames.ANNOTATION_ENTRY + ) +} + +function hasMemoIntrinsicAnnotation(node: MemoAnnotatable) { + return node.annotations.some((it) => + it.expr !== undefined && arkts.isIdentifier(it.expr) && it.expr.name === RuntimeNames.ANNOTATION_INTRINSIC + ) +} + +function hasMemoSkipAnnotation(node: MemoSkipAnnotatable) { + return node.annotations.some((it) => + it.expr !== undefined && arkts.isIdentifier(it.expr) && it.expr.name === RuntimeNames.ANNOTATION_SKIP + ) +} + +export function hasMemoStableAnnotation(node: MemoStableAnnotatable) { + return node.annotations.some((it) => + it.expr !== undefined && arkts.isIdentifier(it.expr) && it.expr.name === RuntimeNames.ANNOTATION_STABLE + ) +} + +export function getMemoFunctionKind(node: MemoAnnotatable): MemoFunctionKind { + const mask = (+hasMemoEntryAnnotation(node) << 2) + (+hasMemoIntrinsicAnnotation(node) << 1) + (+hasMemoAnnotation(node)) + switch (mask) { + case 0: + return MemoFunctionKind.NONE + case 1: + return MemoFunctionKind.MEMO + case 2: + return MemoFunctionKind.INTRINSIC + case 4: + return MemoFunctionKind.ENTRY + default: + console.error(`Conflicting @memo annotations are not allowed`) + throw new Error(`Invalid @memo usage`) + } +} + +export function isWrappable(type: arkts.TypeNode | undefined, arg: arkts.Expression) { + return (type && correctFunctionParamType(type)) || correctObjectExpression(arg) +} + +export function isTrackableParam(node: arkts.ETSParameterExpression, isLast: boolean) { + return !hasMemoSkipAnnotation(node) && !(isLast && node.ident?.name == RuntimeNames.CONTENT) +} + +export function shouldWrap(param: arkts.ETSParameterExpression, isLastParam: boolean, arg: arkts.Expression) { + return isWrappable(param.typeAnnotation, arg) && isTrackableParam(param, isLastParam) +} + +export function dumpAstToFile(node: arkts.AstNode, keepTransformed: string) { + const fileName = path.isAbsolute(keepTransformed) ? + path.join(keepTransformed, arkts.getFilePathFromPackageRoot()) : path.join(__dirname, keepTransformed, arkts.getFilePathFromPackageRoot()) + fs.mkdirSync(path.dirname(fileName), { recursive: true }) + fs.writeFileSync(fileName, node.dumpSrc()) +} + +/** + * Checks that node was obtained from MemoFactory.createSyntheticReturnStatement + * + * TODO: remove when node updates are done in place + * @deprecated + */ +export function isSyntheticReturnStatement(node: arkts.AstNode) { + return ( + arkts.isReturnStatement(node) && + node.argument && arkts.isMemberExpression(node.argument) && + arkts.isIdentifier(node.argument.object) && + node.argument.object.name === RuntimeNames.SCOPE && + arkts.isIdentifier(node.argument.property) && + node.argument.property.name === RuntimeNames.INTERNAL_VALUE + ) || ( + arkts.isBlockStatement(node) && + node.statements.length === 2 && + arkts.isMemberExpression(node.statements[0]) && + arkts.isIdentifier(node.statements[0].object) && + node.statements[0].object.name === RuntimeNames.SCOPE && + arkts.isIdentifier(node.statements[0].property) && + node.statements[0].property.name === RuntimeNames.INTERNAL_VALUE && + arkts.isReturnStatement(node.statements[1]) && + node.statements[1].argument && + arkts.isThisExpression(node.statements[1].argument) + ) || ( + arkts.isBlockStatement(node) && + node.statements.length === 2 && + arkts.isMemberExpression(node.statements[0]) && + arkts.isIdentifier(node.statements[0].object) && + node.statements[0].object.name === RuntimeNames.SCOPE && + arkts.isIdentifier(node.statements[0].property) && + node.statements[0].property.name === RuntimeNames.INTERNAL_VALUE && + arkts.isReturnStatement(node.statements[1]) && + node.statements[1].argument == undefined + ) +} + +/** + * Checks that node was obtained from MemoFactory.createMemoParameterDeclaration + * + * TODO: remove when node updates are done in place + * @deprecated + */ +export function isMemoParametersDeclaration(node: arkts.AstNode) { + return arkts.isVariableDeclaration(node) && + node.declarators.every( + (it) => { + if (!arkts.isIdentifier(it.id)) { + return false + } + return it.id.name.startsWith(RuntimeNames.PARAMETER) + } + ) +} + + +/** + * Checks type node refers to void type + * + * TODO: remove when es2panda API allows to read return type + * @deprecated + */ +export function isVoidType(node: arkts.TypeNode) { + return node.dumpSrc() == "void" +} + +export function getDeclResolveGensym(node: arkts.AstNode): arkts.AstNode | undefined { + const decl = arkts.getDecl(node) + if (arkts.isIdentifier(decl) && decl.name.startsWith(RuntimeNames.GENSYM)) { + if (arkts.isVariableDeclarator(decl.parent)) { + if (arkts.isIdentifier(decl.parent.init)) { + return getDeclResolveGensym(decl.parent.init) + } + if (arkts.isMemberExpression(decl.parent.init)) { + return getDeclResolveGensym(decl.parent.init.property!) + } + } + } + return decl +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/tsconfig.json b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/tsconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..17834578ac916026996c6eb2bd37e96bcce032f3 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/memo-plugin/tsconfig.json @@ -0,0 +1,16 @@ +{ + "extends": "@koalaui/build-common/tsconfig.json", + "compilerOptions": { + "rootDir": ".", + "baseUrl": ".", + "outDir": "./lib", + "module": "ESNext", + }, + "include": [ + "./src/**/*.ts", + ], + "references": [ + { "path": "../../incremental/compat" }, + { "path": "../../incremental/common" } + ] +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/package.json b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/package.json new file mode 100644 index 0000000000000000000000000000000000000000..2731c1bb2bd19a0a54da657edf439a014826848e --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/package.json @@ -0,0 +1,44 @@ +{ + "name": "ui2abc", + "private": true, + "workspaces": [ + "./annotate", + "./libarkts", + "./memo-plugin", + "./ui-plugins", + "../incremental/build-common", + "../interop", + "../incremental/harness" + ], + "devDependencies": { + "@koalaui/ets-tsc": "4.9.5-r5", + "@koalaui/fast-arktsc": "1.5.15", + "@types/chai": "^4.3.1", + "@types/mocha": "^9.1.0", + "bin-links": "^4.0.4", + "chai": "^4.3.6", + "chalk": "^4.1.2", + "copy-webpack-plugin": "^10.2.4", + "minimist": "1.2.8", + "mocha": "^9.2.2", + "node-addon-api": "8.0.0", + "node-api-headers": "0.0.5", + "read-package-json-fast": "^3.0.2", + "rimraf": "^6.0.1", + "ts-loader": "^9.2.8", + "ts-node": "^10.7.0", + "tslib": "^2.3.1", + "typescript": "4.9.5", + "webpack": "^5.93.0", + "webpack-cli": "^5.1.4", + "tsconfig-paths": "^4.2.0", + "commander": "^13.1.0" + }, + "scripts": { + "clean:all": "npm run clean --prefix libarkts && npm run clean:plugins --prefix libarkts && npm run clean --prefix memo-plugin && npm run runtime:clean --prefix memo-plugin && npm run clean --prefix memo-plugin/demo && npm run clean --prefix ../arkoala-arkts/arkui && npm run clean --prefix ../arkoala-arkts/trivial/user", + "build:all": "npm run compile --prefix libarkts && npm run compile:plugins --prefix libarkts && npm run compile --prefix memo-plugin && npm run runtime:prepare --prefix memo-plugin && npm run compile --prefix ui-plugins", + "test:all": "npm run build:arkui:pure-ets --prefix ../arkoala-arkts/arkui && npm run run --prefix libarkts && npm run test --prefix libarkts && npm run demo:run --prefix memo-plugin && npm run test:all --prefix memo-plugin && npm run run:user:pure-ets --prefix ../arkoala-arkts/trivial/user", + "all": "npm run clean:all && npm run build:all && npm run test:all" + } +} + diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/package.json b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/package.json new file mode 100644 index 0000000000000000000000000000000000000000..e2a9f033949e7c470dce611c461c9b1c8cb14507 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/package.json @@ -0,0 +1,16 @@ +{ + "name": "@koalaui/ui-plugins", + "private": true, + "exports": { + "./*": "./lib/*.js" + }, + "files": [ + "./lib/**/*" + ], + "dependencies": {}, + "scripts": { + "clean": "rimraf build", + "compile": "rollup -c ./rollup.config.mjs", + "compile:libarkts": "npm run compile --prefix ../libarkts" + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/rollup.config.mjs b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/rollup.config.mjs new file mode 100644 index 0000000000000000000000000000000000000000..12b3121c5974fb8f2f1482bee48959d6d430bb55 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/rollup.config.mjs @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import nodeResolve from "@rollup/plugin-node-resolve"; +import typescript from "@rollup/plugin-typescript"; +import commonjs from '@rollup/plugin-commonjs' + +export default [ + buildPlugin({ + src: "./src/parsed-stage-plugin.ts", + dst: "./lib/parsed-stage-plugin.js", + }), + buildPlugin({ + src: "./src/checked-stage-plugin.ts", + dst: "./lib/checked-stage-plugin.js", + }), +] + +/** @return {import("rollup").RollupOptions} */ +function buildPlugin({ src, dst }) { + return { + input: src, + output: { + file: dst, + format: "commonjs", + plugins: [ + // terser() + ], + banner: [ + "#!/usr/bin/env node", + APACHE_LICENSE_HEADER() + ].join("\n"), + }, + external: ["@koalaui/libarkts"], + plugins: [ + commonjs(), + typescript({ + outputToFilesystem: false, + module: "esnext", + sourceMap: false, + declarationMap: false, + declaration: false, + composite: false, + }), + nodeResolve({ + extensions: [".js", ".mjs", ".cjs", ".ts", ".cts", ".mts"] + }) + ], + } +} + +function APACHE_LICENSE_HEADER() { + return ` +/** +* @license +* Copyright (c) ${new Date().getUTCFullYear()} Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +` +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/annotation-translator.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/annotation-translator.ts new file mode 100644 index 0000000000000000000000000000000000000000..471ba91b2607e4302db9658792d10e627f96dd2e --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/annotation-translator.ts @@ -0,0 +1,78 @@ + /* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as arkts from "@koalaui/libarkts" +import { DecoratorNames, hasDecorator } from "./property-translators/utils" +import { annotation } from "./common/arkts-utils" +import { CustomComponentNames, InternalAnnotations } from "./utils" + +export class AnnotationsTransformer extends arkts.AbstractVisitor { + + constructor(options?: arkts.VisitorOptions) { + super(options) + this.program = arkts.global.compilerContext.program + } + + insertImport(what: string, where: string) { + const source: arkts.StringLiteral = arkts.factory.createStringLiteral(where) + const imported: arkts.Identifier = arkts.factory.createIdentifier(what, undefined) + const importDecl: arkts.ETSImportDeclaration = arkts.factory.createETSImportDeclaration( + source, + [ + arkts.factory.createImportSpecifier( + imported, + imported + ) + ], + arkts.Es2pandaImportKinds.IMPORT_KINDS_TYPES, + arkts.global.compilerContext.program, + arkts.Es2pandaImportFlags.IMPORT_FLAGS_DEFAULT_IMPORT + ) + arkts.importDeclarationInsert(importDecl) + } + + inStruct = false + + visitor(beforeVisit: arkts.AstNode): arkts.AstNode { + if (arkts.isClassDefinition(beforeVisit) && hasDecorator(beforeVisit, DecoratorNames.COMPONENT)) { + this.inStruct = true + } + // console.log(`builder transform ${node.dumpSrc()} ${arkts.isAnnotationUsage(node)}`) + const node = this.visitEachChild(beforeVisit) + + if (arkts.isETSModule(node)) { + this.insertImport("memo", "@koalaui/runtime/annotations") + } + if (arkts.isFunctionDeclaration(node) && hasDecorator(node, DecoratorNames.BUILDER)) { + return arkts.factory.updateFunctionDeclaration(node, node.function, [ + annotation(InternalAnnotations.MEMO)], node.isAnonymous) + } + if (this.inStruct && arkts.isMethodDefinition(node) && ( + hasDecorator(node, DecoratorNames.BUILDER) || + node.function?.id?.name == CustomComponentNames.COMPONENT_BUILD_ORI) + ) { + node.function!.setAnnotations([annotation(InternalAnnotations.MEMO)]) + return node + } + if (this.inStruct && arkts.isClassProperty(node) && hasDecorator(node, DecoratorNames.BUILDER_PARAM)) { + return node + } + if (arkts.isClassDefinition(node) && hasDecorator(node, DecoratorNames.COMPONENT)) { + this.inStruct = false + return node + } + return node + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/builder-lambda-transformer.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/builder-lambda-transformer.ts new file mode 100644 index 0000000000000000000000000000000000000000..9754d92cec9a94371bce9d82046ef2ff9fd0cf1b --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/builder-lambda-transformer.ts @@ -0,0 +1,217 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as arkts from "@koalaui/libarkts" +import { styledInstance, uiAttributeName } from "./utils" + +function isBuilderLambdaAnnotation(annotation: arkts.AnnotationUsage): boolean { + if (annotation.expr === undefined) { + return false + } + if (!arkts.isIdentifier(annotation.expr)) { + return false + } + return annotation.expr.name == "BuilderLambda" +} + +function builderLambdaArgumentName(annotation: arkts.AnnotationUsage): string | undefined { + if (!isBuilderLambdaAnnotation(annotation)) return undefined + const property = annotation.properties[0] + if (property === undefined) return undefined + if (!arkts.isClassProperty(property)) return undefined + if (property.value === undefined) return undefined + if (!arkts.isStringLiteral(property.value)) return undefined + + return property.value.str +} + +function getIdentifierScriptFunction(node: arkts.Identifier): arkts.ScriptFunction | undefined { + const decl = arkts.getDecl(node) + if (!arkts.isFunctionDeclaration(decl) && + !arkts.isMethodDefinition(decl)) return undefined + + return decl.function +} + +function getScriptFunction(node: arkts.CallExpression): arkts.ScriptFunction | undefined { + if (arkts.isIdentifier(node.callee)) { + return getIdentifierScriptFunction(node.callee) + } + if (arkts.isMemberExpression(node.callee)) { + const decl = arkts.getDecl(node.callee.property!) + if (!arkts.isMethodDefinition(decl)) return undefined + return decl.function + } + return undefined +} + +function findBuilderLambdaAnnotation(func: arkts.ScriptFunction): arkts.AnnotationUsage | undefined { + const declAnnotations = arkts.getAnnotations(func) + if (declAnnotations.length === 0) { + return undefined + } + return declAnnotations.find(it => isBuilderLambdaAnnotation(it)) +} + +function findCallBuilderLambdaAnnotation(node: arkts.CallExpression): arkts.AnnotationUsage | undefined { + const func = getScriptFunction(node) + if (func == undefined) return undefined + + return findBuilderLambdaAnnotation(func) +} + +export function builderLambdaTargetFunctionName(func: arkts.ScriptFunction): string | undefined { + const annotation = findBuilderLambdaAnnotation(func) + if (!annotation) return undefined + + return builderLambdaArgumentName(annotation) +} + +export function builderLambdaFunctionName(node: arkts.CallExpression): string | undefined { + const annotation = findCallBuilderLambdaAnnotation(node) + if (!annotation) return undefined + + return builderLambdaArgumentName(annotation) +} +/* + TODO: remove this once compiler is capable of inferring type on it's own + whole function is a couple of hacks + */ +function inferType(node: arkts.CallExpression): arkts.Identifier | undefined { + if (arkts.isIdentifier(node.callee)) { + const component = node.callee.name.replace("Impl", "") + return arkts.factory.createIdentifier(uiAttributeName(component)) + } + const decl = arkts.getDecl(node.callee!) + if (arkts.isMethodDefinition(decl)) { + if (arkts.isClassDefinition(decl.parent)) { + return decl.parent.ident + } + } + return undefined +} + +function createBuilderLambdaInstanceLambda(node: arkts.CallExpression): arkts.Expression { + return createInstanceLambda(node.arguments[0], inferType(node)) +} + +function createInstanceLambda( + instanceArgument: arkts.Expression, + parameterTypeName?: arkts.Identifier +): arkts.Expression { + if (arkts.isUndefinedLiteral(instanceArgument)) { + return instanceArgument + } + const lambdaParameter = arkts.factory.createETSParameterExpression( + arkts.factory.createIdentifier( + styledInstance, + parameterTypeName !== undefined ? + arkts.factory.createETSTypeReference( + arkts.factory.createETSTypeReferencePart( + parameterTypeName, undefined, undefined + ) + ) + : undefined + ), + false + ) + const instanceLambdaBody = arkts.factory.createBlockStatement([ + arkts.factory.createExpressionStatement(instanceArgument) + ]) + return arkts.factory.createArrowFunctionExpression( + arkts.factory.createScriptFunction( + instanceLambdaBody, + undefined, + [lambdaParameter], + undefined, + false, + arkts.Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_ARROW, + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_NONE, + undefined, + undefined + ) + ) +} + +function transformBuilderLambdaCall(node: arkts.CallExpression): arkts.CallExpression { + const implFunction = builderLambdaFunctionName(node) + if (implFunction === undefined) { + return node + } + return arkts.factory.updateCallExpression( + node, + arkts.factory.createIdentifier(implFunction, undefined), + [ + createBuilderLambdaInstanceLambda(node), + ...node.arguments.slice(1) + ], + node.typeParams, + node.isOptional, + node.hasTrailingComma, + node.trailingBlock + ) +} + +// TODO: for now it all works, but it is unclear +// if it will keep working under Rechek. +// in theory we don't add new files to import here, +// only the new names from the same file, +// to it should be okay. +function transformETSImportDeclaration(node: arkts.ETSImportDeclaration): arkts.ETSImportDeclaration { + const additionalNames: string[] = [] + node.specifiers.forEach(it => { + const name = (it as arkts.ImportSpecifier).imported + const scriptFunction = name ? getIdentifierScriptFunction(name) : undefined + if (scriptFunction) { + const target = builderLambdaTargetFunctionName(scriptFunction) + if (target) { + // TODO: The type name here should not be explicitly manipulated + // but the type checker of the compiler is still incapable + // to infer the proper lambda argument types + additionalNames.push(uiAttributeName(name?.name!)) + additionalNames.push(target) + } + } + }) + if (additionalNames.length == 0) return node + + return arkts.factory.updateETSImportDeclaration( + node, + node.source, + [ ...node.specifiers, + ...additionalNames.map(it => arkts.factory.createImportSpecifier( + arkts.factory.createIdentifier(it), + arkts.factory.createIdentifier(it) + )) + ], + node.isTypeKind ? arkts.Es2pandaImportKinds.IMPORT_KINDS_TYPES : arkts.Es2pandaImportKinds.IMPORT_KINDS_ALL + ) +} + + +export class BuilderLambdaTransformer extends arkts.AbstractVisitor { + visitor(beforeChildren: arkts.AstNode): arkts.AstNode { + const node = this.visitEachChild(beforeChildren) + + if (arkts.isCallExpression(node)) { + return transformBuilderLambdaCall(node) + } + if (arkts.isETSImportDeclaration(node)) { + return transformETSImportDeclaration(node) + } + + return node + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/checked-stage-plugin.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/checked-stage-plugin.ts new file mode 100644 index 0000000000000000000000000000000000000000..de7bbe58d73beb7b2537912e93af4ceeecf8d26c --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/checked-stage-plugin.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as arkts from "@koalaui/libarkts" +import { StructTransformer } from './struct-transformer' +import { StyleTransformer } from "./style-transformer" +import { EtsFirstArgTransformer } from "./ets-first-arg-transformer" +import { BuilderLambdaTransformer } from "./builder-lambda-transformer" + +export interface TransformerOptions { + trace?: boolean, +} + +export default function checkedTransformer( + userPluginOptions?: TransformerOptions +) { + console.log("CHECKED: ", userPluginOptions) + return (node: arkts.ETSModule) => [ + new EtsFirstArgTransformer(), + new StyleTransformer(), + new BuilderLambdaTransformer(), + new StructTransformer() + ] + .reduce((node: arkts.AstNode, transformer) => transformer.visitor(node), node) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/common/arkts-utils.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/common/arkts-utils.ts new file mode 100644 index 0000000000000000000000000000000000000000..64c2ff6f507d1c9da1525cfd323c9221f49afc8a --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/common/arkts-utils.ts @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as arkts from "@koalaui/libarkts" + +export function annotation(name: string): arkts.AnnotationUsage { + const ident: arkts.Identifier = arkts.factory.createIdentifier(name, undefined).setAnnotationUsage() + const annotation: arkts.AnnotationUsage = arkts.factory.createAnnotationUsage(ident, []) + + annotation.modifierFlags = arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_ANNOTATION_USAGE + ident.parent = annotation + + return annotation +} + +export function isAnnotation(node: arkts.AnnotationUsage, annoName: string) { + return node.expr !== undefined && arkts.isIdentifier(node.expr) && node.expr.name === annoName; +} + +export function removeAnnotationByName( + annotations: readonly arkts.AnnotationUsage[], + annoName: string +): arkts.AnnotationUsage[] { + return annotations.filter((it) => !isAnnotation(it, annoName)); +} + +export function expectName(node: arkts.AstNode | undefined): string { + if (!node) { + throw new Error("Expected an identifier, got empty node"); + } + if (!arkts.isIdentifier(node)) { + throw new Error("Expected an identifier, got: " + arkts.nodeType(node).toString()); + } + return node.name; +} + +export function mangle(value: string): string { + return `__${value}`; +} + +export function backingField(originalName: string): string { + return mangle(`backing_${originalName}`); +} + +export function filterDefined(value: (T | undefined)[]): T[] { + return value.filter((it: T | undefined): it is T => it != undefined); +} + +export function collect(...value: (ReadonlyArray | T | undefined)[]): T[] { + const empty: (T | undefined)[] = [] + return filterDefined(empty.concat(...value)) +} + +export function matchPrefix(prefixCollection: string[], name: string): boolean { + for (const prefix of prefixCollection) { + if (name.startsWith(prefix)) { + return true; + } + } + return false; +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/common/gensym-generator.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/common/gensym-generator.ts new file mode 100644 index 0000000000000000000000000000000000000000..36758a54c510b5740c7ba4c53480d2491e08813c --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/common/gensym-generator.ts @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { UniqueId } from "@koalaui/common" + +export class GenSymGenerator { + // Global for the whole program. + private static callCount: number = 0; + static instance: GenSymGenerator; + + // Set `stable` to true if you want to have more predictable values. + // For example for tests. + // Don't use it in production! + private constructor(public stableForTests: boolean = false) { + if (stableForTests) GenSymGenerator.callCount = 0; + } + + static getInstance(stableForTests: boolean = false): GenSymGenerator { + if (!this.instance) { + this.instance = new GenSymGenerator(stableForTests); + } + + return this.instance; + } + + sha1Id(callName: string): string { + const uniqId = new UniqueId(); + uniqId.addString("gensym uniqid"); + uniqId.addString(callName); + uniqId.addI32(GenSymGenerator.callCount++); + return uniqId.compute().substring(0, 7); + } + + stringId(callName: string): string { + return `${GenSymGenerator.callCount++}_${callName}_id`; + } + + id(callName: string = ""): string { + const positionId = (this.stableForTests) ? + this.stringId(callName) : + this.sha1Id(callName); + + const coreceToStr = parseInt(positionId, 16).toString(); + + // compiler use gensym%%_ but % is illegal before after-check phase + return `gensym___${coreceToStr}`; + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/component-transformer.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/component-transformer.ts new file mode 100644 index 0000000000000000000000000000000000000000..19bb69596c731df2456cf0f0632030fcdc940e30 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/component-transformer.ts @@ -0,0 +1,241 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as arkts from "@koalaui/libarkts" +import { nullptr } from "@koalaui/interop" +import { + CustomComponentNames, + getCustomComponentOptionsName, + createOptionalClassProperty +} from "./utils"; +import { + isAnnotation +} from "./common/arkts-utils"; +import { hasDecorator, DecoratorNames } from "./property-translators/utils" +import { annotation } from "./common/arkts-utils"; +import { backingField, expectName } from "./common/arkts-utils"; +import { getStageManagmentType } from "./property-translators/utils"; + +export interface ComponentTransformerOptions { + arkui?: string +} + +type ScopeInfo = { + name: string, + isComponent?: boolean, +} + +interface ComponentContext { + componentNames: string[], + structMembers: Map, +} + +export class ComponentTransformer extends arkts.AbstractVisitor { + private scopeInfos: ScopeInfo[] = []; + private componentNames: string[] = []; + private arkui?: string; + private context: ComponentContext = { componentNames: [], structMembers: new Map() }; + + constructor(options?: ComponentTransformerOptions) { + const _options: ComponentTransformerOptions = options ?? {}; + super(); + this.arkui = _options.arkui; + } + + enter(node: arkts.AstNode) { + if (arkts.isETSStructDeclaration(node) && !!node.definition?.ident) { + const scopeInfo: ScopeInfo = { name: node.definition.ident.name }; + node.definition.annotations.forEach((anno) => { + scopeInfo.isComponent ||= isAnnotation(anno, DecoratorNames.COMPONENT) + }); + this.scopeInfos.push(scopeInfo) + } + } + + exit(node: arkts.AstNode) { + if (arkts.isETSStructDeclaration(node) || arkts.isClassDeclaration(node)) { + if (!node.definition || !node.definition.ident || this.scopeInfos.length === 0) return; + if (this.scopeInfos[this.scopeInfos.length - 1]?.name === node.definition.ident.name) { + this.scopeInfos.pop(); + } + } + } + + isComponentStruct(): boolean { + if (this.scopeInfos.length === 0) return false; + const scopeInfo: ScopeInfo = this.scopeInfos[this.scopeInfos.length - 1]; + return !!scopeInfo.isComponent; + } + + createImportDeclaration(): void { + const source: arkts.StringLiteral = arkts.factory.createStringLiteral( + this.arkui ?? CustomComponentNames.COMPONENT_DEFAULT_IMPORT + ); + const imported: arkts.Identifier = arkts.factory.createIdentifier( + CustomComponentNames.COMPONENT_CLASS_NAME, undefined + ); + const importDecl: arkts.ETSImportDeclaration = arkts.factory.createETSImportDeclaration( + source, + [ + arkts.factory.createImportSpecifier( + imported, + imported + ) + ], + arkts.Es2pandaImportKinds.IMPORT_KINDS_TYPES, + arkts.global.compilerContext.program, + arkts.Es2pandaImportFlags.IMPORT_FLAGS_DEFAULT_IMPORT + ) + // Insert this import at the top of the script's statements. + arkts.importDeclarationInsert(importDecl) + return + } + + processEtsScript(node: arkts.ETSModule): arkts.ETSModule { + if (this.componentNames.length === 0) { + return node + } + + this.createImportDeclaration() + let updateStatements: arkts.AstNode[] = []; + updateStatements.push( + ...this.componentNames.map( + name => arkts.factory.createInterfaceDeclaration( + [], + arkts.factory.createIdentifier( + getCustomComponentOptionsName(name), undefined + ), + undefined, + arkts.factory.createTSInterfaceBody( + this.context.structMembers.has(name) + ? this.context.structMembers.get(name)! + : [] + ), + false, + false + ) + ) + ); + if (updateStatements.length > 0) { + return arkts.updateETSModuleByStatements( + node, + [ + ...node.statements, + ...updateStatements, + ] + ) + } + return node; + } + + processComponent(node: arkts.ClassDeclaration | arkts.ETSStructDeclaration): arkts.ClassDeclaration | arkts.ETSStructDeclaration { + const scopeInfo = this.scopeInfos[this.scopeInfos.length - 1]; + const className = node.definition?.ident?.name; + if (!className || scopeInfo?.name !== className) { + return node; + } + + arkts.GlobalInfo.getInfoInstance().add(className); + this.componentNames.push(className); + + const definition: arkts.ClassDefinition = node.definition + const newDefinition = arkts.factory.updateClassDefinition( + definition, + definition.ident, + undefined, + undefined, // superTypeParams doen't work + definition.implements, + undefined, + arkts.factory.createETSTypeReference( + arkts.factory.createETSTypeReferencePart( + arkts.factory.createIdentifier(CustomComponentNames.COMPONENT_CLASS_NAME, undefined), + arkts.factory.createTSTypeParameterInstantiation( + [ + arkts.factory.createETSTypeReference( + arkts.factory.createETSTypeReferencePart( + arkts.factory.createIdentifier(className, undefined), + undefined, undefined + ) + ), + arkts.factory.createETSTypeReference( + arkts.factory.createETSTypeReferencePart( + arkts.factory.createIdentifier( + `${CustomComponentNames.COMPONENT_INTERFACE_PREFIX}${className}`, undefined + ), undefined, undefined + ) + ), + ] + ), undefined + ) + ), + definition.body, + definition.modifiers, + arkts.classDefinitionFlags(definition) | arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_FINAL | arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_EXPORT + ) + + if (arkts.isETSStructDeclaration(node)) { + this.collectComponentMembers(node, className); + const _node = arkts.factory.createClassDeclaration(newDefinition); + _node.updateModifiers(node.modifierFlags); + return _node; + } else { + return arkts.factory.updateClassDeclaration( + node, + newDefinition + ) + } + } + + collectComponentMembers(node: arkts.ETSStructDeclaration, className: string): void { + if (!this.context.structMembers.has(className)) { + this.context.structMembers.set(className, []); + } + node.definition?.body.map(it => { + if (arkts.isClassProperty(it)) { + this.context.structMembers.get(className)!.push(...this.createInterfaceInnerMember(it)); + } + }); + } + + createInterfaceInnerMember(member: arkts.ClassProperty): arkts.ClassProperty[] { + const originalName: string = expectName(member.key); + const newName: string = backingField(originalName); + const originMember: arkts.ClassProperty = createOptionalClassProperty(originalName, member, + '', arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC); + // Complete BS. + if (member.annotations.length > 0 && !hasDecorator(member, DecoratorNames.BUILDER_PARAM)) { + const newMember: arkts.ClassProperty = createOptionalClassProperty(newName, member, + getStageManagmentType(member), arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC); + return [originMember, newMember] + } + return [originMember]; + } + + visitor(node: arkts.AstNode): arkts.AstNode { + this.enter(node); + const newNode = this.visitEachChild(node) + if (arkts.isETSModule(newNode)) { + const updateNode = this.processEtsScript(newNode) + this.exit(newNode) + return updateNode + } + if (arkts.isETSStructDeclaration(newNode) && this.isComponentStruct()) { + const updateNode = this.processComponent(newNode) + this.exit(newNode) + return updateNode + } + return newNode + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/ets-first-arg-transformer.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/ets-first-arg-transformer.ts new file mode 100644 index 0000000000000000000000000000000000000000..4170a051dd19f0700863702bc74d60dc688d260b --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/ets-first-arg-transformer.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as arkts from "@koalaui/libarkts" +import { builderLambdaFunctionName } from "./builder-lambda-transformer" + +export class EtsFirstArgTransformer extends arkts.AbstractVisitor { + visitor(beforeChildren: arkts.AstNode): arkts.AstNode { + const node = this.visitEachChild(beforeChildren) + if (arkts.isCallExpression(node) && builderLambdaFunctionName(node) !== undefined) { + return arkts.factory.updateCallExpression( + node, + node.callee, + [arkts.factory.createUndefinedLiteral(), ...node.arguments], + node.typeParams + ) + } + return node + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/parsed-stage-plugin.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/parsed-stage-plugin.ts new file mode 100644 index 0000000000000000000000000000000000000000..2ae6e56ef51f03515a605870346adfcf2addb17d --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/parsed-stage-plugin.ts @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as arkts from "@koalaui/libarkts" +import { ComponentTransformer, ComponentTransformerOptions } from './component-transformer' +import { AnnotationsTransformer } from "./annotation-translator" + +export default function parsedTransformer( + userPluginOptions?: ComponentTransformerOptions +) { + console.log(`PARSED: ${userPluginOptions}`) + return (node: arkts.ETSModule) => [ + new ComponentTransformer(userPluginOptions), + new AnnotationsTransformer() + ] + .reduce((node: arkts.AstNode, transformer) => transformer.visitor(node), node) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/property-translators/base.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/property-translators/base.ts new file mode 100644 index 0000000000000000000000000000000000000000..26014a7111ba088e75d907d6cdfd2781e13aef8d --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/property-translators/base.ts @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as arkts from "@koalaui/libarkts" + +export abstract class PropertyTranslator { + constructor( + protected property: arkts.ClassProperty, + protected structName: string + ) { } + + abstract translateMember(): arkts.AstNode[]; +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/property-translators/factory.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/property-translators/factory.ts new file mode 100644 index 0000000000000000000000000000000000000000..eb7c3980f0730d3cbb86571dc7ecf6785a0b2fa0 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/property-translators/factory.ts @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as arkts from "@koalaui/libarkts"; +import { GenSymGenerator } from "../common/gensym-generator"; + +export class factory { + /** + * generate an substitution for optional expression ?., e.g. `{let _tmp = xxx; _tmp == null ? undefined : xxx}`. + * + * @param object item before ?.. + * @param key item after ?.. + */ + static createBlockStatementForOptionalExpression(object: arkts.Expression, key: string): arkts.Expression { + let id = GenSymGenerator.getInstance().id(key); + const statements: arkts.Statement[] = [ + factory.generateLetVariableDecl( + arkts.factory.createIdentifier(id, undefined), + object + ), + factory.generateTernaryExpression(id, key) + ]; + return arkts.factory.createBlockExpression(statements); + } + + /** + * generate a variable declaration, e.g. `let = `; + * + * @param left left expression. + * @param right right expression. + */ + static generateLetVariableDecl(left: arkts.Identifier , right: arkts.Expression): arkts.VariableDeclaration { + return arkts.factory.createVariableDeclaration( + arkts.Es2pandaVariableDeclarationKind.VARIABLE_DECLARATION_KIND_LET, + [ + arkts.factory.createVariableDeclarator( + arkts.Es2pandaVariableDeclaratorFlag.VARIABLE_DECLARATOR_FLAG_LET, + left, + right + ) + ] + ); + } + + /** + * generate a ternary expression, e.g. ` ? : `; + * + * @param testLeft the left hand of the test condition. + * @param key item after ?. + */ + static generateTernaryExpression(testLeft: string, key: string): arkts.ExpressionStatement { + const test = arkts.factory.createBinaryExpression( + arkts.factory.createIdentifier(testLeft, undefined), + arkts.factory.createNullLiteral(), + arkts.Es2pandaTokenType.TOKEN_TYPE_PUNCTUATOR_EQUAL + ); + const consequent: arkts.Expression = arkts.factory.createUndefinedLiteral(); + const alternate: arkts.MemberExpression = arkts.factory.createMemberExpression( + arkts.factory.createIdentifier(testLeft, undefined), + arkts.factory.createIdentifier(key, undefined), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + false, + false + ); + return arkts.factory.createExpressionStatement( + arkts.factory.createConditionalExpression(test, consequent, alternate) + ); + } + + /** + * generate an substitution for two optional expression ?., e.g. a?.b?.c. + * + * @param node entry wrapper class declaration node. + */ + static createDoubleBlockStatementForOptionalExpression( + object: arkts.Expression, + key1: string, + key2: string + ): arkts.Expression { + let id = GenSymGenerator.getInstance().id(key1); + let initial: arkts.Expression = factory.createBlockStatementForOptionalExpression(object, key1) + const statements: arkts.Statement[] = [ + factory.generateLetVariableDecl( + arkts.factory.createIdentifier(id, undefined), + initial + ), + factory.generateTernaryExpression(id, key2) + ]; + return arkts.factory.createBlockExpression(statements); + } + + +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/property-translators/index.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/property-translators/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..9987a4542f41ce31b05ee71b8b9059d8c5ecd98f --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/property-translators/index.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as arkts from "@koalaui/libarkts" + +import { PropertyTranslator } from "./base"; +import { DecoratorNames, hasDecorator } from "./utils"; +import { StateTranslator } from "./state"; + +export { PropertyTranslator }; + +export function classifyProperty(member: arkts.AstNode, structName: string): PropertyTranslator | undefined { + if (!arkts.isClassProperty(member)) return undefined; + + if (hasDecorator(member, DecoratorNames.STATE)) { + return new StateTranslator(member, structName); + } + + return undefined; +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/property-translators/regularProperty.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/property-translators/regularProperty.ts new file mode 100644 index 0000000000000000000000000000000000000000..c755b94dd42932a0cf0156d5c03ca8357ae7e907 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/property-translators/regularProperty.ts @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as arkts from "@koalaui/libarkts" + +import { + createGetter, + createSetter, +} from "./utils"; +import { PropertyTranslator } from "./base"; +import { + GetterSetter, + InitializerConstructor +} from "./types"; +import { + backingField, + expectName +} from "../common/arkts-utils"; + +export class regularPropertyTranslator extends PropertyTranslator implements InitializerConstructor, GetterSetter { + translateMember(): arkts.AstNode[] { + const originalName: string = expectName(this.property.key); + const newName: string = backingField(originalName); + this.cacheTranslatedInitializer(newName, originalName); // TODO: need to release cache after some point... + return this.translateWithoutInitializer(newName, originalName); + } + + cacheTranslatedInitializer(newName: string, originalName: string): void {} + + translateWithoutInitializer(newName: string, originalName: string): arkts.AstNode[] { + return [this.property]; + } + + translateGetter( + originalName: string, + typeAnnotation: arkts.TypeNode | undefined, + returnValue: arkts.Expression + ): arkts.MethodDefinition { + return createGetter(originalName, typeAnnotation, returnValue); + } + + translateSetter( + originalName: string, + typeAnnotation: arkts.TypeNode | undefined, + left: arkts.MemberExpression + ): arkts.MethodDefinition { + const right: arkts.Identifier = arkts.factory.createIdentifier('value', undefined) + return createSetter(originalName, typeAnnotation, left, right); + } + + generateInitializeStruct( + newName: string, + originalName: string + ): arkts.AstNode { + return arkts.factory.createAssignmentExpression( + arkts.factory.createMemberExpression( + arkts.factory.createIdentifier('this', undefined), + arkts.factory.createIdentifier(originalName, undefined), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + false, + false + ), + this.property.value ?? arkts.factory.createIdentifier('undefined', undefined), + arkts.Es2pandaTokenType.TOKEN_TYPE_PUNCTUATOR_SUBSTITUTION + ); + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/property-translators/state.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/property-translators/state.ts new file mode 100644 index 0000000000000000000000000000000000000000..894df2e86c3fd20d271df76d380d23ffb66ae41f --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/property-translators/state.ts @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as arkts from "@koalaui/libarkts" + +import { + createGetter, + createSetter2, + generateThisBacking, + generateGetOrSetCall +} from "./utils"; +import { PropertyTranslator } from "./base"; +import { + GetterSetter, + InitializerConstructor +} from "./types"; +import { + backingField, + expectName +} from "../common/arkts-utils"; +import { createOptionalClassProperty } from "../utils"; +import { factory } from "./factory"; + +export class StateTranslator extends PropertyTranslator implements InitializerConstructor, GetterSetter { + translateMember(): arkts.AstNode[] { + const originalName: string = expectName(this.property.key); + const newName: string = backingField(originalName); + + this.cacheTranslatedInitializer(newName, originalName); // TODO: need to release cache after some point... + return this.translateWithoutInitializer(newName, originalName); + } + + cacheTranslatedInitializer(newName: string, originalName: string): void { + const currentStructInfo: arkts.StructInfo = arkts.GlobalInfo.getInfoInstance().getStructInfo(this.structName); + const initializeStruct: arkts.AstNode = this.generateInitializeStruct(newName, originalName); + currentStructInfo.initializeBody.push(initializeStruct); + arkts.GlobalInfo.getInfoInstance().setStructInfo(this.structName, currentStructInfo); + } + + translateWithoutInitializer(newName: string, originalName: string): arkts.AstNode[] { + const field: arkts.ClassProperty = createOptionalClassProperty(newName, this.property, "StateDecoratedVariable", + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PRIVATE); + const thisValue: arkts.Expression = generateThisBacking(newName, false, true); + const thisGet: arkts.CallExpression = generateGetOrSetCall(thisValue, "get"); + const thisSet: arkts.ExpressionStatement = arkts.factory.createExpressionStatement( + generateGetOrSetCall(thisValue, "set")); + const getter: arkts.MethodDefinition = this.translateGetter(originalName, this.property.typeAnnotation, thisGet); + const setter: arkts.MethodDefinition = this.translateSetter(originalName, this.property.typeAnnotation, thisSet); + + return [field, getter, setter]; + } + + translateGetter( + originalName: string, + typeAnnotation: arkts.TypeNode | undefined, + returnValue: arkts.Expression + ): arkts.MethodDefinition { + return createGetter(originalName, typeAnnotation, returnValue); + } + + translateSetter( + originalName: string, + typeAnnotation: arkts.TypeNode | undefined, + statement: arkts.AstNode + ): arkts.MethodDefinition { + return createSetter2(originalName, typeAnnotation, statement); + } + + generateInitializeStruct( + newName: string, + originalName: string + ): arkts.AstNode { + const binaryItem = arkts.factory.createBinaryExpression( + factory.createBlockStatementForOptionalExpression(arkts.factory.createIdentifier('initializers', undefined), originalName), + this.property.value ?? arkts.factory.createIdentifier('undefined', undefined), + arkts.Es2pandaTokenType.TOKEN_TYPE_PUNCTUATOR_NULLISH_COALESCING + ); + const right = arkts.factory.createETSNewClassInstanceExpression( + arkts.factory.createETSTypeReference( + arkts.factory.createETSTypeReferencePart( + arkts.factory.createIdentifier("StateDecoratedVariable", undefined), + arkts.factory.createTSTypeParameterInstantiation( + this.property.typeAnnotation ? [this.property.typeAnnotation] : [] + ), undefined + ) + ), + [binaryItem] + ); + const assign: arkts.AssignmentExpression = arkts.factory.createAssignmentExpression( + generateThisBacking(newName), + right, + arkts.Es2pandaTokenType.TOKEN_TYPE_PUNCTUATOR_SUBSTITUTION, + ); + return arkts.factory.createExpressionStatement(assign); + } +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/property-translators/types.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/property-translators/types.ts new file mode 100644 index 0000000000000000000000000000000000000000..24fc02bb3812d2d50598e81d3fc4780217392761 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/property-translators/types.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as arkts from "@koalaui/libarkts" + +export interface GetterSetter { + translateGetter( + originalName: string, + typeAnnotation: arkts.TypeNode | undefined, + returnValue: arkts.Expression + ): arkts.MethodDefinition; + translateSetter( + originalName: string, + typeAnnotation: arkts.TypeNode | undefined, + left: arkts.MemberExpression + ): arkts.MethodDefinition; +} + +export interface InitializerConstructor { + cacheTranslatedInitializer( + newName: string, + originalName: string + ): void; + translateWithoutInitializer( + newName: string, + originalName: string + ): arkts.AstNode[]; +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/property-translators/utils.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/property-translators/utils.ts new file mode 100644 index 0000000000000000000000000000000000000000..86b8ac93de0a84e042429cada3d2e00aa0d96d60 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/property-translators/utils.ts @@ -0,0 +1,242 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as arkts from "@koalaui/libarkts" +import { annotation } from "../common/arkts-utils"; + +export enum DecoratorNames { + ENTRY = "Entry", + COMPONENT = "Component", + REUSABLE = "Reusable", + STATE = "State", + STORAGE_LINK = "StorageLink", + STORAGE_PROP = "StorageProp", + LINK = "Link", + PROP = "Prop", + PROVIDE = "Provide", + CONSUME = "Consume", + OBJECT_LINK = "ObjectLink", + OBSERVED = "Observed", + WATCH = "Watch", + BUILDER_PARAM = "BuilderParam", + BUILDER = "Builder", + CUSTOM_DIALOG = "CustomDialog", + LOCAL_STORAGE_PROP = "LocalStorageProp", + LOCAL_STORAGE_LINK = "LocalStorageLink", +} + +export function isDecoratorAnnotation(anno: arkts.AnnotationUsage, decoratorName: DecoratorNames): boolean { + return !!anno.expr && arkts.isIdentifier(anno.expr) && anno.expr.name === decoratorName; +} + +export function hasDecorator(property: arkts.ClassProperty | arkts.ClassDefinition | arkts.ClassDeclaration | arkts.MethodDefinition | arkts.FunctionDeclaration, decoratorName: DecoratorNames): boolean { + if (arkts.isMethodDefinition(property)) { + return property.function!.annotations.some((anno) => isDecoratorAnnotation(anno, decoratorName)); + } + if (arkts.isClassDeclaration(property)) { + return property.decorators.some((anno) => arkts.isIdentifier(anno.expr) && anno.expr.name === decoratorName); + } + return property.annotations.some((anno) => isDecoratorAnnotation(anno, decoratorName)); +} + +export function getStageManagmentType(node: arkts.ClassProperty): string { + if (hasDecorator(node, DecoratorNames.STATE)) { + return "StateDecoratedVariable"; + } else if (hasDecorator(node, DecoratorNames.PROP) || hasDecorator(node, DecoratorNames.STORAGE_PROP) || + hasDecorator(node, DecoratorNames.LOCAL_STORAGE_PROP) || hasDecorator(node, DecoratorNames.OBJECT_LINK) + ) { + return "SyncedProperty"; + } + return "MutableState"; +} + +export function createGetter( + name: string, + type: arkts.TypeNode | undefined, + returns: arkts.Expression +): arkts.MethodDefinition { + const body = arkts.factory.createBlockStatement( + [arkts.factory.createReturnStatement(returns)] + ) + + const key = arkts.factory.createIdentifier(name, undefined) + const scriptFunction = arkts.factory.createScriptFunction( + body, + undefined, + [], + type?.clone(), + false, + arkts.Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_GETTER, + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC, + key, + undefined + ) + + return arkts.factory.createMethodDefinition( + arkts.Es2pandaMethodDefinitionKind.METHOD_DEFINITION_KIND_GET, + key, + arkts.factory.createFunctionExpression(key, scriptFunction), + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC, + false + ); +} + +export function createSetter( + name: string, + type: arkts.TypeNode | undefined, + left: arkts.Expression, + right: arkts.Expression, + needMemo: boolean = false +): arkts.MethodDefinition { + const body = arkts.factory.createBlockStatement( + [ + arkts.factory.createExpressionStatement(arkts.factory.createAssignmentExpression( + left, + right, + arkts.Es2pandaTokenType.TOKEN_TYPE_PUNCTUATOR_SUBSTITUTION + )) + ] + ) + const param: arkts.ETSParameterExpression = arkts.factory.createETSParameterExpression( + arkts.factory.createIdentifier('value', type?.clone()), + false + ); + if (needMemo) { + param.setAnnotations([annotation("memo")]) + } + const key = arkts.factory.createIdentifier(name, undefined) + const scriptFunction = arkts.factory.createScriptFunction( + body, + undefined, + [param], + undefined, + false, + arkts.Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_SETTER, + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC, + key, + undefined + ) + + return arkts.factory.createMethodDefinition( + arkts.Es2pandaMethodDefinitionKind.METHOD_DEFINITION_KIND_SET, + key, + arkts.factory.createFunctionExpression(key, scriptFunction), + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC, + false + ); +} + +export function createSetter2( + name: string, + type: arkts.TypeNode | undefined, + statement: arkts.AstNode +): arkts.MethodDefinition { + const body = arkts.factory.createBlockStatement([statement]); + const param: arkts.ETSParameterExpression = arkts.factory.createETSParameterExpression( + arkts.factory.createIdentifier('value', type?.clone()), + false + ); + const key = arkts.factory.createIdentifier(name, undefined) + const scriptFunction = arkts.factory.createScriptFunction( + body, + undefined, + [param], + undefined, + false, + arkts.Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_SETTER, + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC, + key, + undefined + ); + + return arkts.factory.createMethodDefinition( + arkts.Es2pandaMethodDefinitionKind.METHOD_DEFINITION_KIND_SET, + key, + arkts.factory.createFunctionExpression(key, scriptFunction), + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC, + false + ); +} + +export function generateThisBackingValue( + name: string, + optional: boolean = false, + nonNull: boolean = false +): arkts.MemberExpression { + const member: arkts.Expression = generateThisBacking(name, optional, nonNull); + return arkts.factory.createMemberExpression( + member, + arkts.factory.createIdentifier('value', undefined), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + false, + false + ); +} + +export function generateThisBacking( + name: string, + optional: boolean = false, + nonNull: boolean = false +): arkts.Expression { + const member: arkts.Expression = arkts.factory.createMemberExpression( + arkts.factory.createThisExpression(), + arkts.factory.createIdentifier(name, undefined), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + false, + optional + ); + return nonNull ? arkts.factory.createTSNonNullExpression(member) : member; +} + +function getValueStr(node: arkts.AstNode): string | undefined { + if (!arkts.isClassProperty(node) || !node.value) return undefined; + return arkts.isStringLiteral(node.value) ? node.value.str : undefined; +} + +function getAnnotationValue(anno: arkts.AnnotationUsage, decoratorName: DecoratorNames): string | undefined { + const isSuitableAnnotation: boolean = !!anno.expr + && arkts.isIdentifier(anno.expr) + && anno.expr.name === decoratorName; + if (isSuitableAnnotation && anno.properties.length === 1) { + return getValueStr(anno.properties.at(0)!); + } + return undefined; +} + +export function getValueInAnnotation(node: arkts.ClassProperty, decoratorName: DecoratorNames): string | undefined { + const annotations: readonly arkts.AnnotationUsage[] = node.annotations; + for (let i = 0; i < annotations.length; i++) { + const anno: arkts.AnnotationUsage = annotations[i]; + const str: string | undefined = getAnnotationValue(anno, decoratorName); + if (!!str) { + return str; + } + } + return undefined; +} + +export function generateGetOrSetCall(beforCall: arkts.Expression, type: string) { + return arkts.factory.createCallExpression( + arkts.factory.createMemberExpression( + beforCall, + arkts.factory.createIdentifier(type, undefined), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + false, + false + ), + type === "set" ? [arkts.factory.createIdentifier("value", undefined)] : [], + undefined + ); +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/struct-transformer.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/struct-transformer.ts new file mode 100644 index 0000000000000000000000000000000000000000..698a4d61d20a40f206411dbb3bb656ac0a1e8600 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/struct-transformer.ts @@ -0,0 +1,326 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as arkts from "@koalaui/libarkts" +import { + annotation, + collect, + filterDefined +} from "./common/arkts-utils"; +import { + classifyProperty, + PropertyTranslator +} from "./property-translators"; +import { + CustomComponentNames, + getCustomComponentOptionsName, + getTypeNameFromTypeParameter, + getTypeParamsFromClassDecl, +} from "./utils"; +import { + factory +} from "./ui-factory"; +import { DecoratorNames, hasDecorator } from "./property-translators/utils"; + +function isCustomComponentClass(node: arkts.ClassDeclaration): boolean { + if (!node.definition?.ident?.name) return false; + const name: string = node.definition.ident.name; + const structCollection: Set = arkts.GlobalInfo.getInfoInstance().getStructCollection(); + return structCollection.has(name) +} + +function isKnownMethodDefinition(method: arkts.MethodDefinition, name: string): boolean { + if (!method || !arkts.isMethodDefinition(method)) return false; + + // For now, we only considered matched method name. + const isNameMatched: boolean = method.id?.name === name; + return isNameMatched; +} + +function transformBuildMethod( + method: arkts.MethodDefinition, + typeName: string, + optionsName: string, + isDecl?: boolean +): arkts.MethodDefinition { + const updateKey: arkts.Identifier = arkts.factory.createIdentifier( + CustomComponentNames.COMPONENT_BUILD, undefined + ); + + const scriptFunction: arkts.ScriptFunction = method.function! + const updateScriptFunction = arkts.factory.createScriptFunction( + scriptFunction.body, + scriptFunction.typeParams, + [ + factory.createStyleParameter(typeName), + factory.createContentParameter(), + factory.createInitializersOptionsParameter(optionsName) + ], + arkts.factory.createETSPrimitiveType(arkts.Es2pandaPrimitiveType.PRIMITIVE_TYPE_VOID), + false, + scriptFunction.flags, + scriptFunction.modifierFlags, + updateKey, + [annotation("memo")] + ); + + const modifiers: arkts.Es2pandaModifierFlags = isDecl + ? arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_ABSTRACT + : arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC; + return arkts.factory.createMethodDefinition( + arkts.Es2pandaMethodDefinitionKind.METHOD_DEFINITION_KIND_METHOD, + updateKey, + arkts.factory.createFunctionExpression(updateKey, updateScriptFunction), + modifiers, + false + ); +} + +function createInitializeStruct( + structInfo: arkts.StructInfo, + optionsTypeName: string, + isDecl?: boolean +) { + const updateKey: arkts.Identifier = arkts.factory.createIdentifier( + CustomComponentNames.COMPONENT_INITIALIZE_STRUCT, undefined + ); + + let body: arkts.BlockStatement | undefined; + let modifiers: arkts.Es2pandaModifierFlags = arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_ABSTRACT; + if (!isDecl) { + body = arkts.factory.createBlockStatement(structInfo.initializeBody); + modifiers = arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC; + } + const scriptFunction: arkts.ScriptFunction = arkts.factory.createScriptFunction( + body, + undefined, + [ + factory.createInitializersOptionsParameter(optionsTypeName), + factory.createContentParameter() + ], + arkts.factory.createETSPrimitiveType(arkts.Es2pandaPrimitiveType.PRIMITIVE_TYPE_VOID), + false, + arkts.Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_METHOD, + modifiers, + updateKey, + undefined + ); + + return arkts.factory.createMethodDefinition( + arkts.Es2pandaMethodDefinitionKind.METHOD_DEFINITION_KIND_METHOD, + updateKey, + arkts.factory.createFunctionExpression(updateKey, scriptFunction), + modifiers, + false + ); +} + +function createUpdateStruct( + structInfo: arkts.StructInfo, + optionsTypeName: string, + isDecl?: boolean +) { + const updateKey: arkts.Identifier = arkts.factory.createIdentifier( + CustomComponentNames.COMPONENT_UPDATE_STRUCT, undefined + ) + + let body: arkts.BlockStatement | undefined; + let modifiers: arkts.Es2pandaModifierFlags = arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_ABSTRACT; + if (!isDecl) { + body = arkts.factory.createBlockStatement(structInfo.updateBody); + modifiers = arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC; + } + + const scriptFunction: arkts.ScriptFunction = arkts.factory.createScriptFunction( + body, + undefined, + [ + factory.createInitializersOptionsParameter(optionsTypeName) + ], + arkts.factory.createETSPrimitiveType(arkts.Es2pandaPrimitiveType.PRIMITIVE_TYPE_VOID), + false, + arkts.Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_METHOD, + modifiers, + updateKey, + undefined + ); + + return arkts.factory.createMethodDefinition( + arkts.Es2pandaMethodDefinitionKind.METHOD_DEFINITION_KIND_METHOD, + updateKey, + arkts.factory.createFunctionExpression(updateKey, scriptFunction), + modifiers, + false + ); +} + +function tranformPropertyMembers( + className: string, + propertyTranslators: PropertyTranslator[], + optionsTypeName: string, + isDecl?: boolean, + scope?: ScopeInfo +): arkts.AstNode[] { + const propertyMembers = propertyTranslators.map(translator => + translator.translateMember() + ); + const currentStructInfo: arkts.StructInfo = arkts.GlobalInfo + .getInfoInstance() + .getStructInfo(className); + const collections = []; + if (!scope?.hasInitializeStruct) { + collections.push(createInitializeStruct(currentStructInfo, optionsTypeName, isDecl)) + } + if (!scope?.hasUpdateStruct) { + collections.push(createUpdateStruct(currentStructInfo, optionsTypeName, isDecl)) + } + return collect(...collections, ...propertyMembers); +} + +function tranformClassMembers( + node: arkts.ClassDeclaration, + isDecl?: boolean, + scope?: ScopeInfo +): arkts.ClassDeclaration { + if (!node.definition) { + return node; + } + + let classTypeName: string | undefined; + let classOptionsName: string | undefined; + if (isDecl) { + const [classType, classOptions] = getTypeParamsFromClassDecl(node); + classTypeName = getTypeNameFromTypeParameter(classType); + classOptionsName = getTypeNameFromTypeParameter(classOptions); + } + + const definition: arkts.ClassDefinition = node.definition; + const className: string | undefined = node.definition.ident?.name; + if (!className) { + throw new Error("Non Empty className expected for Component") + } + + const propertyTranslators: PropertyTranslator[] = filterDefined( + definition.body.map(it => classifyProperty(it, className)) + ); + + const translatedMembers: arkts.AstNode[] = tranformPropertyMembers( + className, + propertyTranslators, + classOptionsName ?? getCustomComponentOptionsName(className), + isDecl, + scope + ); + + const updateMembers: arkts.AstNode[] = definition.body + .filter((member)=>!arkts.isClassProperty(member)) + .map((member: arkts.AstNode) => { + if (arkts.isMethodDefinition(member) && hasDecorator(member, DecoratorNames.BUILDER)) { + member.function!.setAnnotations([annotation("memo")]); + return member; + } + if ( + arkts.isMethodDefinition(member) + && isKnownMethodDefinition(member, CustomComponentNames.COMPONENT_CONSTRUCTOR_ORI) + && !isDecl + ) { + return arkts.factory.createMethodDefinition( + arkts.Es2pandaMethodDefinitionKind.METHOD_DEFINITION_KIND_CONSTRUCTOR, + member.id, + arkts.factory.createFunctionExpression(member.id, member.function), + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_CONSTRUCTOR, + false + ); + } + if ( + arkts.isMethodDefinition(member) + && isKnownMethodDefinition(member, CustomComponentNames.COMPONENT_BUILD_ORI) + ) { + const buildMethod = transformBuildMethod( + member, + classTypeName ?? className, + classOptionsName ?? getCustomComponentOptionsName(className), + isDecl + ); + return buildMethod; + } + + return member; + } + ); + + const updateClassDef: arkts.ClassDefinition = arkts.factory.updateClassDefinition( + definition, + definition.ident, + definition.typeParams, + definition.superTypeParams, + definition.implements, + undefined, + definition.super, + [...translatedMembers, ...updateMembers], + definition.modifiers, + arkts.classDefinitionFlags(definition) + ); + + return arkts.factory.updateClassDeclaration(node, updateClassDef); +} + +type ScopeInfo = { + name: string, + hasInitializeStruct?: boolean, + hasUpdateStruct?: boolean, +} + +export class StructTransformer extends arkts.AbstractVisitor { + private scopeInfos: ScopeInfo[] = []; + + enter(node: arkts.AstNode) { + if (arkts.isClassDeclaration(node) && isCustomComponentClass(node)) { + this.scopeInfos.push({ name: node.definition!.ident!.name }); + } + if (arkts.isMethodDefinition(node) && this.scopeInfos.length > 0) { + const name = node.id!.name + const scopeInfo = this.scopeInfos.pop()!; + scopeInfo.hasInitializeStruct ||= (name === CustomComponentNames.COMPONENT_INITIALIZE_STRUCT); + scopeInfo.hasUpdateStruct ||= (name === CustomComponentNames.COMPONENT_UPDATE_STRUCT); + this.scopeInfos.push(scopeInfo); + } + } + + exit(node: arkts.AstNode) { + if (arkts.isClassDeclaration(node) && isCustomComponentClass(node)) { + this.scopeInfos.pop(); + } + } + + visitor(beforeChildren: arkts.AstNode): arkts.AstNode { + this.enter(beforeChildren); + const node = this.visitEachChild(beforeChildren); + if (arkts.isClassDeclaration(node) && isCustomComponentClass(node)) { + let scope: ScopeInfo | undefined; + if (this.scopeInfos.length > 0) { + scope = this.scopeInfos[this.scopeInfos.length - 1]; + } + const newClass: arkts.ClassDeclaration = tranformClassMembers( + node, + arkts.hasModifierFlag(node, arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_DECLARE), + scope + ); + this.exit(beforeChildren); + return newClass; + } + return node + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/style-transformer.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/style-transformer.ts new file mode 100644 index 0000000000000000000000000000000000000000..3073c21438be22269f1bf46f7abc7ccf8a65df3e --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/style-transformer.ts @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as arkts from "@koalaui/libarkts" +import { builderLambdaFunctionName } from "./builder-lambda-transformer" +import { styledInstance } from "./utils" + +export class StyleTransformer extends arkts.AbstractVisitor { + visitor(beforeChildren: arkts.AstNode): arkts.AstNode { + const node = this.visitEachChild(beforeChildren) + const isCallChain = arkts.isCallExpression(node) + && arkts.isMemberExpression(node.callee) + && arkts.isCallExpression(node.callee.object) + if (!isCallChain) { + return node + } + const implFunction = builderLambdaFunctionName(node.callee.object) + if (implFunction === undefined) { + return node + } + return transformStyle(node, node.callee, node.callee.object, node.callee.object.arguments) + } +} + +function transformStyle( + outerCall: arkts.CallExpression, + dot: arkts.MemberExpression, + innerCall: arkts.CallExpression, + args: readonly arkts.Expression[] +): arkts.AstNode { + const firstArg = args[0] + const firstArgOrUndefined = arkts.isUndefinedLiteral(firstArg) ? undefined : firstArg + const restArgs = args.slice(1) + + const newDot = arkts.factory.updateMemberExpression( + dot, + firstArgOrUndefined ?? arkts.factory.createIdentifier(styledInstance, undefined), + dot.property, + dot.kind, + dot.isComputed, + dot.isOptional + ) + + const detachedStyle = arkts.factory.updateCallExpression( + outerCall, + newDot, + outerCall.arguments, + outerCall.typeParams + ) + + return arkts.factory.updateCallExpression( + innerCall, + innerCall.callee, + [detachedStyle, ...restArgs], + innerCall.typeParams + ) +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/ui-factory.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/ui-factory.ts new file mode 100644 index 0000000000000000000000000000000000000000..d182157dcc9ce447be7376af667f2f2ae10f5237 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/ui-factory.ts @@ -0,0 +1,157 @@ +/* + * Copyright (C) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as arkts from "@koalaui/libarkts" +import { + BuilderLambdaNames, + CustomComponentNames +} from "./utils"; +import { annotation } from "./common/arkts-utils"; + +export class factory { + /** + * create `instance: ` as identifier + */ + static createInstanceIdentifier(typeName: string): arkts.Identifier { + return arkts.factory.createIdentifier( + BuilderLambdaNames.STYLE_ARROW_PARAM_NAME, + factory.createTypeReferenceFromString(typeName) + ) + } + + /** + * create `instance: ` as parameter + */ + static createInstanceParameter(typeName: string): arkts.ETSParameterExpression { + return arkts.factory.createETSParameterExpression( + factory.createInstanceIdentifier(typeName), + false + ) + } + + /** + * create `(instance: ) => void` + */ + static createStyleLambdaFunctionType(typeName: string): arkts.ETSFunctionType { + return arkts.factory.createETSFunctionType( + undefined, + [ + factory.createInstanceParameter(typeName) + ], + arkts.factory.createETSPrimitiveType(arkts.Es2pandaPrimitiveType.PRIMITIVE_TYPE_VOID), + false, + arkts.Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_ARROW + ); + } + + /** + * create `style: ((instance: ) => void) | undefined` as identifier + */ + static createStyleIdentifier(typeName: string): arkts.Identifier { + return arkts.factory.createIdentifier( + BuilderLambdaNames.STYLE_PARAM_NAME, + arkts.factory.createETSUnionType([ + factory.createStyleLambdaFunctionType(typeName), + arkts.factory.createETSUndefinedType() + ]) + ) + } + + /** + * create `@memo() style: ((instance: ) => void) | undefined` as parameter + */ + static createStyleParameter(typeName: string): arkts.ETSParameterExpression { + const styleParam: arkts.Identifier = factory.createStyleIdentifier(typeName); + const param = arkts.factory.createETSParameterExpression(styleParam, false); + param.setAnnotations([annotation("memo")]); + return param; + } + + /** + * create `initializers: | undefined` as identifier + */ + static createInitializerOptionsIdentifier(optionsName: string): arkts.Identifier { + return arkts.factory.createIdentifier( + CustomComponentNames.COMPONENT_INITIALIZERS_NAME, + arkts.factory.createETSUnionType([ + factory.createTypeReferenceFromString(optionsName), + arkts.factory.createETSUndefinedType() + ]) + ) + } + + /** + * create `initializers: | undefined` as parameter + */ + static createInitializersOptionsParameter(optionsName: string): arkts.ETSParameterExpression { + return arkts.factory.createETSParameterExpression( + factory.createInitializerOptionsIdentifier( + optionsName + ), + false + ) + } + + /** + * create `content: (() => void) | undefined` as identifier + */ + static createContentIdentifier(): arkts.Identifier { + return arkts.factory.createIdentifier( + BuilderLambdaNames.CONTENT_PARAM_NAME, + arkts.factory.createETSUnionType([ + factory.createLambdaFunctionType(), + arkts.factory.createETSUndefinedType() + ]) + ); + } + + /** + * create `@memo() content: (() => void) | undefined` as parameter + */ + static createContentParameter(): arkts.ETSParameterExpression { + const contentParam: arkts.Identifier = factory.createContentIdentifier(); + const param = arkts.factory.createETSParameterExpression(contentParam, false); + param.setAnnotations([annotation("memo")]); + return param; + } + + /** + * create type from string + */ + static createTypeReferenceFromString(name: string): arkts.TypeNode { + return arkts.factory.createETSTypeReference( + arkts.factory.createETSTypeReferencePart( + arkts.factory.createIdentifier(name, undefined), undefined, undefined + ) + ); + } + + /** + * create `() => `. If returnType is not given, then using `void`. + */ + static createLambdaFunctionType( + params?: arkts.Expression[], + returnType?: arkts.TypeNode | undefined + ): arkts.ETSFunctionType { + return arkts.factory.createETSFunctionType( + undefined, + params ?? [], + returnType + ?? arkts.factory.createETSPrimitiveType(arkts.Es2pandaPrimitiveType.PRIMITIVE_TYPE_VOID), + false, + arkts.Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_ARROW + ) + } +} diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/utils.ts b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/utils.ts new file mode 100644 index 0000000000000000000000000000000000000000..7921366fcf00462b61a4620c4ce66033b9db3dee --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/src/utils.ts @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as arkts from "@koalaui/libarkts" + +export const styledInstance = mangle("instance") + +export function mangle(value: string): string { + return `__${value}` +} + +export enum CustomComponentNames { + COMPONENT_BUILD_ORI = 'build', + COMPONENT_CONSTRUCTOR_ORI = 'constructor', + COMPONENT_DEFAULT_IMPORT = '@ohos.arkui', + COMPONENT_CLASS_NAME = 'StructBase', + COMPONENT_INTERFACE_PREFIX = '__Options_', + COMPONENT_INITIALIZE_STRUCT = '__initializeStruct', + COMPONENT_UPDATE_STRUCT = '__updateStruct', + COMPONENT_BUILD = '_build', + REUSABLE_COMPONENT_REBIND_STATE = '__rebindStates', + COMPONENT_INITIALIZERS_NAME = 'initializers' +} + +export enum BuilderLambdaNames { + ANNOTATION_NAME = 'ComponentBuilder', + ORIGIN_METHOD_NAME = '$_instantiate', + TRANSFORM_METHOD_NAME = '_instantiateImpl', + STYLE_PARAM_NAME = 'style', + STYLE_ARROW_PARAM_NAME = 'instance', + CONTENT_PARAM_NAME = 'content', +} + +export enum InternalAnnotations { + MEMO = 'memo' +} + +export function uiAttributeName(componentName: string): string { + return `UI${componentName}Attribute` +} +export function getCustomComponentOptionsName(className: string): string { + return `${CustomComponentNames.COMPONENT_INTERFACE_PREFIX}${className}` +} + +export function getTypeParamsFromClassDecl(node: arkts.ClassDeclaration | undefined): readonly arkts.TSTypeParameter[] { + return node?.definition?.typeParams?.params ?? []; +} + +export function getTypeNameFromTypeParameter(node: arkts.TSTypeParameter | undefined): string | undefined { + return node?.name?.name; +} + +export function createOptionalClassProperty( + name: string, + property: arkts.ClassProperty, + stageManagementIdent: string, + modifiers: arkts.Es2pandaModifierFlags +): arkts.ClassProperty { + let newType: arkts.TypeNode | undefined = property.typeAnnotation; + if (property.typeAnnotation && arkts.isETSFunctionType(property.typeAnnotation)) { + newType = arkts.factory.createETSFunctionType( + property.typeAnnotation.typeParams, + property.typeAnnotation.params, + property.typeAnnotation.returnType, + false, + property.typeAnnotation.flags + ); + } + const newProperty = arkts.factory.createClassProperty( + arkts.factory.createIdentifier(name, undefined), + undefined, + stageManagementIdent.length ? createStageManagementType(stageManagementIdent, property) : + newType, + modifiers, + false + ); + return arkts.classPropertySetOptional(newProperty, true); +} + +export function createStageManagementType(stageManagementIdent: string, property: arkts.ClassProperty): arkts.ETSTypeReference { + let newType: arkts.TypeNode | undefined = property.typeAnnotation; + if (property.typeAnnotation && arkts.isETSFunctionType(property.typeAnnotation)) { + newType = arkts.factory.createETSFunctionType( + property.typeAnnotation.typeParams, + property.typeAnnotation.params, + property.typeAnnotation.returnType, + false, + property.typeAnnotation.flags + ); + } + return arkts.factory.createETSTypeReference( + arkts.factory.createETSTypeReferencePart( + arkts.factory.createIdentifier(stageManagementIdent, undefined), + arkts.factory.createTSTypeParameterInstantiation( + [ + newType? newType: + arkts.factory.createETSUndefinedType(), + ] + ), + undefined + ) + ); +} \ No newline at end of file diff --git a/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/tsconfig.json b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/tsconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..e636131aa76108979de50177e470b80eed1e1bc3 --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_mirror/ui2abc/ui-plugins/tsconfig.json @@ -0,0 +1,15 @@ +{ + "extends": "@koalaui/build-common/tsconfig.json", + "compilerOptions": { + "outDir": "build", + "baseUrl": ".", + "rootDir": ".", + "module": "CommonJS" + }, + "include": [ + "./src/**/*.ts", + ], + "references": [ + {"path": "../libarkts"} + ] +}