2
* Copyright (c) 2024 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
7
* http://www.apache.org/licenses/LICENSE-2.0
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.
16
let theModule: NativeModule
18
export function nativeModule(): NativeModule {
19
if (theModule) return theModule
21
theModule = new NativeModule()
25
export class NativeModule {
27
loadLibrary("NativeBridgeArk")
30
// TODO: shall be done in static initializer instead
31
static native init(): void;
35
static native _StringLength(arg1: long): int;
36
static native _StringData(arg1: long, arg2: byte[], arg3: int): void;
37
static native _StringMake(arg1: String): long;
38
static native _ManagedStringWrite(value: String, arg1: byte[], arg2: int): int;
39
static native _GetStringFinalizer(): long;
40
static native _InvokeFinalizer(arg1: long, arg2: long): void;
41
static native _GetNodeFinalizer(): long;
42
static native _GetPtrVectorSize(arg1: long): int;
43
static native _GetPtrVectorElement(arg1: long, arg2: int): long;
44
static native _GetGroupedLog(arg1: int): long;
45
static native _StartGroupedLog(arg1: int): void;
46
static native _StopGroupedLog(arg1: int): void;
47
static native _TestPerfNumber(arg1: int): int;
48
static native _TestPerfNumberWithArray(arg1: byte[], arg2: int): void;
49
static native _Test_TextPicker_OnAccept(valueArray: byte[], valueSerializerLength: int): void;
50
static native _StartPerf(traceName: String): void;
51
static native _EndPerf(traceName: String): void;
52
static native _DumpPerf(options: int): long;
53
static native _Test_SetEventsApi(): void;
54
static native _Test_List_OnScrollVisibleContentChange(valueArray: byte[], valueSerializerLength: int): void;
55
static native _Test_Common_OnChildTouchTest(valueArray: byte[], valueSerializerLength: int): void;
56
static native _GetNodeByViewStack(): long;
59
static native _CreateNode(type: int, id: int, flags: int): long
60
static native _DisposeNode(ptr: long): void
61
static native _ApplyModifierFinish(ptr: long): void
62
static native _Dump(nodePtr: long): void
63
static native _AddChild(parent: long, child: long): int
64
static native _RemoveChild(parent: long, child: long): void
65
static native _InsertChildAfter(parent: long, child: long, sibling: long): int
66
static native _InsertChildBefore(parent: long, child: long, sibling: long): int
67
static native _InsertChildAt(parent: long, child: long, position: int): int
68
static native _UnRegisterNodeAsyncEvent(nodePtr: long , kind: int ): void
69
static native _RegisterNodeAsyncEventReceiver(eventReceiver: long ): void
70
static native _UnRegisterNodeAsyncEventReceiver(): void
71
static native _MarkDirty( nodePtr:long, dirtyFlag:int): void
72
static native _IsBuilderNode( nodePtr:long): boolean
73
static native _ConvertLengthMetricsUnit(value: float, originUnit: int, targetUnit: int): float
76
static native _SetCustomCallback(node: long, callbackId: int): void
77
static native _MeasureLayoutAndDraw(root: long): void
78
static native _MeasureNode(root: long, data: float[]): int
79
static native _LayoutNode(root: long, data: float[]): int
80
static native _DrawNode(root: long, data: float[]): int
85
static native _SetMeasureWidth(root: long, value: int): void
86
static native _GetMeasureWidth(root: long): int
87
static native _SetMeasureHeight(root: long, value: int): void
88
static native _GetMeasureHeight(root: long): int
89
static native _SetX(root: long, value: int): void
90
static native _GetX(root: long): int
91
static native _SetY(root: long, value: int): void
92
static native _GetY(root: long): int
94
// getLayoutConstraint
96
static native _SetAlignment(root: long, value: int): void
97
static native _GetAlignment(root: long): int
99
static native _IndexerChecker(node: long): int
101
static native _SetRangeUpdater(node: long, updaterId: int): void
102
static native _SetLazyItemIndexer(node: long, indexerId: int): int
104
static native _SetVsyncCallback(long: long, callbackId: int): int
105
static native _UnblockVsyncWait(long: long): int
108
// _CheckArkoalaEvents -> checkEvent
109
static native _CheckEvents(result: int[], count: int): int
110
// _SendArkoalaEvent -> sedEvent
111
static native _SendEvent(event: int[], count: int): void
113
static native _SetChildTotalCount(ptr: long, value: int): void
116
static native _ShowCrash(messagePtr: String): void
118
static native _GetPipelineContext(nodePtr: long): long