• 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 #ifndef CPP_ABCKIT_ARKTS_CLASS_IMPL_H
17 #define CPP_ABCKIT_ARKTS_CLASS_IMPL_H
18 
19 #include "class.h"
20 #include "annotation.h"
21 
22 // NOLINTBEGIN(performance-unnecessary-value-param)
23 namespace abckit::arkts {
24 
TargetCast()25 inline AbckitArktsClass *Class::TargetCast() const
26 {
27     auto ret = GetApiConfig()->cArktsIapi_->coreClassToArktsClass(GetView());
28     CheckError(GetApiConfig());
29     return ret;
30 }
31 
Class(const core::Class & coreOther)32 inline Class::Class(const core::Class &coreOther) : core::Class(coreOther), targetChecker_(this) {}
33 
RemoveAnnotation(arkts::Annotation anno)34 inline Class Class::RemoveAnnotation(arkts::Annotation anno) const
35 {
36     GetApiConfig()->cArktsMapi_->classRemoveAnnotation(TargetCast(), anno.TargetCast());
37     CheckError(GetApiConfig());
38     return *this;
39 }
40 
AddAnnotation(AnnotationInterface ai)41 inline Annotation Class::AddAnnotation(AnnotationInterface ai)
42 {
43     auto arktsCl = TargetCast();
44     auto arktsAi = ai.TargetCast();
45     const struct AbckitArktsAnnotationCreateParams params {
46         arktsAi
47     };
48     auto arktsAnno = GetApiConfig()->cArktsMapi_->classAddAnnotation(arktsCl, &params);
49     CheckError(GetApiConfig());
50     auto coreAnno = GetApiConfig()->cArktsIapi_->arktsAnnotationToCoreAnnotation(arktsAnno);
51     CheckError(GetApiConfig());
52     return Annotation(core::Annotation(coreAnno, GetApiConfig(), GetResource()));
53 }
54 
55 }  // namespace abckit::arkts
56 // NOLINTEND(performance-unnecessary-value-param)
57 
58 #endif  // CPP_ABCKIT_ARKTS_CLASS_IMPL_H
59