From a8d041609571b460f710f1bf83d11479d8742032 Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Fri, 3 May 2024 16:01:50 +0200 Subject: [PATCH] Reduce includes, don't generate empty servant_traits namespace * ridlbe/c++11/templates/srv/hdr/pre.erb: * ridlbe/c++11/writers/servantheader.rb: * ridlbe/c++11/writers/stubproxyheader.rb: --- ridlbe/c++11/templates/srv/hdr/pre.erb | 1 - ridlbe/c++11/writers/servantheader.rb | 13 +++++++++++-- ridlbe/c++11/writers/stubproxyheader.rb | 3 +-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ridlbe/c++11/templates/srv/hdr/pre.erb b/ridlbe/c++11/templates/srv/hdr/pre.erb index 4fd7468e..489d3222 100644 --- a/ridlbe/c++11/templates/srv/hdr/pre.erb +++ b/ridlbe/c++11/templates/srv/hdr/pre.erb @@ -15,7 +15,6 @@ % else #include "<%= client_header %>" % end - % includes.each do |incfile| #include "<%= incfile %>" % end diff --git a/ridlbe/c++11/writers/servantheader.rb b/ridlbe/c++11/writers/servantheader.rb index b87dc29f..c4f4d60b 100644 --- a/ridlbe/c++11/writers/servantheader.rb +++ b/ridlbe/c++11/writers/servantheader.rb @@ -28,6 +28,7 @@ class ServantHeaderWriter < ServantHeaderBaseWriter def initialize(output = STDOUT, opts = {}) super @include_guard = "__RIDL_#{File.basename(params[:srv_output_hdr] || '').to_random_include_guard}_INCLUDED__" + @servant_traits = false end def pre_visit(parser) @@ -42,7 +43,7 @@ def post_visit(parser) end # Servant traits specializations - visit_servant_traits_specializations(parser) + visit_servant_traits_specializations(parser) if @servant_traits super visitor(PostVisitor).visit @@ -75,6 +76,8 @@ def leave_module(node) def enter_interface(node) return if node.is_local? || node.is_abstract? + @servant_traits = true + super visitor(InterfaceVisitor).visit_pre(node) inc_nest # POA @@ -94,6 +97,8 @@ def enter_valuetype(node) super return if node.is_local? || !node.supports_concrete_interface? + @servant_traits = true + visitor(ValuetypeVisitor).visit_pre(node) end @@ -132,11 +137,15 @@ class ServantHeaderIncludeWriter < ServantHeaderBaseWriter def initialize(output = STDOUT, opts = {}) super @includes = [] - @includes << 'tao/x11/portable_server/servantbase.h' unless params[:no_servant_code] end attr_reader :includes + def enter_interface(node) + @includes << 'tao/x11/portable_server/servantbase.h' unless params[:no_servant_code] + super + end + def post_visit(_parser) properties[:includes] = @includes diff --git a/ridlbe/c++11/writers/stubproxyheader.rb b/ridlbe/c++11/writers/stubproxyheader.rb index 853a7ca4..a0a658b1 100644 --- a/ridlbe/c++11/writers/stubproxyheader.rb +++ b/ridlbe/c++11/writers/stubproxyheader.rb @@ -28,10 +28,9 @@ def initialize(output = STDOUT, opts = {}) super @default_pre_includes = [] @default_post_includes = [] + @object_varout = false end - @object_varout = false - def visit_nodes(parser) @include_guard = "__RIDL_#{File.basename(params[:output_stub_proxy_header] || '').to_random_include_guard}_INCLUDED__" super