[Kde-bindings] branches/KDE/4.4/kdebindings/ruby/qtruby/src
Arno Rehn
kde at arnorehn.de
Fri Jan 29 21:47:41 UTC 2010
SVN commit 1082174 by arnorehn:
backport from trunk:
Apply a patch from Stefano Crocco to prefer non-const
types and methods over const ones.
This fixes various unresolved method/constructor call errors.
Thanks for the patch!
CCMAIL: kde-bindings at kde.org
M +30 -25 lib/Qt/qtruby4.rb
M +10 -0 qtruby.cpp
--- branches/KDE/4.4/kdebindings/ruby/qtruby/src/lib/Qt/qtruby4.rb #1082173:1082174
@@ -2505,51 +2505,52 @@
def Internal.checkarg(argtype, typename)
puts " #{typename} (#{argtype})" if debug_level >= DebugLevel::High
+ const_point = typename =~ /^const\s+/ ? -1 : 0
if argtype == 'i'
if typename =~ /^int&?$|^signed int&?$|^signed$|^qint32&?$/
- return 3
+ return 6 + const_point
elsif typename =~ /^quint32&?$/
- return 2
+ return 4 + const_point
elsif typename =~ /^(?:short|ushort|unsigned short int|unsigned short|uchar||unsigned char|uint|long|ulong|unsigned long int|unsigned|float|double|WId|Q_PID|^quint16&?$|^qint16&?$)$/
- return 2
+ return 4 + const_point
elsif typename =~ /^(quint|qint|qulong|qlong|qreal)/
- return 2
+ return 4 + const_point
else
t = typename.sub(/^const\s+/, '')
t.sub!(/[&*]$/, '')
if isEnum(t)
- return 1
+ return 2
end
end
elsif argtype == 'n'
if typename =~ /^double$|^qreal$/
- return 3
+ return 6 + const_point
elsif typename =~ /^float$/
- return 2
+ return 4 + const_point
elsif typename =~ /^int&?$/
- return 1
+ return 2 + const_point
elsif typename =~ /^(?:short|ushort|uint|long|ulong|signed|unsigned|float|double)$/
- return 1
+ return 2 + const_point
else
t = typename.sub(/^const\s+/, '')
t.sub!(/[&*]$/, '')
if isEnum(t)
- return 1
+ return 2 + const_point
end
end
elsif argtype == 'B'
if typename =~ /^(?:bool)[*&]?$/
- return 1
+ return 2 + const_point
end
elsif argtype == 's'
if typename =~ /^(const )?((QChar)[*&]?)$/
- return 3
+ return 6 + const_point
elsif typename =~ /^(?:(u(nsigned )?)?char\*)$/
- return 2
+ return 4 + const_point
elsif typename =~ /^(?:const (u(nsigned )?)?char\*)$/
- return 1
+ return 2 + const_point
elsif typename =~ /^(?:(?:const )?(QString)[*&]?)$/
- return 4
+ return 8 + const_point
end
elsif argtype == 'a'
# FIXME: shouldn't be hardcoded. Installed handlers should tell what ruby type they expect.
@@ -2563,35 +2564,35 @@
char\*\*
)
)$/x
- return 1
+ return 2 + const_point
end
elsif argtype == 'u'
# Give nil matched against string types a higher score than anything else
if typename =~ /^(?:u?char\*|const u?char\*|(?:const )?((Q(C?)String))[*&]?)$/
- return 2
+ return 4 + const_point
# Numerics will give a runtime conversion error, so they fail the match
elsif typename =~ /^(?:short|ushort|uint|long|ulong|signed|unsigned|int)$/
return -99
else
- return 1
+ return 2 + const_point
end
elsif argtype == 'U'
if typename =~ /QStringList/
- return 2
+ return 4 + const_point
else
- return 1
+ return 2 + const_point
end
else
t = typename.sub(/^const\s+/, '')
t.sub!(/(::)?Ptr$/, '')
t.sub!(/[&*]$/, '')
if argtype == t
- return 2
+ return 4 + const_point
elsif classIsa(argtype, t)
- return 1
+ return 2 + const_point
elsif isEnum(argtype) and
(t =~ /int|qint32|uint|quint32|long|ulong/ or isEnum(t))
- return 1
+ return 2 + const_point
end
end
return -99
@@ -2711,8 +2712,12 @@
# If ambiguous matches occur the problem must be fixed be adjusting the relative
# ranking of the arg types involved in checkarg().
elsif current_match == best_match
- puts "multiple methods matching, this is an error" if debug_level >= DebugLevel::Minimal
- chosen = nil
+ if !isConstMethod(id) and isConstMethod(chosen)
+ chosen = id
+ elsif isConstMethod(id) == isConstMethod(chosen)
+ puts "multiple methods matching, this is an error" if debug_level >= DebugLevel::Minimal
+ chosen = nil
+ end
end
puts "match => #{id.index} score: #{current_match}" if debug_level >= DebugLevel::High
end
--- branches/KDE/4.4/kdebindings/ruby/qtruby/src/qtruby.cpp #1082173:1082174
@@ -2057,6 +2057,15 @@
}
static VALUE
+isConstMethod(VALUE /*self*/, VALUE idx)
+{
+ int id = NUM2INT(rb_funcall(idx, rb_intern("index"), 0));
+ Smoke* smoke = smokeList[NUM2INT(rb_funcall(idx, rb_intern("smoke"), 0))];
+ const Smoke::Method &meth = smoke->methods[id];
+ return (meth.flags & Smoke::mf_const) ? Qtrue : Qfalse;
+}
+
+static VALUE
isObject(VALUE /*self*/, VALUE obj)
{
void * ptr = 0;
@@ -2397,6 +2406,7 @@
rb_define_module_function(qt_internal_module, "findAllMethods", (VALUE (*) (...)) findAllMethods, -1);
rb_define_module_function(qt_internal_module, "findAllMethodNames", (VALUE (*) (...)) findAllMethodNames, 3);
rb_define_module_function(qt_internal_module, "dumpCandidates", (VALUE (*) (...)) dumpCandidates, 1);
+ rb_define_module_function(qt_internal_module, "isConstMethod", (VALUE (*) (...)) isConstMethod, 1);
rb_define_module_function(qt_internal_module, "isObject", (VALUE (*) (...)) isObject, 1);
rb_define_module_function(qt_internal_module, "setCurrentMethod", (VALUE (*) (...)) setCurrentMethod, 1);
rb_define_module_function(qt_internal_module, "getClassList", (VALUE (*) (...)) getClassList, 0);
More information about the Kde-bindings
mailing list