gir_ffi 0.7.7 → 0.7.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Changelog.md +9 -0
- data/lib/ffi-glib/array.rb +1 -1
- data/lib/ffi-glib/error.rb +1 -2
- data/lib/ffi-glib/hash_table.rb +2 -2
- data/lib/ffi-glib/variant.rb +1 -1
- data/lib/ffi-gobject/base.rb +23 -23
- data/lib/ffi-gobject/object.rb +7 -3
- data/lib/ffi-gobject/value.rb +6 -1
- data/lib/ffi-gobject.rb +9 -6
- data/lib/ffi-gobject_introspection/i_base_info.rb +3 -3
- data/lib/ffi-gobject_introspection/i_constant_info.rb +1 -1
- data/lib/ffi-gobject_introspection/i_repository.rb +4 -1
- data/lib/ffi-gobject_introspection/i_type_info.rb +1 -1
- data/lib/ffi-gobject_introspection/i_unresolved_info.rb +7 -0
- data/lib/ffi-gobject_introspection/lib.rb +1 -1
- data/lib/gir_ffi/builders/argument_builder.rb +1 -1
- data/lib/gir_ffi/builders/c_to_ruby_convertor.rb +37 -29
- data/lib/gir_ffi/builders/callback_argument_builder.rb +57 -27
- data/lib/gir_ffi/builders/closure_convertor.rb +12 -8
- data/lib/gir_ffi/builders/closure_to_pointer_convertor.rb +12 -8
- data/lib/gir_ffi/builders/constructor_result_convertor.rb +11 -7
- data/lib/gir_ffi/builders/field_builder.rb +1 -1
- data/lib/gir_ffi/builders/function_builder.rb +1 -1
- data/lib/gir_ffi/builders/mapping_method_builder.rb +1 -1
- data/lib/gir_ffi/builders/marshalling_method_builder.rb +2 -2
- data/lib/gir_ffi/builders/method_template.rb +1 -1
- data/lib/gir_ffi/builders/null_convertor.rb +11 -7
- data/lib/gir_ffi/builders/property_builder.rb +1 -1
- data/lib/gir_ffi/builders/ruby_to_c_convertor.rb +17 -13
- data/lib/gir_ffi/error_argument_info.rb +1 -1
- data/lib/gir_ffi/ffi_ext/pointer.rb +1 -1
- data/lib/gir_ffi/info_ext/i_unresolved_info.rb +12 -0
- data/lib/gir_ffi/info_ext/safe_constant_name.rb +2 -2
- data/lib/gir_ffi/info_ext/safe_function_name.rb +1 -1
- data/lib/gir_ffi/info_ext.rb +1 -0
- data/lib/gir_ffi/module_base.rb +1 -1
- data/lib/gir_ffi/receiver_argument_info.rb +15 -12
- data/lib/gir_ffi/user_data_argument_info.rb +17 -15
- data/lib/gir_ffi/user_data_type_info.rb +14 -12
- data/lib/gir_ffi/version.rb +1 -1
- data/lib/gir_ffi-base/gobject/lib.rb +1 -1
- data/test/base_test_helper.rb +15 -15
- data/test/ffi-glib/array_test.rb +38 -38
- data/test/ffi-glib/byte_array_test.rb +6 -7
- data/test/ffi-glib/bytes_test.rb +9 -9
- data/test/ffi-glib/hash_table_test.rb +26 -23
- data/test/ffi-glib/iconv_test.rb +5 -5
- data/test/ffi-glib/list_test.rb +16 -16
- data/test/ffi-glib/main_loop_test.rb +6 -6
- data/test/ffi-glib/ptr_array_test.rb +45 -45
- data/test/ffi-glib/ruby_closure_test.rb +6 -6
- data/test/ffi-glib/s_list_test.rb +15 -15
- data/test/ffi-glib/strv_test.rb +21 -21
- data/test/ffi-glib/variant_test.rb +4 -4
- data/test/ffi-gobject/gobject_test.rb +35 -35
- data/test/ffi-gobject/object_class_test.rb +1 -1
- data/test/ffi-gobject/object_test.rb +29 -6
- data/test/ffi-gobject/value_test.rb +66 -52
- data/test/ffi-gobject_introspection/i_base_info_test.rb +10 -11
- data/test/ffi-gobject_introspection/i_constant_info_test.rb +6 -6
- data/test/ffi-gobject_introspection/i_enum_info_test.rb +4 -5
- data/test/ffi-gobject_introspection/i_function_info_test.rb +0 -2
- data/test/ffi-gobject_introspection/i_object_info_test.rb +5 -5
- data/test/ffi-gobject_introspection/i_registered_type_info_test.rb +9 -8
- data/test/ffi-gobject_introspection/i_repository_test.rb +16 -16
- data/test/ffi-gobject_introspection/i_type_info_test.rb +16 -2
- data/test/ffi-gobject_introspection/lib_test.rb +2 -2
- data/test/ffi-gobject_test.rb +50 -40
- data/test/gir_ffi/arg_helper_test.rb +5 -5
- data/test/gir_ffi/builder_test.rb +41 -41
- data/test/gir_ffi/builders/argument_builder_test.rb +240 -207
- data/test/gir_ffi/builders/base_argument_builder_test.rb +0 -1
- data/test/gir_ffi/builders/callback_argument_builder_test.rb +81 -15
- data/test/gir_ffi/builders/callback_builder_test.rb +39 -14
- data/test/gir_ffi/builders/callback_return_value_builder_test.rb +41 -33
- data/test/gir_ffi/builders/enum_builder_test.rb +3 -3
- data/test/gir_ffi/builders/field_builder_test.rb +17 -17
- data/test/gir_ffi/builders/function_builder_test.rb +16 -16
- data/test/gir_ffi/builders/interface_builder_test.rb +9 -7
- data/test/gir_ffi/builders/module_builder_test.rb +5 -6
- data/test/gir_ffi/builders/object_builder_test.rb +24 -19
- data/test/gir_ffi/builders/property_builder_test.rb +25 -23
- data/test/gir_ffi/builders/registered_type_builder_test.rb +11 -11
- data/test/gir_ffi/builders/return_value_builder_test.rb +237 -197
- data/test/gir_ffi/builders/signal_closure_builder_test.rb +29 -22
- data/test/gir_ffi/builders/struct_builder_test.rb +10 -10
- data/test/gir_ffi/builders/unintrospectable_builder_test.rb +8 -8
- data/test/gir_ffi/builders/union_builder_test.rb +5 -6
- data/test/gir_ffi/builders/user_defined_builder_test.rb +42 -33
- data/test/gir_ffi/builders/vfunc_builder_test.rb +37 -30
- data/test/gir_ffi/callback_base_test.rb +4 -5
- data/test/gir_ffi/class_base_test.rb +35 -28
- data/test/gir_ffi/error_type_info_test.rb +14 -14
- data/test/gir_ffi/ffi_ext/pointer_test.rb +4 -4
- data/test/gir_ffi/g_type_test.rb +6 -6
- data/test/gir_ffi/in_out_pointer_test.rb +27 -27
- data/test/gir_ffi/in_pointer_test.rb +54 -50
- data/test/gir_ffi/info_ext/i_callable_info_test.rb +8 -7
- data/test/gir_ffi/info_ext/i_callback_info_test.rb +7 -7
- data/test/gir_ffi/info_ext/i_field_info_test.rb +10 -8
- data/test/gir_ffi/info_ext/i_function_info_test.rb +17 -15
- data/test/gir_ffi/info_ext/i_signal_info_test.rb +10 -8
- data/test/gir_ffi/info_ext/i_type_info_test.rb +158 -155
- data/test/gir_ffi/info_ext/i_unresolved_info_test.rb +17 -0
- data/test/gir_ffi/info_ext/safe_constant_name_test.rb +12 -10
- data/test/gir_ffi/info_ext/safe_function_name_test.rb +12 -10
- data/test/gir_ffi/interface_base_test.rb +6 -6
- data/test/gir_ffi/method_stubber_test.rb +16 -13
- data/test/gir_ffi/object_base_test.rb +6 -6
- data/test/gir_ffi/sized_array_test.rb +23 -23
- data/test/gir_ffi/type_map_test.rb +3 -3
- data/test/gir_ffi/unintrospectable_type_info_test.rb +18 -18
- data/test/gir_ffi/user_defined_property_info_test.rb +4 -4
- data/test/gir_ffi/user_defined_type_info_test.rb +16 -16
- data/test/gir_ffi/variable_name_generator_test.rb +6 -6
- data/test/gir_ffi/version_test.rb +1 -1
- data/test/gir_ffi/zero_terminated_test.rb +16 -17
- data/test/gir_ffi-base/glib/boolean_test.rb +13 -13
- data/test/gir_ffi-base/glib/strv_test.rb +11 -11
- data/test/gir_ffi_test.rb +18 -18
- data/test/gir_ffi_test_helper.rb +13 -18
- data/test/integration/derived_classes_test.rb +8 -8
- data/test/integration/generated_gimarshallingtests_test.rb +794 -792
- data/test/integration/generated_gio_test.rb +25 -26
- data/test/integration/generated_glib_test.rb +8 -2
- data/test/integration/generated_gobject_test.rb +16 -9
- data/test/integration/generated_pango_ft2_test.rb +1 -2
- data/test/integration/generated_pango_test.rb +2 -2
- data/test/integration/generated_regress_test.rb +785 -705
- data/test/integration/generated_secret_test.rb +5 -5
- data/test/integration/method_lookup_test.rb +5 -5
- data/test/introspection_test_helper.rb +3 -1
- data/test/minitest/stats_plugin.rb +3 -3
- metadata +6 -3
| @@ -31,7 +31,7 @@ module GirFFI | |
| 31 31 | 
             
                  end
         | 
