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/declarative_frontend/engine/declarative_engine_loader.h" 17 18 #include "base/utils/macros.h" 19 20 #ifdef USE_ARK_ENGINE 21 #include "frameworks/bridge/declarative_frontend/engine/jsi/jsi_declarative_engine.h" 22 #endif 23 24 namespace OHOS::Ace::Framework { 25 26 DeclarativeEngineLoader::DeclarativeEngineLoader() = default; 27 DeclarativeEngineLoader::~DeclarativeEngineLoader() = default; 28 CreateJsEngine(int32_t instanceId) const29RefPtr<JsEngine> DeclarativeEngineLoader::CreateJsEngine(int32_t instanceId) const 30 { 31 32 #ifdef USE_ARK_ENGINE 33 return AceType::MakeRefPtr<JsiDeclarativeEngine>(instanceId); 34 #endif 35 } 36 CreateJsEngineUsingSharedRuntime(int32_t instanceId,void * runtime) const37RefPtr<JsEngine> DeclarativeEngineLoader::CreateJsEngineUsingSharedRuntime(int32_t instanceId, void* runtime) const 38 { 39 #ifdef USE_ARK_ENGINE 40 return AceType::MakeRefPtr<JsiDeclarativeEngine>(instanceId, runtime); 41 #else 42 return nullptr; 43 #endif 44 } 45 CreateCanvasBridge() const46RefPtr<BaseCanvasBridge> DeclarativeEngineLoader::CreateCanvasBridge() const 47 { 48 return nullptr; 49 } 50 CreateXComponentBridge() const51RefPtr<BaseXComponentBridge> DeclarativeEngineLoader::CreateXComponentBridge() const 52 { 53 return nullptr; 54 } 55 56 #if defined(BUILT_IN_JS_ENGINE) GetDeclarative(const char *)57JsEngineLoader& JsEngineLoader::GetDeclarative(const char*) 58 { 59 return DeclarativeEngineLoader::GetInstance(); 60 } 61 #else OHOS_ACE_GetJsEngineLoader()62extern "C" ACE_FORCE_EXPORT void* OHOS_ACE_GetJsEngineLoader() 63 { 64 return &DeclarativeEngineLoader::GetInstance(); 65 } 66 #endif 67 68 } // namespace OHOS::Ace::Framework