Module: GirFFI::TypeMap

Defined in:
lib/gir_ffi/type_map.rb

Constant Summary collapse

TAG_TYPE_MAP =
{
  :enum => :int32,
  :flags => :int32,
  :ghash => :pointer,
  :glist => :pointer,
  :gslist => :pointer,
  :strv => :pointer,
  :object => :pointer,
  :struct => :pointer,
  :error => :pointer,
  :ptr_array => :pointer,
  :array => :pointer,
  :c => GirFFI::SizedArray,
  :utf8 => :pointer,
  :GType => gtype_type,
  :gboolean => GLib::Boolean,
  :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
}

Class Method Summary collapse

Class Method Details

.map_basic_type(type) ⇒ Object



39
40
41
42
# File 'lib/gir_ffi/type_map.rb', line 39

def self.map_basic_type type
  sym = type.to_sym
  TAG_TYPE_MAP[sym] || sym
end

.type_specification_to_ffitype(type) ⇒ Object



44
45
46
47
48
49
50
51
52
53
# File 'lib/gir_ffi/type_map.rb', line 44

def self.type_specification_to_ffitype type
  case type
  when Module
    type.to_ffitype
  when Array
    type[0]
  else
    map_basic_type(type)
  end
end