Module: GirFFI::TypeMap
- Defined in:
- lib/gir_ffi/type_map.rb
Overview
Maps GObject type tags and type specification to types FFI can handle.
Constant Summary collapse
- TAG_TYPE_MAP =
{ enum: :int32, flags: :int32, ghash: :pointer, glist: :pointer, gslist: :pointer, strv: :pointer, interface: :pointer, error: :pointer, ptr_array: :pointer, array: :pointer, c: GirFFI::SizedArray, utf8: :pointer, GType: gsize_type, gboolean: GirFFI::Boolean, gunichar: :uint32, gint8: :int8, guint8: :uint8, gint16: :int16, guint16: :uint16, gint: :int, guint: :uint, gint32: :int32, guint32: :uint32, gint64: :int64, guint64: :uint64, glong: :long, gulong: :ulong, gsize: gsize_type, gfloat: :float, gdouble: :double, void: :void }.freeze
- FLATTENED_TAG_TO_GTYPE_MAP =
{ [:array, true] => GObject::TYPE_ARRAY, [:c, true] => GObject::TYPE_POINTER, [:gboolean, false] => GObject::TYPE_BOOLEAN, [:ghash, true] => GObject::TYPE_HASH_TABLE, [:glist, true] => GObject::TYPE_POINTER, [:gint32, false] => GObject::TYPE_INT, [:gint64, false] => GObject::TYPE_INT64, [:guint64, false] => GObject::TYPE_UINT64, [:strv, true] => GObject::TYPE_STRV, [:utf8, true] => GObject::TYPE_STRING, [:void, true] => GObject::TYPE_POINTER, [:void, false] => GObject::TYPE_NONE }.freeze
Class Method Summary collapse
- .map_basic_type(type) ⇒ Object
- .type_info_to_gtype(type_info) ⇒ Object
- .type_specification_to_ffi_type(type) ⇒ Object
Class Method Details
.map_basic_type(type) ⇒ Object
46 47 48 49 |
# File 'lib/gir_ffi/type_map.rb', line 46 def self.map_basic_type(type) sym = type.to_sym TAG_TYPE_MAP[sym] || sym end |
.type_info_to_gtype(type_info) ⇒ Object
77 78 79 80 81 |
# File 'lib/gir_ffi/type_map.rb', line 77 def self.type_info_to_gtype(type_info) return type_info.interface.gtype if type_info.tag == :interface FLATTENED_TAG_TO_GTYPE_MAP.fetch [type_info.flattened_tag, type_info.pointer?] end |
.type_specification_to_ffi_type(type) ⇒ Object
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/gir_ffi/type_map.rb', line 51 def self.type_specification_to_ffi_type(type) case type when Module type.to_ffi_type when Array type[0] else map_basic_type(type) end end |