From 7ec8c8dd581ed12cae8fed8b2e2036ecefaca37e Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Mon, 27 May 2024 09:33:38 +0200 Subject: [PATCH 1/7] First manual code for optional CDR support --- ridlbe/c++11/templates/cli/src/union_cdr.erb | 2 +- tao/x11/map_cdr_t.h | 52 ++++ tests/idl4/optional/test.idl | 5 +- tests/idl4/optional/test.mpc | 2 +- tests/idl4/optional/testC.cpp | 70 +++++ tests/idl4/optional/testC.h | 294 +++++++++++++++++++ tests/idl4/optional/testCP.h | 116 ++++++++ 7 files changed, 538 insertions(+), 3 deletions(-) create mode 100644 tests/idl4/optional/testC.cpp create mode 100644 tests/idl4/optional/testC.h create mode 100644 tests/idl4/optional/testCP.h diff --git a/ridlbe/c++11/templates/cli/src/union_cdr.erb b/ridlbe/c++11/templates/cli/src/union_cdr.erb index fb2fe042..e6a90852 100644 --- a/ridlbe/c++11/templates/cli/src/union_cdr.erb +++ b/ridlbe/c++11/templates/cli/src/union_cdr.erb @@ -2,7 +2,7 @@ // generated from <%= ridl_template_path %> TAO_CORBA::Boolean operator<< (TAO_OutputCDR &strm, const <%= scoped_cxxname %> &_tao_union) { - if (!(strm <<<%= switchtype.cdr_from_fmt % "_tao_union._d ()" %>)) + if (!(strm << <%= switchtype.cdr_from_fmt % "_tao_union._d ()" %>)) { return false; } diff --git a/tao/x11/map_cdr_t.h b/tao/x11/map_cdr_t.h index b1188170..0f07c5d3 100644 --- a/tao/x11/map_cdr_t.h +++ b/tao/x11/map_cdr_t.h @@ -17,6 +17,58 @@ TAO_BEGIN_VERSIONED_NAMESPACE_DECL + /// Generic sequence CDR streaming helper template + template + struct taox11_optional_cdr + { + /// Unbounded insert + template + static bool insert (_Stream& _strm, const _Tp& _optional) + { + if (!(_strm << ACE_OutputCDR::from_boolean (_optional.has_value ()))) + { + return false; + } + + bool result { true }; + if (_optional.has_value ()) + { + result = _strm << _optional.value (); + } + return result; + } + + /// Unbounded extract + template + static bool extract (_Stream& _strm, _Tp& _optional) + { + bool _has_value{}; + if (!(_strm >> ACE_InputCDR::to_boolean (_has_value))) + { + return false; + } + + if (_has_value) + { + // initialize associated default value + typename _Tp::value_type temp_val{}; + // extract + if (_strm >> temp_val) + { + // set union member and associated discriminant when there are multiple legal discriminant values + _optional= std::move (temp_val); + return true; + } + } + else + { + _optional.reset (); + } + return false; + } + }; + + /// Generic sequence CDR streaming helper template template struct taox11_map_cdr diff --git a/tests/idl4/optional/test.idl b/tests/idl4/optional/test.idl index 5afcbc71..45119a9e 100644 --- a/tests/idl4/optional/test.idl +++ b/tests/idl4/optional/test.idl @@ -5,10 +5,13 @@ * @copyright Copyright (c) Remedy IT Expertise BV */ +typedef map StringLongMap; + +typedef string<650> bds; + struct bar { short x; string y; @optional short z; }; - diff --git a/tests/idl4/optional/test.mpc b/tests/idl4/optional/test.mpc index 0607b3c3..66bd2e3b 100644 --- a/tests/idl4/optional/test.mpc +++ b/tests/idl4/optional/test.mpc @@ -3,7 +3,7 @@ project(*optional_gen_idl): ridl_ostream_defaults { IDL_Files { test.idl - idlflags += --idl-version=4 -Scdr + idlflags += --idl-version=4 } custom_only = 1 } diff --git a/tests/idl4/optional/testC.cpp b/tests/idl4/optional/testC.cpp new file mode 100644 index 00000000..4e11165c --- /dev/null +++ b/tests/idl4/optional/testC.cpp @@ -0,0 +1,70 @@ +/** + * **** Code generated by the RIDL Compiler **** + * RIDL has been developed by: + * Remedy IT Expertise BV + * The Netherlands + * https://www.remedy.nl + */ + +#define __TAOX11_INCLUDE_STUB_PROXY__ + +#if __has_include("tao/x11/base/tao_corba.h") +# include "tao/x11/base/tao_corba.h" +#endif +#include "tao/CDR.h" +#include "tao/x11/basic_arguments.h" +#include "tao/x11/cdr_long_double.h" +#include "tao/x11/base/tao_corba.h" + +#include "testC.h" +// generated from StubProxySourceCDRWriter#pre_visit +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +TAO_CORBA::Boolean operator<< (TAO_OutputCDR&strm, const IDL::optional&_val) +{ + return taox11_optional_cdr>::insert (strm, _val); +} + +TAO_CORBA::Boolean operator>> (TAO_InputCDR& strm, IDL::optional&_val) +{ + return taox11_optional_cdr>::extract (strm, _val); +} + + +// generated from c++11/templates/cli/src/string_cdr +#if defined(_ALIAS_bds_CDR_OPS_IMPL_) +bool _cdr_in_bds ( + TAO_OutputCDR &strm, + const IDL::traits>::value_type &_bstr) +{ + return (strm << ACE_OutputCDR::from_std_string (_bstr, 650)); +} + +bool _cdr_out_bds ( + TAO_InputCDR &strm, + IDL::traits>::value_type &_bstr) +{ + return (strm >> ACE_InputCDR::to_std_string (_bstr, 650)); +} +#endif // _ALIAS_bds_CDR_OPS_IMPL_ + +// generated from c++11/templates/cli/src/struct_cdr +TAO_CORBA::Boolean operator<< (TAO_OutputCDR &strm, const bar &_tao_aggregate) +{ + return + (strm << _tao_aggregate.x ()) && + (strm << _tao_aggregate.y ()) && + (strm << _tao_aggregate.z ()); +} + +TAO_CORBA::Boolean operator>> (TAO_InputCDR &strm, bar &_tao_aggregate) +{ + return + (strm >> _tao_aggregate.x ()) && + (strm >> _tao_aggregate.y ()) && + (strm >> _tao_aggregate.z ()); +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +// -*- END -*- diff --git a/tests/idl4/optional/testC.h b/tests/idl4/optional/testC.h new file mode 100644 index 00000000..ea0177a4 --- /dev/null +++ b/tests/idl4/optional/testC.h @@ -0,0 +1,294 @@ +/** + * **** Code generated by the RIDL Compiler **** + * RIDL has been developed by: + * Remedy IT Expertise BV + * The Netherlands + * https://www.remedy.nl + */ + +#ifndef __RIDL_TESTC_H_HJGBAJHC_INCLUDED__ +#define __RIDL_TESTC_H_HJGBAJHC_INCLUDED__ + +#pragma once + +#include /**/ "tao/x11/base/pre.h" +#include "tao/x11/base/stddef.h" +#include "tao/x11/base/basic_traits.h" +#include "tao/x11/corba.h" +#include "map" +#include "tao/x11/base/bounded_string_t.h" +#include "tao/x11/base/bounded_type_traits_t.h" +#include "tao/x11/optional_t.h" + +#include /**/ "tao/x11/base/versionx11.h" + +#if TAOX11_MAJOR_VERSION != 2 || TAOX11_MINOR_VERSION != 6 || TAOX11_MICRO_VERSION != 0 +#error This file was generated with another RIDL C++11 backend version (2.6.0). Please re-generate. +#endif + +using namespace TAOX11_NAMESPACE; + +// generated from c++11/templates/cli/hdr/typedef +/// @copydoc test.idl::StringLongMap +using StringLongMap = std::map; + +// generated from c++11/templates/cli/hdr/typedef +/// @copydoc test.idl::bds +using bds = TAOX11_IDL::bounded_string<650>; + +// generated from c++11/templates/cli/hdr/struct_pre +/// @copydoc test.idl::bar +class bar +{ +public: + // generated from c++11/templates/cli/hdr/struct_post + bar () = default; + ~bar () = default; + bar (const bar&) = default; + bar (bar&&) = default; + /// Constructor which accepts value for all members + explicit inline bar ( + int16_t x, + std::string y, + IDL::optional z); + bar& operator= (const bar&) = default; + bar& operator= (bar&&) = default; + + /// @copydoc test.idl::bar::x + //@{ + inline void x (int16_t _x11_x) { this->x_ = _x11_x; } + inline int16_t x () const { return this->x_; } + inline int16_t& x () { return this->x_; } + //@} + + /// @copydoc test.idl::bar::y + //@{ + inline void y (const std::string& _x11_y) { this->y_ = _x11_y; } + inline void y (std::string&& _x11_y) { this->y_ = std::move (_x11_y); } + inline const std::string& y () const { return this->y_; } + inline std::string& y () { return this->y_; } + //@} + + /// @copydoc test.idl::bar::z + //@{ + inline void z (const IDL::optional& _x11_z) { this->z_ = _x11_z; } + inline void z (IDL::optional&& _x11_z) { this->z_ = std::move (_x11_z); } + inline const IDL::optional& z () const { return this->z_; } + inline IDL::optional& z () { return this->z_; } + //@} + + /// Exchange the value of two structures in an efficient matter + inline void swap (bar& s); + +private: + int16_t x_{}; + std::string y_{}; + IDL::optional z_{std::nullopt}; +};// bar + +inline void swap (::bar& m1, ::bar& m2) { m1.swap (m2); } + +// generated from StubHeaderIDLTraitsWriter#pre_visit +namespace TAOX11_NAMESPACE::IDL +{ + + // generated from c++11/templates/cli/hdr/map_idl_traits + // Unaliased type : std::map + // MD5 : 9591659AF1C35F72B6270EE9C6D3AFEF +#if !defined(_ALIAS_9591659AF1C35F72B6270EE9C6D3AFEF_TRAITS_DECL_) +#define _ALIAS_9591659AF1C35F72B6270EE9C6D3AFEF_TRAITS_DECL_ + + template<> + struct traits <::StringLongMap> + : IDL::common_traits<::StringLongMap> + { + /// std::false_type or std::true_type type indicating whether + /// this sequence is declared as bounded + using is_bounded = std::false_type; + /// IDL::traits<> for the key type of the sequence + using key_traits = IDL::traits; + /// IDL::traits<> for the value type of the sequence + using value_traits = IDL::traits; + + template > + static inline OStrm_& write_on( + OStrm_& os_, in_type val_, + Formatter fmt_ = Formatter ()) + { + return fmt_ (os_, val_); + } + + template + static inline __Writer write (in_type val) { return {val}; } + }; + + template + inline OStrm_& operator <<( + OStrm_& os, + IDL::traits<::StringLongMap>::__Writer w) + { + using writer_t = IDL::traits<::StringLongMap>::__Writer; + using formatter_t = typename std::conditional< + std::is_same< + typename writer_t::formatter_t, + std::false_type>::value, + formatter<::StringLongMap, OStrm_>, + typename writer_t::formatter_t>::type; + return IDL::traits<::StringLongMap>::write_on (os, w.val_, formatter_t ()); + } + +#endif + + // generated from c++11/templates/cli/hdr/string_idl_traits + // Unaliased type : TAOX11_IDL::bounded_string<650> + // MD5 : 8A4C2C8D2E43F29AF2FF47B029780F14 +#if !defined(_ALIAS_8A4C2C8D2E43F29AF2FF47B029780F14_TRAITS_DECL_) +#define _ALIAS_8A4C2C8D2E43F29AF2FF47B029780F14_TRAITS_DECL_ + + template<> + struct traits > + : IDL::common_traits> + , IDL::bounded_traits> + { + /// std::false_type or std::true_type type indicating whether + /// this string is declared as bounded + using is_bounded = std::true_type ; + /// IDL::traits<> for the element of the string + using element_traits = IDL::traits; + + template > + static inline OStrm_& write_on( + OStrm_& os_, in_type val_, + Formatter fmt_ = Formatter ()) + { + return fmt_ (os_, val_); + } + + template + static inline __Writer write (in_type val) { return {val}; } + }; + + template + inline OStrm_& operator <<( + OStrm_& os, + IDL::traits>::__Writer w) + { + using writer_t = IDL::traits>::__Writer; + using formatter_t = typename std::conditional< + std::is_same< + typename writer_t::formatter_t, + std::false_type>::value, + formatter, OStrm_>, + typename writer_t::formatter_t>::type; + return IDL::traits>::write_on (os, w.val_, formatter_t ()); + } + +#endif + + // generated from c++11/templates/cli/hdr/struct_idl_traits +#if !defined (_STRUCT_BAR_TRAITS_) +#define _STRUCT_BAR_TRAITS_ + template<> + struct traits <::bar> + : IDL::common_traits<::bar> + { + template > + static inline OStrm_& write_on(OStrm_& os_, in_type val_, Formatter fmt_ = Formatter ()) + { + return fmt_ (os_, val_); + } + + template + static inline __Writer write (in_type val) { return {val}; } + }; + + template + struct formatter<::bar, OStrm_>; + + template + OStrm_& operator <<(OStrm_&, IDL::traits<::bar>::__Writer); +#endif // _STRUCT_BAR_TRAITS_ +} // namespace TAOX11_NAMESPACE::IDL + +// generated from StubHeaderIDLTraitsDefWriter#pre_visit +namespace TAOX11_NAMESPACE::IDL +{ + + // generated from c++11/templates/cli/hdr/struct_idl_traits_def + template + struct formatter<::bar, OStrm_> + { + inline OStrm_& operator ()( + OStrm_& os_, + const ::bar& val_) + { + os_ << "bar" + << '{' + << "x=" << IDL::traits::write(val_.x ()) + << ",y=" << IDL::traits::write(val_.y ()) + << '}'; + return os_; + } + }; + + template + inline OStrm_& operator <<(OStrm_& os, IDL::traits<::bar>::__Writer w) + { + using writer_t = IDL::traits<::bar>::__Writer; + using formatter_t = typename std::conditional< + std::is_same< + typename writer_t::formatter_t, + std::false_type>::value, + formatter<::bar, OStrm_>, + typename writer_t::formatter_t>::type; + return IDL::traits<::bar>::write_on (os, w.val_, formatter_t ()); + } +} // namespace TAOX11_NAMESPACE::IDL + +// generated from c++11/templates/cli/inl/struct_inl +inline ::bar::bar ( + int16_t x, + std::string y, + IDL::optional z) + : x_ (std::move (x)) + , y_ (std::move (y)) + , z_ (std::move (z)) +{ +} + +inline void ::bar::swap (::bar& s) +{ + std::swap (this->x_, s.x_); + std::swap (this->y_, s.y_); + std::swap (this->z_, s.z_); +} + +// generated from c++11/templates/cli/hdr/map_os +// Unaliased type : std::map +// MD5 : 9591659AF1C35F72B6270EE9C6D3AFEF +#if !defined (_ALIAS_OSTREAM_9591659AF1C35F72B6270EE9C6D3AFEF_DECL_) +#define _ALIAS_OSTREAM_9591659AF1C35F72B6270EE9C6D3AFEF_DECL_ + +inline std::ostream& operator<< (std::ostream& strm, const ::StringLongMap& _v) +{ + return IDL::traits<::StringLongMap>::write_on (strm, _v); +} + +#endif // _ALIAS_OSTREAM_9591659AF1C35F72B6270EE9C6D3AFEF_DECL_ + +// generated from c++11/templates/cli/hdr/struct_os +inline std::ostream& operator<< (std::ostream& strm, const ::bar& _v) +{ + return IDL::traits<::bar>::write_on (strm, _v); +} + +// generated from c++11/templates/cli/hdr/post +#if !defined (TAOX11_DISABLE_INCLUDE_STUB_PROXY_HDR) && defined (__TAOX11_INCLUDE_STUB_PROXY__) && __has_include("testCP.h") +# include "testCP.h" +#endif + +#include /**/ "tao/x11/base/post.h" + +#endif /* __RIDL_TESTC_H_HJGBAJHC_INCLUDED__ */ + +// -*- END -*- diff --git a/tests/idl4/optional/testCP.h b/tests/idl4/optional/testCP.h new file mode 100644 index 00000000..8405bd15 --- /dev/null +++ b/tests/idl4/optional/testCP.h @@ -0,0 +1,116 @@ +/** + * **** Code generated by the RIDL Compiler **** + * RIDL has been developed by: + * Remedy IT Expertise BV + * The Netherlands + * https://www.remedy.nl + */ + +#ifndef __RIDL_TESTCP_H_DFHECBEC_INCLUDED__ +#define __RIDL_TESTCP_H_DFHECBEC_INCLUDED__ + +#pragma once + +#include "tao/x11/anyinsert_policy_t.h" +#include "tao/x11/map_cdr_t.h" +#include "tao/x11/basic_argument_t.h" + +#include /**/ "tao/x11/base/versionx11.h" + +#if TAOX11_MAJOR_VERSION != 2 || TAOX11_MINOR_VERSION != 6 || TAOX11_MICRO_VERSION != 0 +#error This file was generated with another RIDL C++11 backend version (2.6.0). Please re-generate. +#endif + +// generated from StubProxyHeaderObjRefTraitsWriter#pre_visit +// generated from StubProxyHeaderCDRWriter#pre_visit + +// generated from c++11/templates/cli/prx/map_cdr +// Unaliased type : std::map +// MD5 : 9591659AF1C35F72B6270EE9C6D3AFEF +#if !defined (_ALIAS_9591659AF1C35F72B6270EE9C6D3AFEF_ARG_TRAITS_) +#define _ALIAS_9591659AF1C35F72B6270EE9C6D3AFEF_ARG_TRAITS_ +/// Argument traits specializations for StringLongMap +template<> +class TAOX11_NAMESPACE::Arg_Traits<::StringLongMap> + : public Basic_Arg_Traits_T<::StringLongMap, Any_Insert_Policy_Noop> +{ +}; + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +/// @name CDR streaming operator specializations for StringLongMap +//@{ +inline TAO_CORBA::Boolean operator<< (TAO_OutputCDR& cdr, const IDL::traits<::StringLongMap>::value_type& v) +{ + return taox11_map_cdr<::StringLongMap::key_type, ::StringLongMap::mapped_type>::insert (cdr, v); +} +inline TAO_CORBA::Boolean operator>> (TAO_InputCDR& cdr, IDL::traits<::StringLongMap>::value_type& v) +{ + return taox11_map_cdr<::StringLongMap::key_type, ::StringLongMap::mapped_type>::extract (cdr, v); +} +//@} + +TAO_END_VERSIONED_NAMESPACE_DECL +# endif // !_ALIAS_9591659AF1C35F72B6270EE9C6D3AFEF_ARG_TRAITS_ + +// generated from c++11/templates/cli/prx/string_cdr +// Unaliased type : TAOX11_IDL::bounded_string<650> +// MD5 : 8A4C2C8D2E43F29AF2FF47B029780F14 +#if !defined (_ALIAS_8A4C2C8D2E43F29AF2FF47B029780F14_ARG_TRAITS_) +#define _ALIAS_8A4C2C8D2E43F29AF2FF47B029780F14_ARG_TRAITS_ +/// Argument traits specializations for bds +template<> +class TAOX11_NAMESPACE::Arg_Traits> + : public Basic_Arg_Traits_T, Any_Insert_Policy_Noop> +{ +}; + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +/// CDR streaming methods for bds +bool _cdr_in_bds (TAO_OutputCDR &, const IDL::traits>::value_type&); +bool _cdr_out_bds (TAO_InputCDR &, IDL::traits>::value_type&); +#define _ALIAS_bds_CDR_OPS_IMPL_ + +/// @name CDR streaming operator specializations for bds +//@{ +inline TAO_CORBA::Boolean operator<< (TAO_OutputCDR &cdr, const IDL::traits>::value_type &v) +{ + return _cdr_in_bds (cdr, v); +} +inline TAO_CORBA::Boolean operator>> (TAO_InputCDR &cdr, IDL::traits>::value_type& v) +{ + return _cdr_out_bds (cdr, v); +} +//@} + +TAO_END_VERSIONED_NAMESPACE_DECL +# endif // !_ALIAS_8A4C2C8D2E43F29AF2FF47B029780F14_ARG_TRAITS_ + +// generated from c++11/templates/cli/prx/struct_cdr +# if !defined (_BAR_TRAITS_) +# define _BAR_TRAITS_ +/// Argument traits specializations for bar +template<> +class TAOX11_NAMESPACE::Arg_Traits<::bar> + : public Basic_Arg_Traits_T<::bar, Any_Insert_Policy_Noop> +{ +}; +# endif // !_BAR_TRAITS_ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +/// @name CDR streaming operator specializations for bar +//@{ +TAO_CORBA::Boolean operator<< (TAO_OutputCDR&, const bar&); +TAO_CORBA::Boolean operator>> (TAO_InputCDR&, bar&); +TAO_CORBA::Boolean operator<< (TAO_OutputCDR&, const IDL::optional&); +TAO_CORBA::Boolean operator>> (TAO_InputCDR&, IDL::optional&); +//@} + +TAO_END_VERSIONED_NAMESPACE_DECL + + +#endif /* __RIDL_TESTCP_H_DFHECBEC_INCLUDED__ */ + +// -*- END -*- From 118ea2c864e69567fa97183a69ea862e6ccc2f50 Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Mon, 27 May 2024 09:49:51 +0200 Subject: [PATCH 2/7] Add CDR for optional * ridlbe/c++11/templates/cli/prx/struct_cdr.erb: * ridlbe/c++11/templates/cli/src/struct_cdr.erb: * tests/idl4/optional/testC.cpp: * tests/idl4/optional/testC.h: * tests/idl4/optional/testCP.h: --- ridlbe/c++11/templates/cli/prx/struct_cdr.erb | 9 ++++++++ ridlbe/c++11/templates/cli/src/struct_cdr.erb | 14 +++++++++++++ tests/idl4/optional/testC.cpp | 21 +++++++++---------- tests/idl4/optional/testC.h | 6 +++--- tests/idl4/optional/testCP.h | 9 +++++--- 5 files changed, 42 insertions(+), 17 deletions(-) diff --git a/ridlbe/c++11/templates/cli/prx/struct_cdr.erb b/ridlbe/c++11/templates/cli/prx/struct_cdr.erb index 86a94ebc..8c83178b 100644 --- a/ridlbe/c++11/templates/cli/prx/struct_cdr.erb +++ b/ridlbe/c++11/templates/cli/prx/struct_cdr.erb @@ -18,5 +18,14 @@ TAO_BEGIN_VERSIONED_NAMESPACE_DECL <%= stub_proxy_export_macro %>TAO_CORBA::Boolean operator<< (TAO_OutputCDR&, const <%= scoped_cxxname %>&); <%= stub_proxy_export_macro %>TAO_CORBA::Boolean operator>> (TAO_InputCDR&, <%= scoped_cxxname %>&); //@} +%members.each do |_m| +% if _m.optional? +/// @name CDR streaming operator specializations for <%= _m.cxx_member_type %> +//@{ +<%= stub_proxy_export_macro %>TAO_CORBA::Boolean operator<< (TAO_OutputCDR&, const <%= _m.cxx_member_type %>&); +<%= stub_proxy_export_macro %>TAO_CORBA::Boolean operator>> (TAO_InputCDR&, <%= _m.cxx_member_type %>&); +//@} +% end +%end TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/ridlbe/c++11/templates/cli/src/struct_cdr.erb b/ridlbe/c++11/templates/cli/src/struct_cdr.erb index 2f285f41..d5e77acd 100644 --- a/ridlbe/c++11/templates/cli/src/struct_cdr.erb +++ b/ridlbe/c++11/templates/cli/src/struct_cdr.erb @@ -30,3 +30,17 @@ TAO_CORBA::Boolean operator>> (TAO_InputCDR &<% if member_count > 0 || !base.nil return true; % end } +%members.each do |_m| +% if _m.optional? + +TAO_CORBA::Boolean operator<< (TAO_OutputCDR&strm, const <%= _m.cxx_member_type %>&_val) +{ + return taox11_optional_cdr<<%= _m.cxx_member_type %>>::insert (strm, _val); +} + +TAO_CORBA::Boolean operator>> (TAO_InputCDR& strm, <%= _m.cxx_member_type %>&_val) +{ + return taox11_optional_cdr<<%= _m.cxx_member_type %>>::extract (strm, _val); +} +% end +%end diff --git a/tests/idl4/optional/testC.cpp b/tests/idl4/optional/testC.cpp index 4e11165c..13127fd2 100644 --- a/tests/idl4/optional/testC.cpp +++ b/tests/idl4/optional/testC.cpp @@ -20,17 +20,6 @@ // generated from StubProxySourceCDRWriter#pre_visit TAO_BEGIN_VERSIONED_NAMESPACE_DECL -TAO_CORBA::Boolean operator<< (TAO_OutputCDR&strm, const IDL::optional&_val) -{ - return taox11_optional_cdr>::insert (strm, _val); -} - -TAO_CORBA::Boolean operator>> (TAO_InputCDR& strm, IDL::optional&_val) -{ - return taox11_optional_cdr>::extract (strm, _val); -} - - // generated from c++11/templates/cli/src/string_cdr #if defined(_ALIAS_bds_CDR_OPS_IMPL_) bool _cdr_in_bds ( @@ -65,6 +54,16 @@ TAO_CORBA::Boolean operator>> (TAO_InputCDR &strm, bar &_tao_aggregate) (strm >> _tao_aggregate.z ()); } +TAO_CORBA::Boolean operator<< (TAO_OutputCDR&strm, const IDL::optional&_val) +{ + return taox11_optional_cdr>::insert (strm, _val); +} + +TAO_CORBA::Boolean operator>> (TAO_InputCDR& strm, IDL::optional&_val) +{ + return taox11_optional_cdr>::extract (strm, _val); +} + TAO_END_VERSIONED_NAMESPACE_DECL // -*- END -*- diff --git a/tests/idl4/optional/testC.h b/tests/idl4/optional/testC.h index ea0177a4..bb525660 100644 --- a/tests/idl4/optional/testC.h +++ b/tests/idl4/optional/testC.h @@ -6,8 +6,8 @@ * https://www.remedy.nl */ -#ifndef __RIDL_TESTC_H_HJGBAJHC_INCLUDED__ -#define __RIDL_TESTC_H_HJGBAJHC_INCLUDED__ +#ifndef __RIDL_TESTC_H_DJEBDBGG_INCLUDED__ +#define __RIDL_TESTC_H_DJEBDBGG_INCLUDED__ #pragma once @@ -289,6 +289,6 @@ inline std::ostream& operator<< (std::ostream& strm, const ::bar& _v) #include /**/ "tao/x11/base/post.h" -#endif /* __RIDL_TESTC_H_HJGBAJHC_INCLUDED__ */ +#endif /* __RIDL_TESTC_H_DJEBDBGG_INCLUDED__ */ // -*- END -*- diff --git a/tests/idl4/optional/testCP.h b/tests/idl4/optional/testCP.h index 8405bd15..1560ec11 100644 --- a/tests/idl4/optional/testCP.h +++ b/tests/idl4/optional/testCP.h @@ -6,8 +6,8 @@ * https://www.remedy.nl */ -#ifndef __RIDL_TESTCP_H_DFHECBEC_INCLUDED__ -#define __RIDL_TESTCP_H_DFHECBEC_INCLUDED__ +#ifndef __RIDL_TESTCP_H_IHIFDICE_INCLUDED__ +#define __RIDL_TESTCP_H_IHIFDICE_INCLUDED__ #pragma once @@ -104,6 +104,9 @@ TAO_BEGIN_VERSIONED_NAMESPACE_DECL //@{ TAO_CORBA::Boolean operator<< (TAO_OutputCDR&, const bar&); TAO_CORBA::Boolean operator>> (TAO_InputCDR&, bar&); +//@} +/// @name CDR streaming operator specializations for IDL::optional +//@{ TAO_CORBA::Boolean operator<< (TAO_OutputCDR&, const IDL::optional&); TAO_CORBA::Boolean operator>> (TAO_InputCDR&, IDL::optional&); //@} @@ -111,6 +114,6 @@ TAO_CORBA::Boolean operator>> (TAO_InputCDR&, IDL::optional&); TAO_END_VERSIONED_NAMESPACE_DECL -#endif /* __RIDL_TESTCP_H_DFHECBEC_INCLUDED__ */ +#endif /* __RIDL_TESTCP_H_IHIFDICE_INCLUDED__ */ // -*- END -*- From 235d1eb11dbe74a7b28ba06c946a112b7dd1d51a Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Mon, 27 May 2024 09:59:19 +0200 Subject: [PATCH 3/7] More test * ridlbe/c++11/templates/cli/prx/struct_cdr.erb: * ridlbe/c++11/templates/cli/src/struct_cdr.erb: * tests/idl4/optional/test.idl: * tests/idl4/optional/testC.cpp: * tests/idl4/optional/testC.h: * tests/idl4/optional/testCP.h: --- ridlbe/c++11/templates/cli/prx/struct_cdr.erb | 6 ++ ridlbe/c++11/templates/cli/src/struct_cdr.erb | 6 ++ tests/idl4/optional/test.idl | 2 + tests/idl4/optional/testC.cpp | 26 +++++- tests/idl4/optional/testC.h | 87 +++++++++++++++++-- tests/idl4/optional/testCP.h | 51 ++++++++++- 6 files changed, 168 insertions(+), 10 deletions(-) diff --git a/ridlbe/c++11/templates/cli/prx/struct_cdr.erb b/ridlbe/c++11/templates/cli/prx/struct_cdr.erb index 8c83178b..f38ff87e 100644 --- a/ridlbe/c++11/templates/cli/prx/struct_cdr.erb +++ b/ridlbe/c++11/templates/cli/prx/struct_cdr.erb @@ -20,11 +20,17 @@ TAO_BEGIN_VERSIONED_NAMESPACE_DECL //@} %members.each do |_m| % if _m.optional? +// Unaliased type : <%= _m.cxx_member_type %> +% alias_md5 = _m.cxx_member_type.to_md5 +// MD5 : <%= alias_md5 %> +#if !defined(_CDR_<%= alias_md5 %>_OPTIONAL_DECL_) +#define _CDR_<%= alias_md5 %>_OPTIONAL_DECL_ /// @name CDR streaming operator specializations for <%= _m.cxx_member_type %> //@{ <%= stub_proxy_export_macro %>TAO_CORBA::Boolean operator<< (TAO_OutputCDR&, const <%= _m.cxx_member_type %>&); <%= stub_proxy_export_macro %>TAO_CORBA::Boolean operator>> (TAO_InputCDR&, <%= _m.cxx_member_type %>&); //@} +#endif % end %end diff --git a/ridlbe/c++11/templates/cli/src/struct_cdr.erb b/ridlbe/c++11/templates/cli/src/struct_cdr.erb index d5e77acd..61984939 100644 --- a/ridlbe/c++11/templates/cli/src/struct_cdr.erb +++ b/ridlbe/c++11/templates/cli/src/struct_cdr.erb @@ -33,6 +33,11 @@ TAO_CORBA::Boolean operator>> (TAO_InputCDR &<% if member_count > 0 || !base.nil %members.each do |_m| % if _m.optional? +// Unaliased type : <%= _m.cxx_member_type %> +% alias_md5 = _m.cxx_member_type.to_md5 +// MD5 : <%= alias_md5 %> +#if !defined(_CDR_<%= alias_md5 %>_OPTIONAL_IMPL_) +#define _CDR_<%= alias_md5 %>_OPTIONAL_IMPL_ TAO_CORBA::Boolean operator<< (TAO_OutputCDR&strm, const <%= _m.cxx_member_type %>&_val) { return taox11_optional_cdr<<%= _m.cxx_member_type %>>::insert (strm, _val); @@ -42,5 +47,6 @@ TAO_CORBA::Boolean operator>> (TAO_InputCDR& strm, <%= _m.cxx_member_type %>&_va { return taox11_optional_cdr<<%= _m.cxx_member_type %>>::extract (strm, _val); } +#endif % end %end diff --git a/tests/idl4/optional/test.idl b/tests/idl4/optional/test.idl index 45119a9e..2af834f8 100644 --- a/tests/idl4/optional/test.idl +++ b/tests/idl4/optional/test.idl @@ -8,10 +8,12 @@ typedef map StringLongMap; typedef string<650> bds; +typedef sequence bs; struct bar { short x; string y; @optional short z; + @optional short a; }; diff --git a/tests/idl4/optional/testC.cpp b/tests/idl4/optional/testC.cpp index 13127fd2..761ba3c8 100644 --- a/tests/idl4/optional/testC.cpp +++ b/tests/idl4/optional/testC.cpp @@ -43,7 +43,8 @@ TAO_CORBA::Boolean operator<< (TAO_OutputCDR &strm, const bar &_tao_aggregate) return (strm << _tao_aggregate.x ()) && (strm << _tao_aggregate.y ()) && - (strm << _tao_aggregate.z ()); + (strm << _tao_aggregate.z ()) && + (strm << _tao_aggregate.a ()); } TAO_CORBA::Boolean operator>> (TAO_InputCDR &strm, bar &_tao_aggregate) @@ -51,9 +52,14 @@ TAO_CORBA::Boolean operator>> (TAO_InputCDR &strm, bar &_tao_aggregate) return (strm >> _tao_aggregate.x ()) && (strm >> _tao_aggregate.y ()) && - (strm >> _tao_aggregate.z ()); + (strm >> _tao_aggregate.z ()) && + (strm >> _tao_aggregate.a ()); } +// Unaliased type : IDL::optional +// MD5 : 390A720FCF9D6B2326C7F41A8BC2534C +#if !defined(_CDR_390A720FCF9D6B2326C7F41A8BC2534C_OPTIONAL_IMPL_) +#define _CDR_390A720FCF9D6B2326C7F41A8BC2534C_OPTIONAL_IMPL_ TAO_CORBA::Boolean operator<< (TAO_OutputCDR&strm, const IDL::optional&_val) { return taox11_optional_cdr>::insert (strm, _val); @@ -63,6 +69,22 @@ TAO_CORBA::Boolean operator>> (TAO_InputCDR& strm, IDL::optional&_val) { return taox11_optional_cdr>::extract (strm, _val); } +#endif + +// Unaliased type : IDL::optional +// MD5 : 390A720FCF9D6B2326C7F41A8BC2534C +#if !defined(_CDR_390A720FCF9D6B2326C7F41A8BC2534C_OPTIONAL_IMPL_) +#define _CDR_390A720FCF9D6B2326C7F41A8BC2534C_OPTIONAL_IMPL_ +TAO_CORBA::Boolean operator<< (TAO_OutputCDR&strm, const IDL::optional&_val) +{ + return taox11_optional_cdr>::insert (strm, _val); +} + +TAO_CORBA::Boolean operator>> (TAO_InputCDR& strm, IDL::optional&_val) +{ + return taox11_optional_cdr>::extract (strm, _val); +} +#endif TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/tests/idl4/optional/testC.h b/tests/idl4/optional/testC.h index bb525660..d2e0500e 100644 --- a/tests/idl4/optional/testC.h +++ b/tests/idl4/optional/testC.h @@ -6,8 +6,8 @@ * https://www.remedy.nl */ -#ifndef __RIDL_TESTC_H_DJEBDBGG_INCLUDED__ -#define __RIDL_TESTC_H_DJEBDBGG_INCLUDED__ +#ifndef __RIDL_TESTC_H_DIFDHCCB_INCLUDED__ +#define __RIDL_TESTC_H_DIFDHCCB_INCLUDED__ #pragma once @@ -18,6 +18,7 @@ #include "map" #include "tao/x11/base/bounded_string_t.h" #include "tao/x11/base/bounded_type_traits_t.h" +#include "tao/x11/base/bounded_vector_t.h" #include "tao/x11/optional_t.h" #include /**/ "tao/x11/base/versionx11.h" @@ -36,6 +37,10 @@ using StringLongMap = std::map; /// @copydoc test.idl::bds using bds = TAOX11_IDL::bounded_string<650>; +// generated from c++11/templates/cli/hdr/typedef +/// @copydoc test.idl::bs +using bs = TAOX11_NAMESPACE::IDL::bounded_vector; + // generated from c++11/templates/cli/hdr/struct_pre /// @copydoc test.idl::bar class bar @@ -50,7 +55,8 @@ class bar explicit inline bar ( int16_t x, std::string y, - IDL::optional z); + IDL::optional z, + IDL::optional a); bar& operator= (const bar&) = default; bar& operator= (bar&&) = default; @@ -77,6 +83,14 @@ class bar inline IDL::optional& z () { return this->z_; } //@} + /// @copydoc test.idl::bar::a + //@{ + inline void a (const IDL::optional& _x11_a) { this->a_ = _x11_a; } + inline void a (IDL::optional&& _x11_a) { this->a_ = std::move (_x11_a); } + inline const IDL::optional& a () const { return this->a_; } + inline IDL::optional& a () { return this->a_; } + //@} + /// Exchange the value of two structures in an efficient matter inline void swap (bar& s); @@ -84,6 +98,7 @@ class bar int16_t x_{}; std::string y_{}; IDL::optional z_{std::nullopt}; + IDL::optional a_{std::nullopt}; };// bar inline void swap (::bar& m1, ::bar& m2) { m1.swap (m2); } @@ -183,6 +198,52 @@ namespace TAOX11_NAMESPACE::IDL return IDL::traits>::write_on (os, w.val_, formatter_t ()); } +#endif + + // generated from c++11/templates/cli/hdr/sequence_idl_traits + // Unaliased type : TAOX11_NAMESPACE::IDL::bounded_vector + // MD5 : D0B8C685EFADFAF646AABDA450D4F77E +#if !defined(_ALIAS_D0B8C685EFADFAF646AABDA450D4F77E_TRAITS_DECL_) +#define _ALIAS_D0B8C685EFADFAF646AABDA450D4F77E_TRAITS_DECL_ + + template<> + struct traits <::bs> + : IDL::common_traits<::bs> + , IDL::bounded_traits<::bs> + { + /// std::false_type or std::true_type type indicating whether + /// this sequence is declared as bounded + using is_bounded = std::true_type; + /// IDL::traits<> for the element of the sequence + using element_traits = IDL::traits; + + template > + static inline OStrm_& write_on( + OStrm_& os_, in_type val_, + Formatter fmt_ = Formatter ()) + { + return fmt_ (os_, val_); + } + + template + static inline __Writer write (in_type val) { return {val}; } + }; + + template + inline OStrm_& operator <<( + OStrm_& os, + IDL::traits<::bs>::__Writer w) + { + using writer_t = IDL::traits<::bs>::__Writer; + using formatter_t = typename std::conditional< + std::is_same< + typename writer_t::formatter_t, + std::false_type>::value, + formatter<::bs, OStrm_>, + typename writer_t::formatter_t>::type; + return IDL::traits<::bs>::write_on (os, w.val_, formatter_t ()); + } + #endif // generated from c++11/templates/cli/hdr/struct_idl_traits @@ -249,10 +310,12 @@ namespace TAOX11_NAMESPACE::IDL inline ::bar::bar ( int16_t x, std::string y, - IDL::optional z) + IDL::optional z, + IDL::optional a) : x_ (std::move (x)) , y_ (std::move (y)) , z_ (std::move (z)) + , a_ (std::move (a)) { } @@ -261,6 +324,7 @@ inline void ::bar::swap (::bar& s) std::swap (this->x_, s.x_); std::swap (this->y_, s.y_); std::swap (this->z_, s.z_); + std::swap (this->a_, s.a_); } // generated from c++11/templates/cli/hdr/map_os @@ -276,6 +340,19 @@ inline std::ostream& operator<< (std::ostream& strm, const ::StringLongMap& _v) #endif // _ALIAS_OSTREAM_9591659AF1C35F72B6270EE9C6D3AFEF_DECL_ +// generated from c++11/templates/cli/hdr/sequence_os +// Unaliased type : TAOX11_NAMESPACE::IDL::bounded_vector +// MD5 : D0B8C685EFADFAF646AABDA450D4F77E +#if !defined (_ALIAS_OSTREAM_D0B8C685EFADFAF646AABDA450D4F77E_DECL_) +#define _ALIAS_OSTREAM_D0B8C685EFADFAF646AABDA450D4F77E_DECL_ + +inline std::ostream& operator<< (std::ostream& strm, const ::bs& _v) +{ + return IDL::traits<::bs>::write_on (strm, _v); +} + +#endif // _ALIAS_OSTREAM_D0B8C685EFADFAF646AABDA450D4F77E_DECL_ + // generated from c++11/templates/cli/hdr/struct_os inline std::ostream& operator<< (std::ostream& strm, const ::bar& _v) { @@ -289,6 +366,6 @@ inline std::ostream& operator<< (std::ostream& strm, const ::bar& _v) #include /**/ "tao/x11/base/post.h" -#endif /* __RIDL_TESTC_H_DJEBDBGG_INCLUDED__ */ +#endif /* __RIDL_TESTC_H_DIFDHCCB_INCLUDED__ */ // -*- END -*- diff --git a/tests/idl4/optional/testCP.h b/tests/idl4/optional/testCP.h index 1560ec11..eec4a2a8 100644 --- a/tests/idl4/optional/testCP.h +++ b/tests/idl4/optional/testCP.h @@ -6,14 +6,15 @@ * https://www.remedy.nl */ -#ifndef __RIDL_TESTCP_H_IHIFDICE_INCLUDED__ -#define __RIDL_TESTCP_H_IHIFDICE_INCLUDED__ +#ifndef __RIDL_TESTCP_H_GCEACAAC_INCLUDED__ +#define __RIDL_TESTCP_H_GCEACAAC_INCLUDED__ #pragma once #include "tao/x11/anyinsert_policy_t.h" #include "tao/x11/map_cdr_t.h" #include "tao/x11/basic_argument_t.h" +#include "tao/x11/sequence_cdr_t.h" #include /**/ "tao/x11/base/versionx11.h" @@ -87,6 +88,35 @@ inline TAO_CORBA::Boolean operator>> (TAO_InputCDR &cdr, IDL::traits +// MD5 : D0B8C685EFADFAF646AABDA450D4F77E +#if !defined (_ALIAS_D0B8C685EFADFAF646AABDA450D4F77E_ARG_TRAITS_) +#define _ALIAS_D0B8C685EFADFAF646AABDA450D4F77E_ARG_TRAITS_ +/// Argument traits specializations for bs +template<> +class TAOX11_NAMESPACE::Arg_Traits<::bs> + : public Basic_Arg_Traits_T<::bs, Any_Insert_Policy_Noop> +{ +}; + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +/// @name CDR streaming operator specializations for bs +//@{ +inline TAO_CORBA::Boolean operator<< (TAO_OutputCDR &cdr, const IDL::traits<::bs>::value_type &v) +{ + return taox11_sequence_cdr<::bs::value_type>::insert<100U> (cdr, v); +} +inline TAO_CORBA::Boolean operator>> (TAO_InputCDR &cdr, IDL::traits<::bs>::value_type& v) +{ + return taox11_sequence_cdr<::bs::value_type>::extract<100U> (cdr, v); +} +//@} + +TAO_END_VERSIONED_NAMESPACE_DECL +# endif // !_ALIAS_D0B8C685EFADFAF646AABDA450D4F77E_ARG_TRAITS_ + // generated from c++11/templates/cli/prx/struct_cdr # if !defined (_BAR_TRAITS_) # define _BAR_TRAITS_ @@ -105,15 +135,30 @@ TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_CORBA::Boolean operator<< (TAO_OutputCDR&, const bar&); TAO_CORBA::Boolean operator>> (TAO_InputCDR&, bar&); //@} +// Unaliased type : IDL::optional +// MD5 : 390A720FCF9D6B2326C7F41A8BC2534C +#if !defined(_CDR_390A720FCF9D6B2326C7F41A8BC2534C_OPTIONAL_DECL_) +#define _CDR_390A720FCF9D6B2326C7F41A8BC2534C_OPTIONAL_DECL_ /// @name CDR streaming operator specializations for IDL::optional //@{ TAO_CORBA::Boolean operator<< (TAO_OutputCDR&, const IDL::optional&); TAO_CORBA::Boolean operator>> (TAO_InputCDR&, IDL::optional&); //@} +#endif +// Unaliased type : IDL::optional +// MD5 : 390A720FCF9D6B2326C7F41A8BC2534C +#if !defined(_CDR_390A720FCF9D6B2326C7F41A8BC2534C_OPTIONAL_DECL_) +#define _CDR_390A720FCF9D6B2326C7F41A8BC2534C_OPTIONAL_DECL_ +/// @name CDR streaming operator specializations for IDL::optional +//@{ +TAO_CORBA::Boolean operator<< (TAO_OutputCDR&, const IDL::optional&); +TAO_CORBA::Boolean operator>> (TAO_InputCDR&, IDL::optional&); +//@} +#endif TAO_END_VERSIONED_NAMESPACE_DECL -#endif /* __RIDL_TESTCP_H_IHIFDICE_INCLUDED__ */ +#endif /* __RIDL_TESTCP_H_GCEACAAC_INCLUDED__ */ // -*- END -*- From e7c0788c6fcc67c96c4f7d1cf5d70d1136f239a7 Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Mon, 27 May 2024 10:22:24 +0200 Subject: [PATCH 4/7] Add more optional support, removed ACE_HAS_CPP17 checks * tao/x11/optional_cdr_t.h: Added. * ridlbe/c++11/templates/cli/prx/struct_cdr.erb: * ridlbe/c++11/templates/cli/src/struct_cdr.erb: * ridlbe/c++11/visitors/struct.rb: * ridlbe/c++11/writers/stubproxyheader.rb: * tao/x11/base/bounded_map_t.h: * tao/x11/map_cdr_t.h: * tao/x11/optional_t.h: * tao/x11/portable_server/operation_table_std_map.h: * tao/x11/taox11.mpc: * tests/idl4/optional/test.idl: * tests/idl4/optional/testC.cpp: * tests/idl4/optional/testC.h: * tests/idl4/optional/testCP.h: * tests/interface/client.cpp: * tests/struct/client.cpp: * tests/union/client.cpp: --- ridlbe/c++11/templates/cli/prx/struct_cdr.erb | 10 +- ridlbe/c++11/templates/cli/src/struct_cdr.erb | 20 -- ridlbe/c++11/visitors/struct.rb | 6 +- ridlbe/c++11/writers/stubproxyheader.rb | 1 + tao/x11/base/bounded_map_t.h | 2 - tao/x11/map_cdr_t.h | 52 ----- tao/x11/optional_cdr_t.h | 70 ++++++ tao/x11/optional_t.h | 20 +- .../portable_server/operation_table_std_map.h | 4 - tao/x11/taox11.mpc | 2 + tests/idl4/optional/test.idl | 6 +- tests/idl4/optional/testC.cpp | 53 +---- tests/idl4/optional/testC.h | 204 ++---------------- tests/idl4/optional/testCP.h | 137 ++++-------- tests/interface/client.cpp | 2 - tests/struct/client.cpp | 2 - tests/union/client.cpp | 2 - 17 files changed, 146 insertions(+), 447 deletions(-) create mode 100644 tao/x11/optional_cdr_t.h diff --git a/ridlbe/c++11/templates/cli/prx/struct_cdr.erb b/ridlbe/c++11/templates/cli/prx/struct_cdr.erb index f38ff87e..38b9d789 100644 --- a/ridlbe/c++11/templates/cli/prx/struct_cdr.erb +++ b/ridlbe/c++11/templates/cli/prx/struct_cdr.erb @@ -27,8 +27,14 @@ TAO_BEGIN_VERSIONED_NAMESPACE_DECL #define _CDR_<%= alias_md5 %>_OPTIONAL_DECL_ /// @name CDR streaming operator specializations for <%= _m.cxx_member_type %> //@{ -<%= stub_proxy_export_macro %>TAO_CORBA::Boolean operator<< (TAO_OutputCDR&, const <%= _m.cxx_member_type %>&); -<%= stub_proxy_export_macro %>TAO_CORBA::Boolean operator>> (TAO_InputCDR&, <%= _m.cxx_member_type %>&); +inline <%= stub_proxy_export_macro %>TAO_CORBA::Boolean operator<< (TAO_OutputCDR& _strm, const <%= _m.cxx_member_type %>& _val) +{ + return taox11_optional_cdr<<%= _m.cxx_member_type %>>::insert (_strm, _val); +} +<%= stub_proxy_export_macro %>TAO_CORBA::Boolean operator>> (TAO_InputCDR& _strm, <%= _m.cxx_member_type %>& _val) +{ + return taox11_optional_cdr<<%= _m.cxx_member_type %>>::extract (_strm, _val); +} //@} #endif % end diff --git a/ridlbe/c++11/templates/cli/src/struct_cdr.erb b/ridlbe/c++11/templates/cli/src/struct_cdr.erb index 61984939..2f285f41 100644 --- a/ridlbe/c++11/templates/cli/src/struct_cdr.erb +++ b/ridlbe/c++11/templates/cli/src/struct_cdr.erb @@ -30,23 +30,3 @@ TAO_CORBA::Boolean operator>> (TAO_InputCDR &<% if member_count > 0 || !base.nil return true; % end } -%members.each do |_m| -% if _m.optional? - -// Unaliased type : <%= _m.cxx_member_type %> -% alias_md5 = _m.cxx_member_type.to_md5 -// MD5 : <%= alias_md5 %> -#if !defined(_CDR_<%= alias_md5 %>_OPTIONAL_IMPL_) -#define _CDR_<%= alias_md5 %>_OPTIONAL_IMPL_ -TAO_CORBA::Boolean operator<< (TAO_OutputCDR&strm, const <%= _m.cxx_member_type %>&_val) -{ - return taox11_optional_cdr<<%= _m.cxx_member_type %>>::insert (strm, _val); -} - -TAO_CORBA::Boolean operator>> (TAO_InputCDR& strm, <%= _m.cxx_member_type %>&_val) -{ - return taox11_optional_cdr<<%= _m.cxx_member_type %>>::extract (strm, _val); -} -#endif -% end -%end diff --git a/ridlbe/c++11/visitors/struct.rb b/ridlbe/c++11/visitors/struct.rb index 1ece1e28..9b840014 100644 --- a/ridlbe/c++11/visitors/struct.rb +++ b/ridlbe/c++11/visitors/struct.rb @@ -29,6 +29,10 @@ def is_exception? false end + def has_optional? + true + end + # Return the base of this struct, nil in case of no base struct def base node.base @@ -123,7 +127,7 @@ def cxx_out_type def cxx_in_type if optional? - "const IDL::optional<#{super}>&" + "const IDL::optional<#{cxx_return_type}>&" elsif external? "const std::shared_ptr<#{super}>&" else diff --git a/ridlbe/c++11/writers/stubproxyheader.rb b/ridlbe/c++11/writers/stubproxyheader.rb index a0a658b1..d536362b 100644 --- a/ridlbe/c++11/writers/stubproxyheader.rb +++ b/ridlbe/c++11/writers/stubproxyheader.rb @@ -189,6 +189,7 @@ def enter_struct(node) add_include('tao/x11/basic_argument_t.h') node.members.each { |m| check_idl_type(m.idltype) } + node.members.each { |m| add_include('tao/x11/optional_cdr_t.h') if !m.annotations[:optional].first.nil? } end def enter_union(node) diff --git a/tao/x11/base/bounded_map_t.h b/tao/x11/base/bounded_map_t.h index 6750d2be..609af3f4 100644 --- a/tao/x11/base/bounded_map_t.h +++ b/tao/x11/base/bounded_map_t.h @@ -44,10 +44,8 @@ namespace TAOX11_NAMESPACE using size_type = typename _Map::size_type; using difference_type = typename _Map::difference_type; using allocator_type = typename _Map::allocator_type; -#if defined (ACE_HAS_CPP17) using node_type = typename _Map::node_type; using insert_return_type = typename _Map::insert_return_type; -#endif /* ACE_HAS_CPP17 */ using bound = std::integral_constant; diff --git a/tao/x11/map_cdr_t.h b/tao/x11/map_cdr_t.h index 0f07c5d3..b1188170 100644 --- a/tao/x11/map_cdr_t.h +++ b/tao/x11/map_cdr_t.h @@ -17,58 +17,6 @@ TAO_BEGIN_VERSIONED_NAMESPACE_DECL - /// Generic sequence CDR streaming helper template - template - struct taox11_optional_cdr - { - /// Unbounded insert - template - static bool insert (_Stream& _strm, const _Tp& _optional) - { - if (!(_strm << ACE_OutputCDR::from_boolean (_optional.has_value ()))) - { - return false; - } - - bool result { true }; - if (_optional.has_value ()) - { - result = _strm << _optional.value (); - } - return result; - } - - /// Unbounded extract - template - static bool extract (_Stream& _strm, _Tp& _optional) - { - bool _has_value{}; - if (!(_strm >> ACE_InputCDR::to_boolean (_has_value))) - { - return false; - } - - if (_has_value) - { - // initialize associated default value - typename _Tp::value_type temp_val{}; - // extract - if (_strm >> temp_val) - { - // set union member and associated discriminant when there are multiple legal discriminant values - _optional= std::move (temp_val); - return true; - } - } - else - { - _optional.reset (); - } - return false; - } - }; - - /// Generic sequence CDR streaming helper template template struct taox11_map_cdr diff --git a/tao/x11/optional_cdr_t.h b/tao/x11/optional_cdr_t.h new file mode 100644 index 00000000..1d9742c3 --- /dev/null +++ b/tao/x11/optional_cdr_t.h @@ -0,0 +1,70 @@ +/** + * @file optional_cdr_t.h + * @author Johnny Willemsen + * + * @brief x11 optional marshaling templates + * + * @copyright Copyright (c) Remedy IT Expertise BV + */ + +#ifndef TAOX11_OPTIONAL_CDR_T_H_INCLUDED +#define TAOX11_OPTIONAL_CDR_T_H_INCLUDED + +#include "tao/x11/base/tao_corba.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + + /// Generic sequence CDR streaming helper template + template + struct taox11_optional_cdr + { + /// Unbounded insert + template + static bool insert (_Stream& _strm, const _Tp& _optional) + { + if (!(_strm << ACE_OutputCDR::from_boolean (_optional.has_value ()))) + { + return false; + } + + bool result { true }; + if (_optional.has_value ()) + { + result = _strm << _optional.value (); + } + return result; + } + + /// Unbounded extract + template + static bool extract (_Stream& _strm, _Tp& _optional) + { + bool _has_value{}; + if (!(_strm >> ACE_InputCDR::to_boolean (_has_value))) + { + return false; + } + + if (_has_value) + { + // initialize associated default value + typename _Tp::value_type temp_val{}; + // extract + if (_strm >> temp_val) + { + // set union member and associated discriminant when there are multiple legal discriminant values + _optional= std::move (temp_val); + return true; + } + } + else + { + _optional.reset (); + } + return false; + } + }; + +TAO_END_VERSIONED_NAMESPACE_DECL + +#endif // TAOX11_OPTIONAL_CDR_T_H_INCLUDED diff --git a/tao/x11/optional_t.h b/tao/x11/optional_t.h index aff68909..be47fd21 100644 --- a/tao/x11/optional_t.h +++ b/tao/x11/optional_t.h @@ -3,7 +3,7 @@ * @file optional_t.h * @author Johnny Willemsen * - * @brief template for IDL4 optional annotaiton + * @brief template for IDL4 optional annotation * * @copyright Copyright (c) Remedy IT Expertise BV */ @@ -14,8 +14,6 @@ #include #include "tao/x11/base/versioned_x11_namespace.h" -#if defined (ACE_HAS_CPP17) - namespace TAOX11_NAMESPACE { namespace IDL @@ -25,20 +23,4 @@ namespace TAOX11_NAMESPACE } // namespace IDL } // namespace TAOX11_NAMESPACE -#else - -namespace TAOX11_NAMESPACE -{ - namespace IDL - { - template - class optional - { - public: - T value_; - }; - } -} -#endif - #endif // __IDL__OPTIONAL_T_H_INCLUDED__ diff --git a/tao/x11/portable_server/operation_table_std_map.h b/tao/x11/portable_server/operation_table_std_map.h index 1d804abb..93171d54 100644 --- a/tao/x11/portable_server/operation_table_std_map.h +++ b/tao/x11/portable_server/operation_table_std_map.h @@ -72,11 +72,7 @@ class TAOX11_PortableServer_Export Std_Map_OpTable final const TAO::Operation_Skeletons skel_ptr) override; private: -#if defined (ACE_HAS_CPP17) using key_map_type = std::string_view ; -#else - using key_map_type = std::string ; -#endif /* ACE_HAS_CPP17 */ using map_type = std::unordered_map; diff --git a/tao/x11/taox11.mpc b/tao/x11/taox11.mpc index b29487de..ee29a608 100644 --- a/tao/x11/taox11.mpc +++ b/tao/x11/taox11.mpc @@ -312,6 +312,8 @@ project(taox11) : taox11_defaults, taolib { object_ostream.h object_traits_t.h objproxy.h + optional_t.h + optional_cdr_t.h orb.h orb_constants.h orb_registry.h diff --git a/tests/idl4/optional/test.idl b/tests/idl4/optional/test.idl index 2af834f8..e47e3521 100644 --- a/tests/idl4/optional/test.idl +++ b/tests/idl4/optional/test.idl @@ -5,15 +5,11 @@ * @copyright Copyright (c) Remedy IT Expertise BV */ -typedef map StringLongMap; - -typedef string<650> bds; -typedef sequence bs; - struct bar { short x; string y; @optional short z; @optional short a; + @optional string opt_string; }; diff --git a/tests/idl4/optional/testC.cpp b/tests/idl4/optional/testC.cpp index 761ba3c8..af2d8f35 100644 --- a/tests/idl4/optional/testC.cpp +++ b/tests/idl4/optional/testC.cpp @@ -20,23 +20,6 @@ // generated from StubProxySourceCDRWriter#pre_visit TAO_BEGIN_VERSIONED_NAMESPACE_DECL -// generated from c++11/templates/cli/src/string_cdr -#if defined(_ALIAS_bds_CDR_OPS_IMPL_) -bool _cdr_in_bds ( - TAO_OutputCDR &strm, - const IDL::traits>::value_type &_bstr) -{ - return (strm << ACE_OutputCDR::from_std_string (_bstr, 650)); -} - -bool _cdr_out_bds ( - TAO_InputCDR &strm, - IDL::traits>::value_type &_bstr) -{ - return (strm >> ACE_InputCDR::to_std_string (_bstr, 650)); -} -#endif // _ALIAS_bds_CDR_OPS_IMPL_ - // generated from c++11/templates/cli/src/struct_cdr TAO_CORBA::Boolean operator<< (TAO_OutputCDR &strm, const bar &_tao_aggregate) { @@ -44,7 +27,8 @@ TAO_CORBA::Boolean operator<< (TAO_OutputCDR &strm, const bar &_tao_aggregate) (strm << _tao_aggregate.x ()) && (strm << _tao_aggregate.y ()) && (strm << _tao_aggregate.z ()) && - (strm << _tao_aggregate.a ()); + (strm << _tao_aggregate.a ()) && + (strm << _tao_aggregate.opt_string ()); } TAO_CORBA::Boolean operator>> (TAO_InputCDR &strm, bar &_tao_aggregate) @@ -53,39 +37,10 @@ TAO_CORBA::Boolean operator>> (TAO_InputCDR &strm, bar &_tao_aggregate) (strm >> _tao_aggregate.x ()) && (strm >> _tao_aggregate.y ()) && (strm >> _tao_aggregate.z ()) && - (strm >> _tao_aggregate.a ()); -} - -// Unaliased type : IDL::optional -// MD5 : 390A720FCF9D6B2326C7F41A8BC2534C -#if !defined(_CDR_390A720FCF9D6B2326C7F41A8BC2534C_OPTIONAL_IMPL_) -#define _CDR_390A720FCF9D6B2326C7F41A8BC2534C_OPTIONAL_IMPL_ -TAO_CORBA::Boolean operator<< (TAO_OutputCDR&strm, const IDL::optional&_val) -{ - return taox11_optional_cdr>::insert (strm, _val); -} - -TAO_CORBA::Boolean operator>> (TAO_InputCDR& strm, IDL::optional&_val) -{ - return taox11_optional_cdr>::extract (strm, _val); -} -#endif - -// Unaliased type : IDL::optional -// MD5 : 390A720FCF9D6B2326C7F41A8BC2534C -#if !defined(_CDR_390A720FCF9D6B2326C7F41A8BC2534C_OPTIONAL_IMPL_) -#define _CDR_390A720FCF9D6B2326C7F41A8BC2534C_OPTIONAL_IMPL_ -TAO_CORBA::Boolean operator<< (TAO_OutputCDR&strm, const IDL::optional&_val) -{ - return taox11_optional_cdr>::insert (strm, _val); + (strm >> _tao_aggregate.a ()) && + (strm >> _tao_aggregate.opt_string ()); } -TAO_CORBA::Boolean operator>> (TAO_InputCDR& strm, IDL::optional&_val) -{ - return taox11_optional_cdr>::extract (strm, _val); -} -#endif - TAO_END_VERSIONED_NAMESPACE_DECL // -*- END -*- diff --git a/tests/idl4/optional/testC.h b/tests/idl4/optional/testC.h index d2e0500e..fac9f547 100644 --- a/tests/idl4/optional/testC.h +++ b/tests/idl4/optional/testC.h @@ -6,8 +6,8 @@ * https://www.remedy.nl */ -#ifndef __RIDL_TESTC_H_DIFDHCCB_INCLUDED__ -#define __RIDL_TESTC_H_DIFDHCCB_INCLUDED__ +#ifndef __RIDL_TESTC_H_FAHJHHGA_INCLUDED__ +#define __RIDL_TESTC_H_FAHJHHGA_INCLUDED__ #pragma once @@ -15,10 +15,6 @@ #include "tao/x11/base/stddef.h" #include "tao/x11/base/basic_traits.h" #include "tao/x11/corba.h" -#include "map" -#include "tao/x11/base/bounded_string_t.h" -#include "tao/x11/base/bounded_type_traits_t.h" -#include "tao/x11/base/bounded_vector_t.h" #include "tao/x11/optional_t.h" #include /**/ "tao/x11/base/versionx11.h" @@ -29,18 +25,6 @@ using namespace TAOX11_NAMESPACE; -// generated from c++11/templates/cli/hdr/typedef -/// @copydoc test.idl::StringLongMap -using StringLongMap = std::map; - -// generated from c++11/templates/cli/hdr/typedef -/// @copydoc test.idl::bds -using bds = TAOX11_IDL::bounded_string<650>; - -// generated from c++11/templates/cli/hdr/typedef -/// @copydoc test.idl::bs -using bs = TAOX11_NAMESPACE::IDL::bounded_vector; - // generated from c++11/templates/cli/hdr/struct_pre /// @copydoc test.idl::bar class bar @@ -56,7 +40,8 @@ class bar int16_t x, std::string y, IDL::optional z, - IDL::optional a); + IDL::optional a, + IDL::optional opt_string); bar& operator= (const bar&) = default; bar& operator= (bar&&) = default; @@ -91,6 +76,14 @@ class bar inline IDL::optional& a () { return this->a_; } //@} + /// @copydoc test.idl::bar::opt_string + //@{ + inline void opt_string (const IDL::optional& _x11_opt_string) { this->opt_string_ = _x11_opt_string; } + inline void opt_string (IDL::optional&& _x11_opt_string) { this->opt_string_ = std::move (_x11_opt_string); } + inline const IDL::optional& opt_string () const { return this->opt_string_; } + inline IDL::optional& opt_string () { return this->opt_string_; } + //@} + /// Exchange the value of two structures in an efficient matter inline void swap (bar& s); @@ -99,6 +92,7 @@ class bar std::string y_{}; IDL::optional z_{std::nullopt}; IDL::optional a_{std::nullopt}; + IDL::optional opt_string_{std::nullopt}; };// bar inline void swap (::bar& m1, ::bar& m2) { m1.swap (m2); } @@ -107,145 +101,6 @@ inline void swap (::bar& m1, ::bar& m2) { m1.swap (m2); } namespace TAOX11_NAMESPACE::IDL { - // generated from c++11/templates/cli/hdr/map_idl_traits - // Unaliased type : std::map - // MD5 : 9591659AF1C35F72B6270EE9C6D3AFEF -#if !defined(_ALIAS_9591659AF1C35F72B6270EE9C6D3AFEF_TRAITS_DECL_) -#define _ALIAS_9591659AF1C35F72B6270EE9C6D3AFEF_TRAITS_DECL_ - - template<> - struct traits <::StringLongMap> - : IDL::common_traits<::StringLongMap> - { - /// std::false_type or std::true_type type indicating whether - /// this sequence is declared as bounded - using is_bounded = std::false_type; - /// IDL::traits<> for the key type of the sequence - using key_traits = IDL::traits; - /// IDL::traits<> for the value type of the sequence - using value_traits = IDL::traits; - - template > - static inline OStrm_& write_on( - OStrm_& os_, in_type val_, - Formatter fmt_ = Formatter ()) - { - return fmt_ (os_, val_); - } - - template - static inline __Writer write (in_type val) { return {val}; } - }; - - template - inline OStrm_& operator <<( - OStrm_& os, - IDL::traits<::StringLongMap>::__Writer w) - { - using writer_t = IDL::traits<::StringLongMap>::__Writer; - using formatter_t = typename std::conditional< - std::is_same< - typename writer_t::formatter_t, - std::false_type>::value, - formatter<::StringLongMap, OStrm_>, - typename writer_t::formatter_t>::type; - return IDL::traits<::StringLongMap>::write_on (os, w.val_, formatter_t ()); - } - -#endif - - // generated from c++11/templates/cli/hdr/string_idl_traits - // Unaliased type : TAOX11_IDL::bounded_string<650> - // MD5 : 8A4C2C8D2E43F29AF2FF47B029780F14 -#if !defined(_ALIAS_8A4C2C8D2E43F29AF2FF47B029780F14_TRAITS_DECL_) -#define _ALIAS_8A4C2C8D2E43F29AF2FF47B029780F14_TRAITS_DECL_ - - template<> - struct traits > - : IDL::common_traits> - , IDL::bounded_traits> - { - /// std::false_type or std::true_type type indicating whether - /// this string is declared as bounded - using is_bounded = std::true_type ; - /// IDL::traits<> for the element of the string - using element_traits = IDL::traits; - - template > - static inline OStrm_& write_on( - OStrm_& os_, in_type val_, - Formatter fmt_ = Formatter ()) - { - return fmt_ (os_, val_); - } - - template - static inline __Writer write (in_type val) { return {val}; } - }; - - template - inline OStrm_& operator <<( - OStrm_& os, - IDL::traits>::__Writer w) - { - using writer_t = IDL::traits>::__Writer; - using formatter_t = typename std::conditional< - std::is_same< - typename writer_t::formatter_t, - std::false_type>::value, - formatter, OStrm_>, - typename writer_t::formatter_t>::type; - return IDL::traits>::write_on (os, w.val_, formatter_t ()); - } - -#endif - - // generated from c++11/templates/cli/hdr/sequence_idl_traits - // Unaliased type : TAOX11_NAMESPACE::IDL::bounded_vector - // MD5 : D0B8C685EFADFAF646AABDA450D4F77E -#if !defined(_ALIAS_D0B8C685EFADFAF646AABDA450D4F77E_TRAITS_DECL_) -#define _ALIAS_D0B8C685EFADFAF646AABDA450D4F77E_TRAITS_DECL_ - - template<> - struct traits <::bs> - : IDL::common_traits<::bs> - , IDL::bounded_traits<::bs> - { - /// std::false_type or std::true_type type indicating whether - /// this sequence is declared as bounded - using is_bounded = std::true_type; - /// IDL::traits<> for the element of the sequence - using element_traits = IDL::traits; - - template > - static inline OStrm_& write_on( - OStrm_& os_, in_type val_, - Formatter fmt_ = Formatter ()) - { - return fmt_ (os_, val_); - } - - template - static inline __Writer write (in_type val) { return {val}; } - }; - - template - inline OStrm_& operator <<( - OStrm_& os, - IDL::traits<::bs>::__Writer w) - { - using writer_t = IDL::traits<::bs>::__Writer; - using formatter_t = typename std::conditional< - std::is_same< - typename writer_t::formatter_t, - std::false_type>::value, - formatter<::bs, OStrm_>, - typename writer_t::formatter_t>::type; - return IDL::traits<::bs>::write_on (os, w.val_, formatter_t ()); - } - -#endif - // generated from c++11/templates/cli/hdr/struct_idl_traits #if !defined (_STRUCT_BAR_TRAITS_) #define _STRUCT_BAR_TRAITS_ @@ -311,11 +166,13 @@ inline ::bar::bar ( int16_t x, std::string y, IDL::optional z, - IDL::optional a) + IDL::optional a, + IDL::optional opt_string) : x_ (std::move (x)) , y_ (std::move (y)) , z_ (std::move (z)) , a_ (std::move (a)) + , opt_string_ (std::move (opt_string)) { } @@ -325,34 +182,9 @@ inline void ::bar::swap (::bar& s) std::swap (this->y_, s.y_); std::swap (this->z_, s.z_); std::swap (this->a_, s.a_); + std::swap (this->opt_string_, s.opt_string_); } -// generated from c++11/templates/cli/hdr/map_os -// Unaliased type : std::map -// MD5 : 9591659AF1C35F72B6270EE9C6D3AFEF -#if !defined (_ALIAS_OSTREAM_9591659AF1C35F72B6270EE9C6D3AFEF_DECL_) -#define _ALIAS_OSTREAM_9591659AF1C35F72B6270EE9C6D3AFEF_DECL_ - -inline std::ostream& operator<< (std::ostream& strm, const ::StringLongMap& _v) -{ - return IDL::traits<::StringLongMap>::write_on (strm, _v); -} - -#endif // _ALIAS_OSTREAM_9591659AF1C35F72B6270EE9C6D3AFEF_DECL_ - -// generated from c++11/templates/cli/hdr/sequence_os -// Unaliased type : TAOX11_NAMESPACE::IDL::bounded_vector -// MD5 : D0B8C685EFADFAF646AABDA450D4F77E -#if !defined (_ALIAS_OSTREAM_D0B8C685EFADFAF646AABDA450D4F77E_DECL_) -#define _ALIAS_OSTREAM_D0B8C685EFADFAF646AABDA450D4F77E_DECL_ - -inline std::ostream& operator<< (std::ostream& strm, const ::bs& _v) -{ - return IDL::traits<::bs>::write_on (strm, _v); -} - -#endif // _ALIAS_OSTREAM_D0B8C685EFADFAF646AABDA450D4F77E_DECL_ - // generated from c++11/templates/cli/hdr/struct_os inline std::ostream& operator<< (std::ostream& strm, const ::bar& _v) { @@ -366,6 +198,6 @@ inline std::ostream& operator<< (std::ostream& strm, const ::bar& _v) #include /**/ "tao/x11/base/post.h" -#endif /* __RIDL_TESTC_H_DIFDHCCB_INCLUDED__ */ +#endif /* __RIDL_TESTC_H_FAHJHHGA_INCLUDED__ */ // -*- END -*- diff --git a/tests/idl4/optional/testCP.h b/tests/idl4/optional/testCP.h index eec4a2a8..deb97294 100644 --- a/tests/idl4/optional/testCP.h +++ b/tests/idl4/optional/testCP.h @@ -6,15 +6,14 @@ * https://www.remedy.nl */ -#ifndef __RIDL_TESTCP_H_GCEACAAC_INCLUDED__ -#define __RIDL_TESTCP_H_GCEACAAC_INCLUDED__ +#ifndef __RIDL_TESTCP_H_EEHHIGHB_INCLUDED__ +#define __RIDL_TESTCP_H_EEHHIGHB_INCLUDED__ #pragma once #include "tao/x11/anyinsert_policy_t.h" -#include "tao/x11/map_cdr_t.h" #include "tao/x11/basic_argument_t.h" -#include "tao/x11/sequence_cdr_t.h" +#include "tao/x11/optional_cdr_t.h" #include /**/ "tao/x11/base/versionx11.h" @@ -25,98 +24,6 @@ // generated from StubProxyHeaderObjRefTraitsWriter#pre_visit // generated from StubProxyHeaderCDRWriter#pre_visit -// generated from c++11/templates/cli/prx/map_cdr -// Unaliased type : std::map -// MD5 : 9591659AF1C35F72B6270EE9C6D3AFEF -#if !defined (_ALIAS_9591659AF1C35F72B6270EE9C6D3AFEF_ARG_TRAITS_) -#define _ALIAS_9591659AF1C35F72B6270EE9C6D3AFEF_ARG_TRAITS_ -/// Argument traits specializations for StringLongMap -template<> -class TAOX11_NAMESPACE::Arg_Traits<::StringLongMap> - : public Basic_Arg_Traits_T<::StringLongMap, Any_Insert_Policy_Noop> -{ -}; - -TAO_BEGIN_VERSIONED_NAMESPACE_DECL - -/// @name CDR streaming operator specializations for StringLongMap -//@{ -inline TAO_CORBA::Boolean operator<< (TAO_OutputCDR& cdr, const IDL::traits<::StringLongMap>::value_type& v) -{ - return taox11_map_cdr<::StringLongMap::key_type, ::StringLongMap::mapped_type>::insert (cdr, v); -} -inline TAO_CORBA::Boolean operator>> (TAO_InputCDR& cdr, IDL::traits<::StringLongMap>::value_type& v) -{ - return taox11_map_cdr<::StringLongMap::key_type, ::StringLongMap::mapped_type>::extract (cdr, v); -} -//@} - -TAO_END_VERSIONED_NAMESPACE_DECL -# endif // !_ALIAS_9591659AF1C35F72B6270EE9C6D3AFEF_ARG_TRAITS_ - -// generated from c++11/templates/cli/prx/string_cdr -// Unaliased type : TAOX11_IDL::bounded_string<650> -// MD5 : 8A4C2C8D2E43F29AF2FF47B029780F14 -#if !defined (_ALIAS_8A4C2C8D2E43F29AF2FF47B029780F14_ARG_TRAITS_) -#define _ALIAS_8A4C2C8D2E43F29AF2FF47B029780F14_ARG_TRAITS_ -/// Argument traits specializations for bds -template<> -class TAOX11_NAMESPACE::Arg_Traits> - : public Basic_Arg_Traits_T, Any_Insert_Policy_Noop> -{ -}; - -TAO_BEGIN_VERSIONED_NAMESPACE_DECL - -/// CDR streaming methods for bds -bool _cdr_in_bds (TAO_OutputCDR &, const IDL::traits>::value_type&); -bool _cdr_out_bds (TAO_InputCDR &, IDL::traits>::value_type&); -#define _ALIAS_bds_CDR_OPS_IMPL_ - -/// @name CDR streaming operator specializations for bds -//@{ -inline TAO_CORBA::Boolean operator<< (TAO_OutputCDR &cdr, const IDL::traits>::value_type &v) -{ - return _cdr_in_bds (cdr, v); -} -inline TAO_CORBA::Boolean operator>> (TAO_InputCDR &cdr, IDL::traits>::value_type& v) -{ - return _cdr_out_bds (cdr, v); -} -//@} - -TAO_END_VERSIONED_NAMESPACE_DECL -# endif // !_ALIAS_8A4C2C8D2E43F29AF2FF47B029780F14_ARG_TRAITS_ - -// generated from c++11/templates/cli/prx/sequence_cdr -// Unaliased type : TAOX11_NAMESPACE::IDL::bounded_vector -// MD5 : D0B8C685EFADFAF646AABDA450D4F77E -#if !defined (_ALIAS_D0B8C685EFADFAF646AABDA450D4F77E_ARG_TRAITS_) -#define _ALIAS_D0B8C685EFADFAF646AABDA450D4F77E_ARG_TRAITS_ -/// Argument traits specializations for bs -template<> -class TAOX11_NAMESPACE::Arg_Traits<::bs> - : public Basic_Arg_Traits_T<::bs, Any_Insert_Policy_Noop> -{ -}; - -TAO_BEGIN_VERSIONED_NAMESPACE_DECL - -/// @name CDR streaming operator specializations for bs -//@{ -inline TAO_CORBA::Boolean operator<< (TAO_OutputCDR &cdr, const IDL::traits<::bs>::value_type &v) -{ - return taox11_sequence_cdr<::bs::value_type>::insert<100U> (cdr, v); -} -inline TAO_CORBA::Boolean operator>> (TAO_InputCDR &cdr, IDL::traits<::bs>::value_type& v) -{ - return taox11_sequence_cdr<::bs::value_type>::extract<100U> (cdr, v); -} -//@} - -TAO_END_VERSIONED_NAMESPACE_DECL -# endif // !_ALIAS_D0B8C685EFADFAF646AABDA450D4F77E_ARG_TRAITS_ - // generated from c++11/templates/cli/prx/struct_cdr # if !defined (_BAR_TRAITS_) # define _BAR_TRAITS_ @@ -141,8 +48,14 @@ TAO_CORBA::Boolean operator>> (TAO_InputCDR&, bar&); #define _CDR_390A720FCF9D6B2326C7F41A8BC2534C_OPTIONAL_DECL_ /// @name CDR streaming operator specializations for IDL::optional //@{ -TAO_CORBA::Boolean operator<< (TAO_OutputCDR&, const IDL::optional&); -TAO_CORBA::Boolean operator>> (TAO_InputCDR&, IDL::optional&); +inline TAO_CORBA::Boolean operator<< (TAO_OutputCDR& _strm, const IDL::optional& _val) +{ + return taox11_optional_cdr>::insert (_strm, _val); +} +TAO_CORBA::Boolean operator>> (TAO_InputCDR& _strm, IDL::optional& _val) +{ + return taox11_optional_cdr>::extract (_strm, _val); +} //@} #endif // Unaliased type : IDL::optional @@ -151,14 +64,36 @@ TAO_CORBA::Boolean operator>> (TAO_InputCDR&, IDL::optional&); #define _CDR_390A720FCF9D6B2326C7F41A8BC2534C_OPTIONAL_DECL_ /// @name CDR streaming operator specializations for IDL::optional //@{ -TAO_CORBA::Boolean operator<< (TAO_OutputCDR&, const IDL::optional&); -TAO_CORBA::Boolean operator>> (TAO_InputCDR&, IDL::optional&); +inline TAO_CORBA::Boolean operator<< (TAO_OutputCDR& _strm, const IDL::optional& _val) +{ + return taox11_optional_cdr>::insert (_strm, _val); +} +TAO_CORBA::Boolean operator>> (TAO_InputCDR& _strm, IDL::optional& _val) +{ + return taox11_optional_cdr>::extract (_strm, _val); +} +//@} +#endif +// Unaliased type : IDL::optional +// MD5 : A982838BA1CB55023DC96331D8B18A34 +#if !defined(_CDR_A982838BA1CB55023DC96331D8B18A34_OPTIONAL_DECL_) +#define _CDR_A982838BA1CB55023DC96331D8B18A34_OPTIONAL_DECL_ +/// @name CDR streaming operator specializations for IDL::optional +//@{ +inline TAO_CORBA::Boolean operator<< (TAO_OutputCDR& _strm, const IDL::optional& _val) +{ + return taox11_optional_cdr>::insert (_strm, _val); +} +TAO_CORBA::Boolean operator>> (TAO_InputCDR& _strm, IDL::optional& _val) +{ + return taox11_optional_cdr>::extract (_strm, _val); +} //@} #endif TAO_END_VERSIONED_NAMESPACE_DECL -#endif /* __RIDL_TESTCP_H_GCEACAAC_INCLUDED__ */ +#endif /* __RIDL_TESTCP_H_EEHHIGHB_INCLUDED__ */ // -*- END -*- diff --git a/tests/interface/client.cpp b/tests/interface/client.cpp index a22c777f..9113ea93 100644 --- a/tests/interface/client.cpp +++ b/tests/interface/client.cpp @@ -61,7 +61,6 @@ int main(int argc, char* argv[]) IDL::traits::ref_type obj2; std::swap (obj, obj2); std::swap (obj, obj2); -#if defined (ACE_HAS_CPP17) if (!std::is_swappable::ref_type>()) { TAOX11_TEST_ERROR << "ERROR: IDL::traits::ref_type is not swappable." << std::endl; @@ -71,7 +70,6 @@ int main(int argc, char* argv[]) { TAOX11_TEST_DEBUG << "IDL::traits::ref_type is swappable." << std::endl; } -#endif /* ACE_HAS_CPP17 */ if (!test_nil_invocation()) ++result; diff --git a/tests/struct/client.cpp b/tests/struct/client.cpp index 2c79208e..5ca32df9 100644 --- a/tests/struct/client.cpp +++ b/tests/struct/client.cpp @@ -106,7 +106,6 @@ int main(int argc, char* argv[]) V s5; V s6; test_swap (s5, s6); -#if defined (ACE_HAS_CPP17) if (!std::is_swappable()) { TAOX11_TEST_ERROR << "ERROR: V is not swappable." << std::endl; @@ -116,7 +115,6 @@ int main(int argc, char* argv[]) { TAOX11_TEST_DEBUG << "V is swappable." << std::endl; } -#endif /* ACE_HAS_CPP17 */ TAOX11_TEST_DEBUG << "successfully called Foo::update_struct (" << simple3 << ") => " << simple4 << std::endl; diff --git a/tests/union/client.cpp b/tests/union/client.cpp index 24150340..64e2db25 100644 --- a/tests/union/client.cpp +++ b/tests/union/client.cpp @@ -26,7 +26,6 @@ test_data_union (IDL::traits::ref_type foo) data.pointData (Test::Point (12, 34)); retval += check_union (data, Test::DataType::dtPoint, "before pass_union"); -#if defined (ACE_HAS_CPP17) if (!std::is_swappable()) { TAOX11_TEST_ERROR << "ERROR: V is not swappable." << std::endl; @@ -36,7 +35,6 @@ test_data_union (IDL::traits::ref_type foo) { TAOX11_TEST_DEBUG << "Test::Data is swappable." << std::endl; } -#endif /* ACE_HAS_CPP17 */ if (foo->pass_union (data)) { From 879a09bfa66e89c093395c1f2e7118193d484c7d Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Mon, 27 May 2024 10:22:47 +0200 Subject: [PATCH 5/7] Removed generated fiels --- tests/idl4/optional/testC.cpp | 46 -------- tests/idl4/optional/testC.h | 203 ---------------------------------- tests/idl4/optional/testCP.h | 99 ----------------- 3 files changed, 348 deletions(-) delete mode 100644 tests/idl4/optional/testC.cpp delete mode 100644 tests/idl4/optional/testC.h delete mode 100644 tests/idl4/optional/testCP.h diff --git a/tests/idl4/optional/testC.cpp b/tests/idl4/optional/testC.cpp deleted file mode 100644 index af2d8f35..00000000 --- a/tests/idl4/optional/testC.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/** - * **** Code generated by the RIDL Compiler **** - * RIDL has been developed by: - * Remedy IT Expertise BV - * The Netherlands - * https://www.remedy.nl - */ - -#define __TAOX11_INCLUDE_STUB_PROXY__ - -#if __has_include("tao/x11/base/tao_corba.h") -# include "tao/x11/base/tao_corba.h" -#endif -#include "tao/CDR.h" -#include "tao/x11/basic_arguments.h" -#include "tao/x11/cdr_long_double.h" -#include "tao/x11/base/tao_corba.h" - -#include "testC.h" -// generated from StubProxySourceCDRWriter#pre_visit -TAO_BEGIN_VERSIONED_NAMESPACE_DECL - -// generated from c++11/templates/cli/src/struct_cdr -TAO_CORBA::Boolean operator<< (TAO_OutputCDR &strm, const bar &_tao_aggregate) -{ - return - (strm << _tao_aggregate.x ()) && - (strm << _tao_aggregate.y ()) && - (strm << _tao_aggregate.z ()) && - (strm << _tao_aggregate.a ()) && - (strm << _tao_aggregate.opt_string ()); -} - -TAO_CORBA::Boolean operator>> (TAO_InputCDR &strm, bar &_tao_aggregate) -{ - return - (strm >> _tao_aggregate.x ()) && - (strm >> _tao_aggregate.y ()) && - (strm >> _tao_aggregate.z ()) && - (strm >> _tao_aggregate.a ()) && - (strm >> _tao_aggregate.opt_string ()); -} - -TAO_END_VERSIONED_NAMESPACE_DECL - -// -*- END -*- diff --git a/tests/idl4/optional/testC.h b/tests/idl4/optional/testC.h deleted file mode 100644 index fac9f547..00000000 --- a/tests/idl4/optional/testC.h +++ /dev/null @@ -1,203 +0,0 @@ -/** - * **** Code generated by the RIDL Compiler **** - * RIDL has been developed by: - * Remedy IT Expertise BV - * The Netherlands - * https://www.remedy.nl - */ - -#ifndef __RIDL_TESTC_H_FAHJHHGA_INCLUDED__ -#define __RIDL_TESTC_H_FAHJHHGA_INCLUDED__ - -#pragma once - -#include /**/ "tao/x11/base/pre.h" -#include "tao/x11/base/stddef.h" -#include "tao/x11/base/basic_traits.h" -#include "tao/x11/corba.h" -#include "tao/x11/optional_t.h" - -#include /**/ "tao/x11/base/versionx11.h" - -#if TAOX11_MAJOR_VERSION != 2 || TAOX11_MINOR_VERSION != 6 || TAOX11_MICRO_VERSION != 0 -#error This file was generated with another RIDL C++11 backend version (2.6.0). Please re-generate. -#endif - -using namespace TAOX11_NAMESPACE; - -// generated from c++11/templates/cli/hdr/struct_pre -/// @copydoc test.idl::bar -class bar -{ -public: - // generated from c++11/templates/cli/hdr/struct_post - bar () = default; - ~bar () = default; - bar (const bar&) = default; - bar (bar&&) = default; - /// Constructor which accepts value for all members - explicit inline bar ( - int16_t x, - std::string y, - IDL::optional z, - IDL::optional a, - IDL::optional opt_string); - bar& operator= (const bar&) = default; - bar& operator= (bar&&) = default; - - /// @copydoc test.idl::bar::x - //@{ - inline void x (int16_t _x11_x) { this->x_ = _x11_x; } - inline int16_t x () const { return this->x_; } - inline int16_t& x () { return this->x_; } - //@} - - /// @copydoc test.idl::bar::y - //@{ - inline void y (const std::string& _x11_y) { this->y_ = _x11_y; } - inline void y (std::string&& _x11_y) { this->y_ = std::move (_x11_y); } - inline const std::string& y () const { return this->y_; } - inline std::string& y () { return this->y_; } - //@} - - /// @copydoc test.idl::bar::z - //@{ - inline void z (const IDL::optional& _x11_z) { this->z_ = _x11_z; } - inline void z (IDL::optional&& _x11_z) { this->z_ = std::move (_x11_z); } - inline const IDL::optional& z () const { return this->z_; } - inline IDL::optional& z () { return this->z_; } - //@} - - /// @copydoc test.idl::bar::a - //@{ - inline void a (const IDL::optional& _x11_a) { this->a_ = _x11_a; } - inline void a (IDL::optional&& _x11_a) { this->a_ = std::move (_x11_a); } - inline const IDL::optional& a () const { return this->a_; } - inline IDL::optional& a () { return this->a_; } - //@} - - /// @copydoc test.idl::bar::opt_string - //@{ - inline void opt_string (const IDL::optional& _x11_opt_string) { this->opt_string_ = _x11_opt_string; } - inline void opt_string (IDL::optional&& _x11_opt_string) { this->opt_string_ = std::move (_x11_opt_string); } - inline const IDL::optional& opt_string () const { return this->opt_string_; } - inline IDL::optional& opt_string () { return this->opt_string_; } - //@} - - /// Exchange the value of two structures in an efficient matter - inline void swap (bar& s); - -private: - int16_t x_{}; - std::string y_{}; - IDL::optional z_{std::nullopt}; - IDL::optional a_{std::nullopt}; - IDL::optional opt_string_{std::nullopt}; -};// bar - -inline void swap (::bar& m1, ::bar& m2) { m1.swap (m2); } - -// generated from StubHeaderIDLTraitsWriter#pre_visit -namespace TAOX11_NAMESPACE::IDL -{ - - // generated from c++11/templates/cli/hdr/struct_idl_traits -#if !defined (_STRUCT_BAR_TRAITS_) -#define _STRUCT_BAR_TRAITS_ - template<> - struct traits <::bar> - : IDL::common_traits<::bar> - { - template > - static inline OStrm_& write_on(OStrm_& os_, in_type val_, Formatter fmt_ = Formatter ()) - { - return fmt_ (os_, val_); - } - - template - static inline __Writer write (in_type val) { return {val}; } - }; - - template - struct formatter<::bar, OStrm_>; - - template - OStrm_& operator <<(OStrm_&, IDL::traits<::bar>::__Writer); -#endif // _STRUCT_BAR_TRAITS_ -} // namespace TAOX11_NAMESPACE::IDL - -// generated from StubHeaderIDLTraitsDefWriter#pre_visit -namespace TAOX11_NAMESPACE::IDL -{ - - // generated from c++11/templates/cli/hdr/struct_idl_traits_def - template - struct formatter<::bar, OStrm_> - { - inline OStrm_& operator ()( - OStrm_& os_, - const ::bar& val_) - { - os_ << "bar" - << '{' - << "x=" << IDL::traits::write(val_.x ()) - << ",y=" << IDL::traits::write(val_.y ()) - << '}'; - return os_; - } - }; - - template - inline OStrm_& operator <<(OStrm_& os, IDL::traits<::bar>::__Writer w) - { - using writer_t = IDL::traits<::bar>::__Writer; - using formatter_t = typename std::conditional< - std::is_same< - typename writer_t::formatter_t, - std::false_type>::value, - formatter<::bar, OStrm_>, - typename writer_t::formatter_t>::type; - return IDL::traits<::bar>::write_on (os, w.val_, formatter_t ()); - } -} // namespace TAOX11_NAMESPACE::IDL - -// generated from c++11/templates/cli/inl/struct_inl -inline ::bar::bar ( - int16_t x, - std::string y, - IDL::optional z, - IDL::optional a, - IDL::optional opt_string) - : x_ (std::move (x)) - , y_ (std::move (y)) - , z_ (std::move (z)) - , a_ (std::move (a)) - , opt_string_ (std::move (opt_string)) -{ -} - -inline void ::bar::swap (::bar& s) -{ - std::swap (this->x_, s.x_); - std::swap (this->y_, s.y_); - std::swap (this->z_, s.z_); - std::swap (this->a_, s.a_); - std::swap (this->opt_string_, s.opt_string_); -} - -// generated from c++11/templates/cli/hdr/struct_os -inline std::ostream& operator<< (std::ostream& strm, const ::bar& _v) -{ - return IDL::traits<::bar>::write_on (strm, _v); -} - -// generated from c++11/templates/cli/hdr/post -#if !defined (TAOX11_DISABLE_INCLUDE_STUB_PROXY_HDR) && defined (__TAOX11_INCLUDE_STUB_PROXY__) && __has_include("testCP.h") -# include "testCP.h" -#endif - -#include /**/ "tao/x11/base/post.h" - -#endif /* __RIDL_TESTC_H_FAHJHHGA_INCLUDED__ */ - -// -*- END -*- diff --git a/tests/idl4/optional/testCP.h b/tests/idl4/optional/testCP.h deleted file mode 100644 index deb97294..00000000 --- a/tests/idl4/optional/testCP.h +++ /dev/null @@ -1,99 +0,0 @@ -/** - * **** Code generated by the RIDL Compiler **** - * RIDL has been developed by: - * Remedy IT Expertise BV - * The Netherlands - * https://www.remedy.nl - */ - -#ifndef __RIDL_TESTCP_H_EEHHIGHB_INCLUDED__ -#define __RIDL_TESTCP_H_EEHHIGHB_INCLUDED__ - -#pragma once - -#include "tao/x11/anyinsert_policy_t.h" -#include "tao/x11/basic_argument_t.h" -#include "tao/x11/optional_cdr_t.h" - -#include /**/ "tao/x11/base/versionx11.h" - -#if TAOX11_MAJOR_VERSION != 2 || TAOX11_MINOR_VERSION != 6 || TAOX11_MICRO_VERSION != 0 -#error This file was generated with another RIDL C++11 backend version (2.6.0). Please re-generate. -#endif - -// generated from StubProxyHeaderObjRefTraitsWriter#pre_visit -// generated from StubProxyHeaderCDRWriter#pre_visit - -// generated from c++11/templates/cli/prx/struct_cdr -# if !defined (_BAR_TRAITS_) -# define _BAR_TRAITS_ -/// Argument traits specializations for bar -template<> -class TAOX11_NAMESPACE::Arg_Traits<::bar> - : public Basic_Arg_Traits_T<::bar, Any_Insert_Policy_Noop> -{ -}; -# endif // !_BAR_TRAITS_ - -TAO_BEGIN_VERSIONED_NAMESPACE_DECL - -/// @name CDR streaming operator specializations for bar -//@{ -TAO_CORBA::Boolean operator<< (TAO_OutputCDR&, const bar&); -TAO_CORBA::Boolean operator>> (TAO_InputCDR&, bar&); -//@} -// Unaliased type : IDL::optional -// MD5 : 390A720FCF9D6B2326C7F41A8BC2534C -#if !defined(_CDR_390A720FCF9D6B2326C7F41A8BC2534C_OPTIONAL_DECL_) -#define _CDR_390A720FCF9D6B2326C7F41A8BC2534C_OPTIONAL_DECL_ -/// @name CDR streaming operator specializations for IDL::optional -//@{ -inline TAO_CORBA::Boolean operator<< (TAO_OutputCDR& _strm, const IDL::optional& _val) -{ - return taox11_optional_cdr>::insert (_strm, _val); -} -TAO_CORBA::Boolean operator>> (TAO_InputCDR& _strm, IDL::optional& _val) -{ - return taox11_optional_cdr>::extract (_strm, _val); -} -//@} -#endif -// Unaliased type : IDL::optional -// MD5 : 390A720FCF9D6B2326C7F41A8BC2534C -#if !defined(_CDR_390A720FCF9D6B2326C7F41A8BC2534C_OPTIONAL_DECL_) -#define _CDR_390A720FCF9D6B2326C7F41A8BC2534C_OPTIONAL_DECL_ -/// @name CDR streaming operator specializations for IDL::optional -//@{ -inline TAO_CORBA::Boolean operator<< (TAO_OutputCDR& _strm, const IDL::optional& _val) -{ - return taox11_optional_cdr>::insert (_strm, _val); -} -TAO_CORBA::Boolean operator>> (TAO_InputCDR& _strm, IDL::optional& _val) -{ - return taox11_optional_cdr>::extract (_strm, _val); -} -//@} -#endif -// Unaliased type : IDL::optional -// MD5 : A982838BA1CB55023DC96331D8B18A34 -#if !defined(_CDR_A982838BA1CB55023DC96331D8B18A34_OPTIONAL_DECL_) -#define _CDR_A982838BA1CB55023DC96331D8B18A34_OPTIONAL_DECL_ -/// @name CDR streaming operator specializations for IDL::optional -//@{ -inline TAO_CORBA::Boolean operator<< (TAO_OutputCDR& _strm, const IDL::optional& _val) -{ - return taox11_optional_cdr>::insert (_strm, _val); -} -TAO_CORBA::Boolean operator>> (TAO_InputCDR& _strm, IDL::optional& _val) -{ - return taox11_optional_cdr>::extract (_strm, _val); -} -//@} -#endif - -TAO_END_VERSIONED_NAMESPACE_DECL - - -#endif /* __RIDL_TESTCP_H_EEHHIGHB_INCLUDED__ */ - -// -*- END -*- From 6bdae5cde0f8f47c9261d2e137f7bd077ea037ce Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Mon, 27 May 2024 10:23:22 +0200 Subject: [PATCH 6/7] Removed hack code * ridlbe/c++11/visitors/struct.rb: --- ridlbe/c++11/visitors/struct.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ridlbe/c++11/visitors/struct.rb b/ridlbe/c++11/visitors/struct.rb index 9b840014..c8aa5a64 100644 --- a/ridlbe/c++11/visitors/struct.rb +++ b/ridlbe/c++11/visitors/struct.rb @@ -29,10 +29,6 @@ def is_exception? false end - def has_optional? - true - end - # Return the base of this struct, nil in case of no base struct def base node.base From 7ac448238195f11b946e13230c2595bdb0d5371e Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Mon, 27 May 2024 11:42:21 +0200 Subject: [PATCH 7/7] Add missing whitespace * tao/x11/optional_cdr_t.h: --- tao/x11/optional_cdr_t.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tao/x11/optional_cdr_t.h b/tao/x11/optional_cdr_t.h index 1d9742c3..37a09326 100644 --- a/tao/x11/optional_cdr_t.h +++ b/tao/x11/optional_cdr_t.h @@ -53,7 +53,7 @@ TAO_BEGIN_VERSIONED_NAMESPACE_DECL if (_strm >> temp_val) { // set union member and associated discriminant when there are multiple legal discriminant values - _optional= std::move (temp_val); + _optional = std::move (temp_val); return true; } }