Sha256: 040209e4b3c57af6681f87e66baa639c239102d4da7be7c95110d7af751714d9

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

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

    TAG_TYPE_MAP = {
      :enum => :int32,
      :flags => :int32,
      :ghash => :pointer,
      :glist => :pointer,
      :gslist => :pointer,
      :strv => :pointer,
      :c => :pointer,
      :object => :pointer,
      :struct => :pointer,
      :error => :pointer,
      :ptr_array => :pointer,
      :array => :pointer,
      :utf8 => :pointer,
      :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
      sym = type.to_sym
      TAG_TYPE_MAP[sym] || sym
    end

    def self.type_specification_to_ffitype type
      if Module === type
        type.to_ffitype
      else
        map_basic_type(type)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gir_ffi-0.6.5 lib/gir_ffi/type_map.rb