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 "base/utils/macros.h" 19 #include "frameworks/bridge/js_frontend/engine/jsi/jsi_canvas_bridge.h" 20 #include "frameworks/bridge/js_frontend/engine/jsi/jsi_engine.h" 21 #include "frameworks/bridge/js_frontend/engine/jsi/jsi_xcomponent_bridge.h" 22 23 namespace OHOS::Ace::Framework { 24 25 JsiEngineLoader::JsiEngineLoader() = default; 26 JsiEngineLoader::~JsiEngineLoader() = default; 27 CreateJsEngine(int32_t instanceId) const28RefPtr<JsEngine> JsiEngineLoader::CreateJsEngine(int32_t instanceId) const 29 { 30 return AceType::MakeRefPtr<JsiEngine>(instanceId); 31 } 32 CreateCanvasBridge() const33RefPtr<BaseCanvasBridge> JsiEngineLoader::CreateCanvasBridge() const 34 { 35 return AceType::MakeRefPtr<JsiCanvasBridge>(); 36 } 37 CreateXComponentBridge() const38RefPtr<BaseXComponentBridge> JsiEngineLoader::CreateXComponentBridge() const 39 { 40 #ifdef XCOMPONENT_SUPPORTED 41 return AceType::MakeRefPtr<JsiXComponentBridge>(); 42 #else 43 return nullptr; 44 #endif 45 } 46 47 #if defined(BUILT_IN_JS_ENGINE) Get(const char *)48JsEngineLoader& JsEngineLoader::Get(const char*) 49 { 50 return JsiEngineLoader::GetInstance(); 51 } 52 #else OHOS_ACE_GetJsEngineLoader()53extern "C" ACE_FORCE_EXPORT void* OHOS_ACE_GetJsEngineLoader() 54 { 55 return &JsiEngineLoader::GetInstance(); 56 } 57 #endif 58 59 } // namespace OHOS::Ace::Framework 60