| eRPC Generator (erpcgen) Rev. 1.8.1 NXP Semiconductors

- Main Page
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
erpcgen::Generator Class Referenceabstract

Abstract code generator base class. More...

`#include <Generator.h>`

Inheritance diagram for erpcgen::Generator:

## Public Types
enum | generator_type_t { kC, kPython }

## 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 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...
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 (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
boost::filesystem::path | m_outputDirectory

## is used.
  This function returns symbol output name. Can be different to getName() when Parameters
  [in] | symbol | Symbol.
  [in] | check | Check if output name is not reserved names.
Returns Return symbol output name.
std::string | getOutputName (Symbol *symbol, bool check=true)
Annotation::program_lang_t | getAnnotationLang ()
| Returns Generator flag used for annotation. More...
Annotation * | findAnnotation (Symbol *symbol, std::string name)
| Find annotation in the annotation list. More...
std::vector< Annotation * > | getAnnotations (Symbol *symbol, std::string name)
| Find annotations matching name in the annotation list. More...
Value * | getAnnValue (Symbol *symbol, std::string name)
| This function search and returns Value object for given annotation name. More...
std::string | getAnnStringValue (Symbol *symbol, std::string name)
| This function search and returns string for given annotation name. More...

## Detailed Description

Abstract code generator base class.

## Constructor & Destructor Documentation

Generator::Generator | ( | InterfaceDefinition * | def,
|  | generator_type_t | generatorType
| ) |  |

Constructor.

Interface definition contains all information about parsed files and builtin types.

Parameters

  [in] | def | Contains all Symbols parsed from IDL files.

## Member Function Documentation

Annotation * Generator::findAnnotation | ( | Symbol * | symbol,
|  | std::string | name
| ) |  |
| protected

Find annotation in the annotation list.

Parameters

  [in] | symbol | Symbol from which is annotation extracted.
  [in] | name | Annotation name.

Returns
  An index into the annotation list

DataType * Generator::findChildDataType | ( | std::set< DataType * > & | dataTypes,
|  | DataType * | dataType
| ) |  |
| protected virtual

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.

Parameters

  [in,out] | dataTypes | Vector of found data types.
  [in] | dataType | Top data type.

Returns
  Pointer to given or new DataType.

StructMember * Generator::findParamReferencedFrom | ( | const StructType::member_vector_t & | members,
|  | const std::string & | referenceName
| ) |  |
| protected

This function will return pointer to function parameter/structure member where given reference name is referenced for. Combines findParamReferencedFromUnion and findParamReferencedFromAnn.

Parameters

  [in] | members | Members contain references members and searched members.
  [in] | referenceName | Name of reference for which is member searched.

Returns
  Searched member.

StructMember * Generator::findParamReferencedFromAnn | ( | const StructType::member_vector_t & | members,
|  | const std::string & | referenceName,
|  | const std::string & | annName
| ) |  |
| protected

This function will return pointer to function parameter/structure member where given reference name is referenced for.

Parameters

  [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.

Returns
  Searched member.

StructMember * Generator::findParamReferencedFromUnion | ( | const StructType::member_vector_t & | members,
|  | const std::string & | referenceName
| ) |  |
| protected

This function will return pointer to function parameter/structure member where given reference name is referenced for.

Parameters

  [in] | members | Members contain references members and searched members.
  [in] | referenceName | Name of reference for which is member searched.

Returns
  Searched member.

void Generator::generateGroupOutputFiles | ( | Group * | group | ) |
| protected

This function generates output files for defined interfaces.

Parameters

  [in] | group | Pointer to a group.

void Generator::generateOutputFile | ( | const std::string & | fileName,
|  | const std::string & | templateName,
|  | cpptempl::data_map & | templateData,
|  | const char *const | kParseFile
| ) |  |
| protected

This function open file, generate output into this file and close this file.

Parameters

  [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.

Exceptions

  TemplateException | Thrown, when parse template data into output is not successfully.

virtual void erpcgen::Generator::generateOutputFiles | ( | const std::string & | fileNameExtension | ) |
| protected pure virtual

This function generates output files.

This function call functions for generating client/server header/source files.

Parameters

  [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.

Annotation::program_lang_t Generator::getAnnotationLang | ( |  | ) |
| protected

Returns Generator flag used for annotation.

Returns
  Generator flag used for annotation.

vector< Annotation * > Generator::getAnnotations | ( | Symbol * | symbol,
|  | std::string | name
| ) |  |
| protected

Find annotations matching name in the annotation list.

Parameters

  [in] | symbol | Symbol from which is annotation extracted.
  [in] | name | Annotation name.

Returns
  A vector of matching annotations

string Generator::getAnnStringValue | ( | Symbol * | symbol,
|  | std::string | name
| ) |  |
| protected

This function search and returns string for given annotation name.

Parameters

  [in] | symbol | Symbol from which is annotation extracted.
  [in] | name | Given annotation name.

Returns
  empty string if annotation is not found else string value.

Value * Generator::getAnnValue | ( | Symbol * | symbol,
|  | std::string | name
| ) |  |
| protected

This function search and returns Value object for given annotation name.

Parameters

  [in] | symbol | Symbol from which is annotation extracted.
  [in] | name | Given annotation name.

Returns
  NULL if annotation is not found else value object.

virtual cpptempl::data_map erpcgen::Generator::getFunctionTemplateData | ( | Group * | group,
|  | Function * | fn
| ) |  |
| protected pure 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.

Parameters

  [in] | group | Pointer to a group.
  [in] | fn | From this are set interface function template data.
  [in] | fnIndex | Function index.

Returns
  Contains interface function data.

Implemented in erpcgen::PythonGenerator.

Group * Generator::getGroupByName | ( | std::string | name | ) |
| protected

This function returns pointer to a group with specified name.

Parameters

  [in] | name | Name of the searched group.

Returns
  Pointer to a group with specified name.

string Generator::getTime | ( |  | ) |
| protected

This function return actual time string representation.

Returns
  Actual time.

bool Generator::isMemberDataTypeUsingForwardDeclaration | ( | Symbol * | topSymbol,
|  | Symbol * | memberSymbol
| ) |  |
| protected

This function returns information if member data type symbol is using forward declared type.

Parameters

  [in] | topSymbol | Symbol data type which is using as a member memberSymbol data type.
  [in] | memberSymbol | Member symbol data type of topSymbol.

Return values

  True | when memberSymbol is using forward declared type.
  False | when memberSymbol is not using forward declared type.

data_list Generator::makeGroupIncludesTemplateData | ( | Group * | group | ) |
| protected

This function sets template data for group include directives.

Parameters

  [in] | group | Pointer to a group.

Returns
  List with all group related includes.

data_list Generator::makeGroupInterfacesTemplateData | ( | Group * | 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.

Parameters

  [in] | group | Pointer to a group.

Returns
  Data list of interfaces templates.

virtual cpptempl::data_map erpcgen::Generator::makeGroupSymbolsTemplateData | ( | Group * | group | ) |
| protected pure 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.

Parameters

  [in] | group | Pointer to a group.

Returns
  Data map with group symbols templates.

Implemented in erpcgen::PythonGenerator.

void Generator::openFile | ( | std::ofstream & | fileOutputStream,
|  | const std::string & | fileName
| ) |  |
| protected

This function open file.

Parameters

  [in] | fileName | Output file name.
  [in,out] | fileOutputStream | Opened output file stream.

Exceptions

  std::runtime_error | Thrown, when can't create directory.
  std::runtime_error | Thrown, when file is not open.

virtual void erpcgen::Generator::setBinaryList | ( | StructMember * | structMember | ) |
| inline protected virtual

This function transform binary data type to list and set annotation to it.

Parameters

  [in] | structMember | Structure member, Function parameter or Union member.

virtual void erpcgen::Generator::setTemplateComments | ( | Symbol * | symbol,
|  | cpptempl::data_map & | symbolInfo
| ) |  |
| protected pure virtual

This function will get symbol comments and convert to language specific ones.

Parameters

  [in] | symbol | Pointer to symbol.
  [in,out] | symbolInfo | Data map, which contains information about symbol.

Implemented in erpcgen::PythonGenerator.

string Generator::stripExtension | ( | const std::string & | filename | ) |
| protected

Parameters

  [in] | filename |

Returns
  Filename with stripped extension

## Member Data Documentation

InterfaceDefinition* erpcgen::Generator::m_def
| protected

Interface definitions.

generator_type_t erpcgen::Generator::m_generatorType
| protected

Type of generator.

SymbolScope* erpcgen::Generator::m_globals
| protected

Symbol scope data.

std::vector<Group *> erpcgen::Generator::m_groups
| protected

List of groups.

uint16_t erpcgen::Generator::m_idlCrc16
| protected

Storing crc16 of IDL files and erpcgen version.

boost::filesystem::path erpcgen::Generator::m_outputDirectory
| protected

Output file path.

cpptempl::data_map erpcgen::Generator::m_templateData
| protected

Data prepared for templates files.

std::set<std::string> erpcgen::Generator::reserverdWords
| protected

Program language reserved words.

The documentation for this class was generated from the following files:

- Generator.h
- Generator.cpp