Skip to content

Commit

Permalink
Merge pull request RemedyIT#364 from jwillemsen/jwi-typecodevisitor
Browse files Browse the repository at this point in the history
Move typecode generation out of the various type template
  • Loading branch information
jwillemsen authored Apr 2, 2024
2 parents 9e87cce + adb6d8c commit 192454e
Show file tree
Hide file tree
Showing 27 changed files with 142 additions and 68 deletions.
4 changes: 0 additions & 4 deletions ridlbe/base/visitorbase.rb
Original file line number Diff line number Diff line change
Expand Up @@ -367,10 +367,6 @@ def in_module_scope?
@node.enclosure.is_a?(IDL::AST::Module)
end

def in_interface_scope?
@node.enclosure.is_a?(IDL::AST::Interface)
end

def repository_id
@node.repository_id
end
Expand Down
3 changes: 0 additions & 3 deletions ridlbe/c++11/templates/cli/hdr/ami/attribute.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
/// @copydoc <%= doc_scoped_name %>
//@{
void get_<%= name %> (<%= scoped_cxx_in_type %> ami_return_val);

void get_<%= name %>_excep (IDL::traits<TAOX11_NAMESPACE::Messaging::ExceptionHolder>::ref_type excep_holder);
% unless is_readonly?

void set_<%= name %> ();

void set_<%= name %>_excep (IDL::traits<TAOX11_NAMESPACE::Messaging::ExceptionHolder>::ref_type excep_holder);
% end
//@}
8 changes: 2 additions & 6 deletions ridlbe/c++11/templates/cli/hdr/ami/attribute_amic.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@

// generated from <%= ridl_template_path %>
void <%= sendc_prefix_get %><%= name %> (
<%= interface.handler_scoped_cxx_in_type %> ami_handler);
void <%= sendc_prefix_get %><%= name %> (<%= interface.handler_scoped_cxx_in_type %> ami_handler);
% unless is_readonly?

void <%= sendc_prefix_set %><%= name %> (
<%= interface.handler_scoped_cxx_in_type %> ami_handler,
<%= cxx_in_type %> _x11_<%= cxxname %>);
void <%= sendc_prefix_set %><%= name %> (<%= interface.handler_scoped_cxx_in_type %> ami_handler, <%= cxx_in_type %> _x11_<%= cxxname %>);
% end
1 change: 0 additions & 1 deletion ridlbe/c++11/templates/cli/hdr/ami/interface_amic_fwd.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ using <%= amic_cxxname %>_idl_t = <%= amic_cxxname %>; // IDL traits typename
class <%= proxy_cxxname %>;
using <%= proxy_cxxname %>_ptr = <%= proxy_cxxname %>*;
#endif // !_INTF_AMI<%= _intf_fwd_incl_guard_ %>_AMIC_FWD_
%#
2 changes: 0 additions & 2 deletions ridlbe/c++11/templates/cli/hdr/ami/interface_amic_post.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,3 @@ private:
<%= proxy_cxxname %>_ptr <%= proxy_cxxname.downcase %>_{};
//@}
}; // class <%= amic_cxxname %>
%#
% visit_template('typecode') if generate_typecode_support?
2 changes: 0 additions & 2 deletions ridlbe/c++11/templates/cli/hdr/ami/interface_fwd.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,3 @@ namespace POA
% end
% end
#endif // !_INTF_<%= _intf_fwd_incl_guard_ %>_FWD_
%#
% visit_template('typecode') if generate_typecode_support?
7 changes: 2 additions & 5 deletions ridlbe/c++11/templates/cli/hdr/attribute.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@
% _op_end << ' override' if is_override?
% _op_end << ' = 0' if (interface.is_local? || in_valuetype?)
% _op_end << ';'
virtual <%= cxx_return_type %>
<%= cxxname %> ()<%= _op_end %>
virtual <%= cxx_return_type %> <%= cxxname %> ()<%= _op_end %>
% unless is_readonly?

virtual void
<%= cxxname %> (<%= cxx_in_type %> _v)<%= _op_end %>
virtual void <%= cxxname %> (<%= cxx_in_type %> _v)<%= _op_end %>
//@}
% end
2 changes: 0 additions & 2 deletions ridlbe/c++11/templates/cli/hdr/bitmask.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,3 @@ inline <%= cxx_return_type %> operator& (<%= cxx_in_type %> _taox11_t, <%= cxx_i
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; }