| 32 32 |  | 
| 33 33 | 
             
                  def method_name
         | 
| 34 | 
            -
                     | 
| 34 | 
            +
                    'marshaller'
         | 
| 35 35 | 
             
                  end
         | 
| 36 36 |  | 
| 37 37 | 
             
                  def method_arguments
         | 
| @@ -42,7 +42,7 @@ module GirFFI | |
| 42 42 | 
             
                    if param_names.size == 1
         | 
| 43 43 | 
             
                      ["#{param_names.first} = param_values.first.get_value_plain"]
         | 
| 44 44 | 
             
                    else
         | 
| 45 | 
            -
                      ["#{param_names.join( | 
| 45 | 
            +
                      ["#{param_names.join(', ')} = param_values.map(&:get_value_plain)"]
         | 
| 46 46 | 
             
                    end
         | 
| 47 47 | 
             
                  end
         | 
| 48 48 |  | 
| @@ -1,10 +1,14 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
             | 
| 3 | 
            -
             | 
| 4 | 
            -
                 | 
| 5 | 
            -
             | 
| 1 | 
            +
            module GirFFI
         | 
| 2 | 
            +
              module Builders
         | 
| 3 | 
            +
                # Argument convertor that does nothing
         | 
| 4 | 
            +
                class NullConvertor
         | 
| 5 | 
            +
                  def initialize argument_name
         | 
| 6 | 
            +
                    @argument_name = argument_name
         | 
| 7 | 
            +
                  end
         | 
| 6 8 |  | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 9 | 
            +
                  def conversion
         | 
| 10 | 
            +
                    @argument_name
         | 
| 11 | 
            +
                  end
         | 
| 12 | 
            +
                end
         | 
| 9 13 | 
             
              end
         | 
| 10 14 | 
             
            end
         | 
| @@ -1,17 +1,21 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
             | 
| 3 | 
            -
             | 
| 4 | 
            -
             | 
| 5 | 
            -
                 | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 1 | 
            +
            module GirFFI
         | 
| 2 | 
            +
              module Builders
         | 
| 3 | 
            +
                # Builder that generates code to convert values from Ruby to C. Used by
         | 
| 4 | 
            +
                # argument builders.
         | 
| 5 | 
            +
                class RubyToCConvertor
         | 
| 6 | 
            +
                  def initialize type_info, argument_name
         | 
| 7 | 
            +
                    @type_info = type_info
         | 
| 8 | 
            +
                    @argument_name = argument_name
         | 
| 9 | 
            +
                  end
         | 
| 8 10 |  | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 11 | 
            +
                  def conversion
         | 
| 12 | 
            +
                    args = conversion_arguments @argument_name
         | 
| 13 | 
            +
                    "#{@type_info.argument_class_name}.from(#{args})"
         | 
| 14 | 
            +
                  end
         | 
| 13 15 |  | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            +
                  def conversion_arguments name
         | 
| 17 | 
            +
                    @type_info.extra_conversion_arguments.map(&:inspect).push(name).join(', ')
         | 
| 18 | 
            +
                  end
         | 
| 19 | 
            +
                end
         | 
| 16 20 | 
             
              end
         | 
| 17 21 | 
             
            end
         | 
| @@ -0,0 +1,12 @@ | |
| 1 | 
            +
            module GirFFI
         | 
| 2 | 
            +
              module InfoExt
         | 
| 3 | 
            +
                # Extensions for GObjectIntrospection::IUnresolvedInfo needed by GirFFI
         | 
| 4 | 
            +
                module IUnresolvedInfo
         | 
| 5 | 
            +
                  def to_ffitype
         | 
| 6 | 
            +
                    :pointer
         | 
| 7 | 
            +
                  end
         | 
| 8 | 
            +
                end
         | 
| 9 | 
            +
              end
         | 
| 10 | 
            +
            end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            GObjectIntrospection::IUnresolvedInfo.send :include, GirFFI::InfoExt::IUnresolvedInfo
         | 
    
        data/lib/gir_ffi/info_ext.rb
    CHANGED
    
    | @@ -8,6 +8,7 @@ require 'gir_ffi/info_ext/i_property_info' | |
| 8 8 | 
             
            require 'gir_ffi/info_ext/i_registered_type_info'
         | 
| 9 9 | 
             
            require 'gir_ffi/info_ext/i_signal_info'
         | 
| 10 10 | 
             
            require 'gir_ffi/info_ext/i_type_info'
         | 
| 11 | 
            +
            require 'gir_ffi/info_ext/i_unresolved_info'
         | 
| 11 12 | 
             
            require 'gir_ffi/info_ext/i_vfunc_info'
         | 
| 12 13 | 
             
            require 'gir_ffi/info_ext/safe_constant_name'
         | 
| 13 14 | 
             
            require 'gir_ffi/info_ext/safe_function_name'
         | 
    
        data/lib/gir_ffi/module_base.rb
    CHANGED
    
    
| @@ -1,17 +1,20 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
            #  | 
| 3 | 
            -
             | 
| 4 | 
            -
               | 
| 1 | 
            +
            module GirFFI
         | 
| 2 | 
            +
              # Class to represent the info for the receiver argument of a callback or
         | 
| 3 | 
            +
              # signal handler. Implements the necessary parts of IArgumentInfo's
         | 
| 4 | 
            +
              # interface.
         | 
| 5 | 
            +
              class ReceiverArgumentInfo
         | 
| 6 | 
            +
                attr_reader :argument_type
         | 
| 5 7 |  | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 8 | 
            +
                def initialize type
         | 
| 9 | 
            +
                  @argument_type = type
         | 
| 10 | 
            +
                end
         | 
| 9 11 |  | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 12 | 
            +
                def direction
         | 
| 13 | 
            +
                  :in
         | 
| 14 | 
            +
                end
         | 
| 13 15 |  | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            +
                def name
         | 
| 17 | 
            +
                  '_instance'
         | 
| 18 | 
            +
                end
         | 
| 16 19 | 
             
              end
         | 
| 17 20 | 
             
            end
         | 
| @@ -1,21 +1,23 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
            #  | 
| 3 | 
            -
             | 
| 4 | 
            -
               | 
| 1 | 
            +
            module GirFFI
         | 
| 2 | 
            +
              # Class to represent the info for the user data argument of a signal handler.
         | 
| 3 | 
            +
              # Implements the necessary parts of IArgumentInfo's interface.
         | 
| 4 | 
            +
              class UserDataArgumentInfo
         | 
| 5 | 
            +
                attr_reader :argument_type
         | 
| 5 6 |  | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 7 | 
            +
                def initialize type
         | 
| 8 | 
            +
                  @argument_type = type
         | 
| 9 | 
            +
                end
         | 
| 9 10 |  | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 11 | 
            +
                def direction
         | 
| 12 | 
            +
                  :in
         | 
| 13 | 
            +
                end
         | 
| 13 14 |  | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 15 | 
            +
                def skip?
         | 
| 16 | 
            +
                  false
         | 
| 17 | 
            +
                end
         | 
| 17 18 |  | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 19 | 
            +
                def name
         | 
| 20 | 
            +
                  '_user_data'
         | 
| 21 | 
            +
                end
         | 
| 20 22 | 
             
              end
         | 
| 21 23 | 
             
            end
         | 
| @@ -1,19 +1,21 @@ | |
| 1 1 | 
             
            require 'gir_ffi/info_ext/i_type_info'
         | 
| 2 2 |  | 
| 3 | 
            -
             | 
| 4 | 
            -
            #  | 
| 5 | 
            -
             | 
| 6 | 
            -
               | 
| 3 | 
            +
            module GirFFI
         | 
| 4 | 
            +
              # Represents the type of the user data (closure argument) of a signal or vfunc,
         | 
| 5 | 
            +
              # conforming, as needed, to the interface of GObjectIntrospection::ITypeInfo.
         | 
| 6 | 
            +
              class UserDataTypeInfo
         | 
| 7 | 
            +
                include InfoExt::ITypeInfo
         | 
| 7 8 |  | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 9 | 
            +
                def tag
         | 
| 10 | 
            +
                  :void
         | 
| 11 | 
            +
                end
         | 
| 11 12 |  | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 13 | 
            +
                def pointer?
         | 
| 14 | 
            +
                  true
         | 
| 15 | 
            +
                end
         | 
| 15 16 |  | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 17 | 
            +
                def array_length
         | 
| 18 | 
            +
                  -1
         | 
| 19 | 
            +
                end
         | 
| 18 20 | 
             
              end
         | 
| 19 21 | 
             
            end
         | 
    
        data/lib/gir_ffi/version.rb
    CHANGED
    
    
    
        data/test/base_test_helper.rb
    CHANGED
    
    | @@ -1,11 +1,9 @@ | |
| 1 | 
            -
            if RUBY_PLATFORM == 'java'
         | 
| 2 | 
            -
              require 'rubygems'
         | 
| 3 | 
            -
            end
         | 
| 1 | 
            +
            require 'rubygems' if RUBY_PLATFORM == 'java'
         | 
| 4 2 |  | 
| 5 3 | 
             
            begin
         | 
| 6 4 | 
             
              require 'simplecov'
         | 
| 7 5 | 
             
              SimpleCov.start do
         | 
| 8 | 
            -
                add_filter  | 
| 6 | 
            +
                add_filter '/test/'
         | 
| 9 7 | 
             
              end
         | 
| 10 8 | 
             
            rescue LoadError
         | 
| 11 9 | 
             
            end
         | 
| @@ -28,28 +26,28 @@ module GObjectIntrospection | |
| 28 26 | 
             
              class IRepository
         | 
| 29 27 | 
             
                def shared_library_with_regress namespace
         | 
| 30 28 | 
             
                  case namespace
         | 
| 31 | 
            -
                  when  | 
| 29 | 
            +
                  when 'Regress'
         | 
| 32 30 | 
             
                    return File.join(File.dirname(__FILE__), 'lib', 'libregress.so')
         | 
| 33 | 
            -
                  when  | 
| 31 | 
            +
                  when 'GIMarshallingTests'
         | 
| 34 32 | 
             
                    return File.join(File.dirname(__FILE__), 'lib', 'libgimarshallingtests.so')
         | 
| 35 33 | 
             
                  else
         | 
| 36 34 | 
             
                    return shared_library_without_regress namespace
         | 
| 37 35 | 
             
                  end
         | 
| 38 36 | 
             
                end
         | 
| 39 37 |  | 
| 40 | 
            -
                 | 
| 41 | 
            -
                 | 
| 38 | 
            +
                alias_method :shared_library_without_regress, :shared_library
         | 
| 39 | 
            +
                alias_method :shared_library, :shared_library_with_regress
         | 
| 42 40 | 
             
              end
         | 
| 43 41 | 
             
            end
         | 
| 44 42 |  | 
| 45 43 | 
             
            Thread.abort_on_exception = true
         | 
| 46 44 |  | 
| 47 | 
            -
             | 
| 45 | 
            +
            module BaseTestExtensions
         | 
| 48 46 | 
             
              def assert_defines_singleton_method klass, method, msg = nil
         | 
| 49 47 | 
             
                method = method.to_sym
         | 
| 50 | 
            -
                methods = klass.singleton_methods(false).map | 
| 48 | 
            +
                methods = klass.singleton_methods(false).map(&:to_sym)
         | 
| 51 49 | 
             
                msg = message(msg) {
         | 
| 52 | 
            -
                  "Expected #{mu_pp(klass)} to define singleton method #{mu_pp(method)}, "  | 
| 50 | 
            +
                  "Expected #{mu_pp(klass)} to define singleton method #{mu_pp(method)}, " \
         | 
| 53 51 | 
             
                    "but only found #{mu_pp(methods)}"
         | 
| 54 52 | 
             
                }
         | 
| 55 53 | 
             
                assert_includes methods, method, msg
         | 
| @@ -57,7 +55,7 @@ class Minitest::Test | |
| 57 55 |  | 
| 58 56 | 
             
              def refute_defines_singleton_method klass, method, msg = nil
         | 
| 59 57 | 
             
                method = method.to_sym
         | 
| 60 | 
            -
                methods = klass.singleton_methods(false).map | 
| 58 | 
            +
                methods = klass.singleton_methods(false).map(&:to_sym)
         | 
| 61 59 | 
             
                msg = message(msg) {
         | 
| 62 60 | 
             
                  "Expected #{mu_pp(klass)} not to define singleton method #{mu_pp(method)}"
         | 
| 63 61 | 
             
                }
         | 
| @@ -66,9 +64,9 @@ class Minitest::Test | |
| 66 64 |  | 
| 67 65 | 
             
              def assert_defines_instance_method klass, method, msg = nil
         | 
| 68 66 | 
             
                method = method.to_sym
         | 
| 69 | 
            -
                methods = klass.instance_methods(false).map | 
| 67 | 
            +
                methods = klass.instance_methods(false).map(&:to_sym)
         | 
| 70 68 | 
             
                msg = message(msg) {
         | 
| 71 | 
            -
                  "Expected #{mu_pp(klass)} to define instance method #{mu_pp(method)}, "  | 
| 69 | 
            +
                  "Expected #{mu_pp(klass)} to define instance method #{mu_pp(method)}, " \
         | 
| 72 70 | 
             
                    "but only found #{mu_pp(methods)}"
         | 
| 73 71 | 
             
                }
         | 
| 74 72 | 
             
                assert_includes methods, method, msg
         | 
| @@ -76,10 +74,12 @@ class Minitest::Test | |
| 76 74 |  | 
| 77 75 | 
             
              def refute_defines_instance_method klass, method, msg = nil
         | 
| 78 76 | 
             
                method = method.to_sym
         | 
| 79 | 
            -
                methods = klass.instance_methods(false).map | 
| 77 | 
            +
                methods = klass.instance_methods(false).map(&:to_sym)
         | 
| 80 78 | 
             
                msg = message(msg) {
         | 
| 81 79 | 
             
                  "Expected #{mu_pp(klass)} not to define instance method #{mu_pp(method)}"
         | 
| 82 80 | 
             
                }
         | 
| 83 81 | 
             
                refute_includes methods, method, msg
         | 
| 84 82 | 
             
              end
         | 
| 85 83 | 
             
            end
         | 
| 84 | 
            +
             | 
| 85 | 
            +
            Minitest::Test.send :include, BaseTestExtensions
         | 
    
        data/test/ffi-glib/array_test.rb
    CHANGED
    
    | @@ -1,41 +1,41 @@ | |
| 1 1 | 
             
            require 'gir_ffi_test_helper'
         | 
| 2 2 |  | 
| 3 3 | 
             
            describe GLib::Array do
         | 
| 4 | 
            -
              it  | 
| 4 | 
            +
              it 'knows its element type' do
         | 
| 5 5 | 
             
                arr = GLib::Array.new :gint32
         | 
| 6 6 | 
             
                assert_equal :gint32, arr.element_type
         | 
| 7 7 | 
             
              end
         | 
| 8 8 |  | 
| 9 | 
            -
              describe  | 
| 9 | 
            +
              describe '#append_vals' do
         | 
| 10 10 | 
             
                before do
         | 
| 11 11 | 
             
                  @arr = GLib::Array.new :gint32
         | 
| 12 12 | 
             
                  @result = @arr.append_vals [1, 2, 3]
         | 
| 13 13 | 
             
                end
         | 
| 14 14 |  | 
| 15 | 
            -
                it  | 
| 15 | 
            +
                it 'appends values' do
         | 
| 16 16 | 
             
                  assert_equal 3, @arr.len
         | 
| 17 17 | 
             
                end
         | 
| 18 18 |  | 
| 19 | 
            -
                it  | 
| 19 | 
            +
                it 'returns self' do
         | 
| 20 20 | 
             
                  assert_equal @result, @arr
         | 
| 21 21 | 
             
                end
         | 
| 22 22 | 
             
              end
         | 
| 23 23 |  | 
| 24 | 
            -
              describe  | 
| 24 | 
            +
              describe '#each' do
         | 
| 25 25 | 
             
                before do
         | 
| 26 26 | 
             
                  @arr = GLib::Array.new(:gint32).append_vals [1, 2, 3]
         | 
| 27 27 | 
             
                end
         | 
| 28 28 |  | 
| 29 | 
            -
                it  | 
| 29 | 
            +
                it 'iterates over the values' do
         | 
| 30 30 | 
             
                  a = []
         | 
| 31 | 
            -
                  @arr.each {|v| a << v }
         | 
| 31 | 
            +
                  @arr.each { |v| a << v }
         | 
| 32 32 |  | 
| 33 33 | 
             
                  assert_equal [1, 2, 3], a
         | 
| 34 34 | 
             
                end
         | 
| 35 35 | 
             
              end
         | 
| 36 36 |  | 
| 37 | 
            -
              describe  | 
| 38 | 
            -
                it  | 
| 37 | 
            +
              describe '::wrap' do
         | 
| 38 | 
            +
                it 'wraps a pointer, taking the element type as the first argument' do
         | 
| 39 39 | 
             
                  arr = GLib::Array.new :gint32
         | 
| 40 40 | 
             
                  arr.append_vals [1, 2, 3]
         | 
| 41 41 | 
             
                  arr2 = GLib::Array.wrap :gint32, arr.to_ptr
         | 
| @@ -48,8 +48,8 @@ describe GLib::Array do | |
| 48 48 | 
             
                  proc { GLib::Array.wrap :gint8, arr.to_ptr }.must_output nil, /sizes do not match/
         | 
| 49 49 | 
             
                end
         | 
| 50 50 |  | 
| 51 | 
            -
                it  | 
| 52 | 
            -
                  vals = [1, 2, 3].map {|i| GObject::EnumValue.new.tap {|ev| ev.value = i} }
         | 
| 51 | 
            +
                it 'handles a struct as the element type' do
         | 
| 52 | 
            +
                  vals = [1, 2, 3].map { |i| GObject::EnumValue.new.tap { |ev| ev.value = i } }
         | 
| 53 53 | 
             
                  arr = GLib::Array.new GObject::EnumValue
         | 
| 54 54 | 
             
                  arr.append_vals vals
         | 
| 55 55 | 
             
                  arr2 = GLib::Array.wrap GObject::EnumValue, arr.to_ptr
         | 
| @@ -57,35 +57,35 @@ describe GLib::Array do | |
| 57 57 | 
             
                end
         | 
| 58 58 | 
             
              end
         | 
| 59 59 |  | 
| 60 | 
            -
              it  | 
| 60 | 
            +
              it 'includes Enumerable' do
         | 
| 61 61 | 
             
                GLib::Array.must_include Enumerable
         | 
| 62 62 | 
             
              end
         | 
| 63 63 |  | 
| 64 | 
            -
              it  | 
| 64 | 
            +
              it 'has a working #to_a method' do
         | 
| 65 65 | 
             
                arr = GLib::Array.new :gint32
         | 
| 66 66 | 
             
                arr.append_vals [1, 2, 3]
         | 
| 67 67 | 
             
                assert_equal [1, 2, 3], arr.to_a
         | 
| 68 68 | 
             
              end
         | 
| 69 69 |  | 
| 70 | 
            -
              describe  | 
| 71 | 
            -
                it  | 
| 70 | 
            +
              describe '.from' do
         | 
| 71 | 
            +
                it 'creates a GArray from an array of :gint32' do
         | 
| 72 72 | 
             
                  arr = GLib::Array.from :gint32, [3, 2, 1]
         | 
| 73 73 | 
             
                  arr.data_ptr.read_array_of_int32(3).must_equal [3, 2, 1]
         | 
| 74 74 | 
             
                end
         | 
| 75 75 |  | 
| 76 | 
            -
                it  | 
| 76 | 
            +
                it 'creates a GArray from an array of :gboolean' do
         | 
| 77 77 | 
             
                  arr = GLib::Array.from :gboolean, [true, false, true]
         | 
| 78 78 | 
             
                  arr.data_ptr.read_array_of_int(3).must_equal [1, 0, 1]
         | 
| 79 79 | 
             
                end
         | 
| 80 80 |  | 
| 81 | 
            -
                it  | 
| 81 | 
            +
                it 'return its argument if given a GArray' do
         | 
| 82 82 | 
             
                  arr = GLib::Array.new :gint32
         | 
| 83 83 | 
             
                  arr.append_vals [3, 2, 1]
         | 
| 84 84 | 
             
                  arr2 = GLib::Array.from :gint32, arr
         | 
| 85 85 | 
             
                  assert arr2.equal? arr
         | 
| 86 86 | 
             
                end
         | 
| 87 87 |  | 
| 88 | 
            -
                it  | 
| 88 | 
            +
                it 'wraps its argument if given a pointer' do
         | 
| 89 89 | 
             
                  arr = GLib::Array.new :gint32
         | 
| 90 90 | 
             
                  arr.append_vals [3, 2, 1]
         | 
| 91 91 | 
             
                  pointer = arr.to_ptr
         | 
| @@ -97,27 +97,27 @@ describe GLib::Array do | |
| 97 97 | 
             
                end
         | 
| 98 98 | 
             
              end
         | 
| 99 99 |  | 
| 100 | 
            -
              describe  | 
| 101 | 
            -
                it  | 
| 100 | 
            +
              describe '#==' do
         | 
| 101 | 
            +
                it 'returns true when comparing to an array with the same elements' do
         | 
| 102 102 | 
             
                  arr = GLib::Array.from :gint32, [1, 2, 3]
         | 
| 103 103 |  | 
| 104 104 | 
             
                  arr.must_be :==, [1, 2, 3]
         | 
| 105 105 | 
             
                end
         | 
| 106 106 |  | 
| 107 | 
            -
                it  | 
| 107 | 
            +
                it 'returns false when comparing to an array with different elements' do
         | 
| 108 108 | 
             
                  arr = GLib::Array.from :gint32, [1, 2, 3]
         | 
| 109 109 |  | 
| 110 110 | 
             
                  arr.wont_be :==, [1, 2]
         | 
| 111 111 | 
             
                end
         | 
| 112 112 |  | 
| 113 | 
            -
                it  | 
| 113 | 
            +
                it 'returns true when comparing to a GArray with the same elements' do
         | 
| 114 114 | 
             
                  arr = GLib::Array.from :gint32, [1, 2, 3]
         | 
| 115 115 | 
             
                  other = GLib::Array.from :gint32, [1, 2, 3]
         | 
| 116 116 |  | 
| 117 117 | 
             
                  arr.must_be :==, other
         | 
| 118 118 | 
             
                end
         | 
| 119 119 |  | 
| 120 | 
            -
                it  | 
| 120 | 
            +
                it 'returns false when comparing to a GArray with different elements' do
         | 
| 121 121 | 
             
                  arr = GLib::Array.from :gint32, [1, 2, 3]
         | 
| 122 122 | 
             
                  other = GLib::Array.from :gint32, [1, 2]
         | 
| 123 123 |  | 
| @@ -125,56 +125,56 @@ describe GLib::Array do | |
| 125 125 | 
             
                end
         | 
| 126 126 | 
             
              end
         | 
| 127 127 |  | 
| 128 | 
            -
              describe  | 
| 129 | 
            -
                it  | 
| 128 | 
            +
              describe '#index' do
         | 
| 129 | 
            +
                it 'returns the proper element for an array of :gint32' do
         | 
| 130 130 | 
             
                  arr = GLib::Array.from :gint32, [1, 2, 3]
         | 
| 131 131 | 
             
                  arr.index(2).must_equal 3
         | 
| 132 132 | 
             
                end
         | 
| 133 133 |  | 
| 134 | 
            -
                it  | 
| 135 | 
            -
                  arr = GLib::Array.from :utf8,  | 
| 136 | 
            -
                  arr.index(1).must_equal  | 
| 134 | 
            +
                it 'returns the proper element for an array of :utf8' do
         | 
| 135 | 
            +
                  arr = GLib::Array.from :utf8, %w(a b c)
         | 
| 136 | 
            +
                  arr.index(1).must_equal 'b'
         | 
| 137 137 | 
             
                end
         | 
| 138 138 |  | 
| 139 | 
            -
                it  | 
| 139 | 
            +
                it 'returns the proper element for an array of :gboolean' do
         | 
| 140 140 | 
             
                  arr = GLib::Array.from :gboolean, [true, false, true]
         | 
| 141 141 | 
             
                  arr.index(1).must_equal false
         | 
| 142 142 | 
             
                end
         | 
| 143 143 |  | 
| 144 | 
            -
                it  | 
| 145 | 
            -
                  vals = [1, 2, 3].map {|i| GObject::EnumValue.new.tap {|ev| ev.value = i} }
         | 
| 144 | 
            +
                it 'returns the proper element for an array of struct' do
         | 
| 145 | 
            +
                  vals = [1, 2, 3].map { |i| GObject::EnumValue.new.tap { |ev| ev.value = i } }
         | 
| 146 146 | 
             
                  arr = GLib::Array.from GObject::EnumValue, vals
         | 
| 147 147 | 
             
                  arr.index(1).value.must_equal 2
         | 
| 148 148 | 
             
                end
         | 
| 149 149 |  | 
| 150 | 
            -
                it  | 
| 150 | 
            +
                it 'raises an error if the index is out of bounds' do
         | 
| 151 151 | 
             
                  arr = GLib::Array.from :gint32, [1, 2, 3]
         | 
| 152 152 | 
             
                  proc { arr.index(16) }.must_raise IndexError
         | 
| 153 153 | 
             
                  proc { arr.index(-1) }.must_raise IndexError
         | 
| 154 154 | 
             
                end
         | 
| 155 155 | 
             
              end
         | 
| 156 156 |  | 
| 157 | 
            -
              describe  | 
| 158 | 
            -
                describe  | 
| 159 | 
            -
                  it  | 
| 157 | 
            +
              describe '#reset_typespec' do
         | 
| 158 | 
            +
                describe 'when it needs to guess the type' do
         | 
| 159 | 
            +
                  it 'guesses :uint8 for size 1' do
         | 
| 160 160 | 
             
                    arr = GLib::Array.from :int8, [1, 2, 3]
         | 
| 161 161 | 
             
                    arr.reset_typespec
         | 
| 162 162 | 
             
                    arr.element_type.must_equal :uint8
         | 
| 163 163 | 
             
                  end
         | 
| 164 164 |  | 
| 165 | 
            -
                  it  | 
| 165 | 
            +
                  it 'guesses :uint16 for size 2' do
         | 
| 166 166 | 
             
                    arr = GLib::Array.from :int16, [1, 2, 3]
         | 
| 167 167 | 
             
                    arr.reset_typespec
         | 
| 168 168 | 
             
                    arr.element_type.must_equal :uint16
         | 
| 169 169 | 
             
                  end
         | 
| 170 170 |  | 
| 171 | 
            -
                  it  | 
| 171 | 
            +
                  it 'guesses :uint32 for size 4' do
         | 
| 172 172 | 
             
                    arr = GLib::Array.from :int32, [1, 2, 3]
         | 
| 173 173 | 
             
                    arr.reset_typespec
         | 
| 174 174 | 
             
                    arr.element_type.must_equal :uint32
         | 
| 175 175 | 
             
                  end
         | 
| 176 176 |  | 
| 177 | 
            -
                  it  | 
| 177 | 
            +
                  it 'guesses :uint64 for size 8' do
         | 
| 178 178 | 
             
                    arr = GLib::Array.from :int64, [1, 2, 3]
         | 
| 179 179 | 
             
                    arr.reset_typespec
         | 
| 180 180 | 
             
                    arr.element_type.must_equal :uint64
         | 
| @@ -1,21 +1,20 @@ | |
| 1 1 | 
             
            require 'gir_ffi_test_helper'
         | 
| 2 2 |  | 
| 3 3 | 
             
            describe GLib::ByteArray do
         | 
| 4 | 
            -
              it  | 
| 4 | 
            +
              it 'can succesfully be created with GLib::ByteArray.new' do
         | 
| 5 5 | 
             
                ba = GLib::ByteArray.new
         | 
| 6 6 | 
             
                assert_instance_of GLib::ByteArray, ba
         | 
| 7 7 | 
             
              end
         | 
| 8 8 |  | 
| 9 | 
            -
              it  | 
| 9 | 
            +
              it 'allows strings to be appended to it' do
         | 
| 10 10 | 
             
                ba = GLib::ByteArray.new
         | 
| 11 | 
            -
                ba.append  | 
| 11 | 
            +
                ba.append 'abdc'
         | 
| 12 12 | 
             
                pass
         | 
| 13 13 | 
             
              end
         | 
| 14 14 |  | 
| 15 | 
            -
              it  | 
| 15 | 
            +
              it 'has a working #to_string method' do
         | 
| 16 16 | 
             
                ba = GLib::ByteArray.new
         | 
| 17 | 
            -
                ba = ba.append  | 
| 18 | 
            -
                assert_equal  | 
| 17 | 
            +
                ba = ba.append 'abdc'
         | 
| 18 | 
            +
                assert_equal 'abdc', ba.to_string
         | 
| 19 19 | 
             
              end
         | 
| 20 20 | 
             
            end
         | 
| 21 | 
            -
             |