use strict;
use Parse::Pidl qw(warning fatal);
-use Parse::Pidl::Typelist qw(hasType getType expandAlias);
+use Parse::Pidl::Typelist qw(hasType getType expandAlias mapScalarType);
use Parse::Pidl::Util qw(has_property property_matches);
# Alignment of the built-in scalar types
'uint8' => 1,
'int16' => 2,
'uint16' => 2,
+ 'int1632' => 3,
+ 'uint1632' => 3,
'int32' => 4,
'uint32' => 4,
+ 'int3264' => 5,
+ 'uint3264' => 5,
'hyper' => 8,
+ 'double' => 8,
'pointer' => 8,
'dlong' => 4,
'udlong' => 4,
$is_fixed = 1 if (not $is_conformant and Parse::Pidl::Util::is_constant($size));
$is_inline = 1 if (not $is_conformant and not Parse::Pidl::Util::is_constant($size));
+ if ($i == 0 and $is_fixed and has_property($e, "string")) {
+ $is_fixed = 0;
+ $is_varying = 1;
+ $is_string = 1;
+ delete($e->{PROPERTIES}->{string});
+ }
+
push (@$order, {
TYPE => "ARRAY",
SIZE_IS => $size,
my $a = 1;
if ($e->{POINTERS}) {
- $a = 4;
+ # this is a hack for NDR64
+ # the NDR layer translates this into
+ # an alignment of 4 for NDR and 8 for NDR64
+ $a = 5;
} elsif (has_property($e, "subcontext")) {
$a = 1;
} elsif (has_property($e, "transmit_as")) {
if ($dt->{TYPE} eq "TYPEDEF") {
return align_type($dt->{DATA});
+ } elsif ($dt->{TYPE} eq "CONFORMANCE") {
+ return $dt->{DATA}->{ALIGN};
} elsif ($dt->{TYPE} eq "ENUM") {
return align_type(Parse::Pidl::Typelist::enum_type_fn($dt));
} elsif ($dt->{TYPE} eq "BITMAP") {
ELEMENTS => undef,
PROPERTIES => $e->{PROPERTIES},
HAS_DEFAULT => $hasdefault,
- ORIGINAL => $e
+ ORIGINAL => $e,
+ ALIGN => undef
} unless defined($e->{ELEMENTS});
CheckPointerTypes($e, $pointer_default);
push @elements, $t;
}
+ my $align = undef;
+ if ($e->{NAME}) {
+ $align = align_type($e->{NAME});
+ }
+
return {
TYPE => "UNION",
NAME => $e->{NAME},
ELEMENTS => \@elements,
PROPERTIES => $e->{PROPERTIES},
HAS_DEFAULT => $hasdefault,
- ORIGINAL => $e
+ ORIGINAL => $e,
+ ALIGN => $align
};
}
"bitmap64bit" => ["BITMAP"],
# array
- "range" => ["ELEMENT"],
+ "range" => ["ELEMENT", "PIPE"],
"size_is" => ["ELEMENT"],
"string" => ["ELEMENT"],
"noheader" => ["ELEMENT"],
my $discriminator_type = has_property($type->{DATA}, "switch_type");
$discriminator_type = "uint32" unless defined ($discriminator_type);
- my $t1 = mapToScalar($discriminator_type);
+ my $t1 = mapScalarType(mapToScalar($discriminator_type));
if (not defined($t1)) {
fatal($e, el_name($e) . ": unable to map discriminator type '$discriminator_type' to scalar");
}
- my $t2 = mapToScalar($e2->{TYPE});
+ my $t2 = mapScalarType(mapToScalar($e2->{TYPE}));
if (not defined($t2)) {
fatal($e, el_name($e) . ": unable to map variable used for switch_is() to scalar");
}
}
}
+#####################################################################
+# validate a pipe
+sub ValidPipe($)
+{
+ my ($pipe) = @_;
+ my $data = $pipe->{DATA};
+
+ ValidProperties($pipe, "PIPE");
+
+ fatal($pipe, $pipe->{NAME} . ": 'pipe' is not yet supported by pidl");
+}
+
#####################################################################
# parse a typedef
sub ValidTypedef($)
STRUCT => \&ValidStruct,
UNION => \&ValidUnion,
ENUM => \&ValidEnum,
- BITMAP => \&ValidBitmap
+ BITMAP => \&ValidBitmap,
+ PIPE => \&ValidPipe
}->{$t->{TYPE}}->($t);
}
$d->{TYPE} eq "STRUCT" or
$d->{TYPE} eq "UNION" or
$d->{TYPE} eq "ENUM" or
- $d->{TYPE} eq "BITMAP") && ValidType($d);
+ $d->{TYPE} eq "BITMAP" or
+ $d->{TYPE} eq "PIPE") && ValidType($d);
}
}