Extensions for GObjectIntrospection::IArgInfo needed by GirFFI
TODO: Use class rather than class name
# File lib/gir_ffi/info_ext/i_type_info.rb, line 84 def argument_class_name case flattened_tag when :struct, :union, :object, :interface, :enum, :flags, :callback interface.full_type_name else TAG_TO_WRAPPER_CLASS_MAP[flattened_tag] end end
# 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
# File lib/gir_ffi/info_ext/i_type_info.rb, line 129 def extra_conversion_arguments case flattened_tag when :utf8, :void [flattened_tag] when :c [subtype_tag_or_class, array_fixed_size] when :array, :ghash, :glist, :gslist, :ptr_array, :zero_terminated [element_type] else [] end end
# File lib/gir_ffi/info_ext/i_type_info.rb, line 34 def flattened_tag case tag when :interface interface_type when :array flattened_array_type else tag end end
# 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
# File lib/gir_ffi/info_ext/i_type_info.rb, line 45 def interface_type tag == :interface && interface.info_type end
# File lib/gir_ffi/info_ext/i_type_info.rb, line 19 def make_g_value GObject::Value.for_g_type g_type end
# File lib/gir_ffi/info_ext/i_type_info.rb, line 49 def subtype_tag_or_class index = 0 param_type(index).tag_or_class end
# File lib/gir_ffi/info_ext/i_type_info.rb, line 53 def tag_or_class base = case flattened_tag when :struct, :union, :object, :interface, :enum, :flags Builder.build_class interface else flattened_tag end if pointer? && tag != :utf8 && tag != :filename || interface_type == :object [:pointer, base] else base end end
# File lib/gir_ffi/info_ext/i_type_info.rb, line 112 def to_callback_ffitype type_tag = tag 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
# File lib/gir_ffi/info_ext/i_type_info.rb, line 93 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 # NOTE: Don't use pointer directly to appease JRuby. if subtype == :pointer subtype = :"uint#{FFI.type_size(:pointer)*8}" end [subtype, array_fixed_size] else TypeMap.map_basic_type type_tag end end
# File lib/gir_ffi/info_ext/i_type_info.rb, line 144 def flattened_array_type if zero_terminated? zero_terminated_array_type else array_type end end
# File lib/gir_ffi/info_ext/i_type_info.rb, line 152 def zero_terminated_array_type case element_type when :utf8, :filename :strv else :zero_terminated end end