Parse-Pidl
view release on metacpan or search on metacpan
lib/Parse/Pidl/NDR.pm view on Meta::CPAN
if (has_property($e, "length_is")) {
@length_is = split /,/, has_property($e, "length_is");
}
if (defined($e->{ARRAY_LEN})) {
@bracket_array = @{$e->{ARRAY_LEN}};
}
# Parse the [][][][] style array stuff
for my $i (0 .. $#bracket_array) {
my $d = $bracket_array[$#bracket_array - $i];
my $size = $d;
my $length = $d;
my $is_surrounding = 0;
my $is_varying = 0;
my $is_conformant = 0;
my $is_string = 0;
if ($d eq "*") {
$is_conformant = 1;
if ($size = shift @size_is) {
} elsif ((scalar(@size_is) == 0) and has_property($e, "string")) {
$is_string = 1;
delete($e->{PROPERTIES}->{string});
} else {
print "$e->{FILE}:$e->{LINE}: Must specify size_is() for conformant array!\n";
exit 1;
}
if (($length = shift @length_is) or $is_string) {
$is_varying = 1;
} else {
$length = $size;
}
if ($e == $e->{PARENT}->{ELEMENTS}[-1]
and $e->{PARENT}->{TYPE} ne "FUNCTION") {
$is_surrounding = 1;
}
}
push (@$order, {
TYPE => "ARRAY",
SIZE_IS => $size,
LENGTH_IS => $length,
IS_DEFERRED => "$is_deferred",
IS_SURROUNDING => "$is_surrounding",
IS_ZERO_TERMINATED => "$is_string",
IS_VARYING => "$is_varying",
IS_CONFORMANT => "$is_conformant",
IS_FIXED => (not $is_conformant and Parse::Pidl::Util::is_constant($size)),
IS_INLINE => (not $is_conformant and not Parse::Pidl::Util::is_constant($size))
});
}
# Next, all the pointers
foreach my $i (1..$e->{POINTERS}) {
my $pt = pointer_type($e);
my $level = "EMBEDDED";
# Top level "ref" pointers do not have a referrent identifier
$level = "TOP" if ( defined($pt)
and $i == 1
and $e->{PARENT}->{TYPE} eq "FUNCTION");
push (@$order, {
TYPE => "POINTER",
# for now, there can only be one pointer type per element
POINTER_TYPE => pointer_type($e),
POINTER_INDEX => $pointer_idx,
IS_DEFERRED => "$is_deferred",
LEVEL => $level
});
$pointer_idx++;
# everything that follows will be deferred
$is_deferred = 1 if ($e->{PARENT}->{TYPE} ne "FUNCTION");
my $array_size = shift @size_is;
my $array_length;
my $is_varying;
my $is_conformant;
my $is_string = 0;
if ($array_size) {
$is_conformant = 1;
if ($array_length = shift @length_is) {
$is_varying = 1;
} else {
$array_length = $array_size;
$is_varying =0;
}
}
if (scalar(@size_is) == 0 and has_property($e, "string")) {
$is_string = 1;
$is_varying = $is_conformant = has_property($e, "noheader")?0:1;
delete($e->{PROPERTIES}->{string});
}
if ($array_size or $is_string) {
push (@$order, {
TYPE => "ARRAY",
IS_ZERO_TERMINATED => "$is_string",
SIZE_IS => $array_size,
LENGTH_IS => $array_length,
IS_DEFERRED => "$is_deferred",
IS_SURROUNDING => 0,
IS_VARYING => "$is_varying",
IS_CONFORMANT => "$is_conformant",
IS_FIXED => 0,
IS_INLINE => 0,
});
$is_deferred = 0;
}
}
if (defined(has_property($e, "subcontext"))) {
my $hdr_size = has_property($e, "subcontext");
( run in 0.424 second using v1.01-cache-2.11-cpan-71847e10f99 )