From 61c6ef6bc33a2d3cd439ac215fd7accf05f504e7 Mon Sep 17 00:00:00 2001 From: PhilippHaefele Date: Thu, 4 Apr 2024 16:08:05 +0200 Subject: [PATCH 1/2] erpcgen/C++: Add namespace and change consts to constexpr - Forward declrations are needed somehow for same name typedefs - Using constexpr instead of extern const so we can namespace them easily --- erpcgen/src/CGenerator.cpp | 6 ++++++ erpcgen/src/templates/c_common_header.template | 15 ++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/erpcgen/src/CGenerator.cpp b/erpcgen/src/CGenerator.cpp index 16b86311..5bb5c8d0 100644 --- a/erpcgen/src/CGenerator.cpp +++ b/erpcgen/src/CGenerator.cpp @@ -765,6 +765,8 @@ void CGenerator::makeAliasesTemplateData() DataType *elementDataType = aliasType->getElementType(); setTemplateComments(aliasType, aliasInfo); + aliasInfo["forwardDecl"] = ""; + if (elementDataType->getName() != "") { string realType; @@ -785,14 +787,18 @@ void CGenerator::makeAliasesTemplateData() if (elementDataType->getName() == aliasType->getName() || getOutputName(elementDataType, false) == aliasType->getName()) { + string forwardDecl; if (elementDataType->isStruct()) { realType = "struct " + realType; + forwardDecl = "struct " + getOutputName(aliasType); } else { realType = "union " + realType; + forwardDecl = "union " + getOutputName(aliasType); } + aliasInfo["forwardDecl"] = forwardDecl; } aliasInfo["typenameName"] = realType; diff --git a/erpcgen/src/templates/c_common_header.template b/erpcgen/src/templates/c_common_header.template index 9e203662..912ad3c0 100644 --- a/erpcgen/src/templates/c_common_header.template +++ b/erpcgen/src/templates/c_common_header.template @@ -40,6 +40,9 @@ extern "C" #if !defined(ERPC_TYPE_DEFINITIONS{$scopeNamePrefix}{$scopeNameC}) #define ERPC_TYPE_DEFINITIONS{$scopeNamePrefix}{$scopeNameC} +{% if not cCommonHeaderFile %} +{$fillNamespaceBegin()} +{% endif -- not cCommonHeaderFile %} {% if not empty(enums) %} // Enumerators data types declarations @@ -67,6 +70,9 @@ typedef {$alias.unnamedType} {% endfor -- alias.unnamed.members %} } {$alias.unnamedName}; {% else -- alias.typenameName %} +{% if alias.forwardDecl != "" %} +{$alias.forwardDecl}; +{% endif -- alias.forwardDecl %} typedef {$alias.typenameName};{$alias.ilComment} {% endif -- alias.typenameName %} {% endfor -- aliases %} @@ -95,17 +101,24 @@ union {$us.name} {% endif -- us.type == "union/struct" %} {% endif -- !us.isExternal %} {% endfor -- symbols %} - {% endif -- nonExternalStruct || nonExternalUnion %} {% if not empty(consts) %} // Constant variable declarations {% for c in consts %} {$> c.mlComment} +{% if cCommonHeaderFile %} extern const {$c.typeAndName};{$c.ilComment}{$loop.addNewLineIfNotLast} +{% else -- not cCommonHeaderFile %} +constexpr {$c.typeAndName} = {$c.value};{$c.ilComment}{$loop.addNewLineIfNotLast} +{% endif -- cCommonHeaderFile %} {% endfor -- consts %} {% endif -- consts %} +{% if not cCommonHeaderFile %} + +{$fillNamespaceEnd()} +{% endif -- not cCommonHeaderFile %} #endif // ERPC_TYPE_DEFINITIONS{$scopeNamePrefix}{$scopeNameC} {% if cCommonHeaderFile %} From 57039663a342fe10a94a84a6a89ae9515802b252 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A4fele=2C=20Philipp?= Date: Wed, 10 Apr 2024 10:34:02 +0200 Subject: [PATCH 2/2] Temporary fix for mac pipeline --- install_dependencies.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/install_dependencies.sh b/install_dependencies.sh index ca3f79c1..14862cdb 100755 --- a/install_dependencies.sh +++ b/install_dependencies.sh @@ -25,10 +25,10 @@ Darwin*) brew update echo "Installing dependencies." brew install python3 bison flex -v -f 2>&1 - sudo pip3 install tornado - sudo pip3 install --user nose - sudo pip3 install pytest --upgrade --ignore-installed six - sudo pip3 install pyyaml + sudo pip3 install --break-system-packages tornado + sudo pip3 install --break-system-packages --user nose + sudo pip3 install --break-system-packages pytest --upgrade --ignore-installed six + sudo pip3 install --break-system-packages pyyaml ;; *) echo "Unknown or currently unsupported os: ${unameOut}"