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 LOGD("CreateJsEngineUsingSharedRuntime id:%{public}d", instanceId); 41 return AceType::MakeRefPtr<JsiDeclarativeEngine>(instanceId, runtime); 42 #else 43 return nullptr; 44 #endif 45 } 46 CreateCanvasBridge() const47RefPtr<BaseCanvasBridge> DeclarativeEngineLoader::CreateCanvasBridge() const 48 { 49 return nullptr; 50 } 51 CreateXComponentBridge() const52RefPtr<BaseXComponentBridge> DeclarativeEngineLoader::CreateXComponentBridge() const 53 { 54 return nullptr; 55 } 56 57 #if defined(BUILT_IN_JS_ENGINE) GetDeclarative(const char *)58JsEngineLoader& JsEngineLoader::GetDeclarative(const char*) 59 { 60 return DeclarativeEngineLoader::GetInstance(); 61 } 62 #else OHOS_ACE_GetJsEngineLoader()63extern "C" ACE_FORCE_EXPORT void* OHOS_ACE_GetJsEngineLoader() 64 { 65 return &DeclarativeEngineLoader::GetInstance(); 66 } 67 #endif 68 69 } // namespace OHOS::Ace::Framework