[Kde-bindings] Adding PerlKDE DCOP support
Richard Dale
Richard_Dale at tipitina.demon.co.uk
Mon Jul 11 12:51:26 UTC 2005
I've got PerlKDE built and it runs the kludgeror browser - woo hoo! You can
now write a full featured browser in less than 150 lines of perl, which is
one of the reasons I'm looking forward to this next release of PerlQt. So you
can make use of KParts components from perl.
Another important feature of KDE that would make the PerlKDE bindings even
more powerful is DCOP support. There in already some work on this in
kdebindings/perldcop, but it is limited to just calling existing apps with
DCOP interfaces and doesn't allow you to define DCOP slots and so on.
I've had a look at what was involved adding DCOP support to the Korundum ruby
bindings and extracted the DCOP bits from that project.
There are two functions smokeStackToStream() and smokeStackFromStream() that
interface the Smoke::Stack with QDataStream/QByteArrays that are used to
communicate to and from DCOP:
/*
Copy items from the stack to the stream, each item has a corresponding
description in the
args array of MocArguments. Used for marshalling the args to DCOP calls and
sends, emitting
DCOP signals, and converting the return value of a DCOP slot to a stream.
*/
static void
smokeStackToStream(Marshall *m, Smoke::Stack stack, QDataStream* stream, int
items, MocArgument* args)
{
...
}
/*
Copy items from the stream to the stack, each item has a corresponding
description in the
args array of MocArguments. Used for marshalling the arguments to a DCOP slot
invocation,
and for converting a dcop reply to a ruby value.
*/
static void
smokeStackFromStream(Marshall *m, Smoke::Stack stack, QDataStream* stream, int
items, MocArgument* args)
{
...
}
I only had to add some headers to KDE.xs to get these to compile 'as is' -
there are no ruby dependencies.
Then there are various C++ classes which marshall DCOP args to and from the
Smoke stack, they are very much the same as the C++ classes in Qt.xs (or
Qt.cpp in ruby) for the Qt slots and signals. So porting these to perl just
consists of seeing how the Qt signal/slot classes needed to be changed to
port them to ruby, and then doing the same thing in reverse for the perl DCOP
ones from ruby.
tipitina duke 472% grep ^class KDE.xs
class DCOPReturn : public Marshall {
class DCOPCall : public Marshall {
class DCOPSend : public Marshall {
class EmitDCOPSignal : public Marshall {
class DCOPReplyValue : public Marshall {
class InvokeDCOPSlot : public Marshall {
I've removed some marshalling code for types which weren't in the Smoke
runtime (they didn't have QDataStream methods in there), as they don't really
need to be done for a first release.
There are some native methods implemented for ruby, and these need to be
converted to perl xs ones:
# Add a method for each signal defined via 'k_dcop_signal':
rb_define_method(klass, StringValuePtr(signal), (VALUE (*) (...))
k_dcop_signal, -1);
rb_define_method(klass, "interfaces", (VALUE (*) (...)) dcop_interfaces, 0);
rb_define_method(klass, "functions", (VALUE (*) (...)) dcop_functions, 0);
rb_define_method(klass, "connectDCOPSignal", (VALUE (*) (...))
dcop_connect_signal, 5);
rb_define_method(klass, "disconnectDCOPSignal", (VALUE (*) (...))
dcop_disconnect_signal, 4);
rb_define_singleton_method(kde_module, "dcop_process", (VALUE (*) (...))
dcop_process, 7);
rb_define_singleton_method(kde_module, "dcop_call", (VALUE (*) (...))
dcop_call, -1);
rb_define_singleton_method(kde_module, "dcop_send", (VALUE (*) (...))
dcop_send, -1);
Finally there is some ruby code in KDE.rb, which needs be translated to perl.
There is a DCOPMetaObject which is very similar to the MetaObject class in
QtRuby and PerlQt, and that should be straightforward to translate to perl.
The main difference is that DCOP slots have a return type, whereas Qt slots
are always void.
Apart from adding DCOP support, PerlKDE just needs more marshallers - it
really has a very complete coverage of the KDE api via the SmokeKDE library.
I don't think it is too difficult to look at the Korundum marshallers and
translate them to perl.
On the kde-bindings list Gábor Lehel has recently been adding KCanvas support
to the ruby Korundum bindings, and he has managed to work out what all the
marshalling stuff was about quite successfully from playing with the source.
Encouraged by that, I'm hoping I someone keen on PerlKDE might help out, not
just Ashley, Germain or myself, as it isn't as hard as it sounds.
But even without that help, and asking a few questions about xs stuff, I don't
think it would take me too long and would be a lot of bang for very little
bucks.. I attached to KDE.xs and KDE.rb sources as starting points for
PerlKDE DCOP support.
-- Richard
-------------- next part --------------
A non-text attachment was scrubbed...
Name: perlkde_dcop.tgz
Type: application/x-tgz
Size: 9065 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-bindings/attachments/20050711/cd09d5e4/attachment.bin>
More information about the Kde-bindings
mailing list