1 #ifndef Rosebud_RoseGenerator_H
2 #define Rosebud_RoseGenerator_H
3 #include <Rosebud/CxxGenerator.h>
5 namespace Rosebud {
8 class RoseGenerator: public CxxGenerator {
9  using Base = CxxGenerator;
11 public:
12  using Ptr = std::shared_ptr<RoseGenerator>;
14 private:
15  boost::filesystem::path generatedDir; // directory where generated files are written
17 protected:
18  RoseGenerator() {}
20 public:
21  static Ptr instance();
22  virtual std::string name() const override;
23  virtual std::string purpose() const override;
24  virtual void adjustParser(Sawyer::CommandLine::Parser&) override;
25  virtual void generate(const Ast::ProjectPtr&) override;
27 protected:
28  virtual std::string ctorInitializerExpression(const Ast::PropertyPtr&, const std::string &expr) override;
29  virtual std::string valueType(const Ast::PropertyPtr&) override;
31 private:
32  void adjustAst(const Classes&);
33  bool isTreeEdge(const Ast::PropertyPtr&);
34  void genImplOpen(std::ostream &impl, const Ast::ClassPtr&);
35  void genImplClose(std::ostream &impl, const Ast::ClassPtr&);
36  void genHeaderOpen(std::ostream &header, const Ast::ClassPtr&);
37  void genHeaderClose(std::ostream &header, const Ast::ClassPtr&);
38  void genHeaderIncludes(std::ostream &header, const Ast::ClassPtr&, const Hierarchy&);
39  void genPropertyDataMember(std::ostream &header, const Ast::PropertyPtr&);
40  void genPropertyAccessors(std::ostream &header, std::ostream &impl, const Ast::PropertyPtr&);
41  void genPropertyMutators(std::ostream &header, std::ostream &impl, const Ast::PropertyPtr&);
42  void genProperty(std::ostream &header, std::ostream &impl, const Ast::PropertyPtr&);
43  void genDefaultConstructor(std::ostream &header, std::ostream &impl, const Ast::ClassPtr&);
44  void genArgsConstructor(std::ostream &header, std::ostream &impl, const Ast::ClassPtr&, const Hierarchy&);
45  void genTraversals(std::ostream &header, std::ostream &impl, const Ast::ClassPtr&, const Hierarchy&);
46  void genClass(const Ast::ClassPtr&, const Hierarchy&);
47  void genBasicTypes(const Ast::ProjectPtr&);
48 };
50 } // namespace
51 #endif
Base class for generators that produce C++ code.
Definition: CxxGenerator.h:8
Generator that produces ROSE code.
Definition: RoseGenerator.h:8
virtual void generate(const Ast::ProjectPtr &) override
Generate code.
Graph containing user-defined vertices and edges.
Definition: Graph.h:625
std::shared_ptr< Project > ProjectPtr
Shared-ownership pointer to a Project.
Definition: ud/BasicTypes.h:55
Rosebud is a tool to generate code for ROSE.
Definition: Ast.h:14
virtual void adjustParser(Sawyer::CommandLine::Parser &) override
Add command-line switches and documentation to a parser.
std::vector< Ast::ClassPtr > Classes
Ordered sequence of classes.
Definition: ud/Utility.h:216
virtual std::string purpose() const override
Single-line description for documentation.
virtual std::string name() const override
Every generator should have a unique name.
The parser for a program command line.
virtual std::string valueType(const Ast::PropertyPtr &) override
Type of value for initializing a property.
std::shared_ptr< Property > PropertyPtr
Shared-ownership pointer to a Property.
Definition: ud/BasicTypes.h:49
std::shared_ptr< Class > ClassPtr
Shared-ownership pointer to a Class.
Definition: ud/BasicTypes.h:51
virtual std::string ctorInitializerExpression(const Ast::PropertyPtr &, const std::string &expr) override
Expression for initializing a property in a constructor, or empty.