Module: GirFFI::InfoExt::ITypeInfo
- Includes:
- BuilderHelper
- Defined in:
- lib/gir_ffi/info_ext/i_type_info.rb
Overview
Extensions for GObjectIntrospection::IArgInfo needed by GirFFI
Instance Method Summary
collapse
#const_defined_for, #optionally_define_constant
Instance Method Details
#element_type ⇒ Object
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/gir_ffi/info_ext/i_type_info.rb', line 23
def element_type
case tag
when :glist, :gslist, :array
subtype_tag_or_class 0
when :ghash
[subtype_tag_or_class(0), subtype_tag_or_class(1)]
else
nil
end
end
|
#flattened_array_type ⇒ Object
54
55
56
57
58
59
60
|
# File 'lib/gir_ffi/info_ext/i_type_info.rb', line 54
def flattened_array_type
if zero_terminated?
zero_terminated_array_type
else
array_type
end
end
|
#flattened_tag ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/gir_ffi/info_ext/i_type_info.rb', line 38
def flattened_tag
type_tag = self.tag
case type_tag
when :interface
interface_type
when :array
flattened_array_type
else
type_tag
end
end
|
#g_type ⇒ Object
9
10
11
12
13
14
15
16
17
|
# File 'lib/gir_ffi/info_ext/i_type_info.rb', line 9
def g_type
tag = self.tag
case tag
when :interface
interface.g_type
else
GObject::TYPE_TAG_TO_GTYPE[tag]
end
end
|
#interface_type ⇒ Object
50
51
52
|
# File 'lib/gir_ffi/info_ext/i_type_info.rb', line 50
def interface_type
tag == :interface && interface.info_type
end
|
#interface_type_name ⇒ Object
34
35
36
|
# File 'lib/gir_ffi/info_ext/i_type_info.rb', line 34
def interface_type_name
interface.full_type_name
end
|
#make_g_value ⇒ Object
19
20
21
|
# File 'lib/gir_ffi/info_ext/i_type_info.rb', line 19
def make_g_value
GObject::Value.for_g_type g_type
end
|
#subtype_tag_or_class(index = 0) ⇒ Object
66
67
68
|
# File 'lib/gir_ffi/info_ext/i_type_info.rb', line 66
def subtype_tag_or_class index = 0
param_type(index).tag_or_class
end
|
#subtype_tag_or_class_name(index = 0) ⇒ Object
62
63
64
|
# File 'lib/gir_ffi/info_ext/i_type_info.rb', line 62
def subtype_tag_or_class_name index = 0
param_type(index).tag_or_class_name
end
|
#tag_or_class ⇒ Object
74
75
76
77
78
79
80
81
82
83
84
85
86
|
# File 'lib/gir_ffi/info_ext/i_type_info.rb', line 74
def tag_or_class
type_tag = self.tag
base = if type_tag == :interface
Builder.build_class interface
else
type_tag
end
if pointer? && type_tag != :utf8 && type_tag != :filename || interface_type == :object
[:pointer, base]
else
base
end
end
|
#tag_or_class_name ⇒ Object
70
71
72
|
# File 'lib/gir_ffi/info_ext/i_type_info.rb', line 70
def tag_or_class_name
tag_or_class.inspect
end
|
#to_callback_ffitype ⇒ Object
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
# File 'lib/gir_ffi/info_ext/i_type_info.rb', line 107
def to_callback_ffitype
type_tag = tag
return :string if type_tag == :utf8
return :pointer if pointer?
if type_tag == :interface
case interface.info_type
when :enum, :flags
:int32
else
:pointer
end
else
return TypeMap.map_basic_type type_tag
end
end
|
#to_ffitype ⇒ Object
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
# File 'lib/gir_ffi/info_ext/i_type_info.rb', line 88
def to_ffitype
return :pointer if pointer?
type_tag = tag
case type_tag
when :interface
interface.to_ffitype
when :array
subtype = param_type(0).to_ffitype
if subtype == :pointer
subtype = :"uint#{FFI.type_size(:pointer)*8}"
end
[subtype, array_fixed_size]
else
TypeMap.map_basic_type type_tag
end
end
|