[Kde-bindings] minor qtruby query (was Re: kdebindings/qtruby)

Richard Dale Richard_Dale at tipitina.demon.co.uk
Sat Aug 2 15:46:51 UTC 2003


On Saturday 02 August 2003 14:58, Alexander Kellett wrote:
> heya Richard ;-)
>
> okay. i've just commited this quick patch
> as i'm getting a ton of deprecation warnings
> when running with ruby 1.8.x, this removes
> the ones that i was seeing at least. but,
> there was a bit of strange code that i'm
> not sure i rewrote perfectly.
>
> > -                classname = aClass.name if aClass.type <= Module
>
> which i've replaced with
>
> > +                classname = aClass.name if aClass.is_a? Module
>
> i'm really quite unsure what exactly
> you were trying to do here?
>
> ri 'Module.<=' =>
It's code I copied from a book.. '<=' is in Module as a 'Hierarchy Query - One 
module is considered greater than another if it is included in (or is the 
parent of class of) the other module'. Page 344 of my copy of 'Programming 
Ruby'. Sounds like it's gone now..

> ------------------------------------------------------------- Module#<=>
>      mod <=> aModule -> -1, 0, +1
> ------------------------------------------------------------------------
>      Comparison---Returns -1 if mod includes aModule, 0 if mod is the
>      same as aModule, and +1 if mod is included by aModule or if mod has
>      no relationship with aModule.
>
> in any case i tested all the tutorials
> again with my latest version and other
> than a few missing super's (which i've
> added and commited) they work pretty
> well. so, maybe i'm missing something
> about the statements purpose?
>
> i've updated the ChangeLog with notes
> about this an a number of other changes.
>
> cheers,
> Alex
>
> On Sat, Aug 02, 2003 at 12:08:44PM +0200, Alexander Kellett wrote:
> > CVS commit by lypanov:
> > deprecation warning fixes when running under ruby 1.8.x
> >
> >   M +7 -7      rubylib/qtruby/lib/Qt/Qt.rb   1.3
> >
> > --- kdebindings/qtruby/rubylib/qtruby/lib/Qt/Qt.rb  #1.2:1.3
> > @@ -159,5 +159,5 @@
> >
> >          def hasMembers(aClass)
> > -                classname = aClass.name if aClass.type <= Module
> > +                classname = aClass.name if aClass.is_a? Module
> >                  meta = Meta[classname]
> >                  return meta != nil && (meta.signals.length > 0 or
> > meta.slots.length > 0) @@ -165,5 +165,5 @@
> >
> >          def getSignalNames(aClass)
> > -                classname = aClass.name if aClass.type <= Module
> > +                classname = aClass.name if aClass.is_a? Module
> >                  signalNames = Array.new
> >                  signals = Meta[classname].signals
> > @@ -177,10 +177,10 @@
> >
> >          def signalInfo(qobject, signalName)
> > -                classname = qobject.class.name if qobject.class.type <=
> > Module +                classname = qobject.class.name if
> > qobject.class.is_a? Module signals = Meta[classname].signals
> >                  i = 0
> >                  result = Array.new
> >                  for signal in signals
> > -                        if signal.sub(/\(.*/, '') =~ signalName
> > +                        if signal.sub(/\(.*/, '').include? signalName
> >                                  result.push(signal)
> >                                  result.push(i)
> > @@ -192,10 +192,10 @@
> >
> >          def signalAt(qobject, index)
> > -                classname = qobject.class.name if qobject.class.type <=
> > Module +                classname = qobject.class.name if
> > qobject.class.is_a? Module return Meta[classname].signals[index]
> >          end
> > -
> > +
> >          def slotAt(qobject, index)
> > -                classname = qobject.class.name if qobject.class.type <=
> > Module +                classname = qobject.class.name if
> > qobject.class.is_a? Module return Meta[classname].slots[index]
> >          end
Good! - it looks like you're finding your way around the code ok. This ruby 
stuff is just so readable :-)

You can't declare a slot like SLOT('foobar(int myarg)') at the moment, it 
needs some code like the C++ method 'normalizeSignalSlot' that the Qt runtime 
uses to tidy up what was passed in to the declarations.

-- Richard


More information about the Kde-bindings mailing list