Generates C++ code to create the GOM meta information.
More...
#include <OGF/gom/codegen/codegen.h>
Generates C++ code to create the GOM meta information.
The GOM parser populates the Meta reflection API with description of C++ types (MetaClass, MetaEnum ...). GomCodeGenerator generates code to recreate this description, so that Graphite does not need to parse header files at startup. In addition, GomCodeGenerator generates method adapters and factories to invoke methods and create objects from Python scripts.
Definition at line 76 of file codegen.h.
◆ colons_to_underscores()
std::string OGF::GomCodeGenerator::colons_to_underscores |
( |
const std::string & |
s | ) |
|
|
protected |
Replaces all colons (":") with underscores ("_") in a string.
- Parameters
-
[in] | s | a const reference to the input string |
- Returns
s
with all colons replaced with underscores
◆ factory_name()
std::string OGF::GomCodeGenerator::factory_name |
( |
MetaConstructor * |
constructor | ) |
|
|
protected |
Generates a C++ name for a factory from a MetaMethod.
- Parameters
-
- Returns
- a valid and unique C++ name for a factory
◆ generate() [1/2]
void OGF::GomCodeGenerator::generate |
( |
MetaClass * |
type | ) |
|
|
protected |
Generates C++ code that creates the meta information associated with a class.
C++ code is generated in the stream returned by out(). The function also generates dependencies (superclasses).
- Parameters
-
- See also
- out() generate_class()
◆ generate() [2/2]
void OGF::GomCodeGenerator::generate |
( |
std::ostream & |
out, |
|
|
std::vector< MetaClass * > |
classes, |
|
|
const std::string & |
package_name |
|
) |
| |
Generates C++ code to create the Meta information and adapters.
Dependencies (e.g., superclasses) are also generated, provided that they belong to package package_name
.
- Parameters
-
[out] | out | a reference to the stream that will receive the generated C++ code |
[in] | classes | the list of classes to generate, specified as a vector of pointers to MetaClass objects. |
[in] | package_name | the name of the package |
◆ generate_attributes()
void OGF::GomCodeGenerator::generate_attributes |
( |
const CustomAttributes * |
info, |
|
|
const std::string & |
variable_name, |
|
|
bool |
is_pointer = true |
|
) |
| |
|
protected |
Generates C++ code that creates the CustomAttributes associated with a language construct.
- Parameters
-
[in] | info | pointer to an object that inherits CustomAttributes |
[in] | variable_name | the name of the C++ variable in the generated code where custom attributes should be copied |
[in] | is_pointer | true if variable_name is a pointer (to a class that inherits CustomAttributes), false if variable_name is a reference. |
◆ generate_builtin()
Generates C++ code that creates the meta information associated with a builtin type.
C++ code is generated in the stream returned by out().
- Parameters
-
- See also
- out()
◆ generate_class()
void OGF::GomCodeGenerator::generate_class |
( |
MetaClass * |
mclass | ) |
|
|
protected |
Generates C++ code that creates the meta information associated with a class.
C++ code is generated in the stream returned by out(). The function only generates this MetaClass (and does not take care of dependencies).
- Parameters
-
- See also
- out() generate(MetaClass*)
◆ generate_enum()
void OGF::GomCodeGenerator::generate_enum |
( |
MetaEnum * |
menum | ) |
|
|
protected |
Generates C++ code that creates the meta information associated with an enum.
C++ code is generated in the stream returned by out().
- Parameters
-
- See also
- out()
◆ generate_factory()
void OGF::GomCodeGenerator::generate_factory |
( |
MetaConstructor * |
constructor | ) |
|
|
protected |
◆ generate_method_adapter()
void OGF::GomCodeGenerator::generate_method_adapter |
( |
MetaMethod * |
method | ) |
|
|
protected |
Generates a method adapter.
C++ code is generated in the stream returned by out().
- Parameters
-
◆ generate_method_adapter_arglist()
void OGF::GomCodeGenerator::generate_method_adapter_arglist |
( |
MetaMethod * |
method | ) |
|
|
protected |
Generates a method adapter.
This version is used for the special case where the method takes a ArgList as an argument. C++ code is generated in the stream returned by out().
- Parameters
-
- See also
- generate_method_adapter()
◆ generate_signal_adapter()
void OGF::GomCodeGenerator::generate_signal_adapter |
( |
MetaSignal * |
signal | ) |
|
|
protected |
◆ method_adapter_name()
std::string OGF::GomCodeGenerator::method_adapter_name |
( |
MetaMethod * |
method | ) |
|
|
protected |
Generates a C++ name for a method adapter from a MetaMethod.
- Parameters
-
- Returns
- a valid and unique C++ name for a method adapter
◆ out()
std::ostream& OGF::GomCodeGenerator::out |
( |
| ) |
|
|
inlineprotected |
Gets a reference to the output stream, where the generated C++ code is sent.
- Returns
- a reference to the output stream
Definition at line 244 of file codegen.h.
◆ pass_by_value()
bool OGF::GomCodeGenerator::pass_by_value |
( |
const std::string & |
type_name | ) |
|
|
protected |
Tests whether objects of a given type should be passed by value or by reference.
- Parameters
-
[in] | type_name | C++ type name, as a string |
- Return values
-
true | if objects of type type_name should be passed by value \retvavl false if objects of type type_name should be passed by reference |
◆ stringify()
std::string OGF::GomCodeGenerator::stringify |
( |
const std::string & |
s | ) |
|
|
protected |
Adds double quotes to a string.
- Parameters
-
[in] | s | a const reference to the input string |
- Returns
- the string
s
with double quotes
◆ stringify_default_value()
std::string OGF::GomCodeGenerator::stringify_default_value |
( |
const MetaArg * |
marg | ) |
|
|
protected |
Generates the code that computes an object that represents a default value.
The default value can be either an immediate value or a constructed object, and the behavior is different in both cases.
- Parameters
-
[in] | marg | a const reference to the input MetaArg |
- Return values
-
the | string s with double quotes if default value is a string literal. It is the case if MetaArg is of type std::string or derived from a Name class. Since we cannot test for the latter, we guess it is the case if typename constains "Name" as a substring. |
the | constant that corresponds to the default value otherwise |
The documentation for this class was generated from the following file: