From bfe0162beb0b81af4f7c01424ac1eea8fbb6e56c Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Tue, 8 Oct 2024 16:24:47 +0200 Subject: [PATCH 1/5] Update to IDL4 to C++ beta 2 proposal * ridlbe/c++11/templates/cli/hdr/bitmask.erb: * ridlbe/c++11/templates/cli/src/bitmask_cdr.erb: * tests/idl4/bitmask/client.cpp: --- ridlbe/c++11/templates/cli/hdr/bitmask.erb | 28 ++++++++++++------- .../c++11/templates/cli/src/bitmask_cdr.erb | 6 +--- tests/idl4/bitmask/client.cpp | 16 +++++------ 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/ridlbe/c++11/templates/cli/hdr/bitmask.erb b/ridlbe/c++11/templates/cli/hdr/bitmask.erb index d643f474..26f27aae 100644 --- a/ridlbe/c++11/templates/cli/hdr/bitmask.erb +++ b/ridlbe/c++11/templates/cli/hdr/bitmask.erb @@ -1,15 +1,23 @@ // generated from <%= ridl_template_path %> /// @copydoc <%= doc_scoped_name %> -enum class <%= cxxname %> : <%= bitbound.cxx_type %> +struct <%= cxxname %> { - <%= bitvalues.collect {|e| "/// @copydoc #{doc_scoped_name}::#{e.name}\n #{e.cxxname} = 0x01 << #{e.position}" }.join(",\n ") %> -};// <%= cxxname %> + enum _flags : <%= bitbound.cxx_type %> + { + <%= bitvalues.collect {|e| "/// @copydoc #{doc_scoped_name}::#{e.name}\n #{e.cxxname} = 0x01 << #{e.position}" }.join(",\n ") %> + }; + <%= cxxname %> () = default; + <%= cxxname %> (<%= bitbound.cxx_in_type %> _v) : _value(_v) {} + operator <%= bitbound.cxx_type %>() const { return _value; } +%# <%= cxx_return_type %> operator~ () { return ~_value; } +%# <%= cxx_return_type %> operator| (<%= bitbound.cxx_in_type %> _taox11_y) { return _value | _taox11_y; } +%# <%= cxx_return_type %> operator^ (<%= bitbound.cxx_in_type %> _taox11_y) { return _value ^ _taox11_y; } +%# <%= cxx_return_type %> operator& (<%= bitbound.cxx_in_type %> _taox11_y) { return _value & _taox11_y; } + <%= cxx_return_type %>& operator |= (<%= bitbound.cxx_in_type %> _taox11_rhs) { _value |= _taox11_rhs; return *this; } + <%= cxx_return_type %>& operator &= (<%= bitbound.cxx_in_type %> _taox11_rhs) { _value &= _taox11_rhs; return *this; } + <%= cxx_return_type %>& operator ^= (<%= bitbound.cxx_in_type %> _taox11_rhs) { _value ^= _taox11_rhs; return *this; } +private: + <%= bitbound.cxx_member_type %> _value <%= bitbound.value_initializer %>; +}; // <%= cxxname %> -inline <%= cxx_return_type %> operator~ (<%= cxx_in_type %> _taox11_t) { return static_cast<<%= cxxname %>>(~static_cast<<%= bitbound.cxx_type %>>(_taox11_t)); } -inline <%= cxx_return_type %> operator| (<%= cxx_in_type %> _taox11_t, <%= cxx_in_type %> _taox11_y) { return static_cast<<%= cxxname %>>(static_cast<<%= bitbound.cxx_type %>>(_taox11_t) | static_cast<<%= bitbound.cxx_type %>>(_taox11_y)); } -inline <%= cxx_return_type %> operator^ (<%= cxx_in_type %> _taox11_t, <%= cxx_in_type %> _taox11_y) { return static_cast<<%= cxxname %>>(static_cast<<%= bitbound.cxx_type %>>(_taox11_t) ^ static_cast<<%= bitbound.cxx_type %>>(_taox11_y)); } -inline <%= cxx_return_type %> operator& (<%= cxx_in_type %> _taox11_t, <%= cxx_in_type %> _taox11_y) { return static_cast<<%= cxxname %>>(static_cast<<%= bitbound.cxx_type %>>(_taox11_t) & static_cast<<%= bitbound.cxx_type %>>(_taox11_y)); } -inline <%= cxx_return_type %> operator |= (<%= cxx_inout_type %> _taox11_lhs, <%= cxx_in_type %> _taox11_rhs) { _taox11_lhs = _taox11_lhs | _taox11_rhs; return _taox11_lhs; } -inline <%= cxx_return_type %> operator &= (<%= cxx_inout_type %> _taox11_lhs, <%= cxx_in_type %> _taox11_rhs) { _taox11_lhs = _taox11_lhs & _taox11_rhs; return _taox11_lhs; } -inline <%= cxx_return_type %> operator ^= (<%= cxx_inout_type %> _taox11_lhs, <%= cxx_in_type %> _taox11_rhs) { _taox11_lhs = _taox11_lhs ^ _taox11_rhs; return _taox11_lhs; } diff --git a/ridlbe/c++11/templates/cli/src/bitmask_cdr.erb b/ridlbe/c++11/templates/cli/src/bitmask_cdr.erb index 8785e273..ba2718c5 100644 --- a/ridlbe/c++11/templates/cli/src/bitmask_cdr.erb +++ b/ridlbe/c++11/templates/cli/src/bitmask_cdr.erb @@ -2,16 +2,12 @@ // generated from <%= ridl_template_path %> TAO_CORBA::Boolean operator<< (TAO_OutputCDR &strm, const <%= scoped_cxxname %> &_tao_bitmask) { -#if defined (ACE_HAS_CPP23) - return strm << std::to_underlying (_tao_bitmask); -#else return strm << static_cast<<%= bitbound.cxx_type %>> (_tao_bitmask); -#endif } TAO_CORBA::Boolean operator>> (TAO_InputCDR &strm, <%= scoped_cxxname %> &_tao_bitmask) { - std::underlying_type_t<<%= scoped_cxxname %>> _tao_temp <%= bitbound.value_initializer %>; + std::underlying_type_t<<%= scoped_cxxname %>::_flags> _tao_temp <%= bitbound.value_initializer %>; bool const _tao_success = strm >> <%= bitbound.cdr_to_fmt % "_tao_temp" %>; if (_tao_success) diff --git a/tests/idl4/bitmask/client.cpp b/tests/idl4/bitmask/client.cpp index b13b3390..80bb9b1d 100644 --- a/tests/idl4/bitmask/client.cpp +++ b/tests/idl4/bitmask/client.cpp @@ -38,35 +38,35 @@ int main (int argc, char* argv[]) TAOX11_TEST_ERROR << "Flag my_bitmask1 NOT set: " << static_cast(my_bitmask1) << std::endl; } - if (static_cast>(MyBitMask::flag1) != (0x01 << 1)) + if (static_cast>(MyBitMask::flag1) != (0x01 << 1)) { TAOX11_TEST_ERROR << "MyBitMask::flag1 has wrong value" << std::endl; } - if (static_cast>(MyBitMaskBound8_position::flag64_3) != (0x01 << 3)) + if (static_cast>(MyBitMaskBound8_position::flag64_3) != (0x01 << 3)) { TAOX11_TEST_ERROR << "MyBitMaskBound8_position::flag64_3 has wrong value, position annotation not correctly handled" << std::endl; } - if (static_cast>(MyBitMaskBound8_position::flag64_4) != (0x01 << 4)) + if (static_cast>(MyBitMaskBound8_position::flag64_4) != (0x01 << 4)) { TAOX11_TEST_ERROR << "MyBitMaskBound8_position::flag64_4 has wrong value, position annotation not correctly handled" << std::endl; } - if (static_cast>(MyBitMaskBound8_position::flag64_7) != (0x01 << 7)) + if (static_cast>(MyBitMaskBound8_position::flag64_7) != (0x01 << 7)) { TAOX11_TEST_ERROR << "MyBitMaskBound8_position::flag64_7 has wrong value, position annotation not correctly handled" << std::endl; } - if (!std::is_same, uint8_t>::value) + if (!std::is_same, uint8_t>::value) { TAOX11_TEST_ERROR << "Type of MyBitMaskBound8 is not uint8_t" << std::endl; } - if (!std::is_same, uint16_t>::value) + if (!std::is_same, uint16_t>::value) { TAOX11_TEST_ERROR << "Type of MyBitMaskBound16 is not uint16_t" << std::endl; } - if (!std::is_same, uint32_t>::value) + if (!std::is_same, uint32_t>::value) { TAOX11_TEST_ERROR << "Type of MyBitMaskBound32 is not uint32_t" << std::endl; } - if (!std::is_same, uint64_t>::value) + if (!std::is_same, uint64_t>::value) { TAOX11_TEST_ERROR << "Type of MyBitMaskBound64 is not uint64_t" << std::endl; } From fc83d1b9777fd7e327704ddc052f615fb6cf6235 Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Tue, 8 Oct 2024 16:43:31 +0200 Subject: [PATCH 2/5] Layout * ridlbe/c++11/templates/cli/hdr/bitmask.erb: --- ridlbe/c++11/templates/cli/hdr/bitmask.erb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ridlbe/c++11/templates/cli/hdr/bitmask.erb b/ridlbe/c++11/templates/cli/hdr/bitmask.erb index 26f27aae..9085930e 100644 --- a/ridlbe/c++11/templates/cli/hdr/bitmask.erb +++ b/ridlbe/c++11/templates/cli/hdr/bitmask.erb @@ -5,15 +5,15 @@ struct <%= cxxname %> { enum _flags : <%= bitbound.cxx_type %> { - <%= bitvalues.collect {|e| "/// @copydoc #{doc_scoped_name}::#{e.name}\n #{e.cxxname} = 0x01 << #{e.position}" }.join(",\n ") %> + <%= bitvalues.collect {|e| "/// @copydoc #{doc_scoped_name}::#{e.name}\n #{e.cxxname} = 0x01 << #{e.position}" }.join(",\n ") %> }; <%= cxxname %> () = default; <%= cxxname %> (<%= bitbound.cxx_in_type %> _v) : _value(_v) {} operator <%= bitbound.cxx_type %>() const { return _value; } %# <%= cxx_return_type %> operator~ () { return ~_value; } -%# <%= cxx_return_type %> operator| (<%= bitbound.cxx_in_type %> _taox11_y) { return _value | _taox11_y; } -%# <%= cxx_return_type %> operator^ (<%= bitbound.cxx_in_type %> _taox11_y) { return _value ^ _taox11_y; } -%# <%= cxx_return_type %> operator& (<%= bitbound.cxx_in_type %> _taox11_y) { return _value & _taox11_y; } +%# <%= cxx_return_type %> operator| () { return _value | _taox11_y; } +%# <%= cxx_return_type %> operator^ () { return _value ^ _taox11_y; } +%# <%= cxx_return_type %> operator& () { return _value & _taox11_y; } <%= cxx_return_type %>& operator |= (<%= bitbound.cxx_in_type %> _taox11_rhs) { _value |= _taox11_rhs; return *this; } <%= cxx_return_type %>& operator &= (<%= bitbound.cxx_in_type %> _taox11_rhs) { _value &= _taox11_rhs; return *this; } <%= cxx_return_type %>& operator ^= (<%= bitbound.cxx_in_type %> _taox11_rhs) { _value ^= _taox11_rhs; return *this; } From 63cba03523dadb6f482112055ae4f6d3b10e5141 Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Tue, 8 Oct 2024 16:57:29 +0200 Subject: [PATCH 3/5] Use a class * ridlbe/c++11/templates/cli/hdr/bitmask.erb: --- ridlbe/c++11/templates/cli/hdr/bitmask.erb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ridlbe/c++11/templates/cli/hdr/bitmask.erb b/ridlbe/c++11/templates/cli/hdr/bitmask.erb index 9085930e..f4afc726 100644 --- a/ridlbe/c++11/templates/cli/hdr/bitmask.erb +++ b/ridlbe/c++11/templates/cli/hdr/bitmask.erb @@ -1,8 +1,9 @@ // generated from <%= ridl_template_path %> /// @copydoc <%= doc_scoped_name %> -struct <%= cxxname %> +class <%= cxxname %> { +public: enum _flags : <%= bitbound.cxx_type %> { <%= bitvalues.collect {|e| "/// @copydoc #{doc_scoped_name}::#{e.name}\n #{e.cxxname} = 0x01 << #{e.position}" }.join(",\n ") %> From 8f2e7a039d383ed2fa6e19288626f0707b65963b Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Fri, 18 Oct 2024 14:08:13 +0200 Subject: [PATCH 4/5] Test extensions, reduce code generated * ridlbe/c++11/templates/cli/hdr/bitmask.erb: * ridlbe/c++11/templates/cli/hdr/bitmask_idl_traits.erb: * ridlbe/c++11/templates/srv/src/enum_sarg_traits.erb: * ridlbe/c++11/writers/servantsource.rb: * tests/idl4/bitmask/client.cpp: * tests/idl4/bitmask/foo.cpp: --- ridlbe/c++11/templates/cli/hdr/bitmask.erb | 4 ++ .../templates/cli/hdr/bitmask_idl_traits.erb | 2 +- .../templates/srv/src/enum_sarg_traits.erb | 2 +- ridlbe/c++11/writers/servantsource.rb | 2 +- tests/idl4/bitmask/client.cpp | 54 +++++++++++++++---- tests/idl4/bitmask/foo.cpp | 19 ++++++- 6 files changed, 69 insertions(+), 14 deletions(-) diff --git a/ridlbe/c++11/templates/cli/hdr/bitmask.erb b/ridlbe/c++11/templates/cli/hdr/bitmask.erb index f4afc726..c5dc6eed 100644 --- a/ridlbe/c++11/templates/cli/hdr/bitmask.erb +++ b/ridlbe/c++11/templates/cli/hdr/bitmask.erb @@ -18,6 +18,10 @@ public: <%= cxx_return_type %>& operator |= (<%= bitbound.cxx_in_type %> _taox11_rhs) { _value |= _taox11_rhs; return *this; } <%= cxx_return_type %>& operator &= (<%= bitbound.cxx_in_type %> _taox11_rhs) { _value &= _taox11_rhs; return *this; } <%= cxx_return_type %>& operator ^= (<%= bitbound.cxx_in_type %> _taox11_rhs) { _value ^= _taox11_rhs; return *this; } + <%= cxx_out_type %> operator= (<%= cxx_in_type %>) = default; + <%= cxx_out_type %> operator= (<%= cxx_move_type %>) = default; + <%= cxxname %> (<%= cxx_in_type %>) = default; + <%= cxxname %> (<%= cxx_move_type %>) = default; private: <%= bitbound.cxx_member_type %> _value <%= bitbound.value_initializer %>; }; // <%= cxxname %> diff --git a/ridlbe/c++11/templates/cli/hdr/bitmask_idl_traits.erb b/ridlbe/c++11/templates/cli/hdr/bitmask_idl_traits.erb index cedd7a25..bb32039f 100644 --- a/ridlbe/c++11/templates/cli/hdr/bitmask_idl_traits.erb +++ b/ridlbe/c++11/templates/cli/hdr/bitmask_idl_traits.erb @@ -27,7 +27,7 @@ struct formatter<<%= scoped_cxxtype %>, OStrm_> { bool first_ {true}; %bitvalues.each do |e| - if (static_cast(val_ & <%= scoped_cxxtype %>::<%=e.cxxname %>)) + if (val_ & <%= scoped_cxxtype %>::<%=e.cxxname %>) { if (!first_) os_ << "|"; os_ << "<%= formatted_cxxname %>::<%=e.cxxname %>"; diff --git a/ridlbe/c++11/templates/srv/src/enum_sarg_traits.erb b/ridlbe/c++11/templates/srv/src/enum_sarg_traits.erb index 12d53634..58667a29 100644 --- a/ridlbe/c++11/templates/srv/src/enum_sarg_traits.erb +++ b/ridlbe/c++11/templates/srv/src/enum_sarg_traits.erb @@ -6,7 +6,7 @@ /// Argument traits specializations for <%= name %> template<> class SArg_Traits<<%= scoped_cxxtype %>> - : public Basic_SArg_Traits_T<<%= scoped_cxxtype %>,<% if generate_any_support? %>Any_Insert_Policy_Stream<% else %>Any_Insert_Policy_Noop<% end %>> + : public Basic_SArg_Traits_T<<%= scoped_cxxtype %>, <% if generate_any_support? %>Any_Insert_Policy_Stream<% else %>Any_Insert_Policy_Noop<% end %>> { }; # endif // !_<%= _traits_incl_guard_ %>_SARG_TRAITS_ diff --git a/ridlbe/c++11/writers/servantsource.rb b/ridlbe/c++11/writers/servantsource.rb index 16e117dd..55030963 100644 --- a/ridlbe/c++11/writers/servantsource.rb +++ b/ridlbe/c++11/writers/servantsource.rb @@ -335,7 +335,7 @@ def check_idl_type(idl_type) when IDL::Type::BitSet visitor(BitsetVisitor).visit_sarg_traits(res_idl_type.node)# unless is_tracked?(res_idl_type.node) when IDL::Type::BitMask - visitor(BitmaskVisitor).visit_sarg_traits(res_idl_type.node)# unless is_tracked?(res_idl_type.node) + visitor(BitmaskVisitor).visit_sarg_traits(res_idl_type.node) unless is_tracked?(res_idl_type.node) when IDL::Type::Union visitor(UnionVisitor).visit_sarg_traits(res_idl_type.node) unless is_tracked?(res_idl_type.node) when IDL::Type::Sequence diff --git a/tests/idl4/bitmask/client.cpp b/tests/idl4/bitmask/client.cpp index 80bb9b1d..55929214 100644 --- a/tests/idl4/bitmask/client.cpp +++ b/tests/idl4/bitmask/client.cpp @@ -13,65 +13,71 @@ int main (int argc, char* argv[]) { - // Just compilation test + int error_count = 0; MyBitMask my_bitmask1 = MyBitMask::flag0; - // static_cast is necessary when we map to an `enum class`, when we map to an `enum` the static_cast - // is not necessary but that puts the enum members into the containing namespace. The IDL4 specification - // does put IDL enums in the containing namespace, but doesn't do that for bitmask members - if (static_cast(my_bitmask1 & MyBitMask::flag0)) + if (my_bitmask1 & MyBitMask::flag0) { TAOX11_TEST_INFO << "Flag my_bitmask1 correctly set: " << my_bitmask1 << std::endl; } else { TAOX11_TEST_ERROR << "Flag my_bitmask1 NOT set" << my_bitmask1 << std::endl; + ++error_count; } my_bitmask1 = my_bitmask1 | MyBitMask::flag1; - if (static_cast(my_bitmask1 & MyBitMask::flag0) && static_cast(my_bitmask1 & MyBitMask::flag1)) + if ((my_bitmask1 & MyBitMask::flag0) && (my_bitmask1 & MyBitMask::flag1)) { TAOX11_TEST_INFO << "Flag my_bitmask1 correctly set: " << my_bitmask1 << std::endl; } else { TAOX11_TEST_ERROR << "Flag my_bitmask1 NOT set: " << static_cast(my_bitmask1) << std::endl; + ++error_count; } if (static_cast>(MyBitMask::flag1) != (0x01 << 1)) { TAOX11_TEST_ERROR << "MyBitMask::flag1 has wrong value" << std::endl; + ++error_count; } if (static_cast>(MyBitMaskBound8_position::flag64_3) != (0x01 << 3)) { TAOX11_TEST_ERROR << "MyBitMaskBound8_position::flag64_3 has wrong value, position annotation not correctly handled" << std::endl; + ++error_count; } if (static_cast>(MyBitMaskBound8_position::flag64_4) != (0x01 << 4)) { TAOX11_TEST_ERROR << "MyBitMaskBound8_position::flag64_4 has wrong value, position annotation not correctly handled" << std::endl; + ++error_count; } if (static_cast>(MyBitMaskBound8_position::flag64_7) != (0x01 << 7)) { TAOX11_TEST_ERROR << "MyBitMaskBound8_position::flag64_7 has wrong value, position annotation not correctly handled" << std::endl; + ++error_count; } if (!std::is_same, uint8_t>::value) { TAOX11_TEST_ERROR << "Type of MyBitMaskBound8 is not uint8_t" << std::endl; + ++error_count; } if (!std::is_same, uint16_t>::value) { TAOX11_TEST_ERROR << "Type of MyBitMaskBound16 is not uint16_t" << std::endl; + ++error_count; } if (!std::is_same, uint32_t>::value) { TAOX11_TEST_ERROR << "Type of MyBitMaskBound32 is not uint32_t" << std::endl; + ++error_count; } if (!std::is_same, uint64_t>::value) { TAOX11_TEST_ERROR << "Type of MyBitMaskBound64 is not uint64_t" << std::endl; + ++error_count; } - int error_count = 0; try { IDL::traits::ref_type _orb = CORBA::ORB_init (argc, argv); @@ -106,7 +112,22 @@ int main (int argc, char* argv[]) MyBitMask sout {}; TAOX11_TEST_DEBUG << "Sending MyBitMask sin: " << sin << " sinout: " << sinout << std::endl; - MyBitMask sret = foo->test_mybitmask (sin, sinout, sout); + MyBitMask const sret = foo->test_mybitmask (sin, sinout, sout); + if (sret != MyBitMask::flag2) + { + TAOX11_TEST_ERROR << "ERROR: sret<" << sret << "> != sin<" << sin << ">" << std::endl; + ++error_count; + } + if (sout != sin) + { + TAOX11_TEST_ERROR << "ERROR: sout<" << sout << "> != sin<" << sin << ">" << std::endl; + ++error_count; + } + if (sinout != sin) + { + TAOX11_TEST_ERROR << "ERROR: sinout<" << sinout << "> != sin<" << sin << ">" << std::endl; + ++error_count; + } TAOX11_TEST_DEBUG << "Received MyBitMask sret: " << sret << " sinout: " << sinout << " sout: " << sout << std::endl; MyBitMaskBound8 sin5 {MyBitMaskBound8::flag8_2}; @@ -114,8 +135,23 @@ int main (int argc, char* argv[]) MyBitMaskBound8 sout5 {}; TAOX11_TEST_DEBUG << "Sending MyBitMaskBound8 sin: " << sin5 << " sinout: " << sinout5 << std::endl; - MyBitMaskBound8 sret5 = foo->test_mybitmaskbound8 (sin5, sinout5, sout5); + MyBitMaskBound8 const sret5 = foo->test_mybitmaskbound8 (sin5, sinout5, sout5); TAOX11_TEST_DEBUG << "Received MyBitMaskBound8 sret: " << sret5 << " sinout: " << sinout5 << " sout: " << sout5 << std::endl; + if (sret5 != sin5) + { + TAOX11_TEST_ERROR << "ERROR: sret5<" << sret5 << "> != sin5<" << sin5 << ">" << std::endl; + ++error_count; + } + if (sout5 != sin5) + { + TAOX11_TEST_ERROR << "ERROR: sout<" << sout << "> != sin5<" << sin5 << ">" << std::endl; + ++error_count; + } + if (sinout5 != sin5) + { + TAOX11_TEST_ERROR << "ERROR: sinout5<" << sinout5 << "> != sin5<" << sin5 << ">" << std::endl; + ++error_count; + } TAOX11_TEST_DEBUG << "shutting down..." << std::endl; foo->shutdown (); diff --git a/tests/idl4/bitmask/foo.cpp b/tests/idl4/bitmask/foo.cpp index 6e2546c8..f1320a1d 100644 --- a/tests/idl4/bitmask/foo.cpp +++ b/tests/idl4/bitmask/foo.cpp @@ -20,10 +20,21 @@ Foo::test_mybitmask (const MyBitMask & sin, MyBitMask & sinout, MyBitMask & sout) { + if (!(sin & MyBitMask::flag0)) + { + TAOX11_TEST_ERROR << "ERROR: test_mybitmask: Received incorrect sin<" << sin << ">" << std::endl; + } + else + { + TAOX11_TEST_DEBUG << "test_mybitmask: Received sin<" << sin << ">" << std::endl; + } sout = sin; + if (!(sout & MyBitMask::flag0)) + { + TAOX11_TEST_ERROR << "ERROR: test_mybitmask: Setting sout failed <" << sout << ">" << std::endl; + } sinout = sin; - MyBitMask sret = sin; - return sret; + return MyBitMask::flag2; } MyBitMaskBound8 @@ -31,6 +42,10 @@ Foo::test_mybitmaskbound8 (const MyBitMaskBound8 & sin, MyBitMaskBound8 & sinout, MyBitMaskBound8 & sout) { + if (!(sin & MyBitMaskBound8::flag8_2)) + { + TAOX11_TEST_ERROR << "ERROR: MyBitMaskBound8: Received incorrect sin<" << sin << ">" << std::endl; + } sout = sin; sinout = sin; MyBitMaskBound8 sret = sin; From 6b20defa6a666c46f5b7b9cc835e3a87714c9084 Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Fri, 18 Oct 2024 14:26:44 +0200 Subject: [PATCH 5/5] Fix CDR insertion * ridlbe/c++11/templates/cli/src/bitmask_cdr.erb: * tests/idl4/bitmask/client.cpp: * tests/idl4/bitmask/foo.cpp: --- ridlbe/c++11/templates/cli/src/bitmask_cdr.erb | 3 ++- tests/idl4/bitmask/client.cpp | 2 +- tests/idl4/bitmask/foo.cpp | 8 ++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ridlbe/c++11/templates/cli/src/bitmask_cdr.erb b/ridlbe/c++11/templates/cli/src/bitmask_cdr.erb index ba2718c5..ce62a78e 100644 --- a/ridlbe/c++11/templates/cli/src/bitmask_cdr.erb +++ b/ridlbe/c++11/templates/cli/src/bitmask_cdr.erb @@ -2,7 +2,8 @@ // generated from <%= ridl_template_path %> TAO_CORBA::Boolean operator<< (TAO_OutputCDR &strm, const <%= scoped_cxxname %> &_tao_bitmask) { - return strm << static_cast<<%= bitbound.cxx_type %>> (_tao_bitmask); + std::underlying_type_t<<%= scoped_cxxname %>::_flags> const _tao_temp { _tao_bitmask }; + return strm << <%= bitbound.cdr_from_fmt % "_tao_temp" %>; } TAO_CORBA::Boolean operator>> (TAO_InputCDR &strm, <%= scoped_cxxname %> &_tao_bitmask) diff --git a/tests/idl4/bitmask/client.cpp b/tests/idl4/bitmask/client.cpp index 55929214..68082cbc 100644 --- a/tests/idl4/bitmask/client.cpp +++ b/tests/idl4/bitmask/client.cpp @@ -108,7 +108,7 @@ int main (int argc, char* argv[]) TAOX11_TEST_DEBUG << "narrowed Foo interface" << std::endl; MyBitMask sin {MyBitMask::flag0}; - MyBitMask sinout {}; + MyBitMask sinout {MyBitMask::flag1}; MyBitMask sout {}; TAOX11_TEST_DEBUG << "Sending MyBitMask sin: " << sin << " sinout: " << sinout << std::endl; diff --git a/tests/idl4/bitmask/foo.cpp b/tests/idl4/bitmask/foo.cpp index f1320a1d..22f46f96 100644 --- a/tests/idl4/bitmask/foo.cpp +++ b/tests/idl4/bitmask/foo.cpp @@ -28,6 +28,14 @@ Foo::test_mybitmask (const MyBitMask & sin, { TAOX11_TEST_DEBUG << "test_mybitmask: Received sin<" << sin << ">" << std::endl; } + if (!(sinout & MyBitMask::flag1)) + { + TAOX11_TEST_ERROR << "ERROR: test_mybitmask: Received incorrect sinout<" << sinout << ">" << std::endl; + } + else + { + TAOX11_TEST_DEBUG << "test_mybitmask: Received sinout<" << sinout << ">" << std::endl; + } sout = sin; if (!(sout & MyBitMask::flag0)) {