svn commit: samba r24493 - in branches/SAMBA_4_0/source/pidl:
lib/Parse/Pidl tests
metze at samba.org
metze at samba.org
Thu Aug 16 14:42:23 GMT 2007
Author: metze
Date: 2007-08-16 14:42:22 +0000 (Thu, 16 Aug 2007)
New Revision: 24493
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=24493
Log:
- 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
Modified:
branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/NDR.pm
branches/SAMBA_4_0/source/pidl/tests/ndr.pl
Changeset:
Modified: branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/NDR.pm
===================================================================
--- branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/NDR.pm 2007-08-16 13:41:48 UTC (rev 24492)
+++ branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/NDR.pm 2007-08-16 14:42:22 UTC (rev 24493)
@@ -392,6 +392,18 @@
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 @@
{
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; }
- 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 @@
{
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 @@
{
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 @@
ValidProperties($struct, "STRUCT");
+ return unless defined($struct->{ELEMENTS});
+
foreach my $e (@{$struct->{ELEMENTS}}) {
$e->{PARENT} = $struct;
ValidElement($e);
@@ -1022,7 +1044,9 @@
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 @@
$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);
}
}
Modified: branches/SAMBA_4_0/source/pidl/tests/ndr.pl
===================================================================
--- branches/SAMBA_4_0/source/pidl/tests/ndr.pl 2007-08-16 13:41:48 UTC (rev 24492)
+++ branches/SAMBA_4_0/source/pidl/tests/ndr.pl 2007-08-16 14:42:22 UTC (rev 24493)
@@ -4,7 +4,7 @@
use strict;
use warnings;
-use Test::More tests => 26;
+use Test::More tests => 27;
use FindBin qw($RealBin);
use lib "$RealBin";
use Util;
@@ -225,5 +225,31 @@
"hyper");
is(mapToScalar({TYPE => "TYPEDEF", DATA => {TYPE => "ENUM", PARENT => { PROPERTIES => { enum8bit => 1 } } }}), "uint8");
-is_deeply(ParseType({TYPE => "STRUCT", NAME => "foo" }, "ref"),
- {TYPE => "STRUCT", NAME => "foo" });
+my $t;
+$t = {
+ TYPE => "STRUCT",
+ NAME => "foo",
+ SURROUNDING_ELEMENT => undef,
+ ELEMENTS => undef,
+ PROPERTIES => undef,
+ ORIGINAL => {
+ TYPE => "STRUCT",
+ NAME => "foo"
+ },
+ ALIGN => undef
+};
+is_deeply(ParseType($t->{ORIGINAL}, "ref"), $t);
+
+$t = {
+ TYPE => "UNION",
+ NAME => "foo",
+ SWITCH_TYPE => "uint32",
+ ELEMENTS => undef,
+ PROPERTIES => undef,
+ HAS_DEFAULT => 0,
+ ORIGINAL => {
+ TYPE => "UNION",
+ NAME => "foo"
+ }
+};
+is_deeply(ParseType($t->{ORIGINAL}, "ref"), $t);
More information about the samba-cvs
mailing list