module GirFFI::InfoExt::ITypeInfo
Extensions for GObjectIntrospection::ITypeInfo
needed by GirFFI
Constants
- FLATTENED_TAG_POINTER_TO_GTYPE_MAP
- FLATTENED_TAG_TO_GTYPE_MAP
- GOBJECT_VALUE_NAME
- TAGS_NEEDING_C_TO_RUBY_CONVERSION
- TAGS_NEEDING_RUBY_TO_C_CONVERSION
- TAG_TO_WRAPPER_CLASS_MAP
Public Instance Methods
argument_class_name()
click to toggle source
TODO: Use class rather than class name
# File lib/gir_ffi/info_ext/i_type_info.rb, line 103 def argument_class_name interface_class_name || TAG_TO_WRAPPER_CLASS_MAP[flattened_tag] end
element_type()
click to toggle source
# File lib/gir_ffi/info_ext/i_type_info.rb, line 38 def element_type case tag when :glist, :gslist, :array, :c enumerable_element_type when :ghash dictionary_element_type end end
extra_conversion_arguments()
click to toggle source
# File lib/gir_ffi/info_ext/i_type_info.rb, line 184 def extra_conversion_arguments case flattened_tag when :c [element_type, array_fixed_size] when :array, :ghash, :glist, :gslist, :ptr_array, :zero_terminated [element_type] else [] end end
flattened_tag()
click to toggle source
# File lib/gir_ffi/info_ext/i_type_info.rb, line 47 def flattened_tag @flattened_tag ||= case tag when :interface interface_type when :array flattened_array_type else tag end end
gtype()
click to toggle source
# File lib/gir_ffi/info_ext/i_type_info.rb, line 24 def gtype return interface.gtype if tag == :interface if pointer? FLATTENED_TAG_POINTER_TO_GTYPE_MAP.fetch(flattened_tag, GObject::TYPE_POINTER) else FLATTENED_TAG_TO_GTYPE_MAP.fetch(flattened_tag) end end
gvalue?()
click to toggle source
# File lib/gir_ffi/info_ext/i_type_info.rb, line 197 def gvalue? argument_class_name == GOBJECT_VALUE_NAME end
interface_class()
click to toggle source
# File lib/gir_ffi/info_ext/i_type_info.rb, line 83 def interface_class @interface_class ||= Builder.build_class interface if tag == :interface end
interface_class_name()
click to toggle source
# File lib/gir_ffi/info_ext/i_type_info.rb, line 108 def interface_class_name interface.full_type_name if tag == :interface end
interface_type()
click to toggle source
# File lib/gir_ffi/info_ext/i_type_info.rb, line 59 def interface_type tag == :interface && interface.info_type end
make_g_value()
click to toggle source
# File lib/gir_ffi/info_ext/i_type_info.rb, line 34 def make_g_value GObject::Value.for_gtype gtype end
needs_c_to_ruby_conversion_for_callbacks?()
click to toggle source
# File lib/gir_ffi/info_ext/i_type_info.rb, line 163 def needs_c_to_ruby_conversion_for_callbacks? [:callback, :enum].include?(flattened_tag) || needs_c_to_ruby_conversion_for_functions? end
needs_c_to_ruby_conversion_for_closures?()
click to toggle source
# File lib/gir_ffi/info_ext/i_type_info.rb, line 168 def needs_c_to_ruby_conversion_for_closures? [:array, :c, :error, :ghash, :glist, :struct, :strv].include?(flattened_tag) end
needs_c_to_ruby_conversion_for_functions?()
click to toggle source
# File lib/gir_ffi/info_ext/i_type_info.rb, line 154 def needs_c_to_ruby_conversion_for_functions? TAGS_NEEDING_C_TO_RUBY_CONVERSION.include?(flattened_tag) end
needs_c_to_ruby_conversion_for_properties?()
click to toggle source
# File lib/gir_ffi/info_ext/i_type_info.rb, line 180 def needs_c_to_ruby_conversion_for_properties? [:glist, :ghash, :callback].include?(flattened_tag) end
needs_ruby_to_c_conversion_for_callbacks?()
click to toggle source
# File lib/gir_ffi/info_ext/i_type_info.rb, line 158 def needs_ruby_to_c_conversion_for_callbacks? [:enum].include?(flattened_tag) || needs_ruby_to_c_conversion_for_functions? end
needs_ruby_to_c_conversion_for_closures?()
click to toggle source
# File lib/gir_ffi/info_ext/i_type_info.rb, line 172 def needs_ruby_to_c_conversion_for_closures? [:array].include?(flattened_tag) end
needs_ruby_to_c_conversion_for_functions?()
click to toggle source
# File lib/gir_ffi/info_ext/i_type_info.rb, line 150 def needs_ruby_to_c_conversion_for_functions? TAGS_NEEDING_RUBY_TO_C_CONVERSION.include?(flattened_tag) end
needs_ruby_to_c_conversion_for_properties?()
click to toggle source
# File lib/gir_ffi/info_ext/i_type_info.rb, line 176 def needs_ruby_to_c_conversion_for_properties? [:glist, :ghash, :strv, :callback].include?(flattened_tag) end
tag_or_class()
click to toggle source
# File lib/gir_ffi/info_ext/i_type_info.rb, line 67 def tag_or_class base = case tag when :interface interface_class when :ghash [tag, *element_type] else flattened_tag end if pointer? && tag != :utf8 && tag != :filename [:pointer, base] else base end end
to_callback_ffi_type()
click to toggle source
# File lib/gir_ffi/info_ext/i_type_info.rb, line 125 def to_callback_ffi_type return :pointer if pointer? case tag when :interface interface.to_callback_ffi_type when :gboolean # TODO: Move this logic into TypeMap :bool else TypeMap.map_basic_type tag end end
to_ffi_type()
click to toggle source
# File lib/gir_ffi/info_ext/i_type_info.rb, line 112 def to_ffi_type return :pointer if pointer? case tag when :interface interface.to_ffi_type when :array [subtype_ffi_type(0), array_fixed_size] else TypeMap.map_basic_type tag end end
Private Instance Methods
dictionary_element_type()
click to toggle source
# File lib/gir_ffi/info_ext/i_type_info.rb, line 207 def dictionary_element_type [subtype_tag_or_class(0), subtype_tag_or_class(1)] end
enumerable_element_type()
click to toggle source
# File lib/gir_ffi/info_ext/i_type_info.rb, line 211 def enumerable_element_type subtype_tag_or_class 0 end
flattened_array_type()
click to toggle source
# File lib/gir_ffi/info_ext/i_type_info.rb, line 225 def flattened_array_type if zero_terminated? zero_terminated_array_type else array_type end end
subtype_ffi_type(index)
click to toggle source
# File lib/gir_ffi/info_ext/i_type_info.rb, line 215 def subtype_ffi_type(index) subtype = param_type(index).to_ffi_type if subtype == :pointer # NOTE: Don't use pointer directly to appease JRuby. :"uint#{FFI.type_size(:pointer) * 8}" else subtype end end
subtype_tag_or_class(index)
click to toggle source
# File lib/gir_ffi/info_ext/i_type_info.rb, line 203 def subtype_tag_or_class(index) param_type(index).tag_or_class end
zero_terminated_array_type()
click to toggle source
# File lib/gir_ffi/info_ext/i_type_info.rb, line 233 def zero_terminated_array_type case element_type when :utf8, :filename :strv else :zero_terminated end end