| eRPC Generator (erpcgen) Rev. 1.8.1 NXP Semiconductors

- Main Page
- Classes
- Files

- File List

PythonGenerator.h
1 /*
2 * Copyright (c) 2014-2016 Freescale Semiconductor, Inc.
3 * Copyright 2016-2017 NXP
4 * All rights reserved.
5 *
6 *
7 * SPDX-License-Identifier: BSD-3-Clause
8 */
9
10 #ifndef _EMBEDDED_RPC__PYTHONGENERATOR_H_
11 #define _EMBEDDED_RPC__PYTHONGENERATOR_H_
12
13 #include "Generator.h"
14 #include "cpptempl.h"
15
16 #include <set>
17 #include <string>
18
20 // Classes
22
23 namespace erpcgen {
24
28 class PythonGenerator : public Generator
29 {
30 public:
36 PythonGenerator(InterfaceDefinition *def);
37
43 virtual ~PythonGenerator() {}
44
50 virtual void generate();
51
52 protected:
53 std::string m_suffixStrip;
54 size_t m_suffixStripSize;
55
61 void parseSubtemplates();
62
70 void generateOutputFiles(const std::string &fileName);
71
77 void generateCommonFile(std::string fileName);
78
84 void generateInitFile(std::string fileName);
85
91 void generateClientFile(std::string fileName);
92
98 void generateServerFile(std::string fileName);
99
105 void generateInterfaceFile(std::string fileName);
106
110 virtual void generateGlobalInitFile();
111
124 cpptempl::data_map getFunctionTemplateData(Group *group, Function *fn);
125
132 void setTemplateComments(Symbol *symbol, cpptempl::data_map &symbolInfo);
133
141 std::string getFunctionPrototype(Function *fn);
142
149 void makeConstTemplateData();
150
157 void makeEnumsTemplateData();
158
169 cpptempl::data_map makeGroupSymbolsTemplateData(Group *group);
170
181 cpptempl::data_list getEnumMembersTemplateData(EnumType *enumType);
182
186 void makeAliasesTemplateData();
187
193 void makeFunctionsTemplateData();
194
204 void setStructMembersTemplateData(StructType *structType, cpptempl::data_map &structInfo);
205
209 void setOneStructMemberTemplateData(StructMember *member, cpptempl::data_map &member_info);
210
221 cpptempl::data_map getTypeInfo(DataType *t);
222
230 std::string getBuiltinTypename(const BuiltinType *t);
231
235 std::string filterName(const std::string &name);
236
238 enum comment_type
239 {
240 kMultilineComment,
241 kInlineComment,
242 };
243
252 std::string convertComment(const std::string &comment, comment_type commentType);
253
259 std::string stripWhitespace(const std::string &s);
260
266 bool checkWhitspaceChar(char c);
267
271 void initPythonReservedWords();
272 };
273
274 } // namespace erpcgen
275
276 #endif // _EMBEDDED_RPC__PYTHONGENERATOR_H_
erpcgen::InterfaceDefinition
Collects all definitions from an IDL.
Definition: InterfaceDefinition.h:31
erpcgen::PythonGenerator::makeFunctionsTemplateData
void makeFunctionsTemplateData()
This function sets function type template data.
Definition: PythonGenerator.cpp:567
erpcgen::PythonGenerator::kMultilineComment
Leading multi-line comment.
Definition: PythonGenerator.h:240
erpcgen::StructMember
Member of a struct.
Definition: StructMember.h:38
erpcgen::PythonGenerator::getBuiltinTypename
std::string getBuiltinTypename(const BuiltinType *t)
This function return string representation for given BuiltinType.
Definition: PythonGenerator.cpp:733
erpcgen::PythonGenerator::generateInitFile
void generateInitFile(std::string fileName)
This function generate output package init file.
Definition: PythonGenerator.cpp:66
erpcgen::PythonGenerator::kInlineComment
Trailing inline comment.
Definition: PythonGenerator.h:241
erpcgen::PythonGenerator::setOneStructMemberTemplateData
void setOneStructMemberTemplateData(StructMember *member, cpptempl::data_map &member_info)
Fill in template data for a single struct member.
Definition: PythonGenerator.cpp:549
erpcgen::PythonGenerator::m_suffixStrip
std::string m_suffixStrip
String to remove from suffixes of names.
Definition: PythonGenerator.h:53
erpcgen::PythonGenerator::makeGroupSymbolsTemplateData
cpptempl::data_map makeGroupSymbolsTemplateData(Group *group)
This function sets group symbols template data.
Definition: PythonGenerator.cpp:406
erpcgen::PythonGenerator::checkWhitspaceChar
bool checkWhitspaceChar(char c)
Check if character is whitespace type.
Definition: PythonGenerator.cpp:885
erpcgen::PythonGenerator::generateServerFile
void generateServerFile(std::string fileName)
This function generate output server file.
Definition: PythonGenerator.cpp:84
erpcgen::PythonGenerator::PythonGenerator
PythonGenerator(InterfaceDefinition *def)
This function is constructor of PythonGenerator class.
Definition: PythonGenerator.cpp:38
erpcgen::PythonGenerator::generateClientFile
void generateClientFile(std::string fileName)
This function generate output client file.
Definition: PythonGenerator.cpp:78
erpcgen::BuiltinType
Represents the builtin atomic types.
Definition: BuiltinType.h:26
erpcgen::PythonGenerator::getFunctionTemplateData
cpptempl::data_map getFunctionTemplateData(Group *group, Function *fn)
This function return interface function template data.
Definition: PythonGenerator.cpp:170
erpcgen::StructType
Structure data type.
Definition: StructType.h:29
erpcgen::Function
Function declaration.
Definition: Function.h:117
erpcgen::Symbol
Base class for all named declarations in the IDL.
Definition: Symbol.h:28
erpcgen::PythonGenerator::~PythonGenerator
virtual ~PythonGenerator()
This function is destructor of PythonGenerator class.
Definition: PythonGenerator.h:43
erpcgen::PythonGenerator::generateInterfaceFile
void generateInterfaceFile(std::string fileName)
This function generate output interface file.
Definition: PythonGenerator.cpp:90
erpcgen::PythonGenerator::setStructMembersTemplateData
void setStructMembersTemplateData(StructType *structType, cpptempl::data_map &structInfo)
This function sets struct member information to struct data map variable.
Definition: PythonGenerator.cpp:513
erpcgen::PythonGenerator::parseSubtemplates
void parseSubtemplates()
This function prepare helpful functions located in template files.
Definition: PythonGenerator.cpp:102
erpcgen::PythonGenerator
Code generator for Python.
Definition: PythonGenerator.h:28
erpcgen::PythonGenerator::initPythonReservedWords
void initPythonReservedWords()
Definition: PythonGenerator.cpp:932
erpcgen::PythonGenerator::getFunctionPrototype
std::string getFunctionPrototype(Function *fn)
This function return interface function prototype.
Definition: PythonGenerator.cpp:267
erpcgen::Generator
Abstract code generator base class.
Definition: Generator.h:44
erpcgen::PythonGenerator::generateGlobalInitFile
virtual void generateGlobalInitFile()
This function generate output crc16 source file.
Definition: PythonGenerator.cpp:96
erpcgen::PythonGenerator::stripWhitespace
std::string stripWhitespace(const std::string &s)
Strip leading and trailing whitespace.
Definition: PythonGenerator.cpp:894
erpcgen::DataType
Base class for data types.
Definition: DataType.h:26
erpcgen::PythonGenerator::filterName
std::string filterName(const std::string &name)
Filter symbol names.
Definition: PythonGenerator.cpp:768
erpcgen::PythonGenerator::makeConstTemplateData
void makeConstTemplateData()
This function sets const template data.
Definition: PythonGenerator.cpp:291
erpcgen::PythonGenerator::convertComment
std::string convertComment(const std::string &comment, comment_type commentType)
Converts a C++-style Doxygen comment into a Python Doxygen comment.
Definition: PythonGenerator.cpp:782
erpcgen::PythonGenerator::generateOutputFiles
void generateOutputFiles(const std::string &fileName)
This function generate output files.
Definition: PythonGenerator.cpp:52
erpcgen::Group
An interface that contains functions.
Definition: Group.h:28
erpcgen::PythonGenerator::makeAliasesTemplateData
void makeAliasesTemplateData()
Fill in template data for type aliases.
Definition: PythonGenerator.cpp:367
cpptempl::data_map
Definition: cpptempl.h:190
erpcgen::EnumType
Enumerate data type.
Definition: EnumType.h:28
erpcgen::PythonGenerator::comment_type
comment_type
Possible Doxygen comment styles.
Definition: PythonGenerator.h:238
erpcgen::PythonGenerator::makeEnumsTemplateData
void makeEnumsTemplateData()
This function sets enum template data.
Definition: PythonGenerator.cpp:326
erpcgen::PythonGenerator::getTypeInfo
cpptempl::data_map getTypeInfo(DataType *t)
This function return necessary template data for data type.
Definition: PythonGenerator.cpp:593
erpcgen::PythonGenerator::m_suffixStripSize
size_t m_suffixStripSize
Length of the suffix filter string.
Definition: PythonGenerator.h:54
erpcgen::PythonGenerator::generateCommonFile
void generateCommonFile(std::string fileName)
This function generate output common module.
Definition: PythonGenerator.cpp:72
erpcgen::PythonGenerator::setTemplateComments
void setTemplateComments(Symbol *symbol, cpptempl::data_map &symbolInfo)
This function will get symbol comments and convert to language specific ones.
Definition: PythonGenerator.cpp:164
erpcgen::PythonGenerator::generate
virtual void generate()
This function generate output code for output files.
Definition: PythonGenerator.cpp:115
erpcgen
Definition: AstNode.h:26
erpcgen::PythonGenerator::getEnumMembersTemplateData
cpptempl::data_list getEnumMembersTemplateData(EnumType *enumType)
This function return enum members template data.
Definition: PythonGenerator.cpp:349