[Kde-bindings] Implementing Ruby DCOP

Richard Dale Richard_Dale at tipitina.demon.co.uk
Fri Sep 26 10:20:11 UTC 2003


On Friday 26 September 2003 09:06, Alexander Kellett wrote:
> On Fri, Sep 26, 2003 at 08:43:19AM +0100, Richard Dale wrote:
> > On Friday 26 September 2003 08:23, Richard Dale wrote:
> > > On Friday 26 September 2003 07:57, Richard Dale wrote:
> > > > I like this one best at the moment:
> > > >  $kapp.dcopClient().emit clientDied(pid)
> > >
> > > Oops, I don't think that will work. It should be:
> > >
> > > $kapp.dcopClient().emit.clientDied(pid)
> > >
> > > All this emit does is take zero args and return self.
>
> this is admittedly more like the c++ version,
> and is very easy to implement using method_missing.
>
> but really i'd suggest that whatever is chosen is
> natural to ruby, easy to convert from the equivalent
> c++, and applicable to both dcop and non dcop signals.
>
> > Here's another couple, emitting a block is more ruby-like perhaps?
> >
> >    $kapp.dcopClient().emitDCOPSignal { clientDied(pid_t) }
> >
> >    $kapp.dcopClient().emit { clientDied(pid_t) }
> >
> > 'emitDCOPSignal' name seems to long and noisy to me - I can't see what
> > else a dcopClient would be emitting other than a dcop signal.
>
> not really sure i like this syntax, and its pretty
> difficult to implement :) - you need to do a temporary
> override on the blocks method_missing. which is
> probably possibly knowing ruby, but i've not idea
> how to do so :)
No, you don't need that because the clientDied() method actually exists in 
dcopClient() - it gets added dynamically. It's just a matter of adding an 
option to emit() so that it runs a block if one is passed to it. If the arg 
is an ordinary method call is that just gets called when passed. But if the 
syntax is ugly/not rubylike, perhaps it isn't worth doing.

-- Richard


More information about the Kde-bindings mailing list