/usr/lib/ruby/vendor_ruby/gir_ffi/type_map.rb is in ruby-gir-ffi 0.9.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | require 'gir_ffi/sized_array'
module GirFFI
# Maps GObject type tags and type specification to types FFI can handle.
module TypeMap
sz = FFI.type_size(:size_t) * 8
gsize_type = "uint#{sz}".to_sym
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: gsize_type,
gboolean: GLib::Boolean,
gunichar: :uint32,
gint8: :int8,
guint8: :uint8,
gint16: :int16,
guint16: :uint16,
gint: :int,
gint32: :int32,
guint32: :uint32,
gint64: :int64,
guint64: :uint64,
gsize: gsize_type,
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)
type_specification_to_ffi_type type
end
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
end
end
|