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