% visit_template('typecode') if generate_typecode_support?
2 changes: 0 additions & 2 deletions ridlbe/c++11/templates/cli/hdr/bitset.erb
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,3 @@ private:
}; // <%= cxxname %>

inline void swap (<%= scoped_cxx_out_type %> m1, <%= scoped_cxx_out_type %> m2) { m1.swap (m2); }

% visit_template('typecode') if generate_typecode_support?
1 change: 0 additions & 1 deletion ridlbe/c++11/templates/cli/hdr/enum.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ enum class <%= cxxname %> : <%= bitbound.cxx_type %>
% end
};// <%= cxxname %>

% visit_template('typecode') if generate_typecode_support?
5 changes: 3 additions & 2 deletions ridlbe/c++11/templates/cli/hdr/except_post.erb
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@

protected:
void _info (std::ostream&) const override;
% if member_count > 0

private:
% members.each do |_m|
% members.each do |_m|
<%= _m.cxx_member_type %> <%= _m.cxxname %>_<%= _m.value_initializer %>;
% end
% end
}; // class <%= cxxname %>
% visit_template('typecode') if generate_typecode_support?
2 changes: 0 additions & 2 deletions ridlbe/c++11/templates/cli/hdr/interface_fwd.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,3 @@ class <%= proxy_cxxname %>;
using <%= proxy_cxxname %>_ptr = <%= proxy_cxxname %>*;
% end
#endif // !_INTF_<%= _intf_fwd_incl_guard_ %>_FWD_
%#
% visit_template('typecode') if generate_typecode_support?
2 changes: 0 additions & 2 deletions ridlbe/c++11/templates/cli/hdr/interface_post.erb
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,3 @@ private:
//@}
% end
}; // class <%= cxxname %>
%#
% visit_template('typecode') if generate_typecode_support?
2 changes: 0 additions & 2 deletions ridlbe/c++11/templates/cli/hdr/struct_fwd.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@

// generated from <%= ridl_template_path %>
class <%= cxxname %>;
%#
% visit_template('typecode') if generate_typecode_support?
2 changes: 0 additions & 2 deletions ridlbe/c++11/templates/cli/hdr/struct_post.erb
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,3 @@ private:
};// <%= cxxname %>

inline void swap (<%= scoped_cxx_out_type %> m1, <%= scoped_cxx_out_type %> m2) { m1.swap (m2); }

% visit_template('typecode') if generate_typecode_support?
9 changes: 5 additions & 4 deletions ridlbe/c++11/templates/cli/hdr/typecode.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
%# Generate the typecode for any type which is declared not at module level (could be part of an union or interface)
%if generate_typecode_support?
% unless in_module_scope?

// generated from <%= ridl_template_path %>
#if !defined (__TAOX11_TYPECODE_<%= scoped_cxxname.to_include_guard %>_DECL__)
#define __TAOX11_TYPECODE_<%= scoped_cxxname.to_include_guard %>_DECL__
% if in_module_scope?
extern <%= anytypecode_export_macro %>TAOX11_NAMESPACE::CORBA::typecode_reference const <%= cxx_typecode %>;
% else
static TAOX11_NAMESPACE::CORBA::typecode_reference const <%= cxx_typecode %>;
% end
#endif
% end
%end
9 changes: 9 additions & 0 deletions ridlbe/c++11/templates/cli/hdr/typecode_module.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
%# Generate the typecode for any type at module level
%if in_module_scope?

// generated from <%= ridl_template_path %>
#if !defined (__TAOX11_TYPECODE_<%= scoped_cxxname.to_include_guard %>_DECL__)
#define __TAOX11_TYPECODE_<%= scoped_cxxname.to_include_guard %>_DECL__
extern <%= anytypecode_export_macro %>TAOX11_NAMESPACE::CORBA::typecode_reference const <%= cxx_typecode %>;
#endif
%end
1 change: 0 additions & 1 deletion ridlbe/c++11/templates/cli/hdr/typedef.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
// generated from <%= ridl_template_path %>
/// @copydoc <%= doc_scoped_name %>
using <%= cxxname %> = <%= cxxtype %>;
% visit_template('typecode') if generate_typecode_support? && !is_native?
2 changes: 0 additions & 2 deletions ridlbe/c++11/templates/cli/hdr/union_fwd.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@

