1 /* 2 * Copyright (c) 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 16 #ifndef COMMON_INTEROP_BASE_H 17 #define COMMON_INTEROP_BASE_H 18 19 #include <vector> 20 21 #include "panda_types.h" 22 23 // NOLINTBEGIN 24 25 #define TS_INTEROP_PROFILER 0 26 #define TS_INTEROP_TRACER 0 27 28 #if TS_INTEROP_PROFILER 29 #include "profiler.h" 30 // CC-OFFNXT(G.PRE.09) code gen 31 #define TS_INTEROP_LOGGER(name) InteropMethodCall logger(#name); 32 #endif 33 34 #if TS_INTEROP_TRACER 35 #include "tracer.h" 36 // CC-OFFNXT(G.PRE.09) code gen 37 #define TS_INTEROP_LOGGER(name) InteropMethodCall logger(#name); 38 #endif 39 40 #ifdef TS_INTEROP_LOGGER 41 // CC-OFFNXT(G.PRE.09) code gen 42 #define TS_MAYBE_LOG(name) TS_INTEROP_LOGGER(name); 43 #else 44 // CC-OFFNXT(G.PRE.02) code gen 45 #define TS_MAYBE_LOG(name) 46 #endif 47 48 typedef void (*CallbackCallert)(KInt callbackKind, KByte *argsData, KInt argsLength); 49 typedef void (*CallbackCallerSynct)(KVMContext vmContext, KInt callbackKind, KByte *argsData, KInt argsLength); 50 void SetCallbackCaller(CallbackCallert caller); 51 void SetCallbackCallerSync(CallbackCallerSynct callerSync); 52 53 KVMDeferred *CreateDeferred(KVMContext context, KVMObjectHandle *promise); 54 55 // CC-OFFNXT(G.NAM.01) false positive 56 std::vector<KStringPtr> MakeStringVector(KStringArray strArray); 57 // CC-OFFNXT(G.NAM.01) false positive 58 std::vector<KStringPtr> MakeStringVector(KNativePointerArray arr, KInt size); 59 60 #include "convertors-napi.h" 61 62 // NOLINTEND 63 64 #endif // COMMON_INTEROP_BASE_H 65