Bug 110415 - [qtruby] allow Qt::Object::inherits to use QtRuby syntax
Summary: [qtruby] allow Qt::Object::inherits to use QtRuby syntax
Status: RESOLVED FIXED
Alias: None
Product: bindings
Classification: Developer tools
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR wishlist
Target Milestone: ---
Assignee: kde-bindings
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-08-08 21:06 UTC by Caleb Tennis
Modified: 2005-08-22 17:55 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 Caleb Tennis 2005-08-08 21:06:34 UTC
Version:            (using KDE KDE 3.4.2)
Installed from:    Compiled From Sources

One nice feature would be to allow Qt::Object::inherits() to use the QtRuby naming scheme for valid lookups.  For example, right now:

irb(main):001:0> w = Qt::Widget.new(nil)
irb(main):002:0> w.inherits("Qt::Widget")
=> true
irb(main):003:0> w.inherits("Qt::Object")
=> false
irb(main):004:0> w.inherits("QWidget")
=> true
irb(main):005:0> w.inherits("QObject")
=> true

inherits works for "QObject", but my wish is that it worked for "Qt::Object" as well.
Comment 1 Richard Dale 2005-08-09 11:27:55 UTC
SVN commit 444221 by rdale:

* Caleb Tennis wrote:
  One nice feature would be to allow Qt::Object::inherits() to use the QtRuby 
  naming scheme for valid lookups.  For example, right now:

    irb(main):001:0> w = Qt::Widget.new(nil)
    irb(main):002:0> w.inherits("Qt::Widget")
    => true
    irb(main):003:0> w.inherits("Qt::Object")
    => false
    irb(main):004:0> w.inherits("QWidget")
    => true
    irb(main):005:0> w.inherits("QObject")
    => true

* Inherits now works for "QObject", and for "Qt::Object" as well.

CCBUGS: 110415


 M  +18 -0     ChangeLog  
 M  +20 -0     rubylib/qtruby/Qt.cpp  


--- branches/KDE/3.5/kdebindings/qtruby/ChangeLog #444220:444221
@@ -1,3 +1,21 @@
+2005-08-09  Richard Dale  <Richard_Dale@tipitina.demon.co.uk>
+	
+	* Caleb Tennis wrote:
+	  One nice feature would be to allow Qt::Object::inherits() to use the QtRuby 
+	  naming scheme for valid lookups.  For example, right now:
+
+	    irb(main):001:0> w = Qt::Widget.new(nil)
+	    irb(main):002:0> w.inherits("Qt::Widget")
+	    => true
+	    irb(main):003:0> w.inherits("Qt::Object")
+	    => false
+	    irb(main):004:0> w.inherits("QWidget")
+	    => true
+	    irb(main):005:0> w.inherits("QObject")
+	    => true
+
+	* Inherits now works for "QObject", and for "Qt::Object" as well.
+
 2005-08-04  Richard Dale  <Richard_Dale@tipitina.demon.co.uk>
 
 	* Added a file called 'COPYING' to the qtruby project, with a note that
--- branches/KDE/3.5/kdebindings/qtruby/rubylib/qtruby/Qt.cpp #444220:444221
@@ -1784,6 +1784,25 @@
     return rb_funcall(klass, rb_intern("name"), 0);
 }
 
+// Allow classnames in both 'Qt::Widget' and 'QWidget' formats to be
+// used as an argument to Qt::Object.inherits()
+static VALUE
+inherits_qobject(int argc, VALUE * argv, VALUE /*self*/)
+{
+	if (argc != 1) {
+		return rb_call_super(argc, argv);
+	}
+
+	Smoke::Index * classId = classcache.find(StringValuePtr(argv[0]));
+
+	if (classId == 0) {
+		return rb_call_super(argc, argv);
+	} else {
+		VALUE super_class = rb_str_new2(qt_Smoke->classes[*classId].className);
+		return rb_call_super(argc, &super_class);
+	}
+}
+
 static void
 mocargs_free(void * ptr)
 {
@@ -2477,6 +2496,7 @@
 	rb_define_method(klass, "pretty_print", (VALUE (*) (...)) pretty_print_qobject, 1);
 	rb_define_method(klass, "receivers", (VALUE (*) (...)) receivers_qobject, 0);
 	rb_define_method(klass, "className", (VALUE (*) (...)) class_name, 0);
+	rb_define_method(klass, "inherits", (VALUE (*) (...)) inherits_qobject, -1);
     
 	return klass;
 }
Comment 2 Caleb Tennis 2005-08-22 17:55:26 UTC
Is fixed.