From e1f5ad7ecb6ed92e8ae523e6f8e365a03931acb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Gonz=C3=A1lez=20Moreno?= Date: Tue, 10 Sep 2024 11:18:08 +0200 Subject: [PATCH 1/2] Refs #21621. Fix warning on Ubuntu 24.04 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ricardo González Moreno --- .../fastcdr/idl/templates/TypesHeader.stg | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) 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 d3b83b03..5e12f21a 100644 --- a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesHeader.stg +++ b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesHeader.stg @@ -296,9 +296,23 @@ public: eProsima_user_DllExport $union.name$() { $if(union.defaultAnnotatedMember)$ - $union.defaultAnnotatedMember.name$_(); + selected_member_ = $union.defaultAnnotatedMember.id$; + $if(union.defaultAnnotatedMember.typecode.primitive)$ + member_destructor_ = nullptr; + m_$union.defaultAnnotatedMember.name$ = $member_default_init(union.defaultAnnotatedMember)$; + $else$ + member_destructor_ = [&]() {$union_member_destroy_call(union.defaultAnnotatedMember)$\}; + new(&m_$union.defaultAnnotatedMember.name$) $member_type_declaration(union.defaultAnnotatedMember)$(); + $endif$; $elseif(union.defaultMember)$ - $union.defaultMember.name$_(); + selected_member_ = $union.defaultMember.id$; + $if(union.defaultMember.typecode.primitive)$ + member_destructor_ = nullptr; + m_$union.defaultMember.name$ = $member_default_init(union.defaultMember)$; + $else$ + member_destructor_ = [&]() {$union_member_destroy_call(union.defaultMember)$\}; + new(&m_$union.defaultMember.name$) $member_type_declaration(union.defaultMember)$(); + $endif$; $endif$ } From 6b23e7bbf966529e89c402e96d6e1f2ffe10e7ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Gonz=C3=A1lez=20Moreno?= Date: Tue, 10 Sep 2024 11:26:32 +0200 Subject: [PATCH 2/2] Refs #21621. Improve code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ricardo González Moreno --- .../fastcdr/idl/templates/TypesHeader.stg | 38 +++++++------------ 1 file changed, 14 insertions(+), 24 deletions(-) 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 5e12f21a..dca90bdd 100644 --- a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesHeader.stg +++ b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesHeader.stg @@ -296,23 +296,9 @@ public: eProsima_user_DllExport $union.name$() { $if(union.defaultAnnotatedMember)$ - selected_member_ = $union.defaultAnnotatedMember.id$; - $if(union.defaultAnnotatedMember.typecode.primitive)$ - member_destructor_ = nullptr; - m_$union.defaultAnnotatedMember.name$ = $member_default_init(union.defaultAnnotatedMember)$; - $else$ - member_destructor_ = [&]() {$union_member_destroy_call(union.defaultAnnotatedMember)$\}; - new(&m_$union.defaultAnnotatedMember.name$) $member_type_declaration(union.defaultAnnotatedMember)$(); - $endif$; + $union_member_initialization(union.defaultAnnotatedMember)$ $elseif(union.defaultMember)$ - selected_member_ = $union.defaultMember.id$; - $if(union.defaultMember.typecode.primitive)$ - member_destructor_ = nullptr; - m_$union.defaultMember.name$ = $member_default_init(union.defaultMember)$; - $else$ - member_destructor_ = [&]() {$union_member_destroy_call(union.defaultMember)$\}; - new(&m_$union.defaultMember.name$) $member_type_declaration(union.defaultMember)$(); - $endif$; + $union_member_initialization(union.defaultMember)$ $endif$ } @@ -512,14 +498,7 @@ private: member_destructor_(); \} - selected_member_ = $member.id$; - $if(member.typecode.primitive)$ - member_destructor_ = nullptr; - m_$member.name$ = $member_default_init(member)$; - $else$ - member_destructor_ = [&]() {$union_member_destroy_call(member)$\}; - new(&m_$member.name$) $member_type_declaration(member)$(); - $endif$; + $union_member_initialization(member)$ \} return m_$member.name$; @@ -842,6 +821,17 @@ f $endif$ %> +union_member_initialization(member) ::= << +selected_member_ = $member.id$; +$if(member.typecode.primitive)$ +member_destructor_ = nullptr; +m_$member.name$ = $member_default_init(member)$; +$else$ +member_destructor_ = [&]() {$union_member_destroy_call(member)$\}; +new(&m_$member.name$) $member_type_declaration(member)$(); +$endif$ +>> + //{ Fast DDS-Gen extensions module_conversion(ctx, parent, modules, definition_list) ::= << $modules : { module |