Skip to content

Commit

Permalink
Merge pull request #422 from jwillemsen/jwi-ddsidlannotations
Browse files Browse the repository at this point in the history
Reworked annotation generation for implied DDS IDL
  • Loading branch information
jwillemsen committed Jan 10, 2024
2 parents 1dd17e8 + 152da1a commit df06afb
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 20 deletions.
4 changes: 3 additions & 1 deletion ridlbe/ccmx11/facets/dds/templates/idl/dds/bitmask.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@

// generated from <%= ridl_template_path %>
/// @copydoc <%= doc_scoped_name %>
@bit_bound(<%= bitbound_bits %>)
% annotations.each do |_a|
@<%= _a.id %><% unless _a.fields.empty? %>(<% _a.fields.values.each do |f| %><%= f %><% end %>)<% end %>
% end
bitmask <%= unescaped_name %> {
<%= bitvalues.collect {|e| "/// @copydoc #{e.doc_scoped_name}\n #{e.name}" }.join(",\n ") %>
};
Expand Down
4 changes: 3 additions & 1 deletion ridlbe/ccmx11/facets/dds/templates/idl/dds/enum.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@

// generated from <%= ridl_template_path %>
/// @copydoc <%= doc_scoped_name %>
@bit_bound(<%= bitbound_bits %>)
% annotations.each do |_a|
@<%= _a.id %><% unless _a.fields.empty? %>(<% _a.fields.values.each do |f| %><%= f %><% end %>)<% end %>
% end
enum <%= unescaped_name %> {
<%= enumerators.collect {|e| "/// @copydoc #{e.doc_scoped_name}\n #{e.name}" }.join(",\n ") %>
};
Expand Down
10 changes: 7 additions & 3 deletions ridlbe/ccmx11/facets/dds/templates/idl/dds/struct.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
// generated from <%= ridl_template_path %>
/// @copydoc <%= doc_scoped_name %>
@nested(<% if has_toplevel_annotation? %>FALSE<% else %>TRUE<% end %>)
@<%= extensibility_annotation %>
% annotations.each do |_a|
@<%= _a.id %><% unless _a.fields.empty? %>(<% _a.fields.values.each do |f| %><%= f %><% end %>)<% end %>
% end
struct <%= unescaped_name %><% unless base.nil? %> : <%= base.unescaped_name %><% end %> {
% members.each do |_m|
/// @copydoc <%= _m.doc_scoped_name %>
<% if _m.has_key_annotation? %>@key <% end %><%= strip_global_scope(_m.idltype_unescaped_name) %> <%= _m.unescaped_name %>;
% _m.annotations.each do |_a|
@<%= _a.id %><% unless _a.fields.empty? %>(<% _a.fields.values.each do |f| %><%= f %><% end %>)<% end %>
% end
<%= strip_global_scope(_m.idltype_unescaped_name) %> <%= _m.unescaped_name %>;
% end
};
8 changes: 6 additions & 2 deletions ridlbe/ccmx11/facets/dds/templates/idl/dds/union.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@

// generated from <%= ridl_template_path %>
/// @copydoc <%= doc_scoped_name %>
@nested(<% if has_toplevel_annotation? %>FALSE<% else %>TRUE<% end %>)
@<%= extensibility_annotation %>
% annotations.each do |_a|
@<%= _a.id %><% unless _a.fields.empty? %>(<% _a.fields.values.each do |f| %><%= f %><% end %>)<% end %>
% end
union <%= unescaped_name %> switch (<%= strip_global_scope(switchtype.idltype_unescaped_name) %>) {
% members.each do |_m|
% if _m.is_default?
Expand All @@ -13,6 +14,9 @@ union <%= unescaped_name %> switch (<%= strip_global_scope(switchtype.idltype_un
% end
% end
/// @copydoc <%= _m.doc_scoped_name %>
% _m.annotations.each do |_a|
@<%= _a.id %><% unless _a.fields.empty? %>(<% _a.fields.values.each do |f| %><%= f %><% end %>)<% end %>
% end
<%= strip_global_scope(_m.idltype_unescaped_name) %> <%= _m.unescaped_name %>;
% end
};
9 changes: 1 addition & 8 deletions ridlbe/ccmx11/facets/dds/visitorbase.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,12 @@ def strip_global_scope(typename)

def has_toplevel_annotation?
# 20190730 Add support for AXCIOMA 2 top-level annotation, issue #4729
annot = self.annotations[:'top-level'].first || self.annotations[:TopLevel].first
annot = node.annotations[:'top-level'].first || node.annotations[:TopLevel].first
return false if annot.nil?

annot.fields[:value].nil? || annot.fields[:value]
end

def extensibility_annotation
# DDS X-Types defines that the default for extensibility is appendable
return :final if self.annotations[:'final'].first

:appendable
end

def typesupport_export_include?
params[:typesupport_export_include]
end
Expand Down
17 changes: 12 additions & 5 deletions ridlbe/ccmx11/facets/dds/visitors/struct.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,19 @@ class StructVisitor < Cxx11::NodeVisitorBase
include CcmNames

optional_template :life_cycle_traits
end # StructVisitor

class StructMemberVisitor
def has_key_annotation?
!self.annotations[:key].empty?
def annotations
# Add appendable when it is not final available
ann = node.annotations.dup
unless ann[:'final'].first
ann << IDL::AST::Annotation.new('appendable', {})
end
# Determine correct value for DDS nested annotation
nested = 'TRUE'
nested = 'FALSE' if has_toplevel_annotation?
ann << IDL::AST::Annotation.new('nested', {v: nested})
ann
end
end
end # StructVisitor
end # CCMX11
end # IDL
13 changes: 13 additions & 0 deletions ridlbe/ccmx11/facets/dds/visitors/union.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ def native_scoped_switch_cxxtype
end

optional_template :life_cycle_traits

def annotations
# Add appendable when it is not final available
ann = node.annotations.dup
unless ann[:'final'].first
ann << IDL::AST::Annotation.new('appendable', {})
end
# Determine correct value for DDS nested annotation
nested = 'TRUE'
nested = 'FALSE' if has_toplevel_annotation?
ann << IDL::AST::Annotation.new('nested', {v: nested})
ann
end
end
end # CCMX11
end # IDL

0 comments on commit df06afb

Please sign in to comment.