1 /*
2  * Copyright (c) 2021 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 FOUNDATION_ACE_FRAMEWORKS_DECLARATIVE_FRONTEND_ENGINE_BINDINGS_DEFINES_H
17 #define FOUNDATION_ACE_FRAMEWORKS_DECLARATIVE_FRONTEND_ENGINE_BINDINGS_DEFINES_H
18 
19 #include "frameworks/bridge/declarative_frontend/engine/js_types.h"
20 
21 enum class JavascriptEngine { NONE, ARK };
22 
23 #ifdef USE_ARK_ENGINE
24 
25 #include "ecmascript/napi/include/jsnapi.h"
26 
27 using BindingTarget = panda::Local<panda::ObjectRef>;
28 using FunctionCallback = panda::Local<panda::JSValueRef>(*)(panda::JsiRuntimeCallInfo*);
29 using FunctionGetCallback = panda::Local<panda::JSValueRef>(*)(panda::JsiRuntimeCallInfo*);
30 using FunctionSetCallback = panda::Local<panda::JSValueRef>(*)(panda::JsiRuntimeCallInfo*);
31 template<typename T>
32 using MemberFunctionCallback = panda::Local<panda::JSValueRef>(T::*)(panda::JsiRuntimeCallInfo*);
33 template<typename T>
34 using MemberFunctionGetCallback = panda::Local<panda::JSValueRef>(T::*)(panda::JsiRuntimeCallInfo*);
35 template<typename T>
36 using MemberFunctionSetCallback = panda::Local<panda::JSValueRef>(T::*)(panda::JsiRuntimeCallInfo*);
37 using ExoticGetterCallback = int;
38 using ExoticSetterCallback = int;
39 using ExoticHasPropertyCallback = int;
40 using ExoticIsArrayCallback = int;
41 
42 constexpr const JavascriptEngine cCurrentJSEngine = JavascriptEngine::ARK;
43 
44 #else
45 #error "No engine selected"
46 #endif
47 
48 using JSFunctionCallback = void (*)(const OHOS::Ace::Framework::JSCallbackInfo&);
49 template<typename T>
50 using JSMemberFunctionCallback = void (T::*)(const OHOS::Ace::Framework::JSCallbackInfo&);
51 template<typename T>
52 using JSDestructorCallback = void (*)(T* instance);
53 template<typename T>
54 using JSGCMarkCallback = void (*)(T* instance, const OHOS::Ace::Framework::JSGCMarkCallbackInfo&);
55 
56 #endif
57