• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022-2025 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import { int32 } from "@koalaui/common";
17import { KPointer, KUint8ArrayPtr, KInt } from "./InteropTypes";
18import { callCallback } from "./callback"
19import { loadNativeModuleLibrary } from "./loadLibraries"
20
21export class InteropNativeModule {
22    static {
23        loadNativeModuleLibrary("InteropNativeModule")
24    }
25    static callCallbackFromNative(id: KInt, args: KUint8ArrayPtr, length: KInt): KInt {
26        return callCallback(id, args, length)
27    }
28    native static _GetGroupedLog(index: int32): KPointer
29    native static _StartGroupedLog(index: int32): void
30    native static _StopGroupedLog(index: int32): void
31    native static _AppendGroupedLog(index: int32, message: string): void
32    native static _PrintGroupedLog(index: int32): void
33    native static _GetStringFinalizer(): KPointer
34    native static _InvokeFinalizer(ptr1: KPointer, ptr2: KPointer): void
35    native static _GetPtrVectorElement(ptr1: KPointer, arg: int32): KPointer
36    native static _StringLength(ptr1: KPointer): int32
37    native static _StringData(ptr1: KPointer, arr: KUint8ArrayPtr, i: int32): void
38    native static _StringMake(str1: string): KPointer
39    native static _GetPtrVectorSize(ptr1: KPointer): int32
40    native static _ManagedStringWrite(str1: string, arr: KUint8ArrayPtr, arg: int32): int32
41    native static _NativeLog(str1: string): void
42    native static _Utf8ToString(data: KUint8ArrayPtr, offset: int32, length: int32): string
43    native static _StdStringToString(cstring: KPointer): string
44    native static _CheckCallbackEvent(buffer: KUint8ArrayPtr, bufferLength: int32): int32
45    native static _HoldCallbackResource(resourceId: int32): void
46    native static _ReleaseCallbackResource(resourceId: int32): void
47    native static _CallCallback(callbackKind: int32, args: KUint8ArrayPtr, argsSize: int32): void
48    native static _CallCallbackSync(callbackKind: int32, args: KUint8ArrayPtr, argsSize: int32): void
49    native static _CallCallbackResourceHolder(holder: KPointer, resourceId: int32): void
50    native static _CallCallbackResourceReleaser(releaser: KPointer, resourceId: int32): void
51    native static _LoadVirtualMachine(arg0: int32, arg1: string, arg2: string): int32
52    native static _RunApplication(arg0: int32, arg1: int32): boolean
53    native static _StartApplication(appUrl: string, appParams: string): KPointer
54    native static _EmitEvent(eventType: int32, target: int32, arg0: int32, arg1: int32): void
55    native static _CallForeignVM(context:KPointer, callback: int32, data: KUint8ArrayPtr, dataLength: int32): int32
56    native static _RestartWith(page: string): void
57}
58
59