Skip to content

Commit

Permalink
Implement default_literal for enum
Browse files Browse the repository at this point in the history
    * ridlbe/c++11/config/cxx_type.rb:
    * ridlbe/c++11/visitors/enum.rb:
  • Loading branch information
jwillemsen committed Jan 22, 2024
1 parent e3272d8 commit 04054c9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 33 deletions.
22 changes: 7 additions & 15 deletions ridlbe/c++11/config/cxx_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -862,21 +862,13 @@ def is_pod?
end

def value_initializer
# When we have an annotation directly applied to this node we are using it
# unless node.annotations[:default].first.nil?
# "{#{node.annotations[:default].first.fields[:value]}}"
# else
# # Check whether it is a typedef, if so, we need to see if there is an annotation applied to the typedef (or its typedef)
# res_idl_type = _idltype
# while res_idl_type.is_a?(IDL::Type::ScopedName)
# unless res_idl_type.node.annotations[:default].first.nil?
# return "{#{res_idl_type.node.annotations[:default].first.fields[:value]}}"
# end
# res_idl_type = res_idl_type.node.idltype
# end
# _resolved_idltype.zero_initializer
# end
return "FOO"
res = '{}'
node.enumerators.each do |e|
unless e.annotations[:default_literal].first.nil?
res = '{' + cxx_type + '::' + e.scoped_cxxname + '}'
end
end
return res
end
end

Expand Down
18 changes: 0 additions & 18 deletions ridlbe/c++11/visitors/enum.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,6 @@ def bitbound_bits
node.bitbound_bits
end

def value_initializer
# # When we have an annotation directly applied to this node we are using it
# unless node.annotations[:default].first.nil?
# "{#{node.annotations[:default].first.fields[:value]}}"
# else
# # Check whether it is a typedef, if so, we need to see if there is an annotation applied to the typedef (or its typedef)
# res_idl_type = _idltype
# while res_idl_type.is_a?(IDL::Type::ScopedName)
# unless res_idl_type.node.annotations[:default].first.nil?
# return "{#{res_idl_type.node.annotations[:default].first.fields[:value]}}"
# end
# res_idl_type = res_idl_type.node.idltype
# end
# _resolved_idltype.zero_initializer
# end
return "FOO"
end

# template mapping
map_template :enum, :enum
map_template :typecode, :typecode
Expand Down

0 comments on commit 04054c9

Please sign in to comment.