[Kde-bindings] KDE/kdebindings/perl/qtcore/src
Ryan Melton
ryanmelt at gmail.com
Wed Sep 22 02:17:14 UTC 2010
Here are patches to qtruby that fix the issue reported below. The
draggableicons and puzzle examples now work!
diff --git a/ext/ruby/qtruby/src/Qt.cpp b/ext/ruby/qtruby/src/Qt.cpp
index 36fcddd..d0c3288 100644
--- a/ext/ruby/qtruby/src/Qt.cpp
+++ b/ext/ruby/qtruby/src/Qt.cpp
@@ -526,6 +526,7 @@ findMethod(VALUE /*self*/, VALUE c_value, VALUE
name_value)
VALUE result = rb_ary_new();
Smoke::ModuleIndex classId = Smoke::findClass(c);
Smoke::ModuleIndex meth = Smoke::NullModuleIndex;
+ QList<Smoke::ModuleIndex> milist;
if (classId.smoke != 0) {
meth = classId.smoke->findMethod(c, name);
}
@@ -540,39 +541,47 @@ findMethod(VALUE /*self*/, VALUE c_value, VALUE
name_value)
Smoke::ModuleIndex mnid = s->idMethodName(name);
if (!cid.index || !mnid.index) continue;
meth = s->idMethod(cid.index, mnid.index);
- if (meth.index) break;
+ if (meth.index) milist.append(meth);
}
#ifdef DEBUG
if (do_debug & qtdb_calls) qWarning("Found method QGlobalSpace::%s
=> %d", name, meth.index);
#endif
}
+ else
+ {
+ milist.append(meth);
+ }
- if (meth.index == 0) {
+ if (milist.count() == 0) {
return result;
// empty list
- } else if (meth.index > 0) {
- Smoke::Index i = meth.smoke->methodMaps[meth.index].method;
- if (i == 0) { // shouldn't happen
- rb_raise(rb_eArgError, "Corrupt method %s::%s", c, name);
- } else if(i > 0) { // single match
- const Smoke::Method &methodRef = meth.smoke->methods[i];
- if ((methodRef.flags & Smoke::mf_internal) == 0) {
- rb_ary_push(result, rb_funcall(moduleindex_class,
rb_intern("new"), 2, INT2NUM(smokeList.indexOf(meth.smoke)), INT2NUM(i)));
- }
- } else { // multiple match
- i = -i; // turn into ambiguousMethodList index
- while (meth.smoke->ambiguousMethodList[i]) {
- const Smoke::Method &methodRef =
meth.smoke->methods[meth.smoke->ambiguousMethodList[i]];
- if ((methodRef.flags & Smoke::mf_internal) == 0) {
- rb_ary_push(result, rb_funcall(moduleindex_class,
rb_intern("new"), 2, INT2NUM(smokeList.indexOf(meth.smoke)),
INT2NUM(meth.smoke->ambiguousMethodList[i])));
+ } else {
+ foreach (Smoke::ModuleIndex meth, milist) {
+ if (meth.index > 0) {
+ Smoke::Index i = meth.smoke->methodMaps[meth.index].method;
+ if (i == 0) { // shouldn't happen
+ rb_raise(rb_eArgError, "Corrupt method %s::%s", c,
name);
+ } else if(i > 0) { // single match
+ const Smoke::Method &methodRef =
meth.smoke->methods[i];
+ if ((methodRef.flags & Smoke::mf_internal) == 0) {
+ rb_ary_push(result, rb_funcall(moduleindex_class,
rb_intern("new"), 2, INT2NUM(smokeList.indexOf(meth.smoke)), INT2NUM(i)));
+ }
+ } else { // multiple match
+ i = -i; // turn into ambiguousMethodList index
+ while (meth.smoke->ambiguousMethodList[i]) {
+ const Smoke::Method &methodRef =
meth.smoke->methods[meth.smoke->ambiguousMethodList[i]];
+ if ((methodRef.flags & Smoke::mf_internal) == 0) {
+ rb_ary_push(result,
rb_funcall(moduleindex_class, rb_intern("new"), 2,
INT2NUM(smokeList.indexOf(meth.smoke)),
INT2NUM(meth.smoke->ambiguousMethodList[i])));
//#ifdef DEBUG
- if (do_debug & qtdb_calls) qWarning("Ambiguous Method
%s::%s => %d", c, name, meth.smoke->ambiguousMethodList[i]);
+ if (do_debug & qtdb_calls) qWarning("Ambiguous
Method %s::%s => %d", c, name, meth.smoke->ambiguousMethodList[i]);
//#endif
- }
- i++;
+ }
+ i++;
+ }
+ }
}
- }
+ }
}
return result;
}
diff --git a/lib/Qt/qtruby4.rb b/lib/Qt/qtruby4.rb
index 7acb006..cf235c7 100755
--- a/lib/Qt/qtruby4.rb
+++ b/lib/Qt/qtruby4.rb
@@ -2740,11 +2740,11 @@ module Qt
# Multiple matches are an error; the equality test
below _cannot_ be commented out.
# 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
+ elsif current_match == best_match && id.smoke ==
chosen.smoke
puts "multiple methods matching, this is an error"
if debug_level >= DebugLevel::Minimal
chosen = nil
end
- puts "match => #{id.index} score: #{current_match}" if
debug_level >= DebugLevel::High
+ puts "match => #{id.index} score: #{current_match}
chosen: #{chosen}" if debug_level >= DebugLevel::High
end
puts "Resolved to id: #{chosen.index}" if !chosen.nil? &&
debug_level >= DebugLevel::High
@@ -2764,7 +2764,7 @@ module Qt
method_ids = hash.values_at(*constructor_names).flatten
puts dumpCandidates(method_ids)
else
- puts "setCurrentMethod(smokeList index: #{chosen.smoke},
meth index: #{chosen.index})" if debug_level >= DebugLevel::High
+ puts "setCurrentMethod(smokeList index: #{chosen.smoke},
meth index: #{chosen.index})" if debug_level >= DebugLevel::High && chosen
end
setCurrentMethod(chosen) if chosen
return nil
On Mon, Sep 20, 2010 at 10:09 PM, Ryan Melton <ryanmelt at gmail.com> wrote:
> Looks like this is probably the same probable affecting me in qtruby.
> I'll work on a patch.
> Ryan
>
>
> On Thu, Sep 2, 2010 at 8:49 PM, Chris Michael Burel <chrisburel at gmail.com>wrote:
>
>> SVN commit 1171223 by burel:
>>
>> When calling a method in QGlobalSpace, don't stop when you find the first
>> smoke module that provides the method you're looking for. Look through all
>> smoke modules. This was breaking when calling operator<< on a QPixmap,
>> because that method was defined by the QtGui module. The code would find
>> the methods from QtCore and stop there.
>>
>> I think the other bindings may want this too. I checked Ruby, and it
>> looked incorrect to me.
>>
>> CCMAIL: kde-bindings at kde.org
>>
>> M +7 -4 QtCore4.xs
>>
>>
>> --- trunk/KDE/kdebindings/perl/qtcore/src/QtCore4.xs #1171222:1171223
>> @@ -48,21 +48,23 @@
>> char* classname
>> char* methodname
>> PPCODE:
>> - Smoke::ModuleIndex mi;
>> + QList<Smoke::ModuleIndex> milist;
>> if ( strcmp( classname, "QGlobalSpace" ) == 0 ) {
>> // All modules put their global functions in "QGlobalSpace".
>> So we
>> // have to use each smoke object to look for this method.
>> for (int i = 0; i < smokeList.size(); ++i) {
>> - mi = smokeList.at(i)->findMethod(classname, methodname);
>> + Smoke::ModuleIndex mi =
>> smokeList.at(i)->findMethod(classname, methodname);
>> if( mi.smoke ) {
>> - break;
>> + // Found a result, add it to the return
>> + milist.append(mi);
>> }
>> }
>> }
>> else {
>> // qtcore_Smoke will be able to find any method not in
>> QGlobalSpace
>> - mi = qtcore_Smoke->findMethod(classname, methodname);
>> + milist.append( qtcore_Smoke->findMethod(classname,
>> methodname) );
>> }
>> + foreach (Smoke::ModuleIndex mi, milist) {
>> if ( !mi.index ) {
>> // empty list
>> }
>> @@ -95,6 +97,7 @@
>> }
>> }
>> }
>> + }
>>
>> #// Args: none
>> #// Returns: an array of all classes that qtcore_Smoke knows about
>> _______________________________________________
>> Kde-bindings mailing list
>> Kde-bindings at kde.org
>> https://mail.kde.org/mailman/listinfo/kde-bindings
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-bindings/attachments/20100921/96330163/attachment.html>
More information about the Kde-bindings
mailing list