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 #ifdef USE_ARK_ENGINE 32 return AceType::MakeRefPtr<JsiDeclarativeEngine>(instanceId); 33 #endif 34 } 35 CreateJsEngineUsingSharedRuntime(int32_t instanceId,void * runtime) const36RefPtr<JsEngine> DeclarativeEngineLoader::CreateJsEngineUsingSharedRuntime(int32_t instanceId, void* runtime) const 37 { 38 #ifdef USE_ARK_ENGINE 39 return AceType::MakeRefPtr<JsiDeclarativeEngine>(instanceId, runtime); 40 #else 41 return nullptr; 42 #endif 43 } 44 CreateCanvasBridge() const45RefPtr<BaseCanvasBridge> DeclarativeEngineLoader::CreateCanvasBridge() const 46 { 47 return nullptr; 48 } 49 CreateXComponentBridge() const50RefPtr<BaseXComponentBridge> DeclarativeEngineLoader::CreateXComponentBridge() const 51 { 52 return nullptr; 53 } 54 55 #if defined(BUILT_IN_JS_ENGINE) GetDeclarative(const char *)56JsEngineLoader& JsEngineLoader::GetDeclarative(const char*) 57 { 58 return DeclarativeEngineLoader::GetInstance(); 59 } 60 #else OHOS_ACE_GetJsEngineLoader()61extern "C" ACE_FORCE_EXPORT void* OHOS_ACE_GetJsEngineLoader() 62 { 63 return &DeclarativeEngineLoader::GetInstance(); 64 } 65 #endif 66 67 } // namespace OHOS::Ace::Framework