idlize

Форк
0
/
dummy_impl_prologue.cc 
341 строка · 9.3 Кб
1
/*
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
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
#include "Serializers.h"
16
#include "arkoala-logging.h"
17
#include "common-interop.h"
18
#include "arkoala-macros.h"
19

20
typedef void (*AppendGroupedLogSignature)(int32_t, const std::string&);
21

22
AppendGroupedLogSignature appendGroupedLogPtr = nullptr;
23

24
void SetAppendGroupedLog(void* logger) {
25
    if (logger) appendGroupedLogPtr = reinterpret_cast<AppendGroupedLogSignature>(logger);
26
}
27

28
void dummyClassFinalizer(KNativePointer* ptr) {
29
    char hex[20];
30
    std::snprintf(hex, sizeof(hex), "0x%llx", (long long)ptr);
31
    string out("dummyClassFinalizer(");
32
    out.append(hex);
33
    out.append(")");
34
    appendGroupedLog(1, out);
35
}
36

37
namespace OHOS::Ace::NG {
38
namespace Bridge {
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++;
42

43
    if (needGroupedLog(2)) {
44
        std::string _logData;
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);
48
    }
49

50
    if (!needGroupedLog(1)) {
51
        return result;
52
    }
53
    string out("createNode(");
54
    WriteToString(&out, (Ark_Int32)type);
55
    out.append(", ");
56
    WriteToString(&out, id);
57
    out.append(", ");
58
    WriteToString(&out, flags);
59
    out.append(")");
60
    appendGroupedLog(1, out);
61
    return result;
62
}
63

64
void SetCallbackMethod(%CPP_PREFIX%Ark_APICallbackMethod* method) {}
65
void RegisterCustomNodeEventReceiver(%CPP_PREFIX%CustomEventReceiver eventReceiver) {}
66
int CheckEvent(%CPP_PREFIX%Ark_NodeEvent* event) {
67
    return 0;
68
}
69
void SendAsyncEvent(%CPP_PREFIX%Ark_NodeEvent* event) {}
70
void CallContinuation(Ark_Int32 continuationId, Ark_Int32 argCount, %CPP_PREFIX%Ark_EventCallbackArg* args) {}
71
}
72

73
Ark_Float32 GetDensity(Ark_Int32 deviceId) {
74
    Ark_Float32 result = 1.0f;
75

76
    if (!needGroupedLog(1)) {
77
        return result;
78
    }
79

80
    string out("getDensity(");
81
    WriteToString(&out, deviceId);
82
    out.append(")");
83
    appendGroupedLog(1, out);
84

85
    return result;
86
}
87

88
Ark_Float32 GetFontScale(Ark_Int32 deviceId) {
89
    Ark_Float32 result = 1.0f;
90

91
    if (!needGroupedLog(1)) {
92
        return result;
93
    }
94

95
    string out("getFontScale(");
96
    WriteToString(&out, deviceId);
97
    out.append(")");
98
    appendGroupedLog(1, out);
99

100
    return result;
101
}
102

103
Ark_Float32 GetDesignWidthScale(Ark_Int32 deviceId) {
104
    Ark_Float32 result = 1.0f;
105

106
    if (!needGroupedLog(1)) {
107
        return result;
108
    }
109

110
    string out("getDesignWidthScale(");
111
    WriteToString(&out, deviceId);
112
    out.append(")");
113
    appendGroupedLog(1, out);
114

115
    return result;
116
}
117

118
namespace ApiImpl {
119
Ark_NodeHandle GetNodeByViewStack() {
120
    Ark_NodeHandle result = (Ark_NodeHandle) 234;
121
    if (!needGroupedLog(1)) {
122
        return result;
123
    }
124
    string out("getNodeByViewStack()");
125
    appendGroupedLog(1, out);
126
    return result;
127
}
128

129
void DisposeNode(Ark_NodeHandle node) {
130
    if (!needGroupedLog(1)) {
131
        return;
132
    }
133

134
    string out("disposeNode(");
135
    WriteToString(&out, node);
136
    out.append(")");
137
    appendGroupedLog(1, out);
138
}
139

140
Ark_Int32 AddChild(Ark_NodeHandle parent, Ark_NodeHandle child) {
141
    if (!needGroupedLog(1)) {
142
        return 0;
143
    }
144

145
    string out("addChild(");
146
    WriteToString(&out, parent);
147
    out.append(", ");
148
    WriteToString(&out, child);
149
    out.append(")");
150
    appendGroupedLog(1, out);
151

152
    // TODO: implement test
153
    return 0; // ERROR_CODE_NO_ERROR
154
}
155

156
void RemoveChild(Ark_NodeHandle parent, Ark_NodeHandle child) {
157
    if (!needGroupedLog(1)) {
158
        return;
159
    }
160

161
    string out("removeChild(");
162
    WriteToString(&out, parent);
163
    out.append(", ");
164
    WriteToString(&out, child);
165
    out.append(")");
166
    appendGroupedLog(1, out);
167
}
168

169
Ark_Int32 InsertChildAfter(Ark_NodeHandle parent, Ark_NodeHandle child, Ark_NodeHandle sibling) {
170
    if (!needGroupedLog(1)) {
171
        return 0;
172
    }
173

174
    string out("insertChildAfter(");
175
    WriteToString(&out, parent);
176
    out.append(", ");
177
    WriteToString(&out, child);
178
    out.append(", ");
179
    WriteToString(&out, sibling);
180
    out.append(")");
181
    appendGroupedLog(1, out);
182
    return 0;
183
}
184

185
Ark_Int32 InsertChildBefore(Ark_NodeHandle parent, Ark_NodeHandle child, Ark_NodeHandle sibling) {
186
    if (!needGroupedLog(1)) {
187
        return 0;
188
    }
189

190
    string out("insertChildBefore(");
191
    WriteToString(&out, parent);
192
    out.append(", ");
193
    WriteToString(&out, child);
194
    out.append(", ");
195
    WriteToString(&out, sibling);
196
    out.append(")");
197
    appendGroupedLog(1, out);
198
    return 0;
199
}
200

201
Ark_Int32 InsertChildAt(Ark_NodeHandle parent, Ark_NodeHandle child, Ark_Int32 position) {
202
    if (!needGroupedLog(1)) {
203
        return 0;
204
    }
205

206
    string out("insertChildAt(");
207
    WriteToString(&out, parent);
208
    out.append(", ");
209
    WriteToString(&out, child);
210
    out.append(", ");
211
    WriteToString(&out, position);
212
    out.append(")");
213
    appendGroupedLog(1, out);
214
    return 0;
215
}
216

217
void ApplyModifierFinish(Ark_NodeHandle node) {
218
    if (!needGroupedLog(1)) {
219
        return;
220
    }
221
    string out("applyModifierFinish(");
222
    WriteToString(&out, node);
223
    out.append(")");
224
    appendGroupedLog(1, out);
225
}
226

227
void MarkDirty(Ark_NodeHandle node, Ark_UInt32 flag) {
228
    if (!needGroupedLog(1)) {
229
        return;
230
    }
231
    string out("markDirty(");
232
    WriteToString(&out, node);
233
    out.append(", ");
234
    WriteToString(&out, flag);
235
    out.append(")");
236
    appendGroupedLog(1, out);
237
}
238

239
Ark_Boolean IsBuilderNode(Ark_NodeHandle node) {
240
    Ark_Boolean result = true;
241
    if (!needGroupedLog(1)) {
242
        return result;
243
    }
244
    string out("isBuilderNode(");
245
    WriteToString(&out, node);
246
    out.append(")");
247
    appendGroupedLog(1, out);
248
    return result;
249
}
250

251
Ark_Float32 ConvertLengthMetricsUnit(Ark_Float32 value, Ark_Int32 originUnit, Ark_Int32 targetUnit) {
252
    Ark_Float32 result = value * originUnit;
253
    if (!needGroupedLog(1)) {
254
        return result;
255
    }
256

257
    string out("convertLengthMetricsUnit(");
258
    WriteToString(&out, value);
259
    out.append(", ");
260
    WriteToString(&out, originUnit);
261
    out.append(", ");
262
    WriteToString(&out, targetUnit);
263
    out.append(")");
264
    appendGroupedLog(1, out);
265
    return result;
266
}
267

268
void SetCustomMethodFlag(Ark_NodeHandle node, Ark_Int32 flag) {}
269
Ark_Int32 GetCustomMethodFlag(Ark_NodeHandle node) {
270
    return 0;
271
}
272
void RegisterCustomNodeAsyncEvent(Ark_NodeHandle node, Ark_Int32 eventType, void* extraParam) {}
273
Ark_Int32 UnregisterCustomNodeEvent(Ark_NodeHandle node, Ark_Int32 eventType) {
274
    return 0;
275
}
276

277
void SetCustomCallback(Ark_VMContext context, Ark_NodeHandle node, Ark_Int32 callback) {}
278

279
Ark_Int32 MeasureLayoutAndDraw(Ark_VMContext vmContext, Ark_NodeHandle rootPtr) {
280
    return 0;
281
}
282

283
Ark_Int32 MeasureNode(Ark_VMContext vmContext, Ark_NodeHandle node, Ark_Float32* data) {
284
    return 0;
285
}
286

287
Ark_Int32 LayoutNode(Ark_VMContext vmContext, Ark_NodeHandle node, Ark_Float32* data) {
288
    return 0;
289
}
290

291
Ark_Int32 DrawNode(Ark_VMContext vmContext, Ark_NodeHandle node, Ark_Float32* data) {
292
    return 0;
293
}
294

295
void SetAttachNodePtr(Ark_NodeHandle node, void* value) {}
296
void* GetAttachNodePtr(Ark_NodeHandle node) {
297
    return nullptr;
298
}
299
void SetMeasureWidth(Ark_NodeHandle node, Ark_Int32 value) {}
300

301
Ark_Int32 GetMeasureWidth(Ark_NodeHandle node) {
302
    return 0;
303
}
304

305
void SetMeasureHeight(Ark_NodeHandle node, Ark_Int32 value) {}
306
Ark_Int32 GetMeasureHeight(Ark_NodeHandle node) {
307
    return 0;
308
}
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) {
312
    return 0;
313
}
314
Ark_Int32 GetY(Ark_NodeHandle node) {
315
    return 0;
316
}
317
void SetAlignment(Ark_NodeHandle node, Ark_Int32 value) {}
318
Ark_Int32 GetAlignment(Ark_NodeHandle node) {
319
    return 0;
320
}
321
void GetLayoutConstraint(Ark_NodeHandle node, Ark_Int32* value) {}
322
Ark_Int32 IndexerChecker(Ark_VMContext vmContext, Ark_NodeHandle nodePtr) {
323
    return 0;
324
}
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) {
328
    return nullptr;
329
}
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) {}
334
}
335

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; }
340
}
341
}

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.