Sha256: f9fea7e4fe77176d4094a8470b105590cc2b81f0b3356c9abd71bd5591629c6a

Contents?: true

Size: 825 Bytes

Versions: 3

Compression:

Stored size: 825 Bytes

Contents

module GirFFI
  module TypeMap
    sz = FFI.type_size(:size_t) * 8
    gtype_type = "uint#{sz}".to_sym

    TAG_TYPE_MAP = {
      :GType => gtype_type,
      :gboolean => :bool,
      :gunichar => :uint32,
      :gint8 => :int8,
      :guint8 => :uint8,
      :gint16 => :int16,
      :guint16 => :uint16,
      :gint => :int,
      :gint32 => :int32,
      :guint32 => :uint32,
      :gint64 => :int64,
      :guint64 => :uint64,
      :gfloat => :float,
      :gdouble => :double,
      :void => :void
    }

    def self.map_basic_type type
      TAG_TYPE_MAP[type] || type
    end

    # FIXME: Make name more descriptive.
    def self.map_basic_type_or_string type
      case type
      when :gboolean
        :int32
      when :utf8
        :pointer
      else
        map_basic_type(type)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gir_ffi-0.4.3 lib/gir_ffi/type_map.rb
gir_ffi-0.4.2 lib/gir_ffi/type_map.rb
gir_ffi-0.4.1 lib/gir_ffi/type_map.rb