eRPC Generator (erpcgen)  Rev. 1.7.0
NXP Semiconductors
PythonGenerator.h
1 /*
2  * The Clear BSD License
3  * Copyright (c) 2014-2016 Freescale Semiconductor, Inc.
4  * Copyright 2016-2017 NXP
5  * All rights reserved.
6  *
7  *
8  * Redistribution and use in source and binary forms, with or without modification,
9  * are permitted (subject to the limitations in the disclaimer below) provided
10  * that the following conditions are met:
11  *
12  * o Redistributions of source code must retain the above copyright notice, this list
13  * of conditions and the following disclaimer.
14  *
15  * o Redistributions in binary form must reproduce the above copyright notice, this
16  * list of conditions and the following disclaimer in the documentation and/or
17  * other materials provided with the distribution.
18  *
19  * o Neither the name of the copyright holder nor the names of its
20  * contributors may be used to endorse or promote products derived from this
21  * software without specific prior written permission.
22  *
23  * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE.
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
28  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
31  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  */
35 
36 #ifndef _EMBEDDED_RPC__PYTHONGENERATOR_H_
37 #define _EMBEDDED_RPC__PYTHONGENERATOR_H_
38 
39 #include "Generator.h"
40 #include "cpptempl.h"
41 #include <set>
42 #include <string>
43 
45 // Classes
47 
48 namespace erpcgen {
49 
53 class PythonGenerator : public Generator
54 {
55 public:
62 
68  virtual ~PythonGenerator() {}
69 
75  virtual void generate();
76 
77 protected:
78  std::string m_suffixStrip;
80 
86  void parseSubtemplates();
87 
95  void generateOutputFiles(const std::string &fileName);
96 
102  void generateCommonFile(std::string fileName);
103 
109  void generateInitFile(std::string fileName);
110 
116  void generateClientFile(std::string fileName);
117 
123  void generateServerFile(std::string fileName);
124 
130  void generateInterfaceFile(std::string fileName);
131 
135  virtual void generateGlobalInitFile();
136 
150 
157  void setTemplateComments(Symbol *symbol, cpptempl::data_map &symbolInfo);
158 
166  std::string getFunctionPrototype(Function *fn);
167 
174  void makeConstTemplateData();
175 
182  void makeEnumsTemplateData();
183 
195 
206  cpptempl::data_list getEnumMembersTemplateData(EnumType *enumType);
207 
212 
219 
229  void setStructMembersTemplateData(StructType *structType, cpptempl::data_map &structInfo);
230 
235 
247 
255  std::string getBuiltinTypename(const BuiltinType *t);
256 
260  std::string filterName(const std::string &name);
261 
264  {
267  };
268 
277  std::string convertComment(const std::string &comment, comment_type commentType);
278 
284  std::string stripWhitespace(const std::string &s);
285 
291  bool checkWhitspaceChar(char c);
292 
297 };
298 
299 } // namespace erpcgen
300 
301 #endif // _EMBEDDED_RPC__PYTHONGENERATOR_H_
Collects all definitions from an IDL.
Definition: InterfaceDefinition.h:56
void makeFunctionsTemplateData()
This function sets function type template data.
Definition: PythonGenerator.cpp:562
Leading multi-line comment.
Definition: PythonGenerator.h:265
Member of a struct.
Definition: StructMember.h:63
std::string getBuiltinTypename(const BuiltinType *t)
This function return string representation for given BuiltinType.
Definition: PythonGenerator.cpp:737
void generateInitFile(std::string fileName)
This function generate output package init file.
Definition: PythonGenerator.cpp:90
Trailing inline comment.
Definition: PythonGenerator.h:266
void setOneStructMemberTemplateData(StructMember *member, cpptempl::data_map &member_info)
Fill in template data for a single struct member.
Definition: PythonGenerator.cpp:544
std::string m_suffixStrip
String to remove from suffixes of names.
Definition: PythonGenerator.h:78
cpptempl::data_map makeGroupSymbolsTemplateData(Group *group)
This function sets group symbols template data.
Definition: PythonGenerator.cpp:429
bool checkWhitspaceChar(char c)
Check if character is whitespace type.
Definition: PythonGenerator.cpp:888
void generateServerFile(std::string fileName)
This function generate output server file.
Definition: PythonGenerator.cpp:108
PythonGenerator(InterfaceDefinition *def)
This function is constructor of PythonGenerator class.
Definition: PythonGenerator.cpp:62
void generateClientFile(std::string fileName)
This function generate output client file.
Definition: PythonGenerator.cpp:102
Represents the builtin atomic types.
Definition: BuiltinType.h:51
cpptempl::data_map getFunctionTemplateData(Group *group, Function *fn)
This function return interface function template data.
Definition: PythonGenerator.cpp:194
Structure data type.
Definition: StructType.h:54
Function declaration.
Definition: Function.h:142
Base class for all named declarations in the IDL.
Definition: Symbol.h:53
virtual ~PythonGenerator()
This function is destructor of PythonGenerator class.
Definition: PythonGenerator.h:68
void generateInterfaceFile(std::string fileName)
This function generate output interface file.
Definition: PythonGenerator.cpp:114
void setStructMembersTemplateData(StructType *structType, cpptempl::data_map &structInfo)
This function sets struct member information to struct data map variable.
Definition: PythonGenerator.cpp:508
void parseSubtemplates()
This function prepare helpful functions located in template files.
Definition: PythonGenerator.cpp:126
Code generator for Python.
Definition: PythonGenerator.h:53
void initPythonReservedWords()
Definition: PythonGenerator.cpp:935
std::string getFunctionPrototype(Function *fn)
This function return interface function prototype.
Definition: PythonGenerator.cpp:290
Abstract code generator base class.
Definition: Generator.h:69
virtual void generateGlobalInitFile()
This function generate output crc16 source file.
Definition: PythonGenerator.cpp:120
std::string stripWhitespace(const std::string &s)
Strip leading and trailing whitespace.
Definition: PythonGenerator.cpp:897
Base class for data types.
Definition: DataType.h:51
std::string filterName(const std::string &name)
Filter symbol names.
Definition: PythonGenerator.cpp:772
void makeConstTemplateData()
This function sets const template data.
Definition: PythonGenerator.cpp:314
std::string convertComment(const std::string &comment, comment_type commentType)
Converts a C++-style Doxygen comment into a Python Doxygen comment.
Definition: PythonGenerator.cpp:786
void generateOutputFiles(const std::string &fileName)
This function generate output files.
Definition: PythonGenerator.cpp:76
An interface that contains functions.
Definition: Group.h:53
void makeAliasesTemplateData()
Fill in template data for type aliases.
Definition: PythonGenerator.cpp:390
Definition: cpptempl.h:190
Enumerate data type.
Definition: EnumType.h:53
comment_type
Possible Doxygen comment styles.
Definition: PythonGenerator.h:263
void makeEnumsTemplateData()
This function sets enum template data.
Definition: PythonGenerator.cpp:349
cpptempl::data_map getTypeInfo(DataType *t)
This function return necessary template data for data type.
Definition: PythonGenerator.cpp:588
size_t m_suffixStripSize
Length of the suffix filter string.
Definition: PythonGenerator.h:79
void generateCommonFile(std::string fileName)
This function generate output common module.
Definition: PythonGenerator.cpp:96
void setTemplateComments(Symbol *symbol, cpptempl::data_map &symbolInfo)
This function will get symbol comments and convert to language specific ones.
Definition: PythonGenerator.cpp:188
virtual void generate()
This function generate output code for output files.
Definition: PythonGenerator.cpp:139
Definition: AstNode.h:51
cpptempl::data_list getEnumMembersTemplateData(EnumType *enumType)
This function return enum members template data.
Definition: PythonGenerator.cpp:372