• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024-2025 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 #ifndef CPP_ABCKIT_ARKTS_FUNCTION_IMPL_H
17 #define CPP_ABCKIT_ARKTS_FUNCTION_IMPL_H
18 
19 #include "function.h"
20 #include "annotation.h"
21 #include "../core/annotation.h"
22 #include "annotation_interface.h"
23 
24 // NOLINTBEGIN(performance-unnecessary-value-param)
25 namespace abckit::arkts {
26 
TargetCast()27 inline AbckitArktsFunction *Function::TargetCast() const
28 {
29     auto ret = GetApiConfig()->cArktsIapi_->coreFunctionToArktsFunction(GetView());
30     CheckError(GetApiConfig());
31     return ret;
32 }
33 
Function(const core::Function & other)34 inline Function::Function(const core::Function &other) : core::Function(other), targetChecker_(this) {};
35 
IsNative()36 inline bool Function::IsNative() const
37 {
38     auto arktsFunc = GetApiConfig()->cArktsIapi_->coreFunctionToArktsFunction(GetView());
39     CheckError(GetApiConfig());
40     auto arktsIsNative = GetApiConfig()->cArktsIapi_->functionIsNative(arktsFunc);
41     CheckError(GetApiConfig());
42     return arktsIsNative;
43 }
44 
AddAnnotation(AnnotationInterface ai)45 inline Annotation Function::AddAnnotation(AnnotationInterface ai) const
46 {
47     const struct AbckitArktsAnnotationCreateParams params {
48         ai.TargetCast()
49     };
50     auto arktsAnno = GetApiConfig()->cArktsMapi_->functionAddAnnotation(TargetCast(), &params);
51     CheckError(GetApiConfig());
52     auto coreAnno = GetApiConfig()->cArktsIapi_->arktsAnnotationToCoreAnnotation(arktsAnno);
53     CheckError(GetApiConfig());
54     return Annotation(core::Annotation(coreAnno, GetApiConfig(), GetResource()));
55 }
56 
RemoveAnnotation(Annotation anno)57 inline Function Function::RemoveAnnotation(Annotation anno) const
58 {
59     GetApiConfig()->cArktsMapi_->functionRemoveAnnotation(TargetCast(), anno.TargetCast());
60     CheckError(GetApiConfig());
61     return *this;
62 }
63 
64 }  // namespace abckit::arkts
65 // NOLINTEND(performance-unnecessary-value-param)
66 
67 #endif  // CPP_ABCKIT_ARKTS_FUNCTION_IMPL_H
68