Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: erpcgen: Add namespace and remove typedefs in C++ common header #419

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions erpcgen/src/CGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,8 @@ void CGenerator::makeAliasesTemplateData()
DataType *elementDataType = aliasType->getElementType();
setTemplateComments(aliasType, aliasInfo);

aliasInfo["forwardDecl"] = "";

if (elementDataType->getName() != "")
{
string realType;
Expand All @@ -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;
Expand Down
15 changes: 14 additions & 1 deletion erpcgen/src/templates/c_common_header.template
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 %}
Expand Down Expand Up @@ -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 %}
Expand Down
8 changes: 4 additions & 4 deletions install_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down