ROSE
0.11.145.0
|
Base class for generators that produce C++ code.
Definition at line 8 of file CxxGenerator.h.
#include <Rosebud/CxxGenerator.h>
Protected Member Functions | |
virtual std::string | machineGenerated (char commentType= '/') |
Return a title comment that says the file is machine generated. More... | |
virtual std::string | ctorInitializerExpression (const Ast::PropertyPtr &, const std::string &expr) |
Expression for initializing a property in a constructor, or empty. More... | |
virtual std::string | resetStatement (const Ast::PropertyPtr &) |
Statement to initialize a property. More... | |
virtual std::string | dataMemberType (const Ast::PropertyPtr &) |
Type for the data member for a property. More... | |
virtual std::string | initialValue (const Ast::PropertyPtr &) |
Initial value expression for the property. More... | |
virtual std::string | valueType (const Ast::PropertyPtr &) |
Type of value for initializing a property. More... | |
virtual void | genDestructor (std::ostream &header, std::ostream &impl, const Ast::ClassPtr &) |
Emit code for the class destructor. More... | |
virtual void | genDefaultConstructor (std::ostream &header, std::ostream &impl, const Ast::ClassPtr &, Access) |
Emit code for the class default constructor. More... | |
virtual void | genArgsConstructor (std::ostream &header, std::ostream &impl, const Ast::ClassPtr &, const Hierarchy &, Access) |
Emit code for the constructor with ctor_args property arguments. More... | |
virtual void | genInitProperties (std::ostream &header, std::ostream &impl, const Ast::ClassPtr &) |
Emit code that initializes all local properties. More... | |
Protected Attributes | |
size_t | outputWidth = 130 |
Additional Inherited Members | |
![]() | |
using | Ptr = GeneratorPtr |
![]() | |
virtual void | adjustParser (Sawyer::CommandLine::Parser &) |
Add command-line switches and documentation to a parser. More... | |
virtual std::string | name () const =0 |
Every generator should have a unique name. More... | |
virtual std::string | purpose () const =0 |
Single-line description for documentation. More... | |
virtual void | generate (const Ast::ProjectPtr &)=0 |
Generate code. More... | |
virtual std::string | propertyDataMemberName (const Ast::PropertyPtr &) const |
Data member name for a property. More... | |
virtual std::vector< std::string > | propertyAccessorNames (const Ast::PropertyPtr &) const |
Accessor names for a property. More... | |
virtual std::vector< std::string > | propertyMutatorNames (const Ast::PropertyPtr &) const |
Mutator names for a property. More... | |
![]() | |
static void | registerGenerator (const Ptr &) |
Register a backend for use later. More... | |
static const std::vector< Ptr > & | registeredGenerators () |
Return all registered backends. More... | |
static Ptr | lookup (const std::string &) |
Return the registered generator with the specified name. More... | |
static void | addAllToParser (Sawyer::CommandLine::Parser &) |
Add all known generator switches to parser. More... | |
|
protectedvirtual |
Return a title comment that says the file is machine generated.
|
protectedvirtual |
Expression for initializing a property in a constructor, or empty.
For most properties, this is simply the initialization expression parsed from the input. However, some properties need extra arguments, etc. that can be returned by this funciton. For instance, a TreeEdge property is initialized in a special way:
So the initializer expression for the "foo" property is overridden to add the "*this" argument, but for "bar" it is not overridden.
The expr
argument is the default initializer expression such as the string from the right hand side of the "=" in the property definition, or some other expression.
Reimplemented in Rosebud::RoseGenerator.
|
protectedvirtual |
Statement to initialize a property.
The return string is a statement that initializes the property data member if the data member needs to be initialized other than with a default constructor. This is used in the generated "initializeProperties" member function which is called by user-defined constructors prior to the user assigning a different value. The returned string is either empty or includes the terminating semicolon.
|
protectedvirtual |
Type for the data member for a property.
The base implementation simply returns the property type from the input.
|
protectedvirtual |
Initial value expression for the property.
The base implementation returns whatever expression was to the right of the "=" in the property definition.
|
protectedvirtual |
Type of value for initializing a property.
This is the type used by mutator arguments, but without the const reference part. The base implementation simply returns the type from the property definition after removing volatile
and mutable
, but sometimes we need something else. For instance, a property of type TreeEdge<T>
is never initialized from another tree edge, but rather from a std::shared_ptr<T>
, as follows:
Reimplemented in Rosebud::RoseGenerator.
|
protectedvirtual |
Emit code for the class destructor.
|
protectedvirtual |
Emit code for the class default constructor.
|
protectedvirtual |
Emit code for the constructor with ctor_args property arguments.
|
protectedvirtual |
Emit code that initializes all local properties.