eRPC Generator (erpcgen)
Rev. 1.12.0
NXP Semiconductors
|
Abstract code generator base class. More...
#include <Generator.hpp>
Public Types | |
enum | generator_type_t { kC, kPython, kJava } |
typedef std::vector< DataType * > | datatype_vector_t |
Public Member Functions | |
Generator (InterfaceDefinition *def, generator_type_t generatorType) | |
Constructor. More... | |
virtual | ~Generator () |
Destructor. | |
virtual void | generate ()=0 |
Generate output files. | |
Protected Member Functions | |
void | openFile (std::ofstream &fileOutputStream, const std::string &fileName) |
This function open file. More... | |
void | generateOutputFile (const std::string &fileName, const std::string &templateName, cpptempl::data_map &templateData, const char *const kParseFile) |
This function open file, generate output into this file and close this file. More... | |
std::string | stripExtension (const std::string &filename) |
StructMember * | findParamReferencedFromAnn (const StructType::member_vector_t &members, const std::string &referenceName, const std::string &annName) |
This function will return pointer to function parameter/structure member where given reference name is referenced for. More... | |
StructMember * | findParamReferencedFromUnion (const StructType::member_vector_t &members, const std::string &referenceName) |
This function will return pointer to function parameter/structure member where given reference name is referenced for. More... | |
StructMember * | findParamReferencedFrom (const StructType::member_vector_t &members, const std::string &referenceName) |
This function will return pointer to function parameter/structure member where given reference name is referenced for. Combines findParamReferencedFromUnion and findParamReferencedFromAnn. More... | |
std::string | getTime () |
This function return actual time string representation. More... | |
void | findGroupDataTypes () |
This function finds all group's data types. | |
virtual DataType * | findChildDataType (std::set< DataType * > &dataTypes, DataType *dataType) |
This function finds child data types of specified data type. More... | |
virtual void | setBinaryList (StructMember *structMember) |
This function transform binary data type to list and set annotation to it. More... | |
virtual cpptempl::data_map | makeGroupSymbolsTemplateData (Group *group)=0 |
This function sets group symbols template data. More... | |
virtual cpptempl::data_map | getFunctionTemplateData (Group *group, Function *fn)=0 |
This function return interface function template data. More... | |
virtual cpptempl::data_map | getFunctionTypeTemplateData (Group *group, FunctionType *fn)=0 |
This function returns function type (callbacks type) template data. More... | |
virtual void | setTemplateComments (Symbol *symbol, cpptempl::data_map &symbolInfo)=0 |
This function will get symbol comments and convert to language specific ones. More... | |
cpptempl::data_list | makeGroupInterfacesTemplateData (Group *group) |
This function sets interfaces template data. More... | |
virtual void | generateOutputFiles (const std::string &fileNameExtension)=0 |
This function generates output files. More... | |
std::string | getGroupCommonFileName (Group *group) |
Function return common fileName part for group generated files. More... | |
void | generateGroupOutputFiles (Group *group) |
This function generates output files for defined interfaces. More... | |
void | makeIncludesTemplateData () |
This function sets template data for include directives from an IDL file. | |
cpptempl::data_list | makeGroupIncludesTemplateData (Group *group) |
This function sets template data for group include directives. More... | |
Group * | getGroupByName (const std::string &name) |
This function returns pointer to a group with specified name. More... | |
bool | isMemberDataTypeUsingForwardDeclaration (Symbol *topSymbol, Symbol *memberSymbol) |
This function returns information if member data type symbol is using forward declared type. More... | |
Protected Attributes | |
uint16_t | m_idlCrc16 |
cpptempl::data_map | m_templateData |
InterfaceDefinition * | m_def |
SymbolScope * | m_globals |
std::vector< Group * > | m_groups |
std::set< std::string > | reserverdWords |
generator_type_t | m_generatorType |
std::filesystem::path | m_outputDirectory |
is used. | |||||||
This function returns symbol output name. Can be different to getName() when
| |||||||
std::string | getOutputName (Symbol *symbol, bool check=true) | ||||||
Annotation::program_lang_t | getAnnotationLang () | ||||||
Returns Generator flag used for annotation. More... | |||||||
Annotation * | findAnnotation (Symbol *symbol, const std::string &name) | ||||||
Find annotation in the annotation list. More... | |||||||
std::vector< Annotation * > | getAnnotations (Symbol *symbol, const std::string &name) | ||||||
Find annotations matching name in the annotation list. More... | |||||||
Value * | getAnnValue (Symbol *symbol, const std::string &name) | ||||||
This function search and returns Value object for given annotation name. More... | |||||||
std::string | getAnnStringValue (Symbol *symbol, const std::string &name) | ||||||
This function search and returns string for given annotation name. More... | |||||||
datatype_vector_t | getDataTypesFromSymbolScope (SymbolScope *scope, DataType::data_type_t datatype) | ||||||
This function returns vector of data types from scope. More... | |||||||
virtual std::string | getFunctionPrototype (Group *group, FunctionBase *fn, const std::string &interfaceName="", const std::string &name="", bool insideInterfaceCall=false)=0 | ||||||
This function return interface function prototype. More... | |||||||
Abstract code generator base class.
typedef std::vector<DataType *> erpcgen::Generator::datatype_vector_t |
Vector of data types.
Generator::Generator | ( | InterfaceDefinition * | def, |
generator_type_t | generatorType | ||
) |
Constructor.
Interface definition contains all information about parsed files and builtin types.
[in] | def | Contains all Symbols parsed from IDL files. |
|
protected |
Find annotation in the annotation list.
[in] | symbol | Symbol from which is annotation extracted. |
[in] | name | Annotation name. |
|
protectedvirtual |
This function finds child data types of specified data type.
This function should be overridden by language specific generator, if there is a need to transform data types.
[in,out] | dataTypes | Vector of found data types. |
[in] | dataType | Top data type. |
|
protected |
This function will return pointer to function parameter/structure member where given reference name is referenced for. Combines findParamReferencedFromUnion and findParamReferencedFromAnn.
[in] | members | Members contain references members and searched members. |
[in] | referenceName | Name of reference for which is member searched. |
|
protected |
This function will return pointer to function parameter/structure member where given reference name is referenced for.
[in] | members | Members contain references members and searched members. |
[in] | referenceName | Name of reference for which is member searched. |
[in] | annName | Annotation name for which is member searched. |
|
protected |
This function will return pointer to function parameter/structure member where given reference name is referenced for.
[in] | members | Members contain references members and searched members. |
[in] | referenceName | Name of reference for which is member searched. |
|
protected |
This function generates output files for defined interfaces.
[in] | group | Pointer to a group. |
|
protected |
This function open file, generate output into this file and close this file.
[in] | fileName | Output file name. |
[in] | templateName | Name of template file, which is used for parser. |
[in] | templateData | Template data used for parser. |
[in] | kParseFile | Templates strings converted from text file by txt_to_c.py used for parser. |
TemplateException | Thrown, when parse template data into output is not successfully. |
|
protectedpure virtual |
This function generates output files.
This function call functions for generating client/server header/source files.
[in] | fileNameExtension | Extension for file name (for example for case that each interface will be generated in its set of output files). |
Implemented in erpcgen::PythonGenerator, and erpcgen::JavaGenerator.
|
protected |
|
protected |
Find annotations matching name in the annotation list.
[in] | symbol | Symbol from which is annotation extracted. |
[in] | name | Annotation name. |
|
protected |
This function search and returns string for given annotation name.
[in] | symbol | Symbol from which is annotation extracted. |
[in] | name | Given annotation name. |
|
protected |
This function returns vector of data types from scope.
[in] | scope | Scope with symbols. |
[in] | datatype | Datatype type. |
|
protectedpure virtual |
This function return interface function prototype.
[in] | group | Group to which function belongs. |
[in] | fn | Function for prototyping. |
[in] | interfaceName | Interface name used for function declaration. |
[in] | name | Name used for shared code in case of function type. |
[in] | insideInterfaceCall | interfaceClass specific. |
Implemented in erpcgen::JavaGenerator, and erpcgen::PythonGenerator.
|
protectedpure virtual |
This function return interface function template data.
This function return interface function template data with all data, which are necessary for generating output code for output files.
[in] | group | Pointer to a group. |
[in] | fn | From this are set interface function template data. |
Implemented in erpcgen::JavaGenerator, and erpcgen::PythonGenerator.
|
protectedpure virtual |
This function returns function type (callbacks type) template data.
This function returns function type (callbacks type) template data with all data, which are necessary for generating output code for output files. Shim code is generating common function for serialization/deserialization of data.
[in] | group | Group to which function belongs. |
[in] | fn | From this are set function type template data. |
Implemented in erpcgen::JavaGenerator, and erpcgen::PythonGenerator.
|
protected |
This function returns pointer to a group with specified name.
[in] | name | Name of the searched group. |
|
protected |
Function return common fileName part for group generated files.
group | Pointer to a group. |
|
protected |
This function return actual time string representation.
|
protected |
This function returns information if member data type symbol is using forward declared type.
[in] | topSymbol | Symbol data type which is using as a member memberSymbol data type. |
[in] | memberSymbol | Member symbol data type of topSymbol. |
True | when memberSymbol is using forward declared type. |
False | when memberSymbol is not using forward declared type. |
|
protected |
This function sets template data for group include directives.
[in] | group | Pointer to a group. |
|
protected |
This function sets interfaces template data.
This function sets interfaces template data with all data, which are necessary for generating output code for output files.
[in] | group | Pointer to a group. |
|
protectedpure virtual |
This function sets group symbols template data.
This function sets group symbols template data with all data, which are necessary for generating output code for output files.
[in] | group | Pointer to a group. |
Implemented in erpcgen::JavaGenerator, and erpcgen::PythonGenerator.
|
protected |
This function open file.
[in] | fileName | Output file name. |
[in,out] | fileOutputStream | Opened output file stream. |
std::runtime_error | Thrown, when can't create directory. |
std::runtime_error | Thrown, when file is not open. |
|
inlineprotectedvirtual |
This function transform binary data type to list and set annotation to it.
[in] | structMember | Structure member, Function parameter or Union member. |
|
protectedpure virtual |
This function will get symbol comments and convert to language specific ones.
[in] | symbol | Pointer to symbol. |
[in,out] | symbolInfo | Data map, which contains information about symbol. |
Implemented in erpcgen::JavaGenerator, and erpcgen::PythonGenerator.
|
protected |
[in] | filename |
|
protected |
Interface definitions.
|
protected |
Type of generator.
|
protected |
Symbol scope data.
|
protected |
List of groups.
|
protected |
Storing crc16 of IDL files and erpcgen version.
|
protected |
Output file path.
|
protected |
Data prepared for templates files.
|
protected |
Program language reserved words.