From e398893379a2100c020f967b11516f86845e805f Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Wed, 4 Sep 2024 16:05:57 +0200 Subject: [PATCH] Removed special dds_init/dds_finalize calls, use RTI -constructor argument to let the RTI generate code allocate the memory instead that we do it in our code * ddsx11/vendors/ndds/ridlbe/ccmx11/facets/dds4ndds/templates/udt_traits/ndds/life_cycle_traits.erb: Deleted. * ddsx11/dds/dds_conversion_traits.h: * ddsx11/docs/src/ridlc.asc: * ddsx11/vendors/ndds/MPC/config/ddsx11_vendor_ts_defaults.mpb: * ddsx11/vendors/ndds/dds/ndds_base_traits.h: * ddsx11/vendors/ndds/idl/ddsx11_ndds_stub.mpc: * ddsx11/vendors/ndds/ridlbe/ccmx11/facets/dds4ndds/config.rb: * ddsx11/vendors/ndds/ridlbe/ccmx11/facets/dds4ndds/writers/udttraits_extensions.rb: * ddsx11/vendors/opendds/dds/base_traits.h: * ridlbe/ccmx11/facets/dds/templates/udt_traits/array.erb: * ridlbe/ccmx11/facets/dds/templates/udt_traits/struct.erb: * ridlbe/ccmx11/facets/dds/templates/udt_traits/union.erb: --- ddsx11/dds/dds_conversion_traits.h | 32 +++---------- ddsx11/docs/src/ridlc.asc | 3 -- .../MPC/config/ddsx11_vendor_ts_defaults.mpb | 2 +- ddsx11/vendors/ndds/dds/ndds_base_traits.h | 4 -- ddsx11/vendors/ndds/idl/ddsx11_ndds_stub.mpc | 3 +- .../ridlbe/ccmx11/facets/dds4ndds/config.rb | 24 ---------- .../udt_traits/ndds/life_cycle_traits.erb | 48 ------------------- .../dds4ndds/writers/udttraits_extensions.rb | 14 ------ ddsx11/vendors/opendds/dds/base_traits.h | 2 +- .../facets/dds/templates/udt_traits/array.erb | 2 - .../dds/templates/udt_traits/struct.erb | 2 - .../facets/dds/templates/udt_traits/union.erb | 2 - 12 files changed, 10 insertions(+), 128 deletions(-) delete mode 100644 ddsx11/vendors/ndds/ridlbe/ccmx11/facets/dds4ndds/templates/udt_traits/ndds/life_cycle_traits.erb diff --git a/ddsx11/dds/dds_conversion_traits.h b/ddsx11/dds/dds_conversion_traits.h index 6218ae43d..f9519b20f 100644 --- a/ddsx11/dds/dds_conversion_traits.h +++ b/ddsx11/dds/dds_conversion_traits.h @@ -66,18 +66,6 @@ namespace DDSX11 { __from_dds (to, from, std::is_enum()); return to; } //@} - /** - * Default DDS_DATA_TYPE life cycle methods. - */ - //@{ - template - void dds_init (DDS_DATA_TYPE&) - { } - template - void dds_finalize (DDS_DATA_TYPE&) - { } - //@} - /** * Converting DDS argument traits */ @@ -91,9 +79,9 @@ namespace DDSX11 typedef DDS_DATA_TYPE dds_in_type; dds_in_type value_; - in () { ::DDSX11::dds_init (value_); } - in (const in_type& v) { ::DDSX11::dds_init (value_); ::DDSX11::to_dds (this->value_, v); } - ~in () { ::DDSX11::dds_finalize (value_); } + in () = default; + in (const in_type& v) { ::DDSX11::to_dds (this->value_, v); } + ~in () = default; in& operator =(const in_type& v) { ::DDSX11::to_dds (this->value_, v); return *this; } operator const dds_in_type& () const { return this->value_; } }; @@ -140,11 +128,8 @@ namespace DDSX11 out_type& value_; dds_out_type dds_value_; - out (out_type& v) : value_ (v) { ::DDSX11::dds_init (this->dds_value_); } - ~out () { - ::DDSX11::from_dds (this->value_, this->dds_value_); - ::DDSX11::dds_finalize (this->dds_value_); - } + out (out_type& v) : value_ (v) {} + ~out () { ::DDSX11::from_dds (this->value_, this->dds_value_); } operator dds_out_type& () { return this->dds_value_; } }; @@ -165,11 +150,8 @@ namespace DDSX11 out_type* value_; dds_out_type dds_value_; - out (out_type* v) : value_ (v) { ::DDSX11::dds_init (this->dds_value_); } - ~out () { - ::DDSX11::from_dds (*this->value_, this->dds_value_); - ::DDSX11::dds_finalize (this->dds_value_); - } + out (out_type* v) : value_ (v) {} + ~out () { ::DDSX11::from_dds (*this->value_, this->dds_value_); } operator dds_out_type* () { return &this->dds_value_; } }; diff --git a/ddsx11/docs/src/ridlc.asc b/ddsx11/docs/src/ridlc.asc index 2cadd2216..52d8701e5 100644 --- a/ddsx11/docs/src/ridlc.asc +++ b/ddsx11/docs/src/ridlc.asc @@ -28,7 +28,4 @@ Generate all DDSX11 related files |-Gddsx11,traits | | Generate user defined conversion traits for DDSX11 -|-Sddsx11,nddslfc | | -Do not generate life cycle traits for DDSX11 NDDS support(generated by default). *DDSX11 core use only.* - |======================================================================= diff --git a/ddsx11/vendors/ndds/MPC/config/ddsx11_vendor_ts_defaults.mpb b/ddsx11/vendors/ndds/MPC/config/ddsx11_vendor_ts_defaults.mpb index e22280fe4..48b55541c 100644 --- a/ddsx11/vendors/ndds/MPC/config/ddsx11_vendor_ts_defaults.mpb +++ b/ddsx11/vendors/ndds/MPC/config/ddsx11_vendor_ts_defaults.mpb @@ -7,7 +7,7 @@ // -------------------------------------------------------------------- feature(ddsx11, ndds) : ndds_ts_defaults { - ndds_ts_flags += -update typefiles -enableEscapeChar -typeSequenceSuffix RTISeq -language C++98 -namespace + ndds_ts_flags += -update typefiles -enableEscapeChar -typeSequenceSuffix RTISeq -language C++98 -namespace -constructor Define_Custom(TypeSupport) { } Define_Custom(DummyTypeSupport) { diff --git a/ddsx11/vendors/ndds/dds/ndds_base_traits.h b/ddsx11/vendors/ndds/dds/ndds_base_traits.h index fe52f2888..abb34871a 100644 --- a/ddsx11/vendors/ndds/dds/ndds_base_traits.h +++ b/ddsx11/vendors/ndds/dds/ndds_base_traits.h @@ -153,10 +153,6 @@ namespace DDSX11 inline std::string& from_dds (std::string& to, char* const & from) { if (from) to = from; else to.clear (); return to; } - template <> - inline void dds_init (char*& sample) - { sample = nullptr; } - template <> struct traits : public common_traits, diff --git a/ddsx11/vendors/ndds/idl/ddsx11_ndds_stub.mpc b/ddsx11/vendors/ndds/idl/ddsx11_ndds_stub.mpc index a2ec4d516..f24f702cd 100644 --- a/ddsx11/vendors/ndds/idl/ddsx11_ndds_stub.mpc +++ b/ddsx11/vendors/ndds/idl/ddsx11_ndds_stub.mpc @@ -22,8 +22,7 @@ project (ddsx11_ndds_dcps_all_idl_gen) : install, \ ddsx11_ndds_conversion_traits { after += ddsx11_ndds_types_idl_gen custom_only = 1 - idlflags += -Sddsx11,nddslfc \ - -Wb,stub_export_macro=DDSX11_NDDS_STUB_Export \ + idlflags += -Wb,stub_export_macro=DDSX11_NDDS_STUB_Export \ -Wb,stub_export_include=ddsx11_ndds_stub_export.h -Scph IDL_Files { diff --git a/ddsx11/vendors/ndds/ridlbe/ccmx11/facets/dds4ndds/config.rb b/ddsx11/vendors/ndds/ridlbe/ccmx11/facets/dds4ndds/config.rb index 6511a42a1..0ae6eeb5b 100644 --- a/ddsx11/vendors/ndds/ridlbe/ccmx11/facets/dds4ndds/config.rb +++ b/ddsx11/vendors/ndds/ridlbe/ccmx11/facets/dds4ndds/config.rb @@ -26,30 +26,6 @@ module NDDS fctcfg.depends_on :dds fctcfg.setup_after :dds - # setup facet option handling - # - fctcfg.on_setup do |optlist, ridl_params| - # extend DDS facet options - optlist.for_switch '-S{suppression options}', type: String, separator: true do |swcfg| - swcfg.for_group :ddsx11_group do |grpcfg| - grpcfg.on_prepare do |arg, params| - if /^ddsx11\,(.*)/ =~ arg - return [$1] - end - - nil - end - grpcfg.modify_params :strings, - params: { - 'nddslfc' => { - option_name: :nogen_life_cycle_traits_for_ndds, - description: "-Sddsx11,nddslfc\t\tSuppress generation of life cycle traits for DDSX11 NDDS support (generated by default)" - } - } - end - end - end - # process input / generate code # arguments: # in parser - parser object with full AST from parsed source diff --git a/ddsx11/vendors/ndds/ridlbe/ccmx11/facets/dds4ndds/templates/udt_traits/ndds/life_cycle_traits.erb b/ddsx11/vendors/ndds/ridlbe/ccmx11/facets/dds4ndds/templates/udt_traits/ndds/life_cycle_traits.erb deleted file mode 100644 index 3c8a8ca71..000000000 --- a/ddsx11/vendors/ndds/ridlbe/ccmx11/facets/dds4ndds/templates/udt_traits/ndds/life_cycle_traits.erb +++ /dev/null @@ -1,48 +0,0 @@ -%if generate_lifecycle_traits? - // generated from <%= ridl_template_path %> - - /// Life cycle management for <%= scoped_cxxname %> native DDS type - template<> - inline void dds_init (<%= native_scoped_cxxtype %>& sample) -% if is_visitor_type?(IDL::CCMX11::StructVisitor) - { -% members.each do |_m| - ::DDSX11::dds_init (sample.<%= _m.cxxname %>); -% end - } -% elsif is_visitor_type?(IDL::CCMX11::UnionVisitor) - { -% members.each do |_m| - ::DDSX11::dds_init (sample._u.<%= _m.cxxname %>); -% end - ::DDSX11::dds_init (sample._d); - } -% else - { -% _arr_iter = 0 -% _dimensions = '' -% cxxdim_sizes.each do |_s| -% _iter="iter_#{_arr_iter}" -% _dimensions = _dimensions + "[#{_iter}]" -% inc_nest - for (<%= scoped_cxxtype %>::size_type <%= _iter %> {}; <%= _iter %> <<%= cxxdim_sizes[_arr_iter] %>; ++<%= _iter %>) - { -% _arr_iter = _arr_iter + 1 -% end -% inc_nest - ::DDSX11::dds_init (sample<%= _dimensions %>); -% cxxdim_sizes.each do |_s| -% dec_nest - } -% end -% dec_nest - } -% end -% if has_toplevel_annotation? - template<> - inline void dds_finalize (<%= native_scoped_cxxtype %>& sample) - { - <%= native_scoped_cxxtype %>_finalize (std::addressof (sample)); - } -% end -%end diff --git a/ddsx11/vendors/ndds/ridlbe/ccmx11/facets/dds4ndds/writers/udttraits_extensions.rb b/ddsx11/vendors/ndds/ridlbe/ccmx11/facets/dds4ndds/writers/udttraits_extensions.rb index 4f9e17b72..4a6412c93 100644 --- a/ddsx11/vendors/ndds/ridlbe/ccmx11/facets/dds4ndds/writers/udttraits_extensions.rb +++ b/ddsx11/vendors/ndds/ridlbe/ccmx11/facets/dds4ndds/writers/udttraits_extensions.rb @@ -12,20 +12,6 @@ module CCMX11 module DDSX11 module NDDS module UserDefinedTypeTraitsWriterExt - module WriterExtension - def self.included(base) - base.class_eval do - # add life cycle traits generation helper method - - helper_method :generate_lifecycle_traits? - - def generate_lifecycle_traits? - params[:nogen_life_cycle_traits_for_ndds] ? false : true - end - end - end - end - def self.configure_extension(writer) IDL.log(3, 'Configuring DDS4NDDS UserDefinedTypeTraitsWriterExt extension') # make writer look for templates in ndds folder first diff --git a/ddsx11/vendors/opendds/dds/base_traits.h b/ddsx11/vendors/opendds/dds/base_traits.h index ac3dde3eb..c4bf18542 100644 --- a/ddsx11/vendors/opendds/dds/base_traits.h +++ b/ddsx11/vendors/opendds/dds/base_traits.h @@ -189,7 +189,7 @@ namespace DDSX11 in () {} in (const in_type& v) { ::DDSX11::to_dds (this->value_, v); } - ~in () { ::DDSX11::dds_finalize (value_); } + ~in () {} in& operator =(const in_type& v) { ::DDSX11::to_dds (this->value_, v); return *this; } operator dds_in_type () const { return this->value_; } }; diff --git a/ridlbe/ccmx11/facets/dds/templates/udt_traits/array.erb b/ridlbe/ccmx11/facets/dds/templates/udt_traits/array.erb index d3a50ef94..7abb9f10d 100644 --- a/ridlbe/ccmx11/facets/dds/templates/udt_traits/array.erb +++ b/ridlbe/ccmx11/facets/dds/templates/udt_traits/array.erb @@ -60,8 +60,6 @@ namespace DDSX11 return to; } -%visit_life_cycle_traits - template<> struct traits<<%= scoped_cxxtype %>> : public common_traits<<%= scoped_cxxtype %>, <%= dds_native_element_cxxtype %>>, diff --git a/ridlbe/ccmx11/facets/dds/templates/udt_traits/struct.erb b/ridlbe/ccmx11/facets/dds/templates/udt_traits/struct.erb index d423d967a..665fb39de 100644 --- a/ridlbe/ccmx11/facets/dds/templates/udt_traits/struct.erb +++ b/ridlbe/ccmx11/facets/dds/templates/udt_traits/struct.erb @@ -32,8 +32,6 @@ namespace DDSX11 return to; } -%visit_life_cycle_traits - /** * DDSX11 traits for <%= scoped_cxxname %> */ diff --git a/ridlbe/ccmx11/facets/dds/templates/udt_traits/union.erb b/ridlbe/ccmx11/facets/dds/templates/udt_traits/union.erb index e5bdeead0..a2123d0b9 100644 --- a/ridlbe/ccmx11/facets/dds/templates/udt_traits/union.erb +++ b/ridlbe/ccmx11/facets/dds/templates/udt_traits/union.erb @@ -26,8 +26,6 @@ namespace DDSX11 %nest(2) { visit_template('union_from') } } -%visit_life_cycle_traits - template<> struct traits<<%= scoped_cxxtype %>> : public common_traits<<%= scoped_cxxtype %>, <%= native_scoped_cxxtype %>>