From 7ec537d47f828270546e459d878deab3ce1bcaaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Gonz=C3=A1lez?= Date: Mon, 11 Mar 2024 14:20:59 +0100 Subject: [PATCH 01/26] Support new fastdds naming (#315) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Refs #19451. Support new fastdds naming Signed-off-by: Ricardo González Moreno * Refs #19451. Fix in swig cmake files Signed-off-by: Ricardo González Moreno --------- Signed-off-by: Ricardo González Moreno --- colcon.pkg | 2 +- src/main/java/com/eprosima/fastdds/fastddsgen.java | 8 +++----- .../com/eprosima/fastdds/idl/templates/CMakeLists.stg | 2 +- .../java/com/eprosima/fastdds/idl/templates/SwigCMake.stg | 6 +++--- src/main/java/com/eprosima/fastdds/solution/Solution.java | 8 ++++---- 5 files changed, 12 insertions(+), 14 deletions(-) diff --git a/colcon.pkg b/colcon.pkg index ffb1f984..49c80ffa 100644 --- a/colcon.pkg +++ b/colcon.pkg @@ -1,5 +1,5 @@ { "name": "fastddsgen", "type": "gradle", - "test-dependencies" : ["fastrtps"] + "test-dependencies" : ["fastdds"] } diff --git a/src/main/java/com/eprosima/fastdds/fastddsgen.java b/src/main/java/com/eprosima/fastdds/fastddsgen.java index f1d462bb..abaada35 100644 --- a/src/main/java/com/eprosima/fastdds/fastddsgen.java +++ b/src/main/java/com/eprosima/fastdds/fastddsgen.java @@ -73,7 +73,7 @@ public class fastddsgen private static ArrayList m_platforms = null; private Vector m_idlFiles; - protected static String m_appEnv = "FASTRTPSHOME"; + protected static String m_appEnv = "FASTDDSHOME"; private String m_exampleOption = null; private boolean m_ppDisable = false; //TODO private boolean m_replace = false; @@ -86,7 +86,7 @@ public class fastddsgen private boolean m_publishercode = true; private boolean m_subscribercode = true; private boolean m_atLeastOneStructure = false; - protected static String m_localAppProduct = "fastrtps"; + protected static String m_localAppProduct = "fastdds"; private ArrayList m_includePaths = new ArrayList(); // Mapping where the key holds the path to the template file and the value the wanted output file name @@ -451,7 +451,7 @@ public boolean execute() } // Add product library - solution.addLibrary("fastrtps"); + solution.addLibrary("fastdds"); for (int count = 0; returnedValue && (count < m_idlFiles.size()); ++count) { @@ -528,8 +528,6 @@ private String getVersion() { try { - //InputStream input = this.getClass().getResourceAsStream("/fastrtps_version.h"); - InputStream input = this.getClass().getClassLoader().getResourceAsStream("version"); byte[] b = new byte[input.available()]; input.read(b); 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 fd869d74..04648f07 100644 --- a/src/main/java/com/eprosima/fastdds/idl/templates/CMakeLists.stg +++ b/src/main/java/com/eprosima/fastdds/idl/templates/CMakeLists.stg @@ -39,7 +39,7 @@ $endif$ # Find requirements find_package(fastcdr REQUIRED) -find_package(fastrtps 2.12 REQUIRED) +find_package(fastdds 3 REQUIRED) $solution.projects : { project | $pub_sub_execs(project=project, libraries=solution.libraries, test=test)$}; separator="\n"$ diff --git a/src/main/java/com/eprosima/fastdds/idl/templates/SwigCMake.stg b/src/main/java/com/eprosima/fastdds/idl/templates/SwigCMake.stg index 8f734626..6e3a467a 100644 --- a/src/main/java/com/eprosima/fastdds/idl/templates/SwigCMake.stg +++ b/src/main/java/com/eprosima/fastdds/idl/templates/SwigCMake.stg @@ -45,7 +45,7 @@ message(STATUS "Configuring python wrapper for types in $project.name$...") project($project.name$) find_package(fastcdr REQUIRED) -find_package(fastrtps REQUIRED) +find_package(fastdds 3 REQUIRED) set(CMAKE_POSITION_INDEPENDENT_CODE ON) @@ -64,7 +64,7 @@ target_include_directories(\${PROJECT_NAME} PUBLIC target_link_libraries(\${PROJECT_NAME} PUBLIC fastcdr - fastrtps + fastdds $project.dependencies : { dep | $dep$}; separator=" "$ ) @@ -110,7 +110,7 @@ endif() target_link_libraries(\${\${PROJECT_NAME}_MODULE} Python3::Module - fastrtps + fastdds \${PROJECT_NAME} ) diff --git a/src/main/java/com/eprosima/fastdds/solution/Solution.java b/src/main/java/com/eprosima/fastdds/solution/Solution.java index 697c864f..6510c389 100644 --- a/src/main/java/com/eprosima/fastdds/solution/Solution.java +++ b/src/main/java/com/eprosima/fastdds/solution/Solution.java @@ -49,7 +49,7 @@ public ArrayList getLibraries() for(int count = 0; count < libraries.size(); ++count) { - if(m_example.contains("Win") && libraries.get(count).startsWith("fastrtps")) + if(m_example.contains("Win") && libraries.get(count).startsWith("fastdds")) ret.add(libraries.get(count) + "-" + m_version); else ret.add(libraries.get(count)); @@ -65,7 +65,7 @@ public ArrayList getLibrariesDebug() for(int count = 0; count < libraries.size(); ++count) { - if(m_example.contains("Win") && libraries.get(count).startsWith("fastrtps")) + if(m_example.contains("Win") && libraries.get(count).startsWith("fastdds")) ret.add(libraries.get(count) + "d-" + m_version); else ret.add(libraries.get(count) + "d"); @@ -83,7 +83,7 @@ public ArrayList getLibrariesStatic() { if(libraries.get(count).startsWith("ndds")) ret.add(libraries.get(count) + "z"); - else if(m_example.contains("Win") && libraries.get(count).startsWith("fastrtps")) + else if(m_example.contains("Win") && libraries.get(count).startsWith("fastdds")) ret.add("lib" + libraries.get(count) + "-" + m_version); else ret.add("lib" + libraries.get(count)); @@ -101,7 +101,7 @@ public ArrayList getLibrariesStaticDebug() { if(libraries.get(count).startsWith("ndds")) ret.add(libraries.get(count) + "zd"); - else if(m_example.contains("Win") && libraries.get(count).startsWith("fastrtps")) + else if(m_example.contains("Win") && libraries.get(count).startsWith("fastdds")) ret.add("lib" + libraries.get(count) + "d-" + m_version); else ret.add("lib" + libraries.get(count) + "d"); From f3a5fc3c89892360771a0677cc63215f32fbbb4d Mon Sep 17 00:00:00 2001 From: Eduardo Ponz Segrelles Date: Mon, 18 Mar 2024 12:30:50 +0100 Subject: [PATCH 02/26] Rename RTPS_DllAPI to FASTDDS_EXPORTED_API (#311) Signed-off-by: EduPonz --- .../com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg index 7757141a..816197d5 100644 --- a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg +++ b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg @@ -88,7 +88,7 @@ $definitions; separator="\n"$ fast_macro_declarations() ::= << // Macro declarations // Any macro used on the Fast DDS header files will give an error if it is not redefined here -#define RTPS_DllAPI +#define FASTDDS_EXPORTED_API #define eProsima_user_DllExport >> From 83aa359822497c48ee7685e13425d6e7d5de702c Mon Sep 17 00:00:00 2001 From: Eduardo Ponz Segrelles Date: Mon, 18 Mar 2024 12:56:07 +0100 Subject: [PATCH 03/26] Run Fast DDS Gen CI on PRs to 4.0.x-devel (#317) * Refs #19452: Run Fast DDS Gen CI on PRs to 4.0.x-devel Signed-off-by: EduPonz * Refs #19452: Refactor CI Signed-off-by: EduPonz * Refs #19452: Fix input Signed-off-by: EduPonz * Refs #19452: Fix base branch decision making Signed-off-by: EduPonz * Refs #19452: Select correct branches of the other repos Signed-off-by: EduPonz * Refs #19452: Correctly fetch specified Fast CDR version Signed-off-by: EduPonz * Refs #20640: Tmp disable ccache Signed-off-by: Mario Dominguez * Revert "Refs #20640: Tmp disable ccache" This reverts commit 0927df5beaeaf37a648f65b611fe2af1ce6901d8. --------- Signed-off-by: EduPonz Signed-off-by: Mario Dominguez Co-authored-by: Mario Dominguez --- .github/workflows/ubuntu-ci.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ubuntu-ci.yaml b/.github/workflows/ubuntu-ci.yaml index 1025aa8a..a4f0c455 100644 --- a/.github/workflows/ubuntu-ci.yaml +++ b/.github/workflows/ubuntu-ci.yaml @@ -40,7 +40,7 @@ jobs: java_version: - 'openjdk-11-jdk' - 'openjdk-19-jdk' - fastcdr_version: ${{ fromJson(inputs.fastcdr_version || '["1.1.x", "master"]') }} + fastcdr_version: ${{ fromJson(inputs.fastcdr_version || '["master"]') }} uses: ./.github/workflows/reusable-ubuntu-ci.yaml with: @@ -49,6 +49,6 @@ jobs: foonathan_memory_vendor_branch: ${{ inputs.foonathan_memory_vendor_branch || 'master' }} fastcdr_branch: ${{ matrix.fastcdr_version }} fastdds_branch: ${{ inputs.fastdds_branch || github.head_ref }} - fastdds_python_branch: ${{ inputs.fastdds_python_branch || 'main' }} - fastddsgen_branch: ${{ inputs.fastddsgen_branch || github.ref || 'master' }} - fastdds_fallback_branch: ${{ 'master' }} + fastdds_python_branch: ${{ inputs.fastdds_python_branch || '3.0.x-devel' }} + fastddsgen_branch: ${{ inputs.fastddsgen_branch || github.ref || '4.0.x-devel' }} + fastdds_fallback_branch: ${{ '3.0.x-devel' }} From 9f1e79365fb77c7d3e91f705b244a3f1222b95b3 Mon Sep 17 00:00:00 2001 From: elianalf <62831776+elianalf@users.noreply.github.com> Date: Mon, 25 Mar 2024 12:28:04 +0100 Subject: [PATCH 04/26] Update fastrtps migrated headers (#318) * Refs #20566: Change headers md5.h and SerializedPayload.h from fastrtps tp fastdds Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #20566: Change header fixed_size_string Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #20566: Change fixed_size_string namespace from fastrtps to fastcdr Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> --------- Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> --- .../com/eprosima/fastcdr/idl/templates/TypesHeaderv1.stg | 4 ++-- .../fastdds/idl/parser/typecode/StringTypeCode.java | 2 +- .../eprosima/fastdds/idl/templates/DDSPubSubTypeHeader.stg | 2 +- .../eprosima/fastdds/idl/templates/SerializationSource.stg | 5 +---- .../com/eprosima/fastdds/idl/templates/TypeObjectSource.stg | 6 ++++-- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesHeaderv1.stg b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesHeaderv1.stg index e5dab9b0..172a127e 100644 --- a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesHeaderv1.stg +++ b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesHeaderv1.stg @@ -35,8 +35,6 @@ $endif$ $ctx.directIncludeDependencies : {include | #include "$include$.h"}; separator="\n"$ -#include - #include #include #include @@ -45,6 +43,8 @@ $ctx.directIncludeDependencies : {include | #include "$include$.h"}; separator=" #include #include +#include + #if defined(_WIN32) #if defined(EPROSIMA_USER_DLL_EXPORT) #define eProsima_user_DllExport __declspec( dllexport ) diff --git a/src/main/java/com/eprosima/fastdds/idl/parser/typecode/StringTypeCode.java b/src/main/java/com/eprosima/fastdds/idl/parser/typecode/StringTypeCode.java index e7b2c650..d67c664d 100644 --- a/src/main/java/com/eprosima/fastdds/idl/parser/typecode/StringTypeCode.java +++ b/src/main/java/com/eprosima/fastdds/idl/parser/typecode/StringTypeCode.java @@ -65,7 +65,7 @@ public String getCppTypename() { if (Kind.KIND_STRING == getKind() && isIsBounded() && ctx instanceof com.eprosima.fastcdr.idl.context.Context && ((com.eprosima.fastcdr.idl.context.Context)ctx).isCdrv1TemplatesEnabled()) { - return "eprosima::fastrtps::fixed_string<" + getMaxsize() + ">"; + return "eprosima::fastcdr::fixed_string<" + getMaxsize() + ">"; } return super.getCppTypename(); diff --git a/src/main/java/com/eprosima/fastdds/idl/templates/DDSPubSubTypeHeader.stg b/src/main/java/com/eprosima/fastdds/idl/templates/DDSPubSubTypeHeader.stg index d110194c..71304ffd 100644 --- a/src/main/java/com/eprosima/fastdds/idl/templates/DDSPubSubTypeHeader.stg +++ b/src/main/java/com/eprosima/fastdds/idl/templates/DDSPubSubTypeHeader.stg @@ -27,7 +27,7 @@ $fileHeader(ctx=ctx, file=[ctx.filename, "PubSubTypes.h"], description=["This h #include #include #include -#include +#include #include "$ctx.filename$.h" diff --git a/src/main/java/com/eprosima/fastdds/idl/templates/SerializationSource.stg b/src/main/java/com/eprosima/fastdds/idl/templates/SerializationSource.stg index 37d187fa..8a5dbb12 100644 --- a/src/main/java/com/eprosima/fastdds/idl/templates/SerializationSource.stg +++ b/src/main/java/com/eprosima/fastdds/idl/templates/SerializationSource.stg @@ -1051,11 +1051,8 @@ external_suffix(p, external) ::= <<$p$$if(external)$->$else$.$endif$>> cppTypenameBetweenCdrVersions(typecode) ::= << $if(typecode.isStringType && typecode.isBounded)$ $! Avoid error with namespace when generated fixed_string depending on CDR version !$ -#if FASTCDR_VERSION_MAJOR == 1 -eprosima::fastrtps::fixed_string<$typecode.maxsize$> -#else eprosima::fastcdr::fixed_string<$typecode.maxsize$> -#endif + $else$ $typecode.cppTypename$ diff --git a/src/main/java/com/eprosima/fastdds/idl/templates/TypeObjectSource.stg b/src/main/java/com/eprosima/fastdds/idl/templates/TypeObjectSource.stg index 39f4898b..509da4dd 100644 --- a/src/main/java/com/eprosima/fastdds/idl/templates/TypeObjectSource.stg +++ b/src/main/java/com/eprosima/fastdds/idl/templates/TypeObjectSource.stg @@ -26,12 +26,14 @@ namespace { char dummy; } #include "$ctx.filename$.h" #include "$ctx.filename$TypeObject.h" + #include #include #include + #include -#include -#include +#include +#include #include #include #include From 6f257fd7722fb84c9d2cee49e59e498dc8ca013c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Gonz=C3=A1lez?= Date: Mon, 20 Nov 2023 12:19:14 +0100 Subject: [PATCH 05/26] New argument -genapi [19958] (#261) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Refs #19944. Initial -genapi Signed-off-by: Ricardo González Moreno * Refs #19944. Remove default templates Signed-off-by: Ricardo González Moreno * Refs #19944. Update scope when getting typecodes Signed-off-by: Ricardo González Moreno * Refs #19944. Fix compilation error Signed-off-by: Ricardo González Moreno * Refs #19944. Apply suggestions Signed-off-by: Ricardo González Moreno --------- Signed-off-by: Ricardo González Moreno --- .../eprosima/fastcdr/idl/context/Context.java | 2 - .../fastcdr/idl/templates/TypesHeader.stg | 72 +--- .../fastcdr/idl/templates/TypesHeaderv1.stg | 60 +--- .../fastcdr/idl/templates/TypesSource.stg | 86 +---- .../fastcdr/idl/templates/TypesSourcev1.stg | 75 +---- .../idl/templates/TypesSwigInterface.stg | 68 ---- .../java/com/eprosima/fastdds/fastddsgen.java | 314 +++++++++--------- .../eprosima/fastdds/idl/grammar/Context.java | 111 ++++++- .../fastdds/idl/templates/DDSPubSubMain.stg | 103 ------ .../idl/templates/DDSPubSubTypeHeader.stg | 93 +----- .../idl/templates/DDSPubSubTypeSource.stg | 101 +----- .../templates/DDSPubSubTypeSwigInterface.stg | 78 ----- .../idl/templates/DDSPublisherHeader.stg | 103 ------ .../idl/templates/DDSPublisherSource.stg | 103 ------ .../idl/templates/DDSSubscriberHeader.stg | 103 ------ .../idl/templates/DDSSubscriberSource.stg | 103 ------ .../fastdds/idl/templates/JNIHeader.stg | 86 ----- .../fastdds/idl/templates/JNISource.stg | 85 ----- .../fastdds/idl/templates/JavaSource.stg | 93 ------ .../idl/templates/SerializationHeader.stg | 56 ---- .../idl/templates/SerializationSource.stg | 61 ---- .../idl/templates/SerializationTestSource.stg | 66 ---- .../idl/templates/TypeObjectHeader.stg | 53 +-- .../idl/templates/TypeObjectSource.stg | 50 +-- .../idl/templates/TypesCdrAuxHeader.stg | 98 ------ .../idl/templates/TypesCdrAuxHeaderImpl.stg | 89 ----- .../fastdds/idl/templates/eprosima.stg | 94 ++++++ .../com/eprosima/fastdds/FastDDSGenTest.java | 20 +- thirdparty/dds-types-test | 2 +- thirdparty/idl-parser | 2 +- 30 files changed, 466 insertions(+), 1964 deletions(-) diff --git a/src/main/java/com/eprosima/fastcdr/idl/context/Context.java b/src/main/java/com/eprosima/fastcdr/idl/context/Context.java index 58f1c4a4..3c048fb4 100644 --- a/src/main/java/com/eprosima/fastcdr/idl/context/Context.java +++ b/src/main/java/com/eprosima/fastcdr/idl/context/Context.java @@ -41,8 +41,6 @@ public interface Context public boolean isGenerateTypeObject(); - public boolean isGenerateTypesC(); - public boolean isGenerateTypesROS2(); public boolean isCdr(); diff --git a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesHeader.stg b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesHeader.stg index 72394ffd..b6e244d4 100644 --- a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesHeader.stg +++ b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesHeader.stg @@ -118,10 +118,6 @@ $definition_list$ } // namespace $module.name$ >> -definition_list(definitions) ::= << -$definitions; separator="\n"$ ->> - annotation(ctx, annotation) ::= << namespace $annotation.name$ { $annotation.enums : { enum | $enum_type(ctx=ctx, parent=annotation, enum=enum)$}; separator="\n"$ @@ -146,27 +142,6 @@ public: }; >> -export_list(exports) ::= << -$exports; separator="\n"$ ->> - -exception(ctx, parent, exception) ::= <<>> - -operation(ctx, parent, operation, param_list, operation_type) ::= << - -$operation_type$ -$param_list$ - ->> - -param_list(parameters) ::= <<>> - -param(parameter, parameter_type) ::= << - -$parameter_type$ - ->> - const_decl(ctx, parent, const, const_type) ::= <<$const_type$$if(ctx.inScopedFile)$$if(const.parent)$$if(const.parent.isInterface)$static $endif$$endif$const $const.typeCode.cppTypename$ $const.name$$if(!const.parent)$ = $const.value$$elseif(!const.parent.isInterface)$ = $const.value$$elseif(!const.typeCode.isType_5)$$if(!const.typeCode.isType_6)$ = $const.value$$endif$$endif$;$endif$>> typedef_decl(ctx, parent, typedefs, typedefs_type, declarator_type) ::= << @@ -258,13 +233,6 @@ private: }; >> -member_type(ctx, member, type_member, declarators) ::= << - -$type_member$ -$declarators$ - ->> - union_type(ctx, parent, union, extensions, switch_type) ::= << $switch_type$ /*! @@ -358,13 +326,6 @@ private: }; >> -element_type(ctx, element, type_element, declarator) ::= << - -$type_element$ -$declarator$ - ->> - bitset_type(ctx, parent, bitset, extensions) ::= << /*! * @brief This class represents the structure $bitset.name$ defined by the user in the IDL file. @@ -471,25 +432,6 @@ class $type.name$; >> -sequence_type(ctx, sequence, type_sequence) ::= << - -$type_sequence$ - ->> - -map_type(ctx, map, key_type, value_type) ::= << - -$key_type$ -$value_type$ - ->> - -string_type(ctx, string) ::= <<>> - -wide_string_type(ctx, wstring) ::= <<>> - -array_declarator(ctx, array, array_type) ::= <<>> - /***** Utils *****/ public_struct_inheritances(parent) ::= <<$parent.scopedname$>> @@ -801,3 +743,17 @@ private: void free_memory(); }; >> + +//{ Fast DDS-Gen extensions +module_conversion(ctx, parent, modules, definition_list) ::= << +$modules : { module | +namespace $module.name$ { +}; separator="\n"$ + +$definition_list$ + +$reverse(modules) : { module | +\} // namespace $module.name$ +}; separator="\n"$ +>> +//} diff --git a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesHeaderv1.stg b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesHeaderv1.stg index 172a127e..f88a9cc1 100644 --- a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesHeaderv1.stg +++ b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesHeaderv1.stg @@ -104,17 +104,12 @@ $if(ctx.cdr_both)$ $endif$ >> -// TODO name -> module module(ctx, parent, module, definition_list) ::= << namespace $module.name$ { $definition_list$ } // namespace $module.name$ >> -definition_list(definitions) ::= << -$definitions; separator="\n"$ ->> - annotation(ctx, annotation) ::= << namespace $annotation.name$ { $annotation.enums : { enum | $enum_type(ctx=ctx, parent=annotation, enum=enum)$}; separator="\n"$ @@ -139,10 +134,6 @@ public: }; >> -export_list(exports) ::= << -$exports; separator="\n"$ ->> - exception(ctx, parent, exception) ::= << $if(ctx.printexception)$ /*! @@ -211,10 +202,6 @@ virtual $paramRetType(operation.rettype)$ $operation.name$($paramDeclarations(pa $endif$ >> -param_list(parameters) ::= <<>> - -param(parameter) ::= <<>> - const_decl(ctx, parent, const, const_type) ::= << $ctx.setCdrv1Templates$ $const_type$ @@ -557,39 +544,6 @@ enum $bitmask.name$Bits$bitmask.boundType$ typedef $bitmask.castingType$ $bitmask.name$; >> -sequence_type(ctx, sequence, type_sequence) ::= << - -$type_sequence$ - ->> - -map_type(ctx, map, key_type, value_type) ::= << - -$key_type$ -$value_type$ - ->> - -string_type(ctx, string) ::= <<>> - -wide_string_type(ctx, wstring) ::= <<>> - -array_declarator(ctx, array, array_type) ::= <<>> - -member_type(ctx, member, type_member, declarators) ::= << - -$type_member$ -$declarators$ - ->> - -element_type(ctx, element, type_element, declarator) ::= << - -$type_element$ -$declarator$ - ->> - /***** Utils *****/ public_struct_inheritances(parent) ::= <<$parent.scopedname$>> @@ -951,3 +905,17 @@ private: void free_memory(); }; >> + +//{ Fast DDS-Gen extensions +module_conversion(ctx, parent, modules, definition_list) ::= << +$modules : { module | +namespace $module.name$ { +}; separator="\n"$ + +$definition_list$ + +$reverse(modules) : { module | +\} // namespace $module.name$ +}; separator="\n"$ +>> +//} 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 930b1aeb..a17daaff 100644 --- a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSource.stg +++ b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSource.stg @@ -77,39 +77,6 @@ $definition_list$ } // namespace $module.name$ >> -definition_list(definitions) ::= << -$definitions; separator="\n"$ - ->> - -annotation(ctx, annotation) ::= <<>> - -interface(ctx, parent, interface, export_list) ::= << -$export_list$ ->> - -export_list(exports) ::= << -$exports; separator="\n"$ - ->> - -exception(ctx, parent, exception) ::= <<>> - -operation(ctx, parent, operation, param_list, operation_type) ::= << - -$operation_type$ -$param_list$ - ->> - -param_list(parameters) ::= <<>> - -param(parameter, parameter_type) ::= << - -$parameter_type$ - ->> - const_decl(ctx, parent, const, const_type) ::= << $const_type$ $if(const.parent)$ @@ -123,8 +90,6 @@ $endif$ $endif$ >> -fwd_decl(ctx, parent, type) ::= <<>> - typedef_decl(ctx, parent, typedefs, typedefs_type, declarator_type) ::= << $declarator_type$ $typedefs_type$ @@ -257,13 +222,6 @@ $struct.members:{ member | $public_member_declaration(class=struct.name, member= $extensions : { extension | $extension$}; separator="\n"$ >> -member_type(ctx, member, type_member, declarators) ::= << - -$type_member$ -$declarators$ - ->> - bitset_type(ctx, parent, bitset) ::= << $bitset.name$::$bitset.name$()$if(bitset.inheritance)$ : $bitset_inherit_default_init(bitset.inheritance)$$endif$ @@ -571,36 +529,6 @@ void $union.name$::deserialize( $endif$ >> -element_type(ctx, element, type_element, declarator) ::= << - -$type_element$ -$declarator$ - ->> - -enum_type(ctx, parent, enum) ::= <<>> - -bitmask_type(ctx, parent, bitmask) ::= <<>> - -sequence_type(ctx, sequence, type_sequence) ::= << - -$type_sequence$ - ->> - -map_type(ctx, map, key_type, value_type) ::= << - -$key_type$ -$value_type$ - ->> - -string_type(ctx, string) ::= <<>> - -wide_string_type(ctx, wstring) ::= <<>> - -array_declarator(ctx, array, array_type) ::= <<>> - /***** Utils *****/ public_member_declaration(class, member) ::= << @@ -1411,3 +1339,17 @@ void $scopedtypename$::free_memory() $endif$ >> + +//{ Fast DDS-Gen extensions +module_conversion(ctx, parent, modules, definition_list) ::= << +$modules : { module | +namespace $module.name$ { +}; separator="\n"$ + +$definition_list$ + +$reverse(modules) : { module | +\} // namespace $module.name$ +}; separator="\n"$ +>> +//} diff --git a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSourcev1.stg b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSourcev1.stg index 79ee4010..59f2058b 100644 --- a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSourcev1.stg +++ b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSourcev1.stg @@ -126,22 +126,6 @@ $definition_list$ } // namespace $module.name$ >> -definition_list(definitions) ::= << -$definitions; separator="\n"$ - ->> - -annotation(ctx, annotation) ::= <<>> - -interface(ctx, parent, interface, export_list) ::= << -$export_list$ ->> - -export_list(exports) ::= << -$exports; separator="\n"$ - ->> - exception(ctx, parent, exception) ::= << $if(ctx.printexception)$ $exception.name$::$exception.name$() @@ -238,12 +222,6 @@ $endif$ $endif$ >> -operation(ctx, parent, operation, param_list) ::= <<>> - -param_list(parameters) ::= <<>> - -param(parameter) ::= <<>> - const_decl(ctx, parent, const, const_type) ::= << $ctx.setCdrv1Templates$ $const_type$ @@ -259,8 +237,6 @@ $endif$ $ctx.unsetCdrv1Templates$ >> -fwd_decl(ctx, parent, type) ::= <<>> - typedef_decl(ctx, parent, typedefs, typedefs_type, declarator_type) ::= << $ctx.setCdrv1Templates$ $declarator_type$ @@ -898,43 +874,6 @@ $endif$ $ctx.unsetCdrv1Templates$ >> -enum_type(ctx, parent, enum) ::= <<>> - -bitmask_type(ctx, parent, bitmask) ::= <<>> - -sequence_type(ctx, sequence, type_sequence) ::= << - -$type_sequence$ - ->> - -map_type(ctx, map, key_type, value_type) ::= << - -$key_type$ -$value_type$ - ->> - -string_type(ctx, string) ::= <<>> - -wide_string_type(ctx, wstring) ::= <<>> - -array_declarator(ctx, array, array_type) ::= <<>> - -member_type(ctx, member, type_member, declarators) ::= << - -$type_member$ -$declarators$ - ->> - -element_type(ctx, element, type_element, declarator) ::= << - -$type_element$ -$declarator$ - ->> - /***** Utils *****/ public_member_declaration(class, member) ::= << @@ -2339,3 +2278,17 @@ member_array_default_cstring_init(ctx, name, loopvar, dims) ::= <<$if(rest(dims) indexName(name, loopvar) ::= <<$name$[$loopvar$]>> memberName(name) ::= <> + +//{ Fast DDS-Gen extensions +module_conversion(ctx, parent, modules, definition_list) ::= << +$modules : { module | +namespace $module.name$ { +}; separator="\n"$ + +$definition_list$ + +$reverse(modules) : { module | +\} // namespace $module.name$ +}; separator="\n"$ +>> +//} diff --git a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg index 816197d5..5a2160c1 100644 --- a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg +++ b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg @@ -76,15 +76,6 @@ $endif$ $"\n"$ >> -module(ctx, parent, module, definition_list) ::= << -$definition_list$ ->> - -definition_list(definitions) ::= << -$definitions; separator="\n"$ - ->> - fast_macro_declarations() ::= << // Macro declarations // Any macro used on the Fast DDS header files will give an error if it is not redefined here @@ -123,13 +114,6 @@ $struct.members : { member | $member_getters(struct_name=struct.scopedname, memb >> -member_type(ctx, member, type_member, declarators) ::= << - -$type_member$ -$declarators$ - ->> - template_sequence_name(typecode) ::= <% $if(typecode.isSequenceType)$ $template_sequence_name(typecode.contentTypeCode)$_vector @@ -226,13 +210,6 @@ $union.members : { member | $member_getters(struct_name=union.name, member=membe >> -element_type(ctx, element, type_element, declarator) ::= << - -$type_element$ -$declarator$ - ->> - bitset_type(ctx, parent, bitset, extensions) ::= << //////////////////////////////////////////////////////// // Binding for class $bitset.name$ @@ -248,48 +225,3 @@ bitset_type(ctx, parent, bitset, extensions) ::= << enum_type(ctx, parent, enum) ::= << %traits_penumn(enum $enum.cppTypename$); >> - -// bitmasks are implemented as enums. Therefore, are ported as constants in the target language -bitmask_type(ctx, parent, bitmask) ::= <<>> - -sequence_type(ctx, sequence, type_sequence) ::= << - -$type_sequence$ - ->> - -map_type(ctx, map, key_type, value_type) ::= << - -$key_type$ -$value_type$ - ->> - -string_type(ctx, string) ::= <<>> - -wide_string_type(ctx, wstring) ::= <<>> - -array_declarator(ctx, array, array_type) ::= <<>> - -const_decl(ctx, parent, const, const_type) ::= << - -$const_type$ - ->> - -annotation(ctx, parent, annotation) ::= <<>> - -typedef_decl(ctx, parent, typedefs, typedefs_type, declarator_type) ::= << - -$declarator_type$ -$typedefs_type$ - ->> - -fwd_decl(ctx, parent, type) ::= <<>> - -annotation(ctx, annotation) ::= <<>> - -interface(ctx, parent, interface, export_list) ::= <<>> - -exception(ctx, parent, exception) ::= <<>> diff --git a/src/main/java/com/eprosima/fastdds/fastddsgen.java b/src/main/java/com/eprosima/fastdds/fastddsgen.java index abaada35..830b7efa 100644 --- a/src/main/java/com/eprosima/fastdds/fastddsgen.java +++ b/src/main/java/com/eprosima/fastdds/fastddsgen.java @@ -27,8 +27,6 @@ import com.eprosima.idl.parser.grammar.IDLLexer; import com.eprosima.idl.parser.grammar.IDLParser; import com.eprosima.idl.parser.tree.Annotation; -import com.eprosima.idl.parser.tree.AnnotationDeclaration; -import com.eprosima.idl.parser.tree.AnnotationMember; import com.eprosima.idl.parser.tree.Specification; import com.eprosima.idl.parser.typecode.Kind; import com.eprosima.idl.parser.typecode.PrimitiveTypeCode; @@ -127,6 +125,9 @@ public class fastddsgen // ignoring the relative dir of the input files private boolean m_flat_output_dir = false; + // Generating internal API + private boolean gen_api_ = false; + // Use to know the programming language public enum LANGUAGE { @@ -166,6 +167,75 @@ public fastddsgen( { m_idlFiles.add(arg); } + else if (arg.equals("-cdr")) + { + if (count < args.length) + { + String cdr_version_str = args[count++]; + if (cdr_version_str.equals(CdrVersion.v1_str)) + { + cdr_version_ = CdrVersion.Select.V1; + } + else if (cdr_version_str.equals(CdrVersion.v2_str)) + { + cdr_version_ = CdrVersion.Select.V2; + } + else if (cdr_version_str.equals(CdrVersion.both_str)) + { + cdr_version_ = CdrVersion.Select.BOTH; + } + else + { + throw new BadArgumentException("CDR version value " + cdr_version_str + " is not valid"); + } + } + else + { + throw new BadArgumentException("No CDR version value after -cdr argument"); + } + } + else if (arg.equals("-cs")) + { + m_case_sensitive = true; + } + else if (arg.equals("-d")) + { + if (count < args.length) + { + m_outputDir = Utils.addFileSeparator(args[count++]); + } + else + { + throw new BadArgumentException("No URL specified after -d argument"); + } + } + else if (arg.equals("-de") || arg.equals("-default_extensibility")) + { + if (count < args.length) + { + String extensibility = args[count++]; + if (extensibility.equals(Annotation.final_str)) + { + TypeCode.default_extensibility = TypeCode.ExtensibilityKind.FINAL; + } + else if (extensibility.equals(Annotation.appendable_str)) + { + TypeCode.default_extensibility = TypeCode.ExtensibilityKind.APPENDABLE; + } + else if (extensibility.equals(Annotation.mutable_str)) + { + TypeCode.default_extensibility = TypeCode.ExtensibilityKind.MUTABLE; + } + else + { + throw new BadArgumentException("Extensibility value " + extensibility + " is not valid"); + } + } + else + { + throw new BadArgumentException("No extensibility value after -default_extensibility argument"); + } + } else if (arg.equals("-example")) { if (count < args.length) @@ -181,6 +251,46 @@ else if (arg.equals("-example")) throw new BadArgumentException("No architecture speficied after -example argument"); } } + else if (arg.equals("-extrastg")) + { + if (count + 1 < args.length) + { + m_customStgOutput.put(args[count++], args[count++]); + } + else + { + throw new BadArgumentException("Missing arguments for -extrastg"); + } + } + else if (arg.equals("-flat-output-dir")) + { + m_flat_output_dir = true; + } + else if (arg.equals("-genapi")) + { + gen_api_ = true; + } + else if (arg.equals("-help")) + { + printHelp(); + System.exit(0); + } + else if (arg.equals("-help+")) + { + printEnhacedHelp(); + System.exit(0); + } + else if (arg.equals("-I")) + { + if (count < args.length) + { + m_includePaths.add("-I".concat(args[count++])); + } + else + { + throw new BadArgumentException("No include directory specified after -I argument"); + } + } else if (arg.equals("-language")) { if (count < args.length) @@ -216,6 +326,10 @@ else if (arg.equals("-package")) throw new BadArgumentException("No package after -package argument"); } } + else if (arg.equals("-ppDisable")) + { + m_ppDisable = true; + } else if (arg.equals("-ppPath")) { if (count < args.length) @@ -227,36 +341,14 @@ else if (arg.equals("-ppPath")) throw new BadArgumentException("No URL specified after -ppPath argument"); } } - else if (arg.equals("-extrastg")) - { - if (count + 1 < args.length) - { - m_customStgOutput.put(args[count++], args[count++]); - } - else - { - throw new BadArgumentException("Missing arguments for -extrastg"); - } - } - else if (arg.equals("-ppDisable")) + else if (arg.equals("-python")) { - m_ppDisable = true; + m_python = true; } else if (arg.equals("-replace")) { m_replace = true; } - else if (arg.equals("-d")) - { - if (count < args.length) - { - m_outputDir = Utils.addFileSeparator(args[count++]); - } - else - { - throw new BadArgumentException("No URL specified after -d argument"); - } - } else if (arg.equals("-t")) { if (count < args.length) @@ -268,112 +360,30 @@ else if (arg.equals("-t")) throw new BadArgumentException("No temporary directory specified after -t argument"); } } - else if (arg.equals("-version")) - { - showVersion(); - System.exit(0); - } - else if (arg.equals("-help")) + else if (arg.equals("-test")) { - printHelp(); - System.exit(0); + m_test = true; } - else if (arg.equals("-fusion")) + else if (arg.equals("-typeobject")) { - fusion_ = true; + m_type_object_files = true; } else if (arg.equals("-typeros2")) { m_type_ros2 = true; } - else if (arg.equals("-typeobject")) - { - m_type_object_files = true; - } else if (arg.equals("-typesc")) { m_typesc = true; } - else if (arg.equals("-python")) - { - m_python = true; - } - else if (arg.equals("-test")) - { - m_test = true; - } - else if (arg.equals("-flat-output-dir")) - { - m_flat_output_dir = true; - } - else if (arg.equals("-I")) - { - if (count < args.length) - { - m_includePaths.add("-I".concat(args[count++])); - } - else - { - throw new BadArgumentException("No include directory specified after -I argument"); - } - } - else if (arg.equals("-cs")) - { - m_case_sensitive = true; - } - else if (arg.equals("-de") || arg.equals("-default_extensibility")) + else if (arg.equals("-version")) { - if (count < args.length) - { - String extensibility = args[count++]; - if (extensibility.equals(Annotation.final_str)) - { - TypeCode.default_extensibility = TypeCode.ExtensibilityKind.FINAL; - } - else if (extensibility.equals(Annotation.appendable_str)) - { - TypeCode.default_extensibility = TypeCode.ExtensibilityKind.APPENDABLE; - } - else if (extensibility.equals(Annotation.mutable_str)) - { - TypeCode.default_extensibility = TypeCode.ExtensibilityKind.MUTABLE; - } - else - { - throw new BadArgumentException("Extensibility value " + extensibility + " is not valid"); - } - } - else - { - throw new BadArgumentException("No extensibility value after -default_extensibility argument"); - } + showVersion(); + System.exit(0); } - else if (arg.equals("-cdr")) + else if (arg.equals("-fusion")) { - if (count < args.length) - { - String cdr_version_str = args[count++]; - if (cdr_version_str.equals(CdrVersion.v1_str)) - { - cdr_version_ = CdrVersion.Select.V1; - } - else if (cdr_version_str.equals(CdrVersion.v2_str)) - { - cdr_version_ = CdrVersion.Select.V2; - } - else if (cdr_version_str.equals(CdrVersion.both_str)) - { - cdr_version_ = CdrVersion.Select.BOTH; - } - else - { - throw new BadArgumentException("CDR version value " + cdr_version_str + " is not valid"); - } - } - else - { - throw new BadArgumentException("No CDR version value after -cdr argument"); - } + fusion_ = true; } else // TODO: More options: -rpm, -debug { @@ -554,8 +564,19 @@ public static void printHelp() System.out.println(m_appName + " usage:"); System.out.println("\t" + m_appName + " [options] [ ...]"); System.out.println("\twhere the options are:"); - System.out.println("\t\t-help: shows this help"); - System.out.println("\t\t-version: shows the current version of eProsima Fast DDS gen."); + System.out.println("\t\t-cdr : sets the CDR version used to generate types source code."); + System.out.println("\t\t Values:"); + System.out.println("\t\t\t* " + CdrVersion.v1_str); + System.out.println("\t\t\t* " + CdrVersion.v2_str + " (default)"); + System.out.println("\t\t\t* " + CdrVersion.both_str); + System.out.println("\t\t-cs: IDL grammar apply case sensitive matching."); + System.out.println("\t\t-d : sets an output directory for generated files."); + System.out.print("\t\t-default_extensibility | -de : sets the default extensibility for types without"); + System.out.println(" the @extensibility annotation."); + System.out.println("\t\t Values:"); + System.out.println("\t\t\t* " + Annotation.final_str); + System.out.println("\t\t\t* " + Annotation.appendable_str + " (default)"); + System.out.println("\t\t\t* " + Annotation.mutable_str); System.out.println( "\t\t-example : Generates a solution for a specific platform (example: x64Win64VS2019)"); System.out.println("\t\t\tSupported platforms:"); @@ -563,37 +584,32 @@ public static void printHelp() { System.out.println("\t\t\t * " + m_platforms.get(count)); } - //System.out.println("\t\t-language : Programming language (default: C++)."); - System.out.println("\t\t-replace: replaces existing generated files."); - System.out.println("\t\t-ppDisable: disables the preprocessor."); - System.out.println("\t\t-ppPath: specifies the preprocessor path."); System.out.println("\t\t-extrastg