[Kde-bindings] Delegate support for Qyoto

Arno Rehn arno at arnorehn.de
Tue Apr 1 12:42:47 UTC 2008

Am Montag 31 März 2008 19:37:11 schrieb Richard Dale:
> On Monday 31 March 2008 14:58:43 Arno Rehn wrote:
> > Hi,
> >
> > I just discovered that the deadline for the 4.1 feature plan is 7 April,
> > so I would suggest to add delegate support for Qyoto to this feature
> > list. The implementation of that is rather simple.
> > We already had a discussion about the ugliness of a construct like
> > Connect<bool>(this, SIGNAL("clicked(bool)"), delegate(bool b) { /* some
> > code */ });
> > but this would go away with the C# 3.0 features (If the programmer is
> > willing to use them). Anyway, we could add support methods like
> > AddClickedHandler() which looks even nicer and solve this problems for C#
> > versions prior to 3.0, too.
> In Glasgow when we were discussing, I think I just wanted to start with
> some simple types, whereas you wanted to autogenerate for all types. Did
> our solutions look the same apart from that - I'll need to find the code -
> I don't know where I put it.
My solution was to create 5 generic delegate types, one with one argument, one 
with two arguments and so on. Then create 5 generic Connect overloads, taking 
these delegate types as an argument (instead of a target object and a slot). 
When one of these methods was called, an instance of a new internal class was 
created which had overloads of a slot for every possible signal. I think this 
can be done better somewhere in qt_metacall.

> Does Mono have the C# 3.0 features to implement this then?
C# 3.0 can infere the type of generics based on a generic delegate that is 
given. So you can write Connect(foo, SIGNAL("clicked(bool)"), delegate(bool 
b) {}); without the generic arguments.

> We should add the modular smoke improvements and plans to wrap some KDE
> plugin apis in Ruby and C# to the release plan too I think.
Plasma (for C#) and Akanodi should be in there, at least.

Arno Rehn
arno at arnorehn.de

More information about the Kde-bindings mailing list