From 566c9579104d29a83063636745eec6a9c221dabb Mon Sep 17 00:00:00 2001 From: Cervenka Dusan Date: Wed, 19 Jul 2023 12:11:45 +0200 Subject: [PATCH] Fixed yml tests. Signed-off-by: Cervenka Dusan --- erpc_c/infra/erpc_client_manager.h | 2 + erpc_c/infra/erpc_codec.hpp | 2 +- erpcgen/Makefile | 6 +- erpcgen/VisualStudio_v14/.gitignore | 3 +- erpcgen/VisualStudio_v14/erpcgen.vcxproj | 9 +- .../VisualStudio_v14/erpcgen.vcxproj.filters | 5 +- erpcgen/src/CGenerator.cpp | 57 ++++--- erpcgen/src/CGenerator.hpp | 12 +- erpcgen/src/Generator.cpp | 23 ++- erpcgen/src/PythonGenerator.cpp | 9 +- erpcgen/src/PythonGenerator.hpp | 2 +- erpcgen/src/SymbolScanner.cpp | 53 +++---- erpcgen/src/erpcgen.cpp | 24 +-- .../src/templates/c_client_header.template | 7 +- ...ader.template => c_common_header.template} | 31 +++- .../c_common_standard_header.template | 35 ----- .../src/templates/c_server_header.template | 7 +- .../src/templates/c_server_source.template | 10 +- .../src/templates/cpp_client_header.template | 2 + .../src/templates/cpp_client_source.template | 15 +- erpcgen/src/templates/cpp_coders.template | 5 +- .../templates/cpp_interface_header.template | 3 +- .../src/templates/cpp_server_header.template | 6 +- .../src/templates/cpp_server_source.template | 10 ++ erpcgen/test/conftest.py | 139 ++++++++++++++---- erpcgen/test/test_builtin_types.yml | 6 +- erpcgen/test/test_comments.yml | 10 +- erpcgen/test/test_enum.yml | 12 +- erpcgen/test/test_error_checks_c.yml | 24 +-- erpcgen/test/test_error_return_c.yml | 4 +- erpcgen/test/test_expressions.yml | 2 +- erpcgen/test/test_extern_c.yml | 4 +- erpcgen/test/test_forward_declaration_c.yml | 43 +----- erpcgen/test/test_import.yml | 8 +- erpcgen/test/test_include.yml | 21 +-- .../test/test_includes/test_includes_union.h | 7 +- erpcgen/test/test_name_c.yml | 15 +- erpcgen/test/test_nullable_c.yml | 19 +-- erpcgen/test/test_redundant_definitions.yml | 36 +++-- erpcgen/test/test_scope_c.yml | 8 +- erpcgen/test/test_service_c.yml | 16 +- erpcgen/test/test_struct.yml | 10 +- erpcgen/test/test_types_header.yml | 33 ----- erpcgen/test/test_union_c.yml | 17 ++- erpcsniffer/src/erpcsniffer.cpp | 12 +- test/common/gtestListener.hpp | 6 +- test/common/myAlloc.hpp | 12 +- test/common/unit_test_client.cpp | 2 +- test/common/unit_test_serial_client.cpp | 2 +- test/common/unit_test_serial_server.cpp | 8 +- test/common/unit_test_server.cpp | 6 +- test/common/unit_test_tcp_client.cpp | 2 +- test/common/unit_test_tcp_server.cpp | 8 +- .../test_annotations_server_impl.cpp | 2 +- test/test_arrays/test_arrays_server_impl.cpp | 2 +- test/test_binary/test_binary_server_impl.cpp | 2 +- .../test_builtin/test_builtin_server_impl.cpp | 2 +- .../test_callbacks_server_impl.cpp | 2 +- test/test_const/test_const_client_impl.cpp | 3 +- test/test_enums/test_enums_server_impl.cpp | 2 +- test/test_lists/test_lists_server_impl.cpp | 2 +- test/test_shared/test_shared_server_impl.cpp | 2 +- test/test_struct/test_struct_server_impl.cpp | 2 +- .../test_typedef/test_typedef_server_impl.cpp | 2 +- test/test_unions/test_unions_server_impl.cpp | 2 +- 65 files changed, 434 insertions(+), 421 deletions(-) rename erpcgen/src/templates/{c_common_erpc_header.template => c_common_header.template} (81%) delete mode 100644 erpcgen/src/templates/c_common_standard_header.template delete mode 100644 erpcgen/test/test_types_header.yml diff --git a/erpc_c/infra/erpc_client_manager.h b/erpc_c/infra/erpc_client_manager.h index 8544fb99..48c0f583 100644 --- a/erpc_c/infra/erpc_client_manager.h +++ b/erpc_c/infra/erpc_client_manager.h @@ -25,6 +25,8 @@ */ extern "C" { +#else +#include "erpc_common.h" #endif typedef void (*client_error_handler_t)(erpc_status_t err, diff --git a/erpc_c/infra/erpc_codec.hpp b/erpc_c/infra/erpc_codec.hpp index f89bfc2e..61cab61d 100644 --- a/erpc_c/infra/erpc_codec.hpp +++ b/erpc_c/infra/erpc_codec.hpp @@ -16,7 +16,7 @@ #include "erpc_transport.hpp" #include -#include +#include /*! * @addtogroup infra_codec diff --git a/erpcgen/Makefile b/erpcgen/Makefile index f1cdb274..9118d5c2 100644 --- a/erpcgen/Makefile +++ b/erpcgen/Makefile @@ -70,8 +70,7 @@ SOURCES += $(OBJS_ROOT)/erpcgen_parser.tab.cpp \ # Prevent make from deleting these temp files. .SECONDARY: $(OBJS_ROOT)/erpcgen_parser.tab.cpp \ $(OBJS_ROOT)/erpcgen_lexer.cpp \ - $(OBJS_ROOT)/erpcgen/src/templates/c_common_standard_header.c \ - $(OBJS_ROOT)/erpcgen/src/templates/c_common_erpc_header.c \ + $(OBJS_ROOT)/erpcgen/src/templates/c_common_header.c \ $(OBJS_ROOT)/erpcgen/src/templates/cpp_interface_header.c \ $(OBJS_ROOT)/erpcgen/src/templates/cpp_interface_source.c \ $(OBJS_ROOT)/erpcgen/src/templates/cpp_client_header.c \ @@ -93,8 +92,7 @@ SOURCES += $(OBJS_ROOT)/erpcgen_parser.tab.cpp \ $(OBJS_ROOT)/erpcgen/src/templates/py_coders.c \ $(OBJS_ROOT)/erpcgen/src/templates/py_global_init.c -SOURCES += $(OBJS_ROOT)/erpcgen/src/templates/c_common_standard_header.c \ - $(OBJS_ROOT)/erpcgen/src/templates/c_common_erpc_header.c \ +SOURCES += $(OBJS_ROOT)/erpcgen/src/templates/c_common_header.c \ $(OBJS_ROOT)/erpcgen/src/templates/cpp_interface_header.c \ $(OBJS_ROOT)/erpcgen/src/templates/cpp_interface_source.c \ $(OBJS_ROOT)/erpcgen/src/templates/cpp_client_header.c \ diff --git a/erpcgen/VisualStudio_v14/.gitignore b/erpcgen/VisualStudio_v14/.gitignore index a1280e52..024f1d9a 100644 --- a/erpcgen/VisualStudio_v14/.gitignore +++ b/erpcgen/VisualStudio_v14/.gitignore @@ -9,8 +9,7 @@ cpp_client_header.cpp cpp_server_header.cpp cpp_server_source.cpp cpp_coders.cpp -c_common_standard_header.cpp -c_common_erpc_header.cpp +c_common_header.cpp c_client_source.cpp c_client_header.cpp c_server_header.cpp diff --git a/erpcgen/VisualStudio_v14/erpcgen.vcxproj b/erpcgen/VisualStudio_v14/erpcgen.vcxproj index 538c3ff4..9d37fc2e 100644 --- a/erpcgen/VisualStudio_v14/erpcgen.vcxproj +++ b/erpcgen/VisualStudio_v14/erpcgen.vcxproj @@ -98,8 +98,7 @@ python.exe ..\bin\txt_to_c.py --output .\cpp_coders.cpp ..\src\templates\cpp_coders.template -python.exe ..\bin\txt_to_c.py --output .\c_common_standard_header.cpp ..\src\templates\c_common_standard_header.template -python.exe ..\bin\txt_to_c.py --output .\c_common_erpc_header.cpp ..\src\templates\c_common_erpc_header.template +python.exe ..\bin\txt_to_c.py --output .\c_common_header.cpp ..\src\templates\c_common_header.template python.exe ..\bin\txt_to_c.py --output .\cpp_interface_header.cpp ..\src\templates\cpp_interface_header.template python.exe ..\bin\txt_to_c.py --output .\cpp_interface_source.cpp ..\src\templates\cpp_interface_source.template python.exe ..\bin\txt_to_c.py --output .\cpp_client_header.cpp ..\src\templates\cpp_client_header.template @@ -146,8 +145,7 @@ python.exe ..\bin\txt_to_c.py --output .\py_global_init.cpp ..\src\templates\py_ python.exe ..\bin\txt_to_c.py --output .\cpp_coders.cpp ..\src\templates\cpp_coders.template -python.exe ..\bin\txt_to_c.py --output .\c_common_standard_header.cpp ..\src\templates\c_common_standard_header.template -python.exe ..\bin\txt_to_c.py --output .\c_common_erpc_header.cpp ..\src\templates\c_common_erpc_header.template +python.exe ..\bin\txt_to_c.py --output .\c_common_header.cpp ..\src\templates\c_common_header.template python.exe ..\bin\txt_to_c.py --output .\cpp_interface_header.cpp ..\src\templates\cpp_interface_header.template python.exe ..\bin\txt_to_c.py --output .\cpp_interface_source.cpp ..\src\templates\cpp_interface_source.template python.exe ..\bin\txt_to_c.py --output .\cpp_client_header.cpp ..\src\templates\cpp_client_header.template @@ -246,8 +244,7 @@ python.exe ..\bin\txt_to_c.py --output .\py_global_init.cpp ..\src\templates\py_ - - + diff --git a/erpcgen/VisualStudio_v14/erpcgen.vcxproj.filters b/erpcgen/VisualStudio_v14/erpcgen.vcxproj.filters index 7666e4c5..1d72bbdb 100644 --- a/erpcgen/VisualStudio_v14/erpcgen.vcxproj.filters +++ b/erpcgen/VisualStudio_v14/erpcgen.vcxproj.filters @@ -167,10 +167,7 @@ Source Files - - Source Files - - + Source Files diff --git a/erpcgen/src/CGenerator.cpp b/erpcgen/src/CGenerator.cpp index 782c975b..581f664a 100644 --- a/erpcgen/src/CGenerator.cpp +++ b/erpcgen/src/CGenerator.cpp @@ -31,8 +31,8 @@ using namespace std; static const char *const kIdentifierChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"; // Templates strings converted from text files by txt_to_c.py. -extern const char *const kCCommonStandardHeader; -extern const char *const kCCommonErpcHeader; +extern const char *const kCCommonHeader; +extern const char *const kCppCommonHeader; extern const char *const kCppInterfaceHeader; extern const char *const kCppInterfaceSource; extern const char *const kCppClientHeader; @@ -79,8 +79,8 @@ CGenerator::CGenerator(InterfaceDefinition *def) void CGenerator::generateOutputFiles(const string &fileName) { - generateCommonStandardCHeaderFiles(fileName); - generateCommonErpcCHeaderFiles(fileName); + generateCommonCHeaderFiles(fileName); + generateCommonCppHeaderFiles(fileName); generateInterfaceCppHeaderFile(fileName); generateInterfaceCppSourceFile(fileName); @@ -98,20 +98,22 @@ void CGenerator::generateOutputFiles(const string &fileName) generateServerCSourceFile(fileName); } -void CGenerator::generateCommonStandardCHeaderFiles(string fileName) +void CGenerator::generateCommonCHeaderFiles(string fileName) { - fileName += "_common_standard.h"; - m_templateData["commonStandardCGuardMacro"] = generateIncludeGuardName(fileName); - m_templateData["commonStandardCHeaderName"] = fileName; - generateOutputFile(fileName, "c_common_standard_header", m_templateData, kCCommonStandardHeader); + fileName += "_common.h"; + m_templateData["commonGuardMacro"] = generateIncludeGuardName(fileName); + m_templateData["commonCHeaderName"] = fileName; + m_templateData["cCommonHeaderFile"] = true; + generateOutputFile(fileName, "c_common_header", m_templateData, kCCommonHeader); } -void CGenerator::generateCommonErpcCHeaderFiles(string fileName) +void CGenerator::generateCommonCppHeaderFiles(string fileName) { - fileName += "_common_erpc.h"; - m_templateData["commonErpcCGuardMacro"] = generateIncludeGuardName(fileName); - m_templateData["commonErpcCHeaderName"] = fileName; - generateOutputFile(fileName, "c_common_erpc_header", m_templateData, kCCommonErpcHeader); + fileName += "_common.hpp"; + m_templateData["commonGuardMacro"] = generateIncludeGuardName(fileName); + m_templateData["commonCppHeaderName"] = fileName; + m_templateData["cCommonHeaderFile"] = false; + generateOutputFile(fileName, "c_common_header", m_templateData, kCCommonHeader); } void CGenerator::generateInterfaceCppHeaderFile(string fileName) @@ -478,7 +480,7 @@ void CGenerator::generate() } /* Generate file with shim code version. */ m_templateData["versionGuardMacro"] = - generateIncludeGuardName(format_string("erpc_generated_shim_code_crc_%d", m_idlCrc16).c_str()); + generateIncludeGuardName(format_string("erpc_generated_shim_code_crc_%d", m_idlCrc16)); m_templateData["generateInfraErrorChecks"] = generateInfraErrorChecks; m_templateData["generateAllocErrorChecks"] = generateAllocErrorChecks; @@ -596,7 +598,7 @@ void CGenerator::makeConstTemplateData() if (nullptr == constVarValue) { throw semantic_error( - format_string("line %d: Const pointing to null Value object.", constVar->getLastLine()).c_str()); + format_string("line %d: Const pointing to null Value object.", constVar->getLastLine())); } /* Use char[] for constants. */ @@ -617,8 +619,7 @@ void CGenerator::makeConstTemplateData() if (constVarValue->getType() != kIntegerValue) { throw semantic_error(format_string("line %d: Const enum pointing to non-integer Value object.", - constVar->getLastLine()) - .c_str()); + constVar->getLastLine())); } EnumType *constEnum = dynamic_cast(constVarType); @@ -635,9 +636,8 @@ void CGenerator::makeConstTemplateData() if (value.compare("") == 0) { value = "(" + constVarType->getName() + ") " + constVarValue->toString(); - Log::warning(format_string("Enum value '%s' is not pointing to any '%s' variable \n", - constVarValue->toString().c_str(), constVarType->getName().c_str()) - .c_str()); + Log::warning("Enum value '%s' is not pointing to any '%s' variable \n", + constVarValue->toString().c_str(), constVarType->getName().c_str()); } } else @@ -1104,8 +1104,7 @@ data_map CGenerator::getStructDefinitionTemplateData(Group *group, StructType *s { throw syntax_error( format_string("line %d: Struct member shall use byref option. Member is using forward declared type.", - member->getFirstLine()) - .c_str()); + member->getFirstLine())); } // Handle nullable annotation bool isNullable = @@ -1693,7 +1692,7 @@ data_map CGenerator::getFunctionTemplateData(Group *group, Function *fn) string proto = getFunctionPrototype(group, fn); info["prototype"] = proto; - string protoCpp = getFunctionPrototype(group, fn, fn->getInterface()->getName() + "_client", "", true); + string protoCpp = getFunctionPrototype(group, fn, getOutputName(fn->getInterface()) + "_client", "", true); info["prototypeCpp"] = protoCpp; string protoInterface = getFunctionPrototype(group, fn, "", "", true); info["prototypeInterface"] = protoInterface; @@ -2520,11 +2519,11 @@ data_map CGenerator::getEncodeDecodeCall(const string &name, Group *group, DataT } else { - throw semantic_error(format_string("line %d: Function has function type parameter (callback " - "parameter), but in IDL is missing function definition, which can " - "be passed there.", - structMember->getFirstLine()) - .c_str()); + throw semantic_error( + format_string("line %d: Function has function type parameter (callback " + "parameter), but in IDL is missing function definition, which can " + "be passed there.", + structMember->getFirstLine())); } templateData["encode"] = m_templateData["encodeFunctionType"]; templateData["decode"] = m_templateData["decodeFunctionType"]; diff --git a/erpcgen/src/CGenerator.hpp b/erpcgen/src/CGenerator.hpp index 7809e608..56264b86 100644 --- a/erpcgen/src/CGenerator.hpp +++ b/erpcgen/src/CGenerator.hpp @@ -92,18 +92,18 @@ class CGenerator : public Generator void generateOutputFiles(const std::string &fileNameExtension) override; /*! - * @brief This function generate header file output with common standard code. + * @brief This function generate header file output with common eRPC code. * - * @param[in] fileName Name for common standard header file output. + * @param[in] fileName Name for common eRPC header file output. */ - void generateCommonStandardCHeaderFiles(std::string fileName); + void generateCommonCHeaderFiles(std::string fileName); /*! * @brief This function generate header file output with common eRPC code. * * @param[in] fileName Name for common eRPC header file output. */ - void generateCommonErpcCHeaderFiles(std::string fileName); + void generateCommonCppHeaderFiles(std::string fileName); /*! * @brief This function generate output interface header file. @@ -253,7 +253,7 @@ class CGenerator : public Generator * * @return Contains interface function data. */ - cpptempl::data_map getFunctionTypeTemplateData(Group *group, FunctionType *fn); + cpptempl::data_map getFunctionTypeTemplateData(Group *group, FunctionType *fn) override; /*! * @brief This function will get symbol comments and convert to language specific ones @@ -476,7 +476,7 @@ class CGenerator : public Generator * @return String prototype representation for given function. */ std::string getFunctionPrototype(Group *group, FunctionBase *fn, const std::string &interfaceName = "", - const std::string &name = "", bool insideInterfaceCall = false); + const std::string &name = "", bool insideInterfaceCall = false) override; /*! * @brief This function return interface function representation called by server side. diff --git a/erpcgen/src/Generator.cpp b/erpcgen/src/Generator.cpp index e9369305..5121550a 100644 --- a/erpcgen/src/Generator.cpp +++ b/erpcgen/src/Generator.cpp @@ -17,10 +17,10 @@ #include "format_string.hpp" #include -#include #include #include #include +#include using namespace erpcgen; using namespace cpptempl; @@ -39,6 +39,7 @@ Generator::Generator(InterfaceDefinition *def, generator_type_t generatorType) string scopeName = "erpcShim"; string scopeNameC; string scopeNamePrefix = ""; + string namespaceVal = scopeName; m_templateData["erpcVersion"] = ERPC_VERSION; m_templateData["erpcVersionNumber"] = ERPC_VERSION_NUMBER; @@ -92,13 +93,9 @@ Generator::Generator(InterfaceDefinition *def, generator_type_t generatorType) scopeName = getAnnStringValue(program, SCOPE_NAME_ANNOTATION); } - if (findAnnotation(m_def->getProgramSymbol(), NAMESPACE_ANNOTATION) != nullptr) - { - m_templateData["namespace"] = getAnnStringValue(m_def->getProgramSymbol(), NAMESPACE_ANNOTATION); - } - else + if (findAnnotation(program, NAMESPACE_ANNOTATION) != nullptr) { - m_templateData["namespace"] = "erpcshim"; + namespaceVal = getAnnStringValue(program, NAMESPACE_ANNOTATION); } } @@ -112,6 +109,7 @@ Generator::Generator(InterfaceDefinition *def, generator_type_t generatorType) } m_templateData["scopeNameC"] = scopeNameC; m_templateData["scopeNamePrefix"] = scopeNamePrefix; + m_templateData["namespace"] = namespaceVal; // get group annotation with vector of theirs interfaces m_groups.clear(); @@ -595,10 +593,8 @@ string Generator::getOutputName(Symbol *symbol, bool check) auto it = reserverdWords.find(annName); if (it != reserverdWords.end()) { - throw semantic_error( - format_string("line %d: Wrong symbol name '%s'. Cannot use program language reserved words.", line, - annName.c_str()) - .c_str()); + throw semantic_error(format_string( + "line %d: Wrong symbol name '%s'. Cannot use program language reserved words.", line, annName.c_str())); } } @@ -701,7 +697,7 @@ void Generator::getCallbacksTemplateData(Group *group, const Interface *iface, d for (auto functionType : iface->getFunctionTypes()) { if ((std::find(callbackTypesNames.begin(), callbackTypesNames.end(), functionType->getName()) == - callbackTypesNames.end())) + callbackTypesNames.end())) { callbackTypes.push_back(functionType); callbackTypesNames.push_back(functionType->getName()); @@ -736,7 +732,8 @@ void Generator::getCallbacksTemplateData(Group *group, const Interface *iface, d data_map callbackType; callbackType["name"] = functionType->getName(); callbackType["typenameName"] = getFunctionPrototype(nullptr, functionType); - callbackType["interfaceTypenameName"] = getFunctionPrototype(nullptr, functionType, iface->getName() + "_interface"); + callbackType["interfaceTypenameName"] = + getFunctionPrototype(nullptr, functionType, iface->getName() + "_interface"); if (!functionsInt.empty()) { callbackType["callbacks"] = functionsInt; diff --git a/erpcgen/src/PythonGenerator.cpp b/erpcgen/src/PythonGenerator.cpp index 737fc66f..cde1d2ba 100644 --- a/erpcgen/src/PythonGenerator.cpp +++ b/erpcgen/src/PythonGenerator.cpp @@ -122,6 +122,7 @@ void PythonGenerator::generate() m_templateData["structs"] = empty; m_templateData["unions"] = empty; m_templateData["consts"] = empty; + m_templateData["functions"] = empty; parseSubtemplates(); @@ -625,9 +626,9 @@ data_map PythonGenerator::getTypeInfo(DataType *t) } else { - throw semantic_error(format_string("Function has function type parameter (callback parameter), but in " - "IDL is missing function definition, which can be passed there.") - .c_str()); + throw semantic_error( + "Function has function type parameter (callback parameter), but in " + "IDL is missing function definition, which can be passed there."); } break; } @@ -669,7 +670,7 @@ data_map PythonGenerator::getTypeInfo(DataType *t) StructMember *discriminatorMember = dynamic_cast(discriminatorSym); if (!discriminatorMember) { - throw internal_error(format_string("union discriminator is not a struct member")); + throw internal_error("union discriminator is not a struct member"); } info["discriminatorType"] = getTypeInfo(discriminatorMember->getDataType()); } diff --git a/erpcgen/src/PythonGenerator.hpp b/erpcgen/src/PythonGenerator.hpp index 6c2e9381..f05516a0 100644 --- a/erpcgen/src/PythonGenerator.hpp +++ b/erpcgen/src/PythonGenerator.hpp @@ -156,7 +156,7 @@ class PythonGenerator : public Generator * @return String prototype representation for given function. */ std::string getFunctionPrototype(Group *group, FunctionBase *fn, const std::string &interfaceName = "", - const std::string &name = "", bool insideInterfaceCall = false); + const std::string &name = "", bool insideInterfaceCall = false) override; /*! * @brief This function sets const template data. diff --git a/erpcgen/src/SymbolScanner.cpp b/erpcgen/src/SymbolScanner.cpp index 65c2dfdb..64054581 100644 --- a/erpcgen/src/SymbolScanner.cpp +++ b/erpcgen/src/SymbolScanner.cpp @@ -45,8 +45,7 @@ void SymbolScanner::handleRoot(AstNode *node, bottom_up) forwardTypes += format_string("type name %s: line %d", it->first.c_str(), it->second->getFirstLine()); } throw syntax_error(format_string("Missing type definitions for one or more forward type declarations: %s", - forwardTypes.c_str()) - .c_str()); + forwardTypes.c_str())); } } @@ -643,9 +642,8 @@ AstNode *SymbolScanner::handleStruct(AstNode *node, top_down) AstNode *structNameNode = (*node)[0]; if (!structNameNode && m_currentAlias == nullptr) { - throw semantic_error( - format_string("line %d: illegal anonymous struct definition at file level", node->getToken().getFirstLine()) - .c_str()); + throw semantic_error(format_string("line %d: illegal anonymous struct definition at file level", + node->getToken().getFirstLine())); } // Create the struct symbol. @@ -667,10 +665,10 @@ AstNode *SymbolScanner::handleStruct(AstNode *node, top_down) } else { - throw syntax_error(format_string("line %d: Structure definition type name didn't match data type of " - "forward declaration from line %d.", - tok.getFirstLine(), forwardDecl->second->getFirstLine()) - .c_str()); + throw syntax_error( + format_string("line %d: Structure definition type name didn't match data type of " + "forward declaration from line %d.", + tok.getFirstLine(), forwardDecl->second->getFirstLine())); } } else @@ -823,10 +821,10 @@ AstNode *SymbolScanner::handleUnion(AstNode *node, top_down) } else { - throw syntax_error(format_string("line %d: Union definition type name didn't match data type of " - "forward declaration from line %d.", - tok->getFirstLine(), forwardDecl->second->getFirstLine()) - .c_str()); + throw syntax_error( + format_string("line %d: Union definition type name didn't match data type of " + "forward declaration from line %d.", + tok->getFirstLine(), forwardDecl->second->getFirstLine())); } } else @@ -1059,8 +1057,8 @@ AstNode *SymbolScanner::handleInterface(AstNode *node, bottom_up) { throw syntax_error( format_string("line %d, Callback name %s doesn't exists in interface %s.\n", - funcType->getLocation().m_firstLine, funcType->getName(), - funcType->getInterface()->getName())); + funcType->getLocation().m_firstLine, funcType->getName().c_str(), + funcType->getInterface()->getName().c_str())); } } } @@ -1255,10 +1253,10 @@ AstNode *SymbolScanner::handleParam(AstNode *node, top_down) { if (fun->getParameters().getMembers().size() > funType->getParameters().getMembers().size()) { - throw syntax_error(format_string("line %d: Function definition contains more parameters than " - "function type definition from %d.\n", - fun->getFirstLine(), funType->getFirstLine()) - .c_str()); + throw syntax_error( + format_string("line %d: Function definition contains more parameters than " + "function type definition from %d.\n", + fun->getFirstLine(), funType->getFirstLine())); } else { @@ -1326,7 +1324,7 @@ AstNode *SymbolScanner::handleParam(AstNode *node, top_down) if (dataType == nullptr) { throw syntax_error(format_string("line %d: Callback name %s doesn't exists.\n", - type->getToken().getFirstLine(), functionTypeName)); + type->getToken().getFirstLine(), functionTypeName.c_str())); } break; } @@ -1662,8 +1660,7 @@ Annotation::program_lang_t SymbolScanner::getAnnotationLang(AstNode *annotation) } throw semantic_error(format_string("line %d: Unsupported programming language '%s' specified.", - annotation->getToken().getFirstLine(), lang.c_str()) - .c_str()); + annotation->getToken().getFirstLine(), lang.c_str())); } return Annotation::kAll; @@ -1840,8 +1837,7 @@ void SymbolScanner::addForwardDeclaration(DataType *dataType) { throw semantic_error(format_string("line %d: Declaring type '%s' already declared here '%d'", dataType->getFirstLine(), dataType->getName().c_str(), - symbol->getFirstLine()) - .c_str()); + symbol->getFirstLine())); } auto findDataTypeIT = m_forwardDeclarations.find(dataType->getName()); @@ -1851,8 +1847,7 @@ void SymbolScanner::addForwardDeclaration(DataType *dataType) { throw semantic_error(format_string("line %d: Declaring type '%s' already declared here '%d'", dataType->getFirstLine(), dataType->getName().c_str(), - findDataTypeIT->second->getFirstLine()) - .c_str()); + findDataTypeIT->second->getFirstLine())); } else { @@ -1871,8 +1866,7 @@ void SymbolScanner::removeForwardDeclaration(DataType *dataType) { throw semantic_error(format_string("line %d: Declaring type '%s' already declared here '%d'", dataType->getFirstLine(), dataType->getName().c_str(), - findDataTypeIT->second->getFirstLine()) - .c_str()); + findDataTypeIT->second->getFirstLine())); } m_forwardDeclarations.erase(findDataTypeIT); } @@ -1885,8 +1879,7 @@ void SymbolScanner::addGlobalSymbol(Symbol *symbol) { throw semantic_error(format_string("line %d: Declaring symbol '%s' already declared here '%d'", symbol->getFirstLine(), symbol->getName().c_str(), - findDataTypeIT->second->getFirstLine()) - .c_str()); + findDataTypeIT->second->getFirstLine())); } m_globals->addSymbol(symbol); } diff --git a/erpcgen/src/erpcgen.cpp b/erpcgen/src/erpcgen.cpp index 0e2d180b..40e1cd13 100644 --- a/erpcgen/src/erpcgen.cpp +++ b/erpcgen/src/erpcgen.cpp @@ -98,19 +98,19 @@ class erpcgenTool { kCLanguage, kPythonLanguage, - }; /*!< Generated outputs format. */ + }; /*!< Generated outputs format. */ typedef vector string_vector_t; /*!< Vector of positional arguments. */ - int m_argc; /*!< Number of command line arguments. */ - char **m_argv; /*!< String value for each command line argument. */ - StdoutLogger *m_logger; /*!< Singleton logger instance. */ - verbose_type_t m_verboseType; /*!< Which type of log is need to set (warning, info, debug). */ - const char *m_outputFilePath; /*!< Path to the output file. */ - const char *m_ErpcFile; /*!< ERPC file. */ - string_vector_t m_positionalArgs; /*!< Positional arguments. */ - languages_t m_outputLanguage; /*!< Output language we're generating. */ - InterfaceDefinition::codec_t m_codec; /*!< Used codec type. */ + int m_argc; /*!< Number of command line arguments. */ + char **m_argv; /*!< String value for each command line argument. */ + StdoutLogger *m_logger; /*!< Singleton logger instance. */ + verbose_type_t m_verboseType; /*!< Which type of log is need to set (warning, info, debug). */ + const char *m_outputFilePath; /*!< Path to the output file. */ + const char *m_ErpcFile; /*!< ERPC file. */ + string_vector_t m_positionalArgs; /*!< Positional arguments. */ + languages_t m_outputLanguage; /*!< Output language we're generating. */ + InterfaceDefinition::codec_t m_codec; /*!< Used codec type. */ public: /*! @@ -205,7 +205,7 @@ class erpcgenTool } else { - Log::error(format_string("error: unknown language %s", lang.c_str()).c_str()); + Log::error("error: unknown language %s", lang.c_str()); return 1; } break; @@ -219,7 +219,7 @@ class erpcgenTool } else { - Log::error(format_string("error: unknown codec type %s", codec.c_str()).c_str()); + Log::error("error: unknown codec type %s", codec.c_str()); return 1; } break; diff --git a/erpcgen/src/templates/c_client_header.template b/erpcgen/src/templates/c_client_header.template index 9715e28d..fb83a8b2 100644 --- a/erpcgen/src/templates/c_client_header.template +++ b/erpcgen/src/templates/c_client_header.template @@ -7,8 +7,7 @@ #if !defined({$clientCGuardMacro}) #define {$clientCGuardMacro} -#include "{$commonStandardCHeaderName}" -#include "{$commonErpcCHeaderName}" +#include "{$commonCHeaderName}" #include "erpc_client_manager.h" {% for iface in group.interfaces %} {% for fn in iface.functions %} @@ -22,7 +21,7 @@ {% endfor -- fn %} {% endfor -- iface %} -#ifdef __cplusplus +#if defined(__cplusplus) extern "C" { #endif @@ -64,7 +63,7 @@ void init{$iface.clientClassName}(erpc_client_t client); void deinit{$iface.clientClassName}(void); {% endfor -- iface %} -#ifdef __cplusplus +#if defined(__cplusplus) } #endif diff --git a/erpcgen/src/templates/c_common_erpc_header.template b/erpcgen/src/templates/c_common_header.template similarity index 81% rename from erpcgen/src/templates/c_common_erpc_header.template rename to erpcgen/src/templates/c_common_header.template index 2c4085dd..16363ebc 100644 --- a/erpcgen/src/templates/c_common_erpc_header.template +++ b/erpcgen/src/templates/c_common_header.template @@ -4,8 +4,8 @@ {% endif %} {$commonHeader()} -#if !defined({$commonErpcCGuardMacro}) -#define {$commonErpcCGuardMacro} +#if !defined({$commonGuardMacro}) +#define {$commonGuardMacro} {% if usedUnionType %} #if defined(__CC_ARM) || defined(__ARMCC_VERSION) @@ -13,12 +13,29 @@ #endif {% endif -- usedUnionType %} -#ifdef __cplusplus +{% for inc in includes %} +#include "{$inc}" +{% endfor -- includes %} + +{% if cCommonHeaderFile %} +#if defined(__cplusplus) extern "C" { #endif +#include +#include +#include +{% else %} +#include +#include +#include +{$fillNamespaceBegin()>} +{% endif %} #include "erpc_version.h" +{% if empty(crc16) == false %} +#include "{$crcHeaderName}" +{% endif -- empty(crc16) == false %} {$checkVersion()} {$>checkCrc()} @@ -93,8 +110,12 @@ extern const {$c.typeAndName};{$c.ilComment}{$loop.addNewLineIfNotLast} #endif // ERPC_TYPE_DEFINITIONS{$scopeNamePrefix}{$scopeNameC} +{% if cCommonHeaderFile %} #if defined(__cplusplus) } -#endif // __cplusplus +#endif +{% else %} +{$fillNamespaceEnd()} +{% endif %} -#endif // {$commonErpcCGuardMacro} +#endif // {$commonGuardMacro} diff --git a/erpcgen/src/templates/c_common_standard_header.template b/erpcgen/src/templates/c_common_standard_header.template deleted file mode 100644 index 56e335f5..00000000 --- a/erpcgen/src/templates/c_common_standard_header.template +++ /dev/null @@ -1,35 +0,0 @@ -{% if mlComment != ""%} -{$mlComment} - -{% endif %} -{$commonHeader()} - -#if !defined({$commonStandardCGuardMacro}) -#define {$commonStandardCGuardMacro} - -#ifdef __cplusplus - -{% for inc in includes %} -#include "{$inc}" -{% endfor -- includes %} - -extern "C" -{ -#endif - -#include -#include -#include -#include "erpc_version.h" -{% if empty(crc16) == false %} -#include "{$crcHeaderName}" -{% endif -- empty(crc16) == false %} - -{$checkVersion()} -{$>checkCrc()} - -#ifdef __cplusplus -} -#endif - -#endif // {$commonStandardCGuardMacro} diff --git a/erpcgen/src/templates/c_server_header.template b/erpcgen/src/templates/c_server_header.template index 0f495e6d..e2a7afcb 100644 --- a/erpcgen/src/templates/c_server_header.template +++ b/erpcgen/src/templates/c_server_header.template @@ -7,8 +7,7 @@ #if !defined({$serverCGuardMacro}) #define {$serverCGuardMacro} -#include "{$commonStandardCHeaderName}" -#include "{$commonErpcCHeaderName}" +#include "{$commonCHeaderName}" {% for iface in group.interfaces %} {% for fn in iface.functions %} {% for externalInterface in fn.externalInterfaces %} @@ -21,7 +20,7 @@ {% endfor -- fn %} {% endfor -- iface %} -#ifdef __cplusplus +#if defined(__cplusplus) extern "C" { #endif @@ -69,7 +68,7 @@ void destroy_{$iface.serviceClassName}(erpc_service_t service); {% endfor -- iface %} -#ifdef __cplusplus +#if defined(__cplusplus) } #endif diff --git a/erpcgen/src/templates/c_server_source.template b/erpcgen/src/templates/c_server_source.template index 4274da74..48d9d5ba 100644 --- a/erpcgen/src/templates/c_server_source.template +++ b/erpcgen/src/templates/c_server_source.template @@ -21,11 +21,6 @@ using namespace erpc; using namespace std; {$usingNamespace() >} {% for iface in group.interfaces %} - -ERPC_MANUALLY_CONSTRUCTED_STATIC({$iface.serviceClassName}, s_{$iface.serviceClassName}); -ERPC_MANUALLY_CONSTRUCTED_STATIC({$iface.serverClassName}, s_{$iface.serverClassName}); -{% endfor -- iface %} -{% for iface in group.interfaces %} {% if count(iface.callbacksAll) > 0 %} {% for cb in iface.callbacksAll %} @@ -38,6 +33,8 @@ static const {$cb.name} _{$cb.name}[{$count(cb.callbacks)}] = { {% for c in c class {$iface.serverClassName}: public {$iface.interfaceClassName} { public: + virtual ~{$iface.serverClassName}() {}; + {% for fn in iface.functions %} {$fn.prototypeInterface} @@ -77,6 +74,9 @@ class {$iface.serverClassName}: public {$iface.interfaceClassName} {% endfor -- fn %} }; +ERPC_MANUALLY_CONSTRUCTED_STATIC({$iface.serviceClassName}, s_{$iface.serviceClassName}); +ERPC_MANUALLY_CONSTRUCTED_STATIC({$iface.serverClassName}, s_{$iface.serverClassName}); + erpc_service_t create_{$iface.serviceClassName}(void) { erpc_service_t service; diff --git a/erpcgen/src/templates/cpp_client_header.template b/erpcgen/src/templates/cpp_client_header.template index 4ab1d2fd..85d166bb 100644 --- a/erpcgen/src/templates/cpp_client_header.template +++ b/erpcgen/src/templates/cpp_client_header.template @@ -17,6 +17,8 @@ class {$iface.clientClassName}: public {$iface.interfaceClassName} { public: {$iface.clientClassName}(erpc::ClientManager *manager); + + virtual ~{$iface.clientClassName}(); {% for fn in iface.functions if fn.isNonExternalFunction == true %} {% if fn.mlComment %} diff --git a/erpcgen/src/templates/cpp_client_source.template b/erpcgen/src/templates/cpp_client_source.template index 950740b4..3798ca80 100644 --- a/erpcgen/src/templates/cpp_client_source.template +++ b/erpcgen/src/templates/cpp_client_source.template @@ -11,15 +11,6 @@ #include "{$codecHeader}" #include "{$clientCppHeaderName}" #include "erpc_manually_constructed.hpp" -extern "C" -{ -{% if groupNames %} -// import callbacks declaration from other groups -{% for name in groupNames if name != group.name %} -#include "{$outputFilename}_{$name}_common_erpc.h" -{% endfor %} -{% endif %} -} {$checkVersion()} {$>checkCrc()} @@ -187,7 +178,11 @@ static {$cb.callbacksData.prototype} {$iface.clientClassName}::{$iface.clientClassName}(ClientManager *manager) :m_clientManager(manager) { -}; +} + +{$iface.clientClassName}::~{$iface.clientClassName}() +{ +} {% for fn in iface.functions %} // {$iface.name} interface {$fn.name} function client shim. diff --git a/erpcgen/src/templates/cpp_coders.template b/erpcgen/src/templates/cpp_coders.template index 7f08bf41..1dd7dacc 100644 --- a/erpcgen/src/templates/cpp_coders.template +++ b/erpcgen/src/templates/cpp_coders.template @@ -5,7 +5,7 @@ char * {$info.stringLocalName}_local; codec->readString({$info.stringLocalName}_len, &{$info.stringLocalName}_local); {% if info.stringAllocSize != info.stringLocalName & "_len" %} - if ({$info.stringLocalName}_len <= {$info.stringAllocSize}) + if (({$info.stringAllocSize} >= 0) && ({$info.stringLocalName}_len <= static_cast({$info.stringAllocSize}))) { {% set indent = " " >%} {% else %} @@ -261,7 +261,8 @@ codec->readData({$info.name}, {$info.sizeTemp} * sizeof({$info.builtinTypeName}) uint32_t {$info.stringLocalName}_len = strlen((const char*){$info.name}); {% if info.stringAllocSize != info.stringLocalName & "_len" %} - erpc_assert({$info.stringLocalName}_len <= {$info.stringAllocSize}); + erpc_assert({$info.stringAllocSize} >= 0); + erpc_assert({$info.stringLocalName}_len <= static_cast({$info.stringAllocSize})); {% endif %} codec->writeString({$info.stringLocalName}_len, (const char*){$info.name}); diff --git a/erpcgen/src/templates/cpp_interface_header.template b/erpcgen/src/templates/cpp_interface_header.template index 2c8dc04e..b76e8cfe 100644 --- a/erpcgen/src/templates/cpp_interface_header.template +++ b/erpcgen/src/templates/cpp_interface_header.template @@ -7,7 +7,7 @@ #if !defined({$interfaceCppGuardMacro}) #define {$interfaceCppGuardMacro} -#include "{$commonStandardCHeaderName}" +#include "{$commonCppHeaderName}" {% for iface in group.interfaces %} {% for fn in iface.functions %} {% for externalInterface in fn.externalInterfaces %} @@ -20,7 +20,6 @@ {% endfor -- fn %} {% endfor -- iface %} {$fillNamespaceBegin()} -#include "{$commonErpcCHeaderName}" {% for iface in group.interfaces %} // Abstract base class for {$iface.name} diff --git a/erpcgen/src/templates/cpp_server_header.template b/erpcgen/src/templates/cpp_server_header.template index f6e47fbd..d677cc82 100644 --- a/erpcgen/src/templates/cpp_server_header.template +++ b/erpcgen/src/templates/cpp_server_header.template @@ -23,9 +23,9 @@ class {$iface.serviceClassName} : public erpc::Service { public: - {$iface.serviceClassName}({$iface.interfaceClassName} *_{$iface.interfaceClassName}) - : m_handler(_{$iface.interfaceClassName}) - , erpc::Service({$iface.interfaceClassName}::m_serviceId) {} + {$iface.serviceClassName}({$iface.interfaceClassName} *_{$iface.interfaceClassName}); + + virtual ~{$iface.serviceClassName}(); /*! @brief return service interface handler. */ {$iface.interfaceClassName}* getHandler(void); diff --git a/erpcgen/src/templates/cpp_server_source.template b/erpcgen/src/templates/cpp_server_source.template index 7d034d3b..206b5f47 100644 --- a/erpcgen/src/templates/cpp_server_source.template +++ b/erpcgen/src/templates/cpp_server_source.template @@ -196,6 +196,16 @@ static erpc_status_t {$iface.interfaceClassName}_{$cb.name}_shim({$iface.interfa {% endfor %} {% for iface in group.interfaces -- service subclass method impl %} +{$iface.serviceClassName}::{$iface.serviceClassName}({$iface.interfaceClassName} *_{$iface.interfaceClassName}) + : erpc::Service({$iface.interfaceClassName}::m_serviceId) + , m_handler(_{$iface.interfaceClassName}) +{ +} + +{$iface.serviceClassName}::~{$iface.serviceClassName}() +{ +} + // return service interface handler. {$iface.interfaceClassName}* {$iface.serviceClassName}::getHandler(void) { diff --git a/erpcgen/test/conftest.py b/erpcgen/test/conftest.py index 324dd9bf..759c3157 100644 --- a/erpcgen/test/conftest.py +++ b/erpcgen/test/conftest.py @@ -284,8 +284,8 @@ def _run(cwd, captureOutput, pytestConfig, args, compilerType): # Enable all warnings except for unused functions. defaultArgs = ["-c", "-Wall", "-Werror", "-Wno-unused-function"] defaultArgs += self._args - argsCC = [self._pathCC, "-std=gnu11"] + defaultArgs - argsCXX = [self._pathCXX, "-std=gnu++11"] + defaultArgs + argsCC = [self._pathCC, "-std=gnu17"] + defaultArgs + argsCXX = [self._pathCXX, "-std=gnu++17"] + defaultArgs incl = [] for i in self._includes: @@ -294,15 +294,24 @@ def _run(cwd, captureOutput, pytestConfig, args, compilerType): argsCXX += incl argsCC += incl + hasCSource = False + hasCppSource = False for s in self._sources: if str(s).split(".")[-1] == "cpp": argsCXX.append(str(s)) + hasCppSource = True else: argsCC.append(str(s)) + hasCSource = True - output = [_run(self._cwd, captureOutput, pytestConfig, argsCC, "C")] - output.append(_run(self._cwd, captureOutput, - pytestConfig, argsCXX, "CXX")) + output = [] + + if hasCSource: + output.append(_run(self._cwd, captureOutput, + pytestConfig, argsCC, "C")) + if hasCppSource: + output.append(_run(self._cwd, captureOutput, + pytestConfig, argsCXX, "CXX")) return output @@ -481,29 +490,58 @@ def run(self): pass -class ErpcgenCCompileTest(ErpcgenCompileTest): - # @brief Tests that generated C code will compile successfully. - # - # An objects directory is created under the test case directory. It is used to hold the - # .o files written by the compiler. A .c file with the main() function is also written to - # the objects directory. +class ErpcgenCCppCompileTest(ErpcgenCompileTest): + # @brief Compile with C and CPP main. + def __init__(self, spec: ErpcgenTestSpec, name: str, caseDir: str, outDir: str): + super(ErpcgenCCppCompileTest, self).__init__( + spec, name, caseDir, outDir) + self._caseDir = caseDir + self._out_dir = outDir + + def run(self): + ErpcgenCCompileTest(self._caseDir, self._out_dir).run() + ErpcgenCppCompileTest(self._caseDir, self._out_dir).run() + + +class ErpcgenCCppCompileTestCommon(object): MAIN_CODE = textwrap.dedent(""" int main(void) { return 0; } """) - def __init__(self, spec: ErpcgenTestSpec, name: str, caseDir: str, outDir: str): - super(ErpcgenCCompileTest, self).__init__(spec, name, caseDir, outDir) - self._objs_dir = caseDir.mkdir(OBJECTS_DIR_NAME) - self._compiler = CCompiler(self._objs_dir) + def __init__(self, outDir: str): + self._out_dir = outDir + self._objs_dir = None + self._compiler = None + + def getMainSourceCode(self): + raise ErpcgenTestException( + "Missing implementation for getting main source code") + + def getMainFilename(self): + raise ErpcgenTestException( + "Missing implementation for getting main filename") + + def getObjectsDir(self): + raise ErpcgenTestException( + "Missing implementation for getting objects dir") + + def getCompiler(self): + raise ErpcgenTestException( + "Missing implementation for getting compiler") + def run(self): # TODO run compiler tests on Windows if sys.platform == 'win32': return + self._compiler = self.getCompiler() + + self._objs_dir = self.getObjectsDir() + # Add include directories. self._compiler.add_include(erpc_dir.join("erpc_c", "port")) self._compiler.add_include(erpc_dir.join("erpc_c", "config")) @@ -515,21 +553,70 @@ def run(self): if '.cpp' in file: self._compiler.add_source(self._out_dir.join(file)) - # Add all header includes into main code - headers = ['#include "'+f + - '"' for f in os.listdir(str(self._out_dir)) if '.h' in f] - self.MAIN_CODE = '\n'.join(headers) + self.MAIN_CODE - - # Add both .c and .cpp copies of the main file. - for main_filename in ("main_c.c", "main_cxx.cpp"): - main = self._objs_dir.join(main_filename) - main.write(self.MAIN_CODE) - self._compiler.add_source(main) + mainCode = self.getMainSourceCode() + mainFilename = self.getMainFilename() + main = self._objs_dir.join(mainFilename) + main.write(mainCode) + self._compiler.add_source(main) # Run the compiler. self._compiler.run() +class ErpcgenCCompileTest(ErpcgenCCppCompileTestCommon): + # @brief Tests that generated C code will compile successfully. + # + # An objects directory is created under the test case directory. It is used to hold the + # .o files written by the compiler. A .c file with the main() function is also written to + # the objects directory. + + def __init__(self, caseDir: str, outDir: str): + super(ErpcgenCCompileTest, self).__init__(outDir) + self._objs_dir = caseDir.mkdir(OBJECTS_DIR_NAME + "_c") + self._compiler = CCompiler(self._objs_dir) + + def getMainSourceCode(self): + headers = ['#include "'+f + + '"' for f in os.listdir(str(self._out_dir)) if f[-2:] == '.h'] + return '\n'.join(headers) + self.MAIN_CODE + + def getMainFilename(self): + return "main.c" + + def getObjectsDir(self): + return self._objs_dir + + def getCompiler(self): + return self._compiler + + +class ErpcgenCppCompileTest(ErpcgenCCppCompileTestCommon): + # @brief Tests that generated Cpp code will compile successfully. + # + # An objects directory is created under the test case directory. It is used to hold the + # .o files written by the compiler. A .cpp file with the main() function is also written to + # the objects directory. + + def __init__(self, caseDir: str, outDir: str): + super(ErpcgenCppCompileTest, self).__init__(outDir) + self._objs_dir = caseDir.mkdir(OBJECTS_DIR_NAME + "_cpp") + self._compiler = CCompiler(self._objs_dir) + + def getMainSourceCode(self): + headers = ['#include "'+f + + '"' for f in os.listdir(str(self._out_dir)) if f[-4:] == '.hpp'] + return '\n'.join(headers) + self.MAIN_CODE + + def getMainFilename(self): + return "main.cpp" + + def getObjectsDir(self): + return self._objs_dir + + def getCompiler(self): + return self._compiler + + class ErpcgenPythonCompileTest(ErpcgenCompileTest): # @brief Tests that generated Python code can be successfully compiled. # @@ -572,7 +659,7 @@ class ErpcgenTestCase(object): # Map of language names to compilation test classes. COMPILE_TEST_CLASSES = { - 'c': ErpcgenCCompileTest, + 'c': ErpcgenCCppCompileTest, 'py': ErpcgenPythonCompileTest, } diff --git a/erpcgen/test/test_builtin_types.yml b/erpcgen/test/test_builtin_types.yml index a1abf140..5b53c484 100644 --- a/erpcgen/test/test_builtin_types.yml +++ b/erpcgen/test/test_builtin_types.yml @@ -21,7 +21,7 @@ idl: | interface myintf { {fns[fore]} somefunc({type} i) {fns[after]} } -test.h: +c_test_client.h: - if: not type in ('bool', 'float', 'double') then: - void somefunc({type}_t i); @@ -46,7 +46,7 @@ idl: | interface myintf { somefunc() -> {type} } -test.h: +c_test_client.h: - if: not type in ('bool', 'float', 'double') then: - '{type}_t somefunc(void);' @@ -71,7 +71,7 @@ idl: | struct structwithint { {type} i } -test.h: +test_common.h: - 'struct structwithint {' - if: not type in ('bool', 'float', 'double') then: diff --git a/erpcgen/test/test_comments.yml b/erpcgen/test/test_comments.yml index 0db04396..ea322664 100644 --- a/erpcgen/test/test_comments.yml +++ b/erpcgen/test/test_comments.yml @@ -73,7 +73,7 @@ idl: | sendReceiveStruct(A a) -> A ///< 33 comment; } /*!<30 comment */ -test.h: +test_common.h: - "/*" - not: "!" - "* Comment" @@ -127,6 +127,8 @@ test.h: - //! 10 comment - //!11 comment - //!< 12 comment + +c_test_client.h: - /*! @brief DoxygenComments identifiers */ - //! 28 comment - //!29 comment @@ -136,7 +138,7 @@ test.h: - ///< 33 comment; - - //@} /*!<30 comment */ - - // _test_h_ + - // _c_test_client_h_ test_client.cpp: - "/*" @@ -158,7 +160,7 @@ test_client.cpp: - // DoxygenComments interface sendReceiveList function client shim. - // DoxygenComments interface sendReceiveStruct function client shim. -test_server.h: +test_server.hpp: - "/*" - not: "!" - "* Comment" @@ -173,7 +175,7 @@ test_server.h: - "*/" - /*! @brief Call the correct server shim based on method unique ID. */ - /*! @brief Server shim for sendReceiveList of DoxygenComments interface. */ - - // _test_server_h_ + - // _test_server_hpp_ test_server.cpp: - "/*" diff --git a/erpcgen/test/test_enum.yml b/erpcgen/test/test_enum.yml index a0a294ea..76e6611b 100644 --- a/erpcgen/test/test_enum.yml +++ b/erpcgen/test/test_enum.yml @@ -11,7 +11,7 @@ idl: | B, C } -test.h: +test_common.h: # named enums get a typedef - if: name then: @@ -38,7 +38,7 @@ idl: | B, C } -test.h: +test_common.h: # named enums get a typedef - if: name then: @@ -68,7 +68,7 @@ idl: | B = 30, C = {c_val} } -test.h: +test_common.h: # named enums get a typedef - if: name then: @@ -99,7 +99,7 @@ idl: | enum {name} { A{a_val}{opt_comma} } -test.h: +test_common.h: # named enums get a typedef - if: name then: @@ -123,7 +123,7 @@ idl: | A = 0, B = -1 } -test.h: +test_common.h: # named enums get a typedef - if: name then: @@ -148,7 +148,7 @@ idl: | D= 1*five, E = 2*five, } -test.h: +test_common.h: # named enums get a typedef - A = 0 - B = 5 diff --git a/erpcgen/test/test_error_checks_c.yml b/erpcgen/test/test_error_checks_c.yml index ad1c0d66..28e751bd 100644 --- a/erpcgen/test/test_error_checks_c.yml +++ b/erpcgen/test/test_error_checks_c.yml @@ -25,9 +25,9 @@ test_client.cpp: - if (codec == NULL) - err = kErpcStatus_MemoryError; - codec->startWriteMessage - - g_client->performRequest + - m_clientManager->performRequest - err = codec->getStatus(); - - g_client->callErrorHandler(err, + - m_clientManager->callErrorHandler(err, - if: type[1] != 'NULL' then: - if (err != kErpcStatus_Success) @@ -115,9 +115,9 @@ test_client.cpp: - not: if (result == NULL) - not: codec->updateStatus; - codec->startWriteMessage - - g_client->performRequest + - m_clientManager->performRequest - err = codec->getStatus(); - - g_client->callErrorHandler(err, kErrorTest_f_id) + - m_clientManager->callErrorHandler(err, m_fId) - if: type[1] != 'NULL' then: - if (err != kErpcStatus_Success) @@ -164,9 +164,9 @@ test_client.cpp: - if (codec == NULL) - err = kErpcStatus_MemoryError; - codec->startWriteMessage - - g_client->performRequest + - m_clientManager->performRequest - err = codec->getStatus(); - - g_client->callErrorHandler(err, + - m_clientManager->callErrorHandler(err, - if: type[1] != 'NULL' then: - if (err != kErpcStatus_Success) @@ -214,7 +214,7 @@ test_client.cpp: - if (codec == NULL) - err = kErpcStatus_MemoryError; - codec->startWriteMessage - - g_client->performRequest + - m_clientManager->performRequest - err = codec->getStatus(); test_server.cpp: @@ -261,9 +261,9 @@ test_client.cpp: - not: if (codec == NULL) - not: err = kErpcStatus_MemoryError; - codec->startWriteMessage - - g_client->performRequest + - m_clientManager->performRequest - err = codec->getStatus(); - - g_client->callErrorHandler(err, + - m_clientManager->callErrorHandler(err, test_server.cpp: - erpc_status_t err = kErpcStatus_Success; @@ -312,10 +312,10 @@ test_client.cpp: - err = kErpcStatus_MemoryError; - else - codec->startWriteMessage - - g_client->performRequest(request); + - m_clientManager->performRequest(request); - err = codec->getStatus(); - - g_client->releaseRequest(request); - - g_client->callErrorHandler(err, kErrorTest_f_id); + - m_clientManager->releaseRequest(request); + - m_clientManager->callErrorHandler(err, m_fId); test_server.cpp: - erpc_status_t err = kErpcStatus_Success; diff --git a/erpcgen/test/test_error_return_c.yml b/erpcgen/test/test_error_return_c.yml index 73ba7041..8c2571c3 100644 --- a/erpcgen/test/test_error_return_c.yml +++ b/erpcgen/test/test_error_return_c.yml @@ -28,7 +28,7 @@ idl: | f() -> {type[0]} } test_client.cpp: - - g_client->releaseRequest(request); + - m_clientManager->releaseRequest(request); - if: type[1] != 'NULL' then: - if (err != kErpcStatus_Success) @@ -71,7 +71,7 @@ idl: | f() -> {type[0]} } test_client.cpp: - - g_client->releaseRequest(request); + - m_clientManager->releaseRequest(request); - if: type[0] != 'A' and type[0] != 'string' then: - if (err != kErpcStatus_Success) diff --git a/erpcgen/test/test_expressions.yml b/erpcgen/test/test_expressions.yml index 6b3f5dcf..1d3ee2f6 100644 --- a/erpcgen/test/test_expressions.yml +++ b/erpcgen/test/test_expressions.yml @@ -15,7 +15,7 @@ idl: | const int32 a = 2 const int32 b = a * two + three -1 -test.h: +test_common.h: # named enums get a typedef - if: name then: diff --git a/erpcgen/test/test_extern_c.yml b/erpcgen/test/test_extern_c.yml index 6e778483..0b9d9575 100644 --- a/erpcgen/test/test_extern_c.yml +++ b/erpcgen/test/test_extern_c.yml @@ -2,7 +2,7 @@ name: extern c empty desc: do the extern "C" blocks get produced for empty input idl: "" -test.h: +test_common.h: - | #if defined(__cplusplus) extern "C" { @@ -19,7 +19,7 @@ idl: | interface Foo { foofn() -> void } -test.h: +test_common.h: - | #if defined(__cplusplus) extern "C" { diff --git a/erpcgen/test/test_forward_declaration_c.yml b/erpcgen/test/test_forward_declaration_c.yml index c39f0594..79b01021 100644 --- a/erpcgen/test/test_forward_declaration_c.yml +++ b/erpcgen/test/test_forward_declaration_c.yml @@ -1,42 +1,3 @@ ---- -name: struct before function -desc: forward declaration of structure before function which is using type. -params: - dir: - - "in" - - "out" -idl: - struct forwardStruct; - - oneway forwardCallback_t(forwardStruct s); - - struct forwardStruct - { - forwardCallback_t pCallback; /*!< Pointer to callback function */ - } - - interface foo - { - myFun({dir} forwardCallback_t pCallback1_t) -> void - - forwardCallback_t forwardCallback; - } - -test.h: - - typedef struct forwardStruct forwardStruct; - - typedef void (*forwardCallback_t)(const forwardStruct * s); - - - struct forwardStruct - - "{" - - forwardCallback_t pCallback; - - "};" -test_server.cpp: - - if: dir == 'in' - then: - - not: erpc_free(pCallback1_t); - else: - - erpc_free(pCallback1_t); - --- name: struct before struct desc: forward declaration of structure before structure which is using type. @@ -58,7 +19,7 @@ idl: myFun(in forwardStruct s) -> void } -test.h: +test_common.h: - typedef struct struct2 struct2; - typedef struct forwardStruct forwardStruct; @@ -102,7 +63,7 @@ idl: | { myFun(in forwardUnion u @discriminator(discriminator), unionCases discriminator) -> void } -test.h: +test_common.h: - typedef struct structure structure; - typedef union forwardUnion forwardUnion; diff --git a/erpcgen/test/test_import.yml b/erpcgen/test/test_import.yml index 03c4095c..ab41d3b9 100644 --- a/erpcgen/test/test_import.yml +++ b/erpcgen/test/test_import.yml @@ -4,10 +4,16 @@ desc: C/Py import test is the same. idl: | import "imports/test2.erpc" -test.h: +c_test_client.h: - void hello1(int32_t a); - void hello2(int32_t a); - void hello3(int32_t a); - void hello4(int32_t a); - void hello5(int32_t a); +c_test_server.h: + - void hello1(int32_t a); + - void hello2(int32_t a); + - void hello3(int32_t a); + - void hello4(int32_t a); + - void hello5(int32_t a); diff --git a/erpcgen/test/test_include.yml b/erpcgen/test/test_include.yml index c1d886b4..8bc3ece5 100644 --- a/erpcgen/test/test_include.yml +++ b/erpcgen/test/test_include.yml @@ -21,24 +21,5 @@ idl: | interface foo { bar(in string x) -> void } -test.h: +test_common.h: - '#include "stdio.h"' ---- -name: C include two interfaces -desc: -idl: | - program test; - - @include("stdio.h") - @include("stdio.h") - interface fooA { - barA(in string xA) -> void - } - - @include("stdio.h") - interface fooB { - barB(in string xB) -> void - } -test_server.cpp: - - '#include "stdio.h"' - - not: '#include "stdio.h"' \ No newline at end of file diff --git a/erpcgen/test/test_includes/test_includes_union.h b/erpcgen/test/test_includes/test_includes_union.h index 97cef1a0..01e78bea 100644 --- a/erpcgen/test/test_includes/test_includes_union.h +++ b/erpcgen/test/test_includes/test_includes_union.h @@ -6,10 +6,15 @@ * SPDX-License-Identifier: BSD-3-Clause */ -#include +#ifndef TEST_INCLUDES_UNION +#define TEST_INCLUDES_UNION + +#include typedef union unionType { int32_t x; float y; }unionType; + +#endif diff --git a/erpcgen/test/test_name_c.yml b/erpcgen/test/test_name_c.yml index 0354379c..4d4196bb 100644 --- a/erpcgen/test/test_name_c.yml +++ b/erpcgen/test/test_name_c.yml @@ -31,22 +31,27 @@ idl: | oneway functionName2(S a @name(m)) } -test.h: +test_common.h: - enum EnumName - D - struct StructName StructName - StructName type - struct StructName - int32_t d + +c_test_client.h: - function(const StructName * m) test_client.cpp: - write_StructName_struct - write_StructName_struct - data->d - - void function(const StructName * m) + - void I_client::function(const StructName * m) - write_StructName_struct(codec, m) - - void functionName2(const StructName * m) + - void I_client::functionName2(const StructName * m) + +c_test_server.h: + - function(const StructName * m) test_server.cpp: - read_StructName_struct @@ -58,5 +63,7 @@ test_server.cpp: - function(m); - erpc_free(m); - functionName2(m); + +c_test_server.cpp: + - ERPC_MANUALLY_CONSTRUCTED_STATIC(I_service, s_I_service); - create_I_service - - s_I_service diff --git a/erpcgen/test/test_nullable_c.yml b/erpcgen/test/test_nullable_c.yml index c60c69cc..1ee80060 100644 --- a/erpcgen/test/test_nullable_c.yml +++ b/erpcgen/test/test_nullable_c.yml @@ -11,7 +11,7 @@ idl: | bar({dir} string a @nullable @max_length(8)) -> void } test_client.cpp: - - re: void bar\(\w*\s*char \* a\) + - re: void foo_client::bar\(\w*\s*char \* a\) - if (a == NULL) - codec->writeNullFlag(true) - if: dir in ('in', 'inout') @@ -58,7 +58,7 @@ idl: | bar({dir} ustring a @nullable @max_length(8)) -> void } test_client.cpp: - - re: void bar\(\w*\s*unsigned\s*char\s*\* a\) + - re: void foo_client::bar\(\w*\s*unsigned\s*char\s*\* a\) - if (a == NULL) - codec->writeNullFlag(true) - if: dir in ('in', 'inout') @@ -113,11 +113,12 @@ idl: | interface foo { bar(Vector v @nullable) -> void } -test.h: +test_common.h: - '{type[1]} v[3]' +c_test_client.h: - void bar(const Vector * v); test_client.cpp: - - re: void bar\(const Vector \* v\) + - re: void foo_client::bar\(const Vector \* v\) - if (v == NULL) - writeNullFlag(true) - "{" @@ -152,7 +153,7 @@ test_client.cpp: - writeNullFlag(false) - write_list_bool_1_t_struct - '}' - - void bar(const erpc_pair * s) + - void foo_client::bar(const erpc_pair * s) - write_erpc_pair_struct test_server.cpp: - void read_erpc_pair_struct @@ -182,7 +183,7 @@ test_client.cpp: - writeNullFlag(false) - write_binary_t_struct - '}' - - void bar(const erpc_pair * s) + - void foo_client::bar(const erpc_pair * s) - write_erpc_pair_struct test_server.cpp: - void read_erpc_pair_struct @@ -339,9 +340,9 @@ idl: | test_client.cpp: - if: dir == 'inout' then: - - void bar(const bool * l, uint32_t * c) + - void foo_client::bar(const bool * l, uint32_t * c) else: - - void bar(const bool * l, uint32_t c) + - void foo_client::bar(const bool * l, uint32_t c) - if: dir == 'inout' and ann == '@nullable' then: - if ((l == NULL) || (c == NULL)) @@ -404,7 +405,7 @@ idl: | } test_client.cpp: - - void bar(bool * l, uint32_t * c) + - void foo_client::bar(bool * l, uint32_t * c) - if: ann == '@nullable' then: - if ((l == NULL) || (c == NULL)) diff --git a/erpcgen/test/test_redundant_definitions.yml b/erpcgen/test/test_redundant_definitions.yml index ea947b13..230f77dd 100644 --- a/erpcgen/test/test_redundant_definitions.yml +++ b/erpcgen/test/test_redundant_definitions.yml @@ -40,7 +40,7 @@ idl: | interface foo { bar(in Vector vector_x, out Wector vector_y) -> void } -test.h: +test_common.h: - typedef struct Vector Vector - typedef struct Wector Wector - struct Vector @@ -50,7 +50,7 @@ test_server.cpp: - read_Vector_struct - not: read_Wector_struct - write_Wector_struct -test_client.cpp: +test_client.cpp: - write_Vector_struct - not: read_Vector_struct - read_Wector_struct @@ -124,44 +124,52 @@ idl: | interface fooA { barA(out Vector vector_x, in Wector vector_y) -> void } -test.h: +test_common.h: - typedef struct Vector Vector - typedef struct Wector Wector - typedef struct NoGroup NoGroup; - struct Vector - struct Wector - struct NoGroup +c_test_server.h: - enum _foo_ids - void bar(const NoGroup * noGroup_z) test_server.cpp: - read_NoGroup_struct - not: write_NoGroup_struct - - not: Vector_struct + - not: Vector_struct - not: Wector_struct - foo_service::bar_shim -test_client.cpp: +c_test_client.h: + - enum _foo_ids + - void bar(const NoGroup * noGroup_z) +test_client.cpp: - not: read_NoGroup_struct - write_NoGroup_struct - - not: Vector_struct + - not: Vector_struct - not: Wector_struct - bar(const NoGroup * noGroup_z) -test_A.h: +test_A_common.h: - typedef struct Vector Vector - typedef struct Wector Wector - typedef struct NoGroup NoGroup; - struct Vector - struct Wector - struct NoGroup +c_test_A_server.h: - enum _fooA_ids - void barA(Vector * vector_x, const Wector * vector_y) -test_A_server.cpp: +test_A_server.cpp: - read_Wector_struct - not: write_Wector_struct - write_Vector_struct - not: read_Vector_struct - not: NoGroup_struct - fooA_service::barA_shim -test_A_client.cpp: +c_test_A_client.h: + - enum _fooA_ids + - void barA(Vector * vector_x, const Wector * vector_y) +test_A_client.cpp: - write_Wector_struct - not: read_Wector_struct - read_Vector_struct @@ -200,14 +208,14 @@ idl: | interface foo_B { bar_B(out VectorB b) -> void } -test.h: +test_A_common.h: - typedef struct VectorA VectorA - typedef struct VectorB VectorB - struct VectorA - struct VectorB - not: bar_A(const VectorA * a) - not: bar_AA(const VectorA * aa, VectorB * bb) -test_A.h: +c_test_A_client.h: - not: typedef - bar_A(const VectorA * a) - bar_AA(const VectorA * aa, VectorB * bb) @@ -216,10 +224,10 @@ test_A_server.cpp: - write_VectorB_struct - not: write_VectorA_struct - not: read_VectorB_struct -test_B.h: +c_test_B_client.h: - not: typedef - bar_B(VectorB * b) -test_B_server.cpp: +test_B_server.cpp: - write_VectorB_struct - not: read_VectorB_struct - not: VectorA_struct @@ -235,4 +243,4 @@ test_B_server.cpp: # interface foo { # bar(zz discriminator, Scalar scalar_y @discriminator(discriminator)) -> void -# } \ No newline at end of file +# } diff --git a/erpcgen/test/test_scope_c.yml b/erpcgen/test/test_scope_c.yml index e9775256..b0d20a20 100644 --- a/erpcgen/test/test_scope_c.yml +++ b/erpcgen/test/test_scope_c.yml @@ -5,7 +5,7 @@ idl: | interface test { bar(int32 x) -> void } -test.h: +test_common.h: - | #if !defined(ERPC_TYPE_DEFINITIONS_ERPCSHIM) #define ERPC_TYPE_DEFINITIONS_ERPCSHIM @@ -21,7 +21,7 @@ idl: | interface test { bar(int32 x) -> void } -test.h: +test_common.h: - | #if !defined(ERPC_TYPE_DEFINITIONS_TEST) #define ERPC_TYPE_DEFINITIONS_TEST @@ -38,7 +38,7 @@ idl: | interface test { bar(int32 x) -> void } -test.h: +test_common.h: - | #if !defined(ERPC_TYPE_DEFINITIONS_MYSCOPE) #define ERPC_TYPE_DEFINITIONS_MYSCOPE @@ -55,7 +55,7 @@ idl: | interface test { bar(int32 x) -> void } -test.h: +test_common.h: - | #if !defined(ERPC_TYPE_DEFINITIONS) #define ERPC_TYPE_DEFINITIONS diff --git a/erpcgen/test/test_service_c.yml b/erpcgen/test/test_service_c.yml index 5865cfac..5446b86f 100644 --- a/erpcgen/test/test_service_c.yml +++ b/erpcgen/test/test_service_c.yml @@ -8,17 +8,18 @@ idl: | oneway f() } -test_server.h: +c_test_server.h: - erpc_service_t create_ErrorTest_service(void); - void destroy_ErrorTest_service(erpc_service_t service); -test_server.cpp: +c_test_server.cpp: - ERPC_MANUALLY_CONSTRUCTED_STATIC(ErrorTest_service, s_ErrorTest_service); + - ERPC_MANUALLY_CONSTRUCTED_STATIC(ErrorTest_server, s_ErrorTest_server); - erpc_service_t create_ErrorTest_service(void) - "{" - erpc_service_t service; - "#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC" - - service = new (nothrow) ErrorTest_service(); + - service = new (nothrow) ErrorTest_service(new (nothrow)ErrorTest_server()); - "#else" - if (s_ErrorTest_service.isUsed()) - "{" @@ -26,7 +27,8 @@ test_server.cpp: - "}" - else - "{" - - s_ErrorTest_service.construct(); + - s_ErrorTest_server.construct(); + - s_ErrorTest_service.construct(s_ErrorTest_server.get()); - service = s_ErrorTest_service.get(); - "}" - "#endif" @@ -35,11 +37,15 @@ test_server.cpp: - void destroy_ErrorTest_service(erpc_service_t service) - "{" - "#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC" - - erpc_assert(service != NULL); + - if (service) + - "{" + - delete (ErrorTest_server *)(((ErrorTest_service *)service)->getHandler()); - delete (ErrorTest_service *)service; + - "}" - "#else" - (void)service; - erpc_assert(service == s_ErrorTest_service.get()); - s_ErrorTest_service.destroy(); + - s_ErrorTest_server.destroy(); - "#endif" - "}" diff --git a/erpcgen/test/test_struct.yml b/erpcgen/test/test_struct.yml index afb5f5ce..b376b48f 100644 --- a/erpcgen/test/test_struct.yml +++ b/erpcgen/test/test_struct.yml @@ -20,7 +20,7 @@ idl: | interface B { testF(inout A b) ->void } -test.h: +test_common.h: - typedef struct A A; - struct A - if: type in ('bool', 'float', 'double') @@ -41,7 +41,7 @@ idl: | interface foo { bar(ListType x) -> ListType } -test.h: +test_common.h: - typedef struct list_int32_1_t list_int32_1_t; - typedef list_int32_1_t ListType; - struct list_int32_1_t @@ -52,7 +52,7 @@ test_client.cpp: - read_list_int32_1_t_struct - if(NULL == data) - return; - - ListType * bar(const ListType * x) + - ListType * foo_client::bar(const ListType * x) test_server.cpp: - read_list_int32_1_t_struct - if(NULL == data) @@ -72,7 +72,7 @@ idl: | interface foo { bar(Vector x, binary y) -> void } -test.h: +test_common.h: - typedef struct binary_t binary_t; - typedef struct Vector Vector; - struct binary_t @@ -97,7 +97,7 @@ idl: | foo(Vector a) -> void bar() -> Vector } -test.h: +test_common.h: - typedef struct binary_t binary_t; - typedef struct Vector Vector; - struct binary_t diff --git a/erpcgen/test/test_types_header.yml b/erpcgen/test/test_types_header.yml deleted file mode 100644 index 97b461b9..00000000 --- a/erpcgen/test/test_types_header.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- -name: types header file -desc: places all type definitions into separate header file "test_types.h" -idl: | - @types_header("test_types.h") - program test - - struct Vector { - int8 a - int16 b - int32 c - } - - interface test { - bar(Vector x) -> void - } -test.h: - - '#include "test_types.h"' - - not: // Aliases data types declarations - - not: typedef struct Vector Vector; - - not: // Structures data types declarations - - not: struct Vector - - void bar(const Vector * x); -test_types.h: - - '#if !defined(_test_types_h_)' - - '#include ' - - '#include ' - - '#include ' - - // Aliases data types declarations - - typedef struct Vector Vector; - - // Structures/unions data types declarations - - struct Vector - - not: void bar(const Vector * x); diff --git a/erpcgen/test/test_union_c.yml b/erpcgen/test/test_union_c.yml index 2673fa9f..04b04e78 100644 --- a/erpcgen/test/test_union_c.yml +++ b/erpcgen/test/test_union_c.yml @@ -21,7 +21,7 @@ idl: | myUnion(fruitType discriminator, unionType unionVariable @discriminator(discriminator)) -> void } -test.h: +test_common.h: - not: typedef union unionType unionType; - not: union unionType - not: int32 x; @@ -72,7 +72,7 @@ idl: | myUnion(fruitType discriminator, unionType unionVariable @discriminator(discriminator)) -> void } -test.h: +test_common.h: - typedef union unionType unionType; - union unionType - "{" @@ -95,6 +95,8 @@ test.h: - int32_t blah; - "};" - "};" + +c_test_client.h: - void myUnion(fruitType discriminator, const unionType * unionVariable); test_client.cpp: @@ -146,10 +148,12 @@ test_client.cpp: - break; - "}" - "}" - - void myUnion(fruitType discriminator, const unionType * unionVariable) + - void foo_client::myUnion(fruitType discriminator, const unionType * unionVariable) - not: codec->read(static_cast(discriminator)); - write_unionType_union(codec, static_cast(discriminator), unionVariable) +c_test_server.h: + - void myUnion(fruitType discriminator, const unionType * unionVariable); test_server.cpp: - static void read_unionType_union(erpc::Codec * codec, int32_t & discriminator, unionType * data); @@ -268,15 +272,20 @@ idl: | myUnion(structType structVariable) -> void } -test.h: +test_common.h: - struct structType - fruitType discriminator - unionType unionVariable + +c_test_client.h: - void myUnion(const structType * structVariable); test_client.cpp: - write_unionType_union(codec, static_cast(data->discriminator), &data->unionVariable); +c_test_server.h: + - void myUnion(const structType * structVariable); + test_server.cpp: - int32_t _tmp_local_i32; - read_unionType_union(codec, _tmp_local_i32, &data->unionVariable); diff --git a/erpcsniffer/src/erpcsniffer.cpp b/erpcsniffer/src/erpcsniffer.cpp index 043c328b..6650b749 100644 --- a/erpcsniffer/src/erpcsniffer.cpp +++ b/erpcsniffer/src/erpcsniffer.cpp @@ -118,11 +118,11 @@ class erpcsnifferTool const char *m_outputFilePath; /*!< Path to the output file. */ const char *m_ErpcFile; /*!< ERPC file. */ string_vector_t m_positionalArgs; - transports_t m_transport; /*!< Transport used for receiving messages. */ - uint64_t m_quantity; /*!< Quantity of logs to store. */ - uint32_t m_baudrate; /*!< Baudrate rate speed. */ - const char *m_port; /*!< Name or number of port. Based on used transport. */ - const char *m_host; /*!< Host name */ + transports_t m_transport; /*!< Transport used for receiving messages. */ + uint64_t m_quantity; /*!< Quantity of logs to store. */ + uint32_t m_baudrate; /*!< Baudrate rate speed. */ + const char *m_port; /*!< Name or number of port. Based on used transport. */ + const char *m_host; /*!< Host name */ public: /*! @@ -225,7 +225,7 @@ class erpcsnifferTool } else { - Log::error(format_string("error: unknown transport type %s", transport.c_str()).c_str()); + Log::error("error: unknown transport type %s", transport.c_str()); return 1; } break; diff --git a/test/common/gtestListener.hpp b/test/common/gtestListener.hpp index 27a9a141..1c64134f 100644 --- a/test/common/gtestListener.hpp +++ b/test/common/gtestListener.hpp @@ -26,10 +26,10 @@ class LeakChecker : public ::testing::EmptyTestEventListener { int serverAlloc = getServerAllocated(); - EXPECT_EQ(MyAlloc::allocated(), 0) - << "Leaked (on client side) : " << MyAlloc::allocated() << " unit(s) need be freed!"; + EXPECT_EQ(::MyAlloc::allocated(), 0) + << "Leaked (on client side) : " << ::MyAlloc::allocated() << " unit(s) need be freed!"; EXPECT_EQ(serverAlloc, 0) << "Leaked (on server side) : " << serverAlloc << " unit(s) need be freed!"; - MyAlloc::allocated(0); + ::MyAlloc::allocated(0); } }; diff --git a/test/common/myAlloc.hpp b/test/common/myAlloc.hpp index ad30476d..b2d11bdc 100644 --- a/test/common/myAlloc.hpp +++ b/test/common/myAlloc.hpp @@ -10,6 +10,8 @@ #ifndef _EMBEDDED_RPC__MYALLOC_H_ #define _EMBEDDED_RPC__MYALLOC_H_ +#if defined(__cplusplus) + #include "erpc_port.h" //////////////////////////////////////////////////////////////////////////////// @@ -38,15 +40,13 @@ class MyAlloc static int allocated_; }; -namespace std { -using ::MyAlloc; -} - //////////////////////////////////////////////////////////////////////////////// // Definitions //////////////////////////////////////////////////////////////////////////////// -#define erpc_malloc(X) MyAlloc::my_malloc(X) -#define erpc_free(X) MyAlloc::my_free((X)) +#define erpc_malloc(X) ::MyAlloc::my_malloc(X) +#define erpc_free(X) ::MyAlloc::my_free((X)) + +#endif // __cplusplus #endif // _EMBEDDED_RPC__MYALLOC_H_ diff --git a/test/common/unit_test_client.cpp b/test/common/unit_test_client.cpp index 104f704a..097d22a6 100644 --- a/test/common/unit_test_client.cpp +++ b/test/common/unit_test_client.cpp @@ -84,7 +84,7 @@ class MinimalistPrinter : public ::testing::EmptyTestEventListener // Definitions //////////////////////////////////////////////////////////////////////////////// -int MyAlloc::allocated_ = 0; +int ::MyAlloc::allocated_ = 0; #if defined(RPMSG) #define APP_ERPC_READY_EVENT_DATA (1) diff --git a/test/common/unit_test_serial_client.cpp b/test/common/unit_test_serial_client.cpp index 469fc80d..e3078092 100644 --- a/test/common/unit_test_serial_client.cpp +++ b/test/common/unit_test_serial_client.cpp @@ -43,7 +43,7 @@ MyMessageBufferFactory g_msgFactory; BasicCodecFactory g_basicCodecFactory; ClientManager *g_client; -int MyAlloc::allocated_ = 0; +int ::MyAlloc::allocated_ = 0; //////////////////////////////////////////////////////////////////////////////// // Set up global fixture diff --git a/test/common/unit_test_serial_server.cpp b/test/common/unit_test_serial_server.cpp index f84e7e62..8bfa0126 100644 --- a/test/common/unit_test_serial_server.cpp +++ b/test/common/unit_test_serial_server.cpp @@ -19,7 +19,7 @@ #include using namespace erpc; -using namespace erpcshim; +using namespace erpcShim; class MyMessageBufferFactory : public MessageBufferFactory { @@ -45,7 +45,7 @@ MyMessageBufferFactory g_msgFactory; BasicCodecFactory g_basicCodecFactory; SimpleServer g_server; -int MyAlloc::allocated_ = 0; +int ::MyAlloc::allocated_ = 0; Common_service *svc_common; @@ -92,8 +92,8 @@ void quit() int32_t getServerAllocated() { - int result = MyAlloc::allocated(); - MyAlloc::allocated(0); + int result = ::MyAlloc::allocated(); + ::MyAlloc::allocated(0); return result; } diff --git a/test/common/unit_test_server.cpp b/test/common/unit_test_server.cpp index 83e7f68f..ed356f4d 100644 --- a/test/common/unit_test_server.cpp +++ b/test/common/unit_test_server.cpp @@ -39,7 +39,7 @@ int main(int argc, const char *argv[]); // Variables //////////////////////////////////////////////////////////////////////////////// -int MyAlloc::allocated_ = 0; +int ::MyAlloc::allocated_ = 0; erpc_service_t service_common = NULL; erpc_server_t server; @@ -151,7 +151,7 @@ void quit() int32_t getServerAllocated() { - int result = MyAlloc::allocated(); - MyAlloc::allocated(0); + int result = ::MyAlloc::allocated(); + ::MyAlloc::allocated(0); return result; } diff --git a/test/common/unit_test_tcp_client.cpp b/test/common/unit_test_tcp_client.cpp index 636d6f53..d10231bf 100644 --- a/test/common/unit_test_tcp_client.cpp +++ b/test/common/unit_test_tcp_client.cpp @@ -48,7 +48,7 @@ ClientManager *g_client; Crc16 g_crc16; -int MyAlloc::allocated_ = 0; +int ::MyAlloc::allocated_ = 0; //////////////////////////////////////////////////////////////////////////////// // Set up global fixture diff --git a/test/common/unit_test_tcp_server.cpp b/test/common/unit_test_tcp_server.cpp index 5aa55f9b..28597fed 100644 --- a/test/common/unit_test_tcp_server.cpp +++ b/test/common/unit_test_tcp_server.cpp @@ -17,7 +17,7 @@ #include "unit_test.h" using namespace erpc; -using namespace erpcshim; +using namespace erpcShim; class MyMessageBufferFactory : public MessageBufferFactory { @@ -45,7 +45,7 @@ SimpleServer g_server; Crc16 g_crc16; -int MyAlloc::allocated_ = 0; +int ::MyAlloc::allocated_ = 0; Common_service *svc_common; @@ -101,8 +101,8 @@ void quit() int32_t getServerAllocated() { - int result = MyAlloc::allocated(); - MyAlloc::allocated(0); + int result = ::MyAlloc::allocated(); + ::MyAlloc::allocated(0); return result; } diff --git a/test/test_annotations/test_annotations_server_impl.cpp b/test/test_annotations/test_annotations_server_impl.cpp index 31501499..74f4761d 100644 --- a/test/test_annotations/test_annotations_server_impl.cpp +++ b/test/test_annotations/test_annotations_server_impl.cpp @@ -18,7 +18,7 @@ #include using namespace erpc; -using namespace erpcshim; +using namespace erpcShim; AnnotateTest_service *svc; diff --git a/test/test_arrays/test_arrays_server_impl.cpp b/test/test_arrays/test_arrays_server_impl.cpp index 79ab8133..b48f66fb 100644 --- a/test/test_arrays/test_arrays_server_impl.cpp +++ b/test/test_arrays/test_arrays_server_impl.cpp @@ -18,7 +18,7 @@ #include using namespace erpc; -using namespace erpcshim; +using namespace erpcShim; PointersService_service *svc; diff --git a/test/test_binary/test_binary_server_impl.cpp b/test/test_binary/test_binary_server_impl.cpp index 83094bac..7e1ad36a 100644 --- a/test/test_binary/test_binary_server_impl.cpp +++ b/test/test_binary/test_binary_server_impl.cpp @@ -16,7 +16,7 @@ #include using namespace erpc; -using namespace erpcshim; +using namespace erpcShim; Binary_service *svc; diff --git a/test/test_builtin/test_builtin_server_impl.cpp b/test/test_builtin/test_builtin_server_impl.cpp index 9dfda5f7..5daced06 100644 --- a/test/test_builtin/test_builtin_server_impl.cpp +++ b/test/test_builtin/test_builtin_server_impl.cpp @@ -17,7 +17,7 @@ #include using namespace erpc; -using namespace erpcshim; +using namespace erpcShim; BuiltinServices_service *svc; diff --git a/test/test_callbacks/test_callbacks_server_impl.cpp b/test/test_callbacks/test_callbacks_server_impl.cpp index 38551dac..cfb1be71 100644 --- a/test/test_callbacks/test_callbacks_server_impl.cpp +++ b/test/test_callbacks/test_callbacks_server_impl.cpp @@ -17,7 +17,7 @@ #include using namespace erpc; -using namespace erpcshim; +using namespace erpcShim; ClientCore0Services_service *svc; diff --git a/test/test_const/test_const_client_impl.cpp b/test/test_const/test_const_client_impl.cpp index 6d87f2b2..cd3e6e26 100644 --- a/test/test_const/test_const_client_impl.cpp +++ b/test/test_const/test_const_client_impl.cpp @@ -7,8 +7,7 @@ */ #include "gtest.h" -#include "test_common_erpc.h" -#include "test_common_standard.h" +#include "test_common.h" #include "unit_test_wrapped.h" //////////////////////////////////////////////////////////////////////////////// diff --git a/test/test_enums/test_enums_server_impl.cpp b/test/test_enums/test_enums_server_impl.cpp index 501ef7e4..7bd98846 100644 --- a/test/test_enums/test_enums_server_impl.cpp +++ b/test/test_enums/test_enums_server_impl.cpp @@ -17,7 +17,7 @@ #include using namespace erpc; -using namespace erpcshim; +using namespace erpcShim; EnumsService_service *svc; diff --git a/test/test_lists/test_lists_server_impl.cpp b/test/test_lists/test_lists_server_impl.cpp index 4fd185f8..7f5e517b 100644 --- a/test/test_lists/test_lists_server_impl.cpp +++ b/test/test_lists/test_lists_server_impl.cpp @@ -18,7 +18,7 @@ #include using namespace erpc; -using namespace erpcshim; +using namespace erpcShim; PointersService_service *svc; diff --git a/test/test_shared/test_shared_server_impl.cpp b/test/test_shared/test_shared_server_impl.cpp index a319b133..5890d6f8 100644 --- a/test/test_shared/test_shared_server_impl.cpp +++ b/test/test_shared/test_shared_server_impl.cpp @@ -16,7 +16,7 @@ #include using namespace erpc; -using namespace erpcshim; +using namespace erpcShim; SharedService_service *svc; diff --git a/test/test_struct/test_struct_server_impl.cpp b/test/test_struct/test_struct_server_impl.cpp index 0d320c41..9214bcfd 100644 --- a/test/test_struct/test_struct_server_impl.cpp +++ b/test/test_struct/test_struct_server_impl.cpp @@ -18,7 +18,7 @@ #include using namespace erpc; -using namespace erpcshim; +using namespace erpcShim; ArithmeticService1_service *svc1; ArithmeticService2_service *svc2; diff --git a/test/test_typedef/test_typedef_server_impl.cpp b/test/test_typedef/test_typedef_server_impl.cpp index 65af1f2f..eeeabca9 100644 --- a/test/test_typedef/test_typedef_server_impl.cpp +++ b/test/test_typedef/test_typedef_server_impl.cpp @@ -18,7 +18,7 @@ #include using namespace erpc; -using namespace erpcshim; +using namespace erpcShim; TypedefService_service *svc; diff --git a/test/test_unions/test_unions_server_impl.cpp b/test/test_unions/test_unions_server_impl.cpp index f2d4a80f..ea53611b 100644 --- a/test/test_unions/test_unions_server_impl.cpp +++ b/test/test_unions/test_unions_server_impl.cpp @@ -18,7 +18,7 @@ #include using namespace erpc; -using namespace erpcshim; +using namespace erpcShim; ArithmeticService_service *svc;