[Kde-bindings] [Bug 229798] qtruby can't discern overloaded function which have QList parameter.

Richard Dale richard.dale at telefonica.net
Sun Mar 7 22:33:58 UTC 2010


https://bugs.kde.org/show_bug.cgi?id=229798





--- Comment #1 from Richard Dale <richard dale telefonica net>  2010-03-07 23:33:57 ---
On Sunday 07 March 2010 11:11:35 am ruby.twiddler at gmail.com wrote:
> https://bugs.kde.org/show_bug.cgi?id=229798
> 
>            Summary: qtruby can't discern overloaded function which have
>                     QList parameter.
>            Product: bindings
>            Version: unspecified
>           Platform: Compiled Sources
>         OS/Version: Linux
>             Status: UNCONFIRMED
>           Severity: normal
>           Priority: NOR
>          Component: general
>         AssignedTo: kde-bindings at kde.org
>         ReportedBy: ruby.twiddler at gmail.com
> 
> 
> Version:           Rev: 1097205 Last Changed Date: 2010-03-01: ruby-1.8.7
> (using KDE 4.4.0)
> OS:                Linux
> Installed from:    Compiled From Sources
> 
> qtruby can't discern overloaded function which have QList parameter.
> 
> KCoreConfigSkeleton::ItemEnum have two overloaded functions.
>    ItemEnum (const QString &_group, const QString &_key, qint32 &reference,
> const QList< Choice2 > &choices, qint32 defaultValue=0)
> 
>     ItemEnum (const QString &_group, const QString &_key, qint32
> &reference, const QList< Choice > &choices, qint32 defaultValue=0)
> 
> QList< Choise2 > and QList< Choise > are different.
> but qtruby end with error.
> /usr/lib/ruby/site_ruby/1.8/Qt/qtruby4.rb:2611:in `initialize': unresolved
> constructor call KDE::ConfigSkeleton::ItemEnum (ArgumentError)
> 
> 
> I want ruby to deal with it.
> here is my patch to treat the problem.
> 
> ------ patch file from here -----
> diff -x .svn -uNrb kdebindings-latest/ruby/qtruby/src/lib/Qt/qtruby4.rb
> kdebindings-fix/ruby/qtruby/src/lib/Qt/qtruby4.rb
> --- kdebindings-latest/ruby/qtruby/src/lib/Qt/qtruby4.rb    2010-03-05
> 11:10:02.000000000 +0900
> +++ kdebindings-fix/ruby/qtruby/src/lib/Qt/qtruby4.rb    2010-03-06
> 16:08:35.000000000 +0900
> @@ -2503,7 +2503,8 @@
>              Qt.debug_level
>          end
> 
> -        def Internal.checkarg(argtype, typename)
> +        def Internal.checkarg(arg, typename)
> +            argtype = get_value_type(arg)
>              puts "      #{typename} (#{argtype})" if debug_level >=
> DebugLevel::High
>              const_point = typename =~ /^const\s+/ ? -1 : 0
>              if argtype == 'i'
> @@ -2579,6 +2580,9 @@
>              elsif argtype == 'U'
>                  if typename =~ /QStringList/
>                      return 4 + const_point
> +                elsif typename =~ /QList<(.+)>/ && arg.kind_of?(Array) &&
> !arg.empty? &&
> +                        get_value_type(arg[0]) == $1
> +                    return 3
>                  else
>                      return 2 + const_point
>                  end
> @@ -2701,7 +2705,7 @@
>                      current_match = 0
>                      (0...args.length).each do
> 
>                          |i|
> 
> -                        current_match += checkarg(get_value_type(args[i]),
> get_arg_type_name(id, i))
> +                        current_match += checkarg(args[i],
> get_arg_type_name(id, i))
>                      end
> 
>                      # Note that if current_match > best_match, then chosen
> must be nil
> 
> 
> ------ end of patch file -----
> 
> 
> --- sample test code ---
> #!/usr/bin/ruby
> APP_NAME = "test"
> APP_VERSION = "0.1"
> 
> require 'korundum4'
> 
> about = KDE::AboutData.new(APP_NAME, nil, KDE::ki18n(APP_NAME),
> APP_VERSION) KDE::CmdLineArgs.init(ARGV, about)
> 
> $app = KDE::Application.new
> args = KDE::CmdLineArgs.parsedArgs()
> 
> class SettingsTest < KDE::ConfigSkeleton
>     def test(list)
>         choices = []
>         list.each do |i|
>             c = ItemEnum::Choice.new
>             c.name = i
>             choices << c
>         end
>         item = ItemEnum.new(currentGroup, "foods", 0, choices, 0)
>     end
> end
> 
> s = SettingsTest.new
> p s.test( %q{ takoyaki dorayaki } )
> --- end of sample test code ---
ItemEnum::Choice2 is the new version of ItemEnum::Choice and so I don't think 
we need to support both in language bindings. In the rest of the Qt/KDE apis 
overloading on a different QList type is pretty rare and I would rather special 
case them on an individual basis, instead of making the general purpose method 
overload resolution code handle them. In the code in the patch above it will 
examine the first argument of every type of QList, and not just where it is 
needed. That will slow down the processing for every QList based argument type 
just for the tiny number of method calls where it is needed.

-- Richard

-- 
Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the Kde-bindings mailing list