summaryrefslogtreecommitdiff
path: root/source4/pidl/lib/Parse
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2007-08-16 14:42:22 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 15:02:01 -0500
commit575c8709262bb97ef1b14d128058620a9200e447 (patch)
treeddd0d5743c05a9718453a93c481d455af69f7276 /source4/pidl/lib/Parse
parentb76b6a15225329941c20070d05356aba56044173 (diff)
downloadsamba-575c8709262bb97ef1b14d128058620a9200e447.tar.gz
samba-575c8709262bb97ef1b14d128058620a9200e447.tar.bz2
samba-575c8709262bb97ef1b14d128058620a9200e447.zip
r24493: - it turns out that
foreach my $e (@{$union->{ELEMENTS}}) { changes $union->{ELEMENTS} from undef into an empty array. this removes the difference between struct foo { }; and struct foo; So we need to explicit return before. - we should return the same element for layout for structs and unions with no elements. - fix the testsuite to match metze (This used to be commit 5f1f50cd27e3702b79a19dbe1079498cbfc4842b)
Diffstat (limited to 'source4/pidl/lib/Parse')
-rw-r--r--source4/pidl/lib/Parse/Pidl/NDR.pm44
1 files changed, 34 insertions, 10 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/NDR.pm b/source4/pidl/lib/Parse/Pidl/NDR.pm
index e9c4b59358..e950591cb7 100644
--- a/source4/pidl/lib/Parse/Pidl/NDR.pm
+++ b/source4/pidl/lib/Parse/Pidl/NDR.pm
@@ -392,6 +392,18 @@ sub ParseStruct($$)
my @elements = ();
my $surrounding = undef;
+ return {
+ TYPE => "STRUCT",
+ NAME => $struct->{NAME},
+ SURROUNDING_ELEMENT => undef,
+ ELEMENTS => undef,
+ PROPERTIES => $struct->{PROPERTIES},
+ ORIGINAL => $struct,
+ ALIGN => undef
+ } unless defined($struct->{ELEMENTS});
+
+ CheckPointerTypes($struct, $pointer_default);
+
foreach my $x (@{$struct->{ELEMENTS}})
{
my $e = ParseElement($x, $pointer_default);
@@ -433,12 +445,23 @@ sub ParseUnion($$)
{
my ($e, $pointer_default) = @_;
my @elements = ();
+ my $hasdefault = 0;
my $switch_type = has_property($e, "switch_type");
unless (defined($switch_type)) { $switch_type = "uint32"; }
-
if (has_property($e, "nodiscriminant")) { $switch_type = undef; }
-
- my $hasdefault = 0;
+
+ return {
+ TYPE => "UNION",
+ NAME => $e->{NAME},
+ SWITCH_TYPE => $switch_type,
+ ELEMENTS => undef,
+ PROPERTIES => $e->{PROPERTIES},
+ HAS_DEFAULT => $hasdefault,
+ ORIGINAL => $e
+ } unless defined($e->{ELEMENTS});
+
+ CheckPointerTypes($e, $pointer_default);
+
foreach my $x (@{$e->{ELEMENTS}})
{
my $t;
@@ -501,11 +524,6 @@ sub ParseType($$)
{
my ($d, $pointer_default) = @_;
- if ($d->{TYPE} eq "STRUCT" or $d->{TYPE} eq "UNION") {
- return $d if (not defined($d->{ELEMENTS}));
- CheckPointerTypes($d, $pointer_default);
- }
-
my $data = {
STRUCT => \&ParseStruct,
UNION => \&ParseUnion,
@@ -589,6 +607,8 @@ sub CheckPointerTypes($$)
{
my ($s,$default) = @_;
+ return unless defined($s->{ELEMENTS});
+
foreach my $e (@{$s->{ELEMENTS}}) {
if ($e->{POINTERS} and not defined(pointer_type($e))) {
$e->{PROPERTIES}->{$default} = 1;
@@ -1005,6 +1025,8 @@ sub ValidStruct($)
ValidProperties($struct, "STRUCT");
+ return unless defined($struct->{ELEMENTS});
+
foreach my $e (@{$struct->{ELEMENTS}}) {
$e->{PARENT} = $struct;
ValidElement($e);
@@ -1022,7 +1044,9 @@ sub ValidUnion($)
if (has_property($union->{PARENT}, "nodiscriminant") and has_property($union->{PARENT}, "switch_type")) {
fatal($union->{PARENT}, $union->{PARENT}->{NAME} . ": switch_type() on union without discriminant");
}
-
+
+ return unless defined($union->{ELEMENTS});
+
foreach my $e (@{$union->{ELEMENTS}}) {
$e->{PARENT} = $union;
@@ -1129,7 +1153,7 @@ sub ValidInterface($)
$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") && ValidType($d);
}
}