• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "frameworks/bridge/js_frontend/engine/jsi/jsi_engine_loader.h"
17 
18 #include "frameworks/bridge/js_frontend/engine/jsi/jsi_canvas_bridge.h"
19 #include "frameworks/bridge/js_frontend/engine/jsi/jsi_xcomponent_bridge.h"
20 
21 namespace OHOS::Ace::Framework {
22 
23 JsiEngineLoader::JsiEngineLoader() = default;
24 JsiEngineLoader::~JsiEngineLoader() = default;
25 
CreateJsEngine(int32_t instanceId) const26 RefPtr<JsEngine> JsiEngineLoader::CreateJsEngine(int32_t instanceId) const
27 {
28     return AceType::MakeRefPtr<JsiEngine>(instanceId);
29 }
30 
CreateCanvasBridge() const31 RefPtr<BaseCanvasBridge> JsiEngineLoader::CreateCanvasBridge() const
32 {
33     return AceType::MakeRefPtr<JsiCanvasBridge>();
34 }
35 
CreateXComponentBridge() const36 RefPtr<BaseXComponentBridge> JsiEngineLoader::CreateXComponentBridge() const
37 {
38 #ifdef XCOMPONENT_SUPPORTED
39     return AceType::MakeRefPtr<JsiXComponentBridge>();
40 #else
41     return nullptr;
42 #endif
43 }
44 
45 #if defined(BUILT_IN_JS_ENGINE)
Get(const char *)46 JsEngineLoader& JsEngineLoader::Get(const char*)
47 {
48     return JsiEngineLoader::GetInstance();
49 }
50 #else
OHOS_ACE_GetJsEngineLoader()51 extern "C" ACE_FORCE_EXPORT void* OHOS_ACE_GetJsEngineLoader()
52 {
53     return &JsiEngineLoader::GetInstance();
54 }
55 #endif
56 
57 } // namespace OHOS::Ace::Framework
58