Updated Perl API for DBus
Daniel P. Berrange
dan at berrange.com
Tue Nov 23 15:54:20 PST 2004
I've done some further work on the Perl APIs I mentioned a few months
back. The previous low level APIs (equiv of Python dbus_bindings.pyx)
are now in Net::DBus::Binding::* modules. Using these, I've created a
set of high level APIs (equiv of Python dbus.py) for application
developers in Net::DBus::* modules - for ease of learning I'm trying
to keep the object & method names as close as possible to those in the
python bindings.
For a quick demo I've created Perl functional equivalents of the four
python example programs, using the same object/service names. So the
Perl example-client ought to work with the Python example-service
and vica-verca. Likewise for the example-signal-emitter and the
example-signal-recipient scripts.
The place where we divert from Python is with data typing. Since Perl
is a very loosely typed language, fields are added to messages as strings,
arrays or dictionaries. For interoperating with more strongly typed
languages, hints must be given about the data type to use. For example,
if a remote object had a 'getUser(id)' method which expected 'id' to be
a uint32 then rather than just calling
my $id = "123";
$object->getUser($id); # Encodes $id as a string
you'd have to do
my $id = "123";
$object->getUser(duint32($id)); # Encode $id as a uint32
When importing Net::DBus, it automatically provides these data type
hinting functions (dbool, dbyte, dint32, duint32, dfloat, dstring, etc).
Not ideal, but I'm can't think of anything better since Perl is weakly
typed and has no way of knowing what data types the remote method will
be expecting. If anyone's got other suggestions I'm open to them....
For those interested code is browsable as before from
http://cvs.berrange.com/cgi-bin/viewcvs.cgi/freeware/DBus/
While experimental RPMs (& soon Debian packages) are on my nightly
builder
http://autobuild.berrange.com/~builder/
Regards,
Dan.
--
|=- GPG key: http://www.berrange.com/~dan/gpgkey.txt -=|
|=- Perl modules: http://search.cpan.org/~danberr/ -=|
|=- Projects: http://freshmeat.net/~danielpb/ -=|
|=- berrange at redhat.com - Daniel Berrange - dan at berrange.com -=|
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: not available
Url : http://freedesktop.org/pipermail/dbus/attachments/20041123/9c0708b8/attachment.pgp
More information about the dbus
mailing list