// generated from <%= ridl_template_path %>
class <%= stub_export_macro %><%= cxxname %>;
%#
% visit_template('typecode') if generate_typecode_support?
1 change: 0 additions & 1 deletion ridlbe/c++11/templates/cli/hdr/union_post.erb
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,3 @@ private:

inline void swap (<%= scoped_cxx_out_type %> m1, <%= scoped_cxx_out_type %> m2) { m1.swap (m2); }

% visit_template('typecode') if generate_typecode_support?
2 changes: 0 additions & 2 deletions ridlbe/c++11/templates/cli/hdr/valuebox_def.erb
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,3 @@ protected:

bool _obv_marshal_v (TAO_OutputCDR &) const override;
};
%#
% visit_template('typecode') if generate_typecode_support?
2 changes: 0 additions & 2 deletions ridlbe/c++11/templates/cli/hdr/valuebox_fwd.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@

// generated from <%= ridl_template_path %>
class <%= cxxname %>;
%#
% visit_template('typecode') if generate_typecode_support?
2 changes: 0 additions & 2 deletions ridlbe/c++11/templates/cli/hdr/valuetype_fwd.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,3 @@ class <%= stub_export_macro %><%= factory_cxxname %>;
% end

#endif // !_VALUETYPE_<%= _vt_fwd_incl_guard_ %>_FWD_
%#
% visit_template('typecode') if generate_typecode_support?
2 changes: 0 additions & 2 deletions ridlbe/c++11/templates/cli/hdr/valuetype_post.erb
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,3 @@ protected:
_obv_unmarshal_<%= scoped_cxxname.scope_to_cxxname %>_v (TAO_InputCDR &, TAO_ChunkInfo &) = 0;
% end
}; // class <%= cxxname %>
%#
% visit_template('typecode') if generate_typecode_support?
16 changes: 4 additions & 12 deletions ridlbe/c++11/templates/srv/hdr/ami/attribute.erb
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@

// generated from <%= ridl_template_path %>
virtual void
get_<%= name %> (<%= scoped_cxx_in_type %> ami_return_val) = 0;

virtual void
get_<%= name %>_excep (IDL::traits<TAOX11_NAMESPACE::Messaging::ExceptionHolder>::ref_type excep_holder) = 0;

virtual void get_<%= name %> (<%= scoped_cxx_in_type %> ami_return_val) = 0;
virtual void get_<%= name %>_excep (IDL::traits<TAOX11_NAMESPACE::Messaging::ExceptionHolder>::ref_type excep_holder) = 0;
% unless is_readonly?
virtual void
set_<%= name %> () = 0;

virtual void
set_<%= name %>_excep (IDL::traits<TAOX11_NAMESPACE::Messaging::ExceptionHolder>::ref_type excep_holder) = 0;

virtual void set_<%= name %> () = 0;
virtual void set_<%= name %>_excep (IDL::traits<TAOX11_NAMESPACE::Messaging::ExceptionHolder>::ref_type excep_holder) = 0;
% end
10 changes: 9 additions & 1 deletion ridlbe/c++11/writers/amistubheader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ def post_visit(parser)

visit_anyops(parser) if params[:gen_any_ops]

visit_typecodes(parser) if params[:gen_typecodes]

# generate inline methods
visit_inlines(parser)

Expand Down Expand Up @@ -162,6 +164,8 @@ def leave_interface(node)

dec_nest
ami_handler_interface.visit_post(node)

ami_handler_interface.visit_typecode_module(node) if params[:gen_typecodes]
super
end

Expand Down Expand Up @@ -192,6 +196,10 @@ def visit_anyops(parser)
writer(AmiStubHeaderAnyOpWriter).visit_nodes(parser)
end

def visit_typecodes(parser)
# No separate writer for typecodes
end

def visit_traits_specializations(parser)
writer(AmiStubHeaderTraitsWriter).visit_nodes(parser)
end
Expand Down Expand Up @@ -389,7 +397,7 @@ def declare_interface(node)

def enter_interface(node)
if needs_ami_generation?(node)
ami_handler_interface.visit_anyop(node)
ami_handler_interface.visit_anyop(node)
end
end
end # AmiStubHeaderAnyOpWriter
Expand Down
Loading

0 comments on commit 192454e

Please sign in to comment.