Subject: | Can't parse type with a(asaasay) |
Hi,
I have problem to call methods from zeitgeist that have signature
a(asaasay).
I think the problem is in Introspector.pm:_parse_type when parse type
with "aa..." (array of array of anything)
In my tests I solved this changing in sub _parse_type:
if ($current->[0] eq "array") {
$current = pop @cont;
}
by:
while ($current->[0] eq "array"){
$current = pop @cont;
}
Thanks for this nice module.
Subject: | parse_type.pl |
use Data::Dumper;
our %simple_type_map = (
"byte" => ord('y'),
"bool" => ord('b'),
"double" => ord('d'),
"string" => ord('s'),
"int16" => ord('n'),
"uint16" => ord('q'),
"int32" => ord('i'),
"uint32" => ord('u'),
"int64" => ord('x'),
"uint64" => ord('t'),
"objectpath" => ord('o'),
"signature" => ord('g'),
);
our %simple_type_rev_map = (
ord('y') => "byte",
ord('b') => "bool",
ord('d') => "double",
ord('s') => "string",
ord('n') => "int16",
ord('q') => "uint16",
ord('i') => "int32",
ord('u') => "uint32",
ord('x') => "int64",
ord('t') => "uint64",
ord('o') => "objectpath",
ord('g') => "signature",
);
sub _parse_type {
my $sig = shift;
print "parsing type\n";
my $root = [];
my $current = $root;
my @cont;
while (my $type = shift @{$sig}) {
if (exists $simple_type_rev_map{ord($type)}) {
push @{$current}, $simple_type_rev_map{ord($type)};
while ($current->[0] eq "array"){
#if ($current->[0] eq "array") {
$current = pop @cont;
#}
}
} else {
if ($type eq "(") {
my $new = ["struct"];
push @{$current}, $new;
push @cont, $current;
$current = $new;
} elsif ($type eq "a") {
my $new = ["array"];
push @cont, $current;
push @{$current}, $new;
$current = $new;
} elsif ($type eq "{") {
if ($current->[0] ne "array") {
die "dict must only occur within an array";
}
$current->[0] = "dict";
} elsif ($type eq ")") {
die "unexpected end of struct" unless
$current->[0] eq "struct";
$current = pop @cont;
while ($current->[0] eq "array") {
$current = pop @cont;
}
} elsif ($type eq "}") {
die "unexpected end of dict" unless
$current->[0] eq "dict";
$current = pop @cont;
while ($current->[0] eq "array") {
$current = pop @cont;
}
} elsif ($type eq "v") {
push @{$current}, ["variant"];
while ($current->[0] eq "array") {
$current = pop @cont;
}
} else {
die "unknown type sig '$type'";
}
}
}
print "$type\n";
print "current: ", Dumper($current);
print "cont: ", Dumper(@cont);
print "\n============================================================\n";
return @{$root};
}
_parse_type(["a","(","a","a","s","a","a","s","a","y",")"]);
#_parse_type(["(","a","a","s","a","a","s","a","y",")"]);
#_parse_type(["a","(","a","s","a","a","a","a","a","a","s","a","y",")"]);
#$type = "a(asaasay)";
#print _parse_type(@type);