10 #ifndef _EMBEDDED_RPC__CGENERATOR_H_ 11 #define _EMBEDDED_RPC__CGENERATOR_H_ 13 #include "Generator.hpp" 14 #include "cpptempl.hpp" 15 #include "types/Group.hpp" 62 cpptempl::data_list m_symbolsTemplate;
64 std::vector<ListType *>
71 std::vector<StructType *> m_structListTypes;
82 void parseSubtemplates();
92 void generateOutputFiles(
const std::string &fileNameExtension)
override;
99 void generateTypesHeaderFile();
106 void generateCommonHeaderFiles(
const std::string &fileName);
113 void generateClientSourceFile(std::string fileName);
120 void generateServerHeaderFile(std::string fileName);
127 void generateServerSourceFile(std::string fileName);
132 virtual void generateCrcFile();
137 void transformAliases();
146 cpptempl::data_map getSymbolTemplateByName(
const std::string &name);
160 DataType *findChildDataType(std::set<DataType *> &dataTypes,
DataType *dataType)
override;
167 void setBinaryList(
StructMember *structMember)
override;
193 cpptempl::data_map getFunctionTemplateData(
Group *group,
Function *fn)
override;
215 void setTemplateComments(
Symbol *symbol, cpptempl::data_map &symbolInfo)
override;
223 void makeConstTemplateData();
237 cpptempl::data_map makeGroupSymbolsTemplateData(
Group *group)
override;
249 cpptempl::data_list makeGroupCallbacksTemplateData(
Group *group);
261 cpptempl::data_map getStructDeclarationTemplateData(
StructType *structType);
277 cpptempl::data_map getStructDefinitionTemplateData(
Group *group,
StructType *structType,
278 cpptempl::data_map structInfo);
290 cpptempl::data_map getUnionDeclarationTemplateData(
UnionType *unionType);
307 cpptempl::data_map getUnionDefinitionTemplateData(
Group *group,
UnionType *unionType, cpptempl::data_map &unionInfo,
308 bool &needUnionsServerFree);
318 void setUnionMembersTemplateData(
UnionType *unionType, cpptempl::data_map &unionInfo);
331 std::string getUnionMembersData(
UnionType *unionType, std::string indent);
339 void makeEnumsTemplateData();
347 void makeSymbolsDeclarationTemplateData();
359 cpptempl::data_map getEnumTemplateData(
EnumType *enumType);
371 cpptempl::data_list getEnumMembersTemplateData(
EnumType *enumType);
379 void makeAliasesTemplateData();
393 std::string getAliasName(
DataType *dataType);
407 cpptempl::data_map getTypeInfo(
DataType *t,
bool isFunction);
427 std::string getFunctionPrototype(
Group *group,
FunctionBase *fn,
const std::string name =
"");
446 std::string generateIncludeGuardName(
const std::string &filename);
455 std::string getBuiltinTypename(
const BuiltinType *t);
471 std::string getTypenameName(
DataType *t,
const std::string &name);
488 cpptempl::data_map getEncodeDecodeCall(
const std::string &name,
Group *group,
DataType *t,
StructType *structType,
489 bool inDataContainer,
StructMember *structMember,
bool &needTempVariable,
490 bool isFunctionParam);
511 void giveBracesToArrays(std::string &name);
522 std::string getExtraDirectionPointer(
StructMember *structMember);
533 std::string getExtraPointerInReturn(
DataType *dataType);
545 cpptempl::data_map firstAllocOnServerWhenIsNeed(
const std::string &name,
StructMember *structMember);
557 cpptempl::data_map firstAllocOnReturnWhenIsNeed(
const std::string &name,
DataType *dataType);
567 cpptempl::data_map allocateCall(
const std::string &name,
Symbol *symbol);
580 void setSymbolDataToSide(
const Symbol *symbolType,
const std::set<_param_direction> &directions,
581 cpptempl::data_list &toClient, cpptempl::data_list &toServer, cpptempl::data_map &dataMap);
591 bool isNeedCallFree(
DataType *dataType);
603 void setCallingFreeFunctions(
Symbol *symbol, cpptempl::data_map &info,
bool returnType);
612 std::string returnSpaceWhenNotEmpty(
const std::string ¶m);
624 bool containsString(
DataType *dataType);
636 bool containsList(
DataType *dataType);
649 bool containsByrefParamToFree(
DataType *dataType, std::set<DataType *> &dataTypes);
673 bool isBinaryList(
const ListType *listType);
683 bool isListStruct(
const StructType *structType);
696 bool generateServerFreeFunctions(
StructMember *structMember);
706 void setNoSharedAnn(
Symbol *parentSymbol,
Symbol *childSymbol);
709 bool isFunctionParam, cpptempl::data_map &templateData);
720 std::string getScalarTypename(
DataType *dataType);
729 std::string getDirection(_param_direction direction);
764 void initCReservedWords();
775 void scanStructForAnnotations(
StructType *currentStructType,
bool isFunction);
790 #endif // _EMBEDDED_RPC__CGENERATOR_H_ Collects all definitions from an IDL.
Definition: InterfaceDefinition.hpp:31
Function data type.
Definition: FunctionType.hpp:31
Member of a struct.
Definition: StructMember.hpp:38
Annotation class.
Definition: Annotation.hpp:28
Typedef.
Definition: AliasType.hpp:26
Represents the builtin atomic types.
Definition: BuiltinType.hpp:26
Structure data type.
Definition: StructType.hpp:29
Function declaration.
Definition: Function.hpp:117
Base class for all named declarations in the IDL.
Definition: Symbol.hpp:28
virtual ~CGenerator()
This function is destructor of CGenerator class.
Definition: CGenerator.hpp:44
Variable length list of another data type.
Definition: ListType.hpp:26
CGenerator(InterfaceDefinition *def)
This function is constructor of CGenerator class.
Definition: CGenerator.cpp:47
Abstract code generator base class.
Definition: Generator.hpp:45
Base class for data types.
Definition: DataType.hpp:26
An interface that contains functions.
Definition: Group.hpp:28
Function base declaration.
Definition: Function.hpp:30
Enumerate data type.
Definition: EnumType.hpp:28
Discriminated union data type.
Definition: UnionType.hpp:28
virtual void generate() override
This function generate output code for output files.
Definition: CGenerator.cpp:404
Code generator for C.
Definition: CGenerator.hpp:27
Definition: AstNode.hpp:26