• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  *
4  * HDF is dual licensed: you can use it either under the terms of
5  * the GPL, or the BSD license, at your option.
6  * See the LICENSE file in the root of this repository for complete details.
7  */
8 
9 #ifndef OHOS_HDI_AST_ATTRIBUTE_H
10 #define OHOS_HDI_AST_ATTRIBUTE_H
11 
12 #include "ast/ast_node.h"
13 
14 namespace OHOS {
15 namespace HDI {
16 class ASTAttr : public ASTNode {
17 public:
18     using Attribute = uint32_t;
19     static constexpr Attribute NONE = 0U;
20     static constexpr Attribute MINI = 0x1U;
21     static constexpr Attribute LITE = 0x1U << 1;
22     static constexpr Attribute FULL = 0x1U << 2;
23     static constexpr Attribute ONEWAY = 0x1U << 3;
24     static constexpr Attribute CALLBACK = 0x1U << 4;
25 
value_(value)26     explicit ASTAttr(Attribute value = ASTAttr::NONE) : value_(value) {}
27 
28     std::string ToString() const override;
29 
30     std::string Dump(const std::string &prefix) override;
31 
SetValue(Attribute value)32     inline void SetValue(Attribute value)
33     {
34         value_ |= value;
35     }
36 
HasValue(Attribute attr)37     bool HasValue(Attribute attr) const
38     {
39         return (value_ & attr) != 0;
40     }
41 
42     bool Match(SystemLevel level) const;
43 
44 private:
45     Attribute value_;
46 };
47 
48 enum class ParamAttr {
49     PARAM_IN,
50     PARAM_OUT,
51 };
52 
53 class ASTParamAttr : public ASTNode {
54 public:
ASTParamAttr(ParamAttr value)55     explicit ASTParamAttr(ParamAttr value) : ASTNode(), value_(value) {}
56 
57     std::string ToString() const override;
58 
59     std::string Dump(const std::string &prefix) override;
60 
61 public:
62     ParamAttr value_;
63 };
64 } // namespace HDI
65 } // namespace OHOS
66 
67 #endif // OHOS_HDI_AST_ATTRIBUTE_H