Skip to content

Commit

Permalink
Refs #19388. Fix including a dependant IDL without structures
Browse files Browse the repository at this point in the history
Signed-off-by: Ricardo González Moreno <[email protected]>
  • Loading branch information
richiware committed Aug 22, 2023
1 parent 029b44d commit f1f3fb3
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ $endif$

$definitions; separator="\n"$

$if(ctx.thereIsStructOrUnion)$
#include "$ctx.filename$CdrAux.ipp"
$endif$
>>

module(ctx, parent, module, definition_list) ::= <<
Expand Down
45 changes: 22 additions & 23 deletions src/main/java/com/eprosima/fastdds/fastddsgen.java
Original file line number Diff line number Diff line change
Expand Up @@ -842,40 +842,39 @@ private Project parseIDL(
}
}

// TODO: Uncomment following lines and create templates
System.out.println("Generating TopicDataTypes files...");
if (ctx.isThereIsStructOrUnion())
{
if (returnedValue &=
Utils.writeFile(output_dir + ctx.getFilename() + "CdrAux.hpp",
maintemplates.getTemplate("com/eprosima/fastdds/idl/templates/TypesCdrAuxHeader.stg"), m_replace))
{
project.addProjectIncludeFile(relative_dir + ctx.getFilename() + "CdrAux.hpp");
returnedValue &=
Utils.writeFile(output_dir + ctx.getFilename() + "CdrAux.ipp",
maintemplates.getTemplate("com/eprosima/fastdds/idl/templates/TypesCdrAuxHeaderImpl.stg"), m_replace);
}
}
returnedValue &=
Utils.writeFile(output_dir + ctx.getFilename() + "PubSubTypes.h",
Utils.writeFile(output_dir + ctx.getFilename() + "PubSubTypes.h",
maintemplates.getTemplate("com/eprosima/fastdds/idl/templates/DDSPubSubTypeHeader.stg"), m_replace);
project.addProjectIncludeFile(relative_dir + ctx.getFilename() + "PubSubTypes.h");

if (ctx.existsLastStructure())
{
m_atLeastOneStructure = true;
project.setHasStruct(true);

if (returnedValue =
Utils.writeFile(output_dir + ctx.getFilename() + "CdrAux.hpp",
maintemplates.getTemplate("com/eprosima/fastdds/idl/templates/TypesCdrAuxHeader.stg"), m_replace))
if (returnedValue &=
Utils.writeFile(output_dir + ctx.getFilename() + "PubSubTypes.cxx",
maintemplates.getTemplate("com/eprosima/fastdds/idl/templates/DDSPubSubTypeSource.stg"), m_replace))
{
if (returnedValue =
Utils.writeFile(output_dir + ctx.getFilename() + "CdrAux.ipp",
maintemplates.getTemplate("com/eprosima/fastdds/idl/templates/TypesCdrAuxHeaderImpl.stg"), m_replace))
project.addProjectSrcFile(relative_dir + ctx.getFilename() + "PubSubTypes.cxx");
if (m_python)
{
if (returnedValue =
Utils.writeFile(output_dir + ctx.getFilename() + "PubSubTypes.cxx",
maintemplates.getTemplate("com/eprosima/fastdds/idl/templates/DDSPubSubTypeSource.stg"), m_replace))
{
project.addProjectIncludeFile(relative_dir + ctx.getFilename() + "CdrAux.hpp");
project.addProjectSrcFile(relative_dir + ctx.getFilename() + "PubSubTypes.cxx");
if (m_python)
{
System.out.println("Generating Swig interface files...");
returnedValue = Utils.writeFile(
output_dir + ctx.getFilename() + "PubSubTypes.i",
maintemplates.getTemplate("com/eprosima/fastdds/idl/templates/DDSPubSubTypeSwigInterface.stg"), m_replace);
}
}
System.out.println("Generating Swig interface files...");
returnedValue &= Utils.writeFile(
output_dir + ctx.getFilename() + "PubSubTypes.i",
maintemplates.getTemplate("com/eprosima/fastdds/idl/templates/DDSPubSubTypeSwigInterface.stg"), m_replace);
}
}

Expand Down
14 changes: 14 additions & 0 deletions src/main/java/com/eprosima/fastdds/idl/grammar/Context.java
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,20 @@ else if (content.getKind() == Kind.KIND_MAP)
typecodes.add(new SimpleEntry<String, TypeCode>(sequence.getCppTypename(), sequence));
}

public boolean isThereIsStructOrUnion()
{
for (TypeDeclaration type : m_types.values())
{
if (type.getTypeCode() instanceof StructTypeCode ||
type.getTypeCode() instanceof UnionTypeCode)
{
return true;
}
}

return false;
}

/*** Functions inherited from FastCDR Context ***/

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ target_link_libraries($project.name$ $solution.libraries : { library | $library$
$project.name$_lib $project.dependencies : { dep | $dep$_lib}; separator=" "$)
$endif$


$if(test)$
# $project.name$ Serialization Test
add_executable($project.name$SerializationTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ $fileHeader(ctx=ctx, file=[ctx.filename, "CdrAux.ipp"], description=["This sourc
#ifndef _FAST_DDS_GENERATED_$ctx.headerGuardName$CDRAUX_IPP_
#define _FAST_DDS_GENERATED_$ctx.headerGuardName$CDRAUX_IPP_

$ctx.directIncludeDependencies : {include | #include "$include$CdrAux.hpp"}; separator="\n"$
#include "$ctx.filename$CdrAux.hpp"

$if(ctx.cdr)$
Expand Down

0 comments on commit f1f3fb3

Please sign in to comment.