diff --git a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSource.stg b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSource.stg index 4766e621..a01f7adb 100644 --- a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSource.stg +++ b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSource.stg @@ -55,7 +55,9 @@ $endif$ $definitions; separator="\n"$ +$if(ctx.thereIsStructOrUnion)$ #include "$ctx.filename$CdrAux.ipp" +$endif$ >> module(ctx, parent, module, definition_list) ::= << diff --git a/src/main/java/com/eprosima/fastdds/fastddsgen.java b/src/main/java/com/eprosima/fastdds/fastddsgen.java index d7fa41ad..31799010 100644 --- a/src/main/java/com/eprosima/fastdds/fastddsgen.java +++ b/src/main/java/com/eprosima/fastdds/fastddsgen.java @@ -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); } } diff --git a/src/main/java/com/eprosima/fastdds/idl/grammar/Context.java b/src/main/java/com/eprosima/fastdds/idl/grammar/Context.java index cdc3eaf3..fc3ba60a 100644 --- a/src/main/java/com/eprosima/fastdds/idl/grammar/Context.java +++ b/src/main/java/com/eprosima/fastdds/idl/grammar/Context.java @@ -303,6 +303,20 @@ else if (content.getKind() == Kind.KIND_MAP) typecodes.add(new SimpleEntry(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 diff --git a/src/main/java/com/eprosima/fastdds/idl/templates/CMakeLists.stg b/src/main/java/com/eprosima/fastdds/idl/templates/CMakeLists.stg index 67c6483f..62078d2b 100644 --- a/src/main/java/com/eprosima/fastdds/idl/templates/CMakeLists.stg +++ b/src/main/java/com/eprosima/fastdds/idl/templates/CMakeLists.stg @@ -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 diff --git a/src/main/java/com/eprosima/fastdds/idl/templates/TypesCdrAuxHeaderImpl.stg b/src/main/java/com/eprosima/fastdds/idl/templates/TypesCdrAuxHeaderImpl.stg index e6cb8f4d..335f9538 100644 --- a/src/main/java/com/eprosima/fastdds/idl/templates/TypesCdrAuxHeaderImpl.stg +++ b/src/main/java/com/eprosima/fastdds/idl/templates/TypesCdrAuxHeaderImpl.stg @@ -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)$