| eRPC Generator (erpcgen) Rev. 1.8.1 NXP Semiconductors

- Main Page
- Classes
- Files

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

Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
erpcgen::PythonGenerator Class Reference

Code generator for Python. More...

`#include <PythonGenerator.h>`

Inheritance diagram for erpcgen::PythonGenerator:

## Public Member Functions
| PythonGenerator (InterfaceDefinition *def)
| This function is constructor of PythonGenerator class. More...
virtual | ~PythonGenerator ()
| This function is destructor of PythonGenerator class. More...
virtual void | generate ()
| This function generate output code for output files. More...
Public Member Functions inherited from erpcgen::Generator
| Generator (InterfaceDefinition *def, generator_type_t generatorType)
| Constructor. More...
virtual | ~Generator ()
| Destructor.

## Protected Types
enum | comment_type { kMultilineComment, kInlineComment }
| Possible Doxygen comment styles. More...

## Protected Member Functions
void | parseSubtemplates ()
| This function prepare helpful functions located in template files. More...
void | generateOutputFiles (const std::string &fileName)
| This function generate output files. More...
void | generateCommonFile (std::string fileName)
| This function generate output common module. More...
void | generateInitFile (std::string fileName)
| This function generate output package init file. More...
void | generateClientFile (std::string fileName)
| This function generate output client file. More...
void | generateServerFile (std::string fileName)
| This function generate output server file. More...
void | generateInterfaceFile (std::string fileName)
| This function generate output interface file. More...
virtual void | generateGlobalInitFile ()
| This function generate output crc16 source file.
cpptempl::data_map | getFunctionTemplateData (Group *group, Function *fn)
| This function return interface function template data. More...
void | setTemplateComments (Symbol *symbol, cpptempl::data_map &symbolInfo)
| This function will get symbol comments and convert to language specific ones. More...
std::string | getFunctionPrototype (Function *fn)
| This function return interface function prototype. More...
void | makeConstTemplateData ()
| This function sets const template data. More...
void | makeEnumsTemplateData ()
| This function sets enum template data. More...
cpptempl::data_map | makeGroupSymbolsTemplateData (Group *group)
| This function sets group symbols template data. More...
cpptempl::data_list | getEnumMembersTemplateData (EnumType *enumType)
| This function return enum members template data. More...
void | makeAliasesTemplateData ()
| Fill in template data for type aliases.
void | makeFunctionsTemplateData ()
| This function sets function type template data. More...
void | setStructMembersTemplateData (StructType *structType, cpptempl::data_map &structInfo)
| This function sets struct member information to struct data map variable. More...
void | setOneStructMemberTemplateData (StructMember *member, cpptempl::data_map &member_info)
| Fill in template data for a single struct member.
cpptempl::data_map | getTypeInfo (DataType *t)
| This function return necessary template data for data type. More...
std::string | getBuiltinTypename (const BuiltinType *t)
| This function return string representation for given BuiltinType. More...
std::string | filterName (const std::string &name)
| Filter symbol names.
std::string | convertComment (const std::string &comment, comment_type commentType)
| Converts a C++-style Doxygen comment into a Python Doxygen comment. More...
std::string | stripWhitespace (const std::string &s)
| Strip leading and trailing whitespace. More...
bool | checkWhitspaceChar (char c)
| Check if character is whitespace type. More...
void | initPythonReservedWords ()
Protected Member Functions inherited from erpcgen::Generator
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...
cpptempl::data_list | makeGroupInterfacesTemplateData (Group *group)
| This function sets interfaces template data. 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...
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...

## Protected Attributes
std::string | m_suffixStrip
| String to remove from suffixes of names.
size_t | m_suffixStripSize
| Length of the suffix filter string.
Protected Attributes inherited from erpcgen::Generator
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

## Additional Inherited Members
Public Types inherited from erpcgen::Generator
enum | generator_type_t { kC, kPython }

## Detailed Description

Code generator for Python.

## Member Enumeration Documentation

enum erpcgen::PythonGenerator::comment_type
| protected

Possible Doxygen comment styles.

Enumerator
kMultilineComment | Leading multi-line comment.
kInlineComment | Trailing inline comment.

## Constructor & Destructor Documentation

PythonGenerator::PythonGenerator | ( | InterfaceDefinition * | def | ) |

This function is constructor of PythonGenerator class.

Parameters

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

virtual erpcgen::PythonGenerator::~PythonGenerator | ( |  | ) |
| inline virtual

This function is destructor of PythonGenerator class.

This function close opened files.

## Member Function Documentation

bool PythonGenerator::checkWhitspaceChar | ( | char | c | ) |
| protected

Check if character is whitespace type.

