15
#include "Serializers.h"
16
#include "arkoala-logging.h"
17
#include "common-interop.h"
18
#include "arkoala-macros.h"
20
typedef void (*AppendGroupedLogSignature)(int32_t, const std::string&);
22
AppendGroupedLogSignature appendGroupedLogPtr = nullptr;
24
void SetAppendGroupedLog(void* logger) {
25
if (logger) appendGroupedLogPtr = reinterpret_cast<AppendGroupedLogSignature>(logger);
28
void dummyClassFinalizer(KNativePointer* ptr) {
30
std::snprintf(hex, sizeof(hex), "0x%llx", (long long)ptr);
31
string out("dummyClassFinalizer(");
34
appendGroupedLog(1, out);
37
namespace OHOS::Ace::NG {
39
Ark_NodeHandle CreateNode(GENERATED_Ark_NodeType type, Ark_Int32 id, Ark_Int32 flags) {
40
static uintptr_t peer_num = 1;
41
Ark_NodeHandle result = (Ark_NodeHandle) peer_num++;
43
if (needGroupedLog(2)) {
45
_logData.append(" Ark_NodeHandle peer" + std::to_string((uintptr_t)result) + " = GetBasicNodeApi()->createNode(GENERATED_Ark_NodeType("
46
+ std::to_string(type) + "), " + std::to_string(id) + ", " + std::to_string(flags) + ");\n");
47
appendGroupedLog(2, _logData);
50
if (!needGroupedLog(1)) {
53
string out("createNode(");
54
WriteToString(&out, (Ark_Int32)type);
56
WriteToString(&out, id);
58
WriteToString(&out, flags);
60
appendGroupedLog(1, out);
64
void SetCallbackMethod(%CPP_PREFIX%Ark_APICallbackMethod* method) {}
65
void RegisterCustomNodeEventReceiver(%CPP_PREFIX%CustomEventReceiver eventReceiver) {}
66
int CheckEvent(%CPP_PREFIX%Ark_NodeEvent* event) {
69
void SendAsyncEvent(%CPP_PREFIX%Ark_NodeEvent* event) {}
70
void CallContinuation(Ark_Int32 continuationId, Ark_Int32 argCount, %CPP_PREFIX%Ark_EventCallbackArg* args) {}
73
Ark_Float32 GetDensity(Ark_Int32 deviceId) {
74
Ark_Float32 result = 1.0f;
76
if (!needGroupedLog(1)) {
80
string out("getDensity(");
81
WriteToString(&out, deviceId);
83
appendGroupedLog(1, out);
88
Ark_Float32 GetFontScale(Ark_Int32 deviceId) {
89
Ark_Float32 result = 1.0f;
91
if (!needGroupedLog(1)) {
95
string out("getFontScale(");
96
WriteToString(&out, deviceId);
98
appendGroupedLog(1, out);
103
Ark_Float32 GetDesignWidthScale(Ark_Int32 deviceId) {
104
Ark_Float32 result = 1.0f;
106
if (!needGroupedLog(1)) {
110
string out("getDesignWidthScale(");
111
WriteToString(&out, deviceId);
113
appendGroupedLog(1, out);
119
Ark_NodeHandle GetNodeByViewStack() {
120
Ark_NodeHandle result = (Ark_NodeHandle) 234;
121
if (!needGroupedLog(1)) {
124
string out("getNodeByViewStack()");
125
appendGroupedLog(1, out);
129
void DisposeNode(Ark_NodeHandle node) {
130
if (!needGroupedLog(1)) {
134
string out("disposeNode(");
135
WriteToString(&out, node);
137
appendGroupedLog(1, out);
140
Ark_Int32 AddChild(Ark_NodeHandle parent, Ark_NodeHandle child) {
141
if (!needGroupedLog(1)) {
145
string out("addChild(");
146
WriteToString(&out, parent);
148
WriteToString(&out, child);
150
appendGroupedLog(1, out);
156
void RemoveChild(Ark_NodeHandle parent, Ark_NodeHandle child) {
157
if (!needGroupedLog(1)) {
161
string out("removeChild(");
162
WriteToString(&out, parent);
164
WriteToString(&out, child);
166
appendGroupedLog(1, out);
169
Ark_Int32 InsertChildAfter(Ark_NodeHandle parent, Ark_NodeHandle child, Ark_NodeHandle sibling) {
170
if (!needGroupedLog(1)) {
174
string out("insertChildAfter(");
175
WriteToString(&out, parent);
177
WriteToString(&out, child);
179
WriteToString(&out, sibling);
181
appendGroupedLog(1, out);
185
Ark_Int32 InsertChildBefore(Ark_NodeHandle parent, Ark_NodeHandle child, Ark_NodeHandle sibling) {
186
if (!needGroupedLog(1)) {
190
string out("insertChildBefore(");
191
WriteToString(&out, parent);
193
WriteToString(&out, child);
195
WriteToString(&out, sibling);
197
appendGroupedLog(1, out);
201
Ark_Int32 InsertChildAt(Ark_NodeHandle parent, Ark_NodeHandle child, Ark_Int32 position) {
202
if (!needGroupedLog(1)) {
206
string out("insertChildAt(");
207
WriteToString(&out, parent);
209
WriteToString(&out, child);
211
WriteToString(&out, position);
213
appendGroupedLog(1, out);
217
void ApplyModifierFinish(Ark_NodeHandle node) {
218
if (!needGroupedLog(1)) {
221
string out("applyModifierFinish(");
222
WriteToString(&out, node);
224
appendGroupedLog(1, out);
227
void MarkDirty(Ark_NodeHandle node, Ark_UInt32 flag) {
228
if (!needGroupedLog(1)) {
231
string out("markDirty(");
232
WriteToString(&out, node);
234
WriteToString(&out, flag);
236
appendGroupedLog(1, out);
239
Ark_Boolean IsBuilderNode(Ark_NodeHandle node) {
240
Ark_Boolean result = true;
241
if (!needGroupedLog(1)) {
244
string out("isBuilderNode(");
245
WriteToString(&out, node);
247
appendGroupedLog(1, out);
251
Ark_Float32 ConvertLengthMetricsUnit(Ark_Float32 value, Ark_Int32 originUnit, Ark_Int32 targetUnit) {
252
Ark_Float32 result = value * originUnit;
253
if (!needGroupedLog(1)) {
257
string out("convertLengthMetricsUnit(");
258
WriteToString(&out, value);
260
WriteToString(&out, originUnit);
262
WriteToString(&out, targetUnit);
264
appendGroupedLog(1, out);
268
void SetCustomMethodFlag(Ark_NodeHandle node, Ark_Int32 flag) {}
269
Ark_Int32 GetCustomMethodFlag(Ark_NodeHandle node) {
272
void RegisterCustomNodeAsyncEvent(Ark_NodeHandle node, Ark_Int32 eventType, void* extraParam) {}
273
Ark_Int32 UnregisterCustomNodeEvent(Ark_NodeHandle node, Ark_Int32 eventType) {
277
void SetCustomCallback(Ark_VMContext context, Ark_NodeHandle node, Ark_Int32 callback) {}
279
Ark_Int32 MeasureLayoutAndDraw(Ark_VMContext vmContext, Ark_NodeHandle rootPtr) {
283
Ark_Int32 MeasureNode(Ark_VMContext vmContext, Ark_NodeHandle node, Ark_Float32* data) {
287
Ark_Int32 LayoutNode(Ark_VMContext vmContext, Ark_NodeHandle node, Ark_Float32* data) {
291
Ark_Int32 DrawNode(Ark_VMContext vmContext, Ark_NodeHandle node, Ark_Float32* data) {
295
void SetAttachNodePtr(Ark_NodeHandle node, void* value) {}
296
void* GetAttachNodePtr(Ark_NodeHandle node) {
299
void SetMeasureWidth(Ark_NodeHandle node, Ark_Int32 value) {}
301
Ark_Int32 GetMeasureWidth(Ark_NodeHandle node) {
305
void SetMeasureHeight(Ark_NodeHandle node, Ark_Int32 value) {}
306
Ark_Int32 GetMeasureHeight(Ark_NodeHandle node) {
309
void SetX(Ark_NodeHandle node, Ark_Int32 value) {}
310
void SetY(Ark_NodeHandle node, Ark_Int32 value) {}
311
Ark_Int32 GetX(Ark_NodeHandle node) {
314
Ark_Int32 GetY(Ark_NodeHandle node) {
317
void SetAlignment(Ark_NodeHandle node, Ark_Int32 value) {}
318
Ark_Int32 GetAlignment(Ark_NodeHandle node) {
321
void GetLayoutConstraint(Ark_NodeHandle node, Ark_Int32* value) {}
322
Ark_Int32 IndexerChecker(Ark_VMContext vmContext, Ark_NodeHandle nodePtr) {
325
void SetRangeUpdater(Ark_NodeHandle nodePtr, Ark_Int32 updaterId) {}
326
void SetLazyItemIndexer(Ark_VMContext vmContext, Ark_NodeHandle nodePtr, Ark_Int32 indexerId) {}
327
Ark_PipelineContext GetPipelineContext(Ark_NodeHandle node) {
330
void SetVsyncCallback(Ark_VMContext vmContext, Ark_PipelineContext pipelineContext, Ark_Int32 callbackId) {}
331
void UnblockVsyncWait(Ark_VMContext vmContext, Ark_PipelineContext pipelineContext) {}
332
void SetChildTotalCount(Ark_NodeHandle node, Ark_Int32 totalCount) {}
333
void ShowCrash(Ark_CharPtr message) {}
336
namespace GeneratedEvents {
337
const %CPP_PREFIX%ArkUIEventsAPI* g_OverriddenEventsImpl = nullptr;
338
const %CPP_PREFIX%ArkUIEventsAPI* %CPP_PREFIX%GetArkUiEventsAPI() { return g_OverriddenEventsImpl; }
339
void %CPP_PREFIX%SetArkUiEventsAPI(const %CPP_PREFIX%ArkUIEventsAPI* api) { g_OverriddenEventsImpl = api; }