module GirFFI::InfoExt::ITypeInfo

Public Instance Methods

element_type() click to toggle source
# File lib/gir_ffi/info_ext/i_type_info.rb, line 27
def element_type
  case tag
  when :glist, :gslist, :array
    subtype_tag 0
  when :ghash
    [subtype_tag(0), subtype_tag(1)]
  else
    nil
  end
end
flattened_array_type() click to toggle source
# File lib/gir_ffi/info_ext/i_type_info.rb, line 66
def flattened_array_type
  if zero_terminated?
    if element_type == :utf8
      :strv
    else
      # TODO: Check that array_type == :c
      # TODO: Perhaps distinguish :c from zero-terminated :c
      :c
    end
  else
    array_type
  end
end
flattened_tag() click to toggle source
# File lib/gir_ffi/info_ext/i_type_info.rb, line 51
def flattened_tag
  case tag
  when :interface
    interface_type
  when :array
    flattened_array_type
  else
    tag
  end
end
interface_type() click to toggle source
# File lib/gir_ffi/info_ext/i_type_info.rb, line 62
def interface_type
  interface.info_type
end
interface_type_name() click to toggle source
# File lib/gir_ffi/info_ext/i_type_info.rb, line 38
def interface_type_name
  interface.full_type_name
end
layout_specification_type() click to toggle source
# File lib/gir_ffi/info_ext/i_type_info.rb, line 8
def layout_specification_type
  ffitype = GirFFI::Builder.itypeinfo_to_ffitype self
  case ffitype
  when Class
    ffitype.const_get :Struct
  when :bool
    :int
  when :array
    subtype = param_type(0).layout_specification_type
    # XXX Don't use pointer directly to appease JRuby.
    if subtype == :pointer
      subtype = :"uint#{FFI.type_size(:pointer)*8}"
    end
    [subtype, array_fixed_size]
  else
    ffitype
  end
end
type_specification() click to toggle source
# File lib/gir_ffi/info_ext/i_type_info.rb, line 42
def type_specification
  tag = self.tag
  if tag == :array
    "[#{flattened_array_type.inspect}, #{element_type.inspect}]"
  else
    tag.inspect
  end
end