Bug 229798 - qtruby can't discern overloaded function which have QList parameter.
Summary: qtruby can't discern overloaded function which have QList parameter.
Status: RESOLVED WORKSFORME
Alias: None
Product: bindings
Classification: Developer tools
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: kde-bindings
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-03-07 12:10 UTC by ruby.twiddler
Modified: 2023-01-11 05:19 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ruby.twiddler 2010-03-07 12:10:10 UTC
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 ---
Comment 1 Richard Dale 2010-03-07 23:33:57 UTC
On Sunday 07 March 2010 11:11:35 am ruby.twiddler@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@kde.org
>         ReportedBy: ruby.twiddler@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
Comment 2 Andrew Crouthamel 2018-11-02 23:00:08 UTC
Dear Bug Submitter,

This bug has been stagnant for a long time. Could you help us out and re-test if the bug is valid in the latest version? I am setting the status to NEEDSINFO pending your response, please change the Status back to REPORTED when you respond.

Thank you for helping us make KDE software even better for everyone!
Comment 3 Andrew Crouthamel 2018-11-16 05:30:59 UTC
Dear Bug Submitter,

This is a reminder that this bug has been stagnant for a long time. Could you help us out and re-test if the bug is valid in the latest version?

Thank you for helping us make KDE software even better for everyone!
Comment 4 Justin Zobel 2022-12-12 01:56:06 UTC
Thank you for reporting this issue in KDE software. As it has been a while since this issue was reported, can we please ask you to see if you can reproduce the issue with a recent software version?

If you can reproduce the issue, please change the status to "REPORTED" when replying. Thank you!
Comment 5 Bug Janitor Service 2022-12-27 05:21:23 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 6 Bug Janitor Service 2023-01-11 05:19:19 UTC
This bug has been in NEEDSINFO status with no change for at least
30 days. The bug is now closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

Thank you for helping us make KDE software even better for everyone!