[Kde-bindings] Qyoto Delegate Patch
Arno Rehn
arno at arnorehn.de
Thu Jul 12 19:48:16 UTC 2007
Hi,
based on the discussion Richard and I had at akademy about signals mapping
onto delegates, I hacked kalyptus to generate generic delegates but keep the
various overloaded 'Connect' methods. In my opinion it's simply the less
ugliest possibility.
Now you can say:
Connect(button, SIGNAL("clicked(bool)"), delegate(bool b) {
Console.WriteLine("Bool {0}", b);
});
or
button.AddClickedHandler(delegate(bool b) {
Console.WriteLine("Bool {0}", b);
});
Instead of an anonymous delegate you could of course give a normal method to
the functions.
The other possibility would have been to make also the Connect method generic,
which would then look like this:
Connect<bool>(button, SIGNAL("clicked(bool)"), delegate(bool b) {
Console.WriteLine("Bool {0}", b);
});
With this version we would have to check what delegate type the programmer
actually used and then connect to the appropiate imternal slot. So the actual
amount of code generated wouldn't decrease, we'd only have less
overloaded 'Connect' methods.
Personally spoken, I think the first version without a generic Connect is much
nicer.
I uploaded a patch here since it's quite a large one:
http://pumphaus.kilu.de/programming/delegate_patch.patch
It also adds a new option to the CMakeLists.txt with which you can
enable/disable the new experimental API (ENABLE_QYOTO_EXPERIMENTAL, disabled
by default). Patch from the top level kdebindings directory, with -p0.
--
Arno Rehn
arno at arnorehn.de
More information about the Kde-bindings
mailing list