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 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 GetValue()37 inline Attribute GetValue() const 38 { 39 return value_; 40 } 41 HasValue(Attribute attr)42 bool HasValue(Attribute attr) const 43 { 44 return (value_ & attr) != 0; 45 } 46 47 bool Match(SystemLevel level) const; 48 49 private: 50 Attribute value_; 51 }; 52 53 enum class ParamAttr { 54 PARAM_IN, 55 PARAM_OUT, 56 }; 57 58 class ASTParamAttr : public ASTNode { 59 public: ASTParamAttr(ParamAttr value)60 explicit ASTParamAttr(ParamAttr value) : ASTNode(), value_(value) {} 61 62 std::string ToString() const override; 63 64 std::string Dump(const std::string &prefix) override; 65 66 public: 67 ParamAttr value_; 68 }; 69 } // namespace HDI 70 } // namespace OHOS 71 72 #endif // OHOS_HDI_AST_ATTRIBUTE_H