/* * Copyright (c) 2021 Huawei Device Co., Ltd. * * HDF is dual licensed: you can use it either under the terms of * the GPL, or the BSD license, at your option. * See the LICENSE file in the root of this repository for complete details. */ #ifndef HC_GEN_MACRO_GEN_H #define HC_GEN_MACRO_GEN_H #include #include #include "generator.h" namespace OHOS { namespace Hardware { class MacroGen : public Generator { public: explicit MacroGen(std::shared_ptr ast); ~MacroGen() override = default; bool Output() override; private: bool Initialize(); bool TemplateNodeSeparate(); std::string GenFullName(int32_t depth, const std::shared_ptr &node, const std::string &sep); bool GenNodeForeach(int32_t depth, const std::shared_ptr &node); bool NodeWalk(); void SetTypeData(uint32_t type, const std::shared_ptr ¤t, uint32_t &arraySize, int32_t depth); void SetTypeDataUinit64(const std::string &arrayName, uint32_t &arraySize, uint32_t arrayType, const std::shared_ptr ¤t); bool HeaderTopOutput(); bool HeaderBottomOutput(); const std::string &ToUpperString(std::string &str); bool GenArray(const std::string &arrName, uint32_t &arrSize, uint32_t type, const std::shared_ptr &node); std::string GenRefObjName(int32_t depth, const std::shared_ptr &object); std::ofstream ofs_; std::string outFileName_; std::map nodeNameMap_; }; } // namespace Hardware } // namespace OHOS #endif // HC_GEN_MACRO_GEN_H