perl DCOP module
Anders Lund <[email protected]>
| Newsgroups | gmane.comp.kde.devel.kate |
|---|---|
| Organization | Saguaro |
| Message-ID | <[email protected]> |
Hi Malte,
I am experimenting with the DCOP module, for use with kscript/kate.
It never passed
make test, though most of (those i tried) the examples in the test suite works
if I run them from another script, or using -e
My worst problems are
* I can't pass unsigned (ints)
* The usage of wantarray in the objects prevents writing sane code.
My perl version is 5.6.1, do I need a newer/older one?
And, is there anything I can do to help with the DCOP module? XS is still
somewhat black to me, but I do see something related to return type in there,
I suggest that objects returns the value if the return type is not void. As
for the unsigned integer problems, I am confused, as the code looks sane to
me.
The following script explains nicely the problems I have (note that the key
dcop method KateMainWindowDCOPIface::currentDocumentIfaceNumber() isn't
available in CVS yet):
#!/usr/bin/perl
# convert current document contents to lower case.
# avoid setText(), which deletes the undo history and hl.
use DCOP;
my $client = new DCOP;
$client->attach();
#print STDOUT "$_\n" for (0..$#ARGV); # for kscript
my $app = "kate"; #shift @ARGV;
my $win = "KateMainWindow0";
# Kate special: document number == Iface #
sub interface( $$ ) {
my ($interf, $number) = @_;
$client->createObject( $app, "$interf#$number" );
}
my $mw = $client->createObject( $app, $win );
my ($docNumber) = $mw->currentDocumentIfaceNumber();
my $editIF = interface( "EditInterface", $docNumber );
my ($text) = $editIF->text();
#### This line fails, which it should NOT!!!
# (DCOP should return the value, if the return type != "void"):
#my $lastLine = $editIF->numLines() - 1;
# instead we have to do:
my ($lastLine) = $editIF->numLines();
$lastLine--;
##### The next one fails too, again it SHOULD NOT!!!!!:
#my $lastCol = length( $editIF->textLine($lastLine) );
# I could grab number/length of lines of the text instead:
# my @lines = split "\n", $text;
# my $lastLine = $#lines;
# my $lastCol = length $lines[$#lines];
##### The rest does not work, as we can not pass unsigned integers
my ($line) = $editIF->textLine($lastLine);
$lastCol = length ( $line );
$editIF->removeText( 0, 0, $lastLine, $lastCol );
$editIF->insertText( 0, 0, lc $text );
# DONE!
$client->detach();
# for debug:
# this is the last line, length: 35
-anders