• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2024 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 "plugins/ets/runtime/interop_js/ets_proxy/ets_method_set.h"
17 
18 #include "plugins/ets/runtime/types/ets_method.h"
19 
20 #include <functional>
21 
22 namespace ark::ets::interop::js::ets_proxy {
23 
Create(EtsMethod * singleMethod)24 EtsMethodSet EtsMethodSet::Create(EtsMethod *singleMethod)
25 {
26     ASSERT(nullptr != singleMethod);
27     EtsClass *const enclosingClass = singleMethod->GetClass();
28 
29     return EtsMethodSet(singleMethod, enclosingClass);
30 }
31 
GetName() const32 const char *EtsMethodSet::GetName() const
33 {
34     ASSERT(anyMethod_ != nullptr);
35     return anyMethod_->GetName();
36 }
37 
MergeWith(const EtsMethodSet & other)38 void EtsMethodSet::MergeWith(const EtsMethodSet &other)
39 {
40     if (other.entries_.size() > entries_.size()) {
41         entries_.resize(other.entries_.size());
42     }
43     for (uint32_t i = 0; i < other.entries_.size(); ++i) {
44         EtsMethod *newMethod = other.entries_[i];
45         if (nullptr == newMethod) {
46             continue;
47         }
48         if (nullptr == entries_[i]) {
49             entries_[i] = other.entries_[i];
50         } else {
51             isValid_ = false;  // error: duplicate number of parameters
52         }
53     }
54 }
55 
56 }  // namespace ark::ets::interop::js::ets_proxy
57