Parameters

  [in] | c | Checked character.

string PythonGenerator::convertComment | ( | const std::string & | comment,
|  | comment_type | commentType
| ) |  |
| protected

Converts a C++-style Doxygen comment into a Python Doxygen comment.

Parameters

  [in,out] | comment | The C++ comment.
  [in] | commentType | Inline or multiline comment.

Returns
  Python form of the provided comment.

void PythonGenerator::generate | ( |  | ) |
| virtual

This function generate output code for output files.

This code call all necessary functions for prepare output code and parse it into output files.

Implements erpcgen::Generator.

void PythonGenerator::generateClientFile | ( | std::string | fileName | ) |
| protected

This function generate output client file.

Parameters

  [in] | fileName | Name for output files.

void PythonGenerator::generateCommonFile | ( | std::string | fileName | ) |
| protected

This function generate output common module.

Parameters

  [in] | fileName | Name for output files.

void PythonGenerator::generateInitFile | ( | std::string | fileName | ) |
| protected

This function generate output package init file.

Parameters

  [in] | fileName | Name for output files.

void PythonGenerator::generateInterfaceFile | ( | std::string | fileName | ) |
| protected

This function generate output interface file.

Parameters

  [in] | fileName | Name for output files.

void PythonGenerator::generateOutputFiles | ( | const std::string & | fileName | ) |
| protected virtual

This function generate output files.

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

Parameters

  [in] | fileName | Name for output files.

Implements erpcgen::Generator.

void PythonGenerator::generateServerFile | ( | std::string | fileName | ) |
| protected

This function generate output server file.

Parameters

  [in] | fileName | Name for output files.

string PythonGenerator::getBuiltinTypename | ( | const BuiltinType * | t | ) |
| protected

This function return string representation for given BuiltinType.

Parameters

  [in] | t | Builtin type.

Returns
  String representation for given builtin type.

data_list PythonGenerator::getEnumMembersTemplateData | ( | EnumType * | enumType | ) |
| protected

This function return enum members template data.

This function return enum members template data with all data, which are necessary for generating output code for output files.

Parameters

  [in] | enumType | Pointer to enum.

Returns
  Contains enum members data.

string PythonGenerator::getFunctionPrototype | ( | Function * | fn | ) |
| protected

This function return interface function prototype.

Parameters

  [in] | fn | Function for prototyping.

Returns
  String prototype representation for given function.

data_map PythonGenerator::getFunctionTemplateData | ( | Group * | group,
|  | Function * | fn
| ) |  |
| protected 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.

Implements erpcgen::Generator.

data_map PythonGenerator::getTypeInfo | ( | DataType * | t | ) |
| protected

This function return necessary template data for data type.

This function return data type template data with all necessary data, which are necessary for generating output code for output files.

Parameters

  [in] | t | Data type. From this are set data type template data.

Returns
  Contains data type template data.

void PythonGenerator::initPythonReservedWords | ( |  | ) |
| protected

Stores reserved words for Python program language.

void PythonGenerator::makeConstTemplateData | ( |  | ) |
| protected

This function sets const template data.

This function sets const template data with all data, which are necessary for generating output code for output files.

void PythonGenerator::makeEnumsTemplateData | ( |  | ) |
| protected

This function sets enum template data.

This function sets enum template data with all data, which are necessary for generating output code for output files.

void PythonGenerator::makeFunctionsTemplateData | ( |  | ) |
| protected

This function sets function type template data.

This is used for registering callback functions in generated output.

data_map PythonGenerator::makeGroupSymbolsTemplateData | ( | Group * | group | ) |
| protected 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.

Implements erpcgen::Generator.

void PythonGenerator::parseSubtemplates | ( |  | ) |
| protected

This function prepare helpful functions located in template files.

These function may be used while parsing templates

void PythonGenerator::setStructMembersTemplateData | ( | StructType * | structType,
|  | cpptempl::data_map & | structInfo
| ) |  |
| protected

This function sets struct member information to struct data map variable.

This function sets struct member information to struct data map variable, which are necessary for generating output code for output files.

Parameters

  [in] | structType | Struct, which contains struct members.
  [in,out] | structInfo | Data map, which contains information about struct and struct members.

void PythonGenerator::setTemplateComments | ( | Symbol * | symbol,
|  | cpptempl::data_map & | symbolInfo
| ) |  |
| protected 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.

Implements erpcgen::Generator.

string PythonGenerator::stripWhitespace | ( | const std::string & | s | ) |
| protected

Strip leading and trailing whitespace.

Parameters

  [in] | s | String from which are stripped white spaces.

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

- PythonGenerator.h
- PythonGenerator.cpp