Sha256: ce24d01d0865faa0fe16ea3c071cc5a71841e284d5ca3d3541729924e185587d

Contents?: true

Size: 719 Bytes

Versions: 5

Compression:

Stored size: 719 Bytes

Contents

module RbGCCXML

  # Node that represents <ArrayType>, which is any static array
  # declaration.
  # One oddity on how GCC-XML parses certain array designations:
  #  
  #   void func(int in[4][3]);
  #
  # will be parsed out as
  #
  #   void func(int* in[3]);
  #
  # aka, a pointer to a 3-element array, so keep this in mind when doing
  # comparisons or wondering why the to_cpp output is so odd
  class ArrayType < Type

    def ==(val)
      check_sub_type_without(val, /\[\d\]/)
    end

    # See Node#to_cpp
    def to_cpp(qualified = true)
      type = NodeCache.find(attributes["type"])
      "#{type.to_cpp(qualified)}[#{attributes["max"].gsub(/[^\d]/, '').to_i + 1}]"
    end
    once :to_cpp

  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rbgccxml-1.0.4 lib/rbgccxml/nodes/types/array_type.rb
rbgccxml-1.0.3 lib/rbgccxml/nodes/types/array_type.rb
rbgccxml-1.0.2 lib/rbgccxml/nodes/types/array_type.rb
rbgccxml-1.0.1 lib/rbgccxml/nodes/types/array_type.rb
rbgccxml-1.0 lib/rbgccxml/nodes/types/array_type.rb