1 /*
2  * Copyright (c) 2023 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 "bridge/common/utils/engine_helper.h"
17 
18 namespace OHOS::Ace {
19 std::shared_mutex EngineHelper::mutex_;
20 std::unordered_map<int32_t, WeakPtr<Framework::JsEngine>> EngineHelper::engineWeakMap_;
21 
ScopedDelegate(const RefPtr<Framework::FrontendDelegate> & delegate,int32_t id)22 ScopedDelegate::ScopedDelegate(const RefPtr<Framework::FrontendDelegate>& delegate, int32_t id)
23     : delegate_(delegate), scope_(new ContainerScope(id))
24 {}
25 
~ScopedDelegate()26 ScopedDelegate::~ScopedDelegate()
27 {
28     delete scope_;
29     scope_ = nullptr;
30 }
31 
AddEngine(int32_t id,WeakPtr<Framework::JsEngine> engine)32 void EngineHelper::AddEngine(int32_t id, WeakPtr<Framework::JsEngine> engine)
33 {
34     engineWeakMap_.emplace(id, engine);
35 }
36 
GetEngine(int32_t id)37 RefPtr<Framework::JsEngine> EngineHelper::GetEngine(int32_t id)
38 {
39     return nullptr;
40 }
41 
RemoveEngine(int32_t id)42 void EngineHelper::RemoveEngine(int32_t id)
43 {
44     engineWeakMap_.erase(id);
45 }
46 
GetCurrentEngine()47 RefPtr<Framework::JsEngine> EngineHelper::GetCurrentEngine()
48 {
49     return nullptr;
50 }
51 
GetCurrentEngineSafely()52 RefPtr<Framework::JsEngine> EngineHelper::GetCurrentEngineSafely()
53 {
54     return nullptr;
55 }
56 
GetCurrentDelegate()57 ScopedDelegate EngineHelper::GetCurrentDelegate()
58 {
59     return { nullptr, 0 };
60 }
61 
GetCurrentDelegateSafely()62 ScopedDelegate EngineHelper::GetCurrentDelegateSafely()
63 {
64     return { nullptr, 0 };
65 }
66 
StringToPair(const std::string & match)67 std::pair<int32_t, int32_t> EngineHelper::StringToPair(const std::string& match)
68 {
69     std::pair<int32_t, int32_t> res;
70     return res;
71 }
72 
GetPositionOnJsCode()73 std::pair<int32_t, int32_t> EngineHelper::GetPositionOnJsCode()
74 {
75     return { 0, 0 };
76 }
77 } // namespace OHOS::Ace
78