diff options
author | Stefan Metzmacher <metze@samba.org> | 2011-01-31 13:23:08 +0100 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2011-02-01 11:21:42 +0100 |
commit | 76f2ddf5a9cef9e8253b11dec1304d51e47eda54 (patch) | |
tree | 612e4f272e9301ec54a2ade610fa1dc4231a3435 /pidl | |
parent | 5ae04bca01b974672fcc3c68acf3fc9bab61ba05 (diff) | |
download | samba-76f2ddf5a9cef9e8253b11dec1304d51e47eda54.tar.gz samba-76f2ddf5a9cef9e8253b11dec1304d51e47eda54.tar.bz2 samba-76f2ddf5a9cef9e8253b11dec1304d51e47eda54.zip |
pidl:NDR: add support for 'ms_union' property.
metze
Diffstat (limited to 'pidl')
-rw-r--r-- | pidl/lib/Parse/Pidl/NDR.pm | 61 | ||||
-rwxr-xr-x | pidl/tests/ndr.pl | 39 |
2 files changed, 54 insertions, 46 deletions
diff --git a/pidl/lib/Parse/Pidl/NDR.pm b/pidl/lib/Parse/Pidl/NDR.pm index 21b75687a7..3edb9b732f 100644 --- a/pidl/lib/Parse/Pidl/NDR.pm +++ b/pidl/lib/Parse/Pidl/NDR.pm @@ -81,9 +81,9 @@ my $scalar_alignment = { 'dnsp_string' => 1 }; -sub GetElementLevelTable($$) +sub GetElementLevelTable($$$) { - my ($e, $pointer_default) = @_; + my ($e, $pointer_default, $ms_union) = @_; my $order = []; my $is_deferred = 0; @@ -307,9 +307,9 @@ sub GetElementLevelTable($$) return $order; } -sub GetTypedefLevelTable($$$) +sub GetTypedefLevelTable($$$$) { - my ($e, $data, $pointer_default) = @_; + my ($e, $data, $pointer_default, $ms_union) = @_; my $order = []; @@ -432,30 +432,30 @@ sub align_type($) die("Unknown data type type $dt->{TYPE}"); } -sub ParseElement($$) +sub ParseElement($$$) { - my ($e, $pointer_default) = @_; + my ($e, $pointer_default, $ms_union) = @_; $e->{TYPE} = expandAlias($e->{TYPE}); if (ref($e->{TYPE}) eq "HASH") { - $e->{TYPE} = ParseType($e->{TYPE}, $pointer_default); + $e->{TYPE} = ParseType($e->{TYPE}, $pointer_default, $ms_union); } return { NAME => $e->{NAME}, TYPE => $e->{TYPE}, PROPERTIES => $e->{PROPERTIES}, - LEVELS => GetElementLevelTable($e, $pointer_default), + LEVELS => GetElementLevelTable($e, $pointer_default, $ms_union), REPRESENTATION_TYPE => ($e->{PROPERTIES}->{represent_as} or $e->{TYPE}), ALIGN => align_type($e->{TYPE}), ORIGINAL => $e }; } -sub ParseStruct($$) +sub ParseStruct($$$) { - my ($struct, $pointer_default) = @_; + my ($struct, $pointer_default, $ms_union) = @_; my @elements = (); my $surrounding = undef; @@ -473,7 +473,7 @@ sub ParseStruct($$) foreach my $x (@{$struct->{ELEMENTS}}) { - my $e = ParseElement($x, $pointer_default); + my $e = ParseElement($x, $pointer_default, $ms_union); if ($x != $struct->{ELEMENTS}[-1] and $e->{LEVELS}[0]->{IS_SURROUNDING}) { fatal($x, "conformant member not at end of struct"); @@ -510,8 +510,10 @@ sub ParseStruct($$) sub ParseUnion($$) { - my ($e, $pointer_default) = @_; + my ($e, $pointer_default, $ms_union) = @_; my @elements = (); + my $is_ms_union = $ms_union; + $is_ms_union = 1 if has_property($e, "ms_union"); my $hasdefault = 0; my $switch_type = has_property($e, "switch_type"); unless (defined($switch_type)) { $switch_type = "uint32"; } @@ -524,6 +526,7 @@ sub ParseUnion($$) ELEMENTS => undef, PROPERTIES => $e->{PROPERTIES}, HAS_DEFAULT => $hasdefault, + IS_MS_UNION => $is_ms_union, ORIGINAL => $e, ALIGN => undef } unless defined($e->{ELEMENTS}); @@ -536,7 +539,7 @@ sub ParseUnion($$) if ($x->{TYPE} eq "EMPTY") { $t = { TYPE => "EMPTY" }; } else { - $t = ParseElement($x, $pointer_default); + $t = ParseElement($x, $pointer_default, $ms_union); } if (has_property($x, "default")) { $t->{CASE} = "default"; @@ -561,6 +564,7 @@ sub ParseUnion($$) ELEMENTS => \@elements, PROPERTIES => $e->{PROPERTIES}, HAS_DEFAULT => $hasdefault, + IS_MS_UNION => $is_ms_union, ORIGINAL => $e, ALIGN => $align }; @@ -568,7 +572,7 @@ sub ParseUnion($$) sub ParseEnum($$) { - my ($e, $pointer_default) = @_; + my ($e, $pointer_default, $ms_union) = @_; return { TYPE => "ENUM", @@ -580,9 +584,9 @@ sub ParseEnum($$) }; } -sub ParseBitmap($$) +sub ParseBitmap($$$) { - my ($e, $pointer_default) = @_; + my ($e, $pointer_default, $ms_union) = @_; return { TYPE => "BITMAP", @@ -594,9 +598,9 @@ sub ParseBitmap($$) }; } -sub ParseType($$) +sub ParseType($$$) { - my ($d, $pointer_default) = @_; + my ($d, $pointer_default, $ms_union) = @_; my $data = { STRUCT => \&ParseStruct, @@ -604,14 +608,14 @@ sub ParseType($$) ENUM => \&ParseEnum, BITMAP => \&ParseBitmap, TYPEDEF => \&ParseTypedef, - }->{$d->{TYPE}}->($d, $pointer_default); + }->{$d->{TYPE}}->($d, $pointer_default, $ms_union); return $data; } sub ParseTypedef($$) { - my ($d, $pointer_default) = @_; + my ($d, $pointer_default, $ms_union) = @_; my $data; @@ -621,7 +625,7 @@ sub ParseTypedef($$) $d->{PROPERTIES} = $d->{DATA}->{PROPERTIES}; } - $data = ParseType($d->{DATA}, $pointer_default); + $data = ParseType($d->{DATA}, $pointer_default, $ms_union); $data->{ALIGN} = align_type($d->{NAME}); } else { $data = getType($d->{DATA}); @@ -631,7 +635,7 @@ sub ParseTypedef($$) NAME => $d->{NAME}, TYPE => $d->{TYPE}, PROPERTIES => $d->{PROPERTIES}, - LEVELS => GetTypedefLevelTable($d, $data, $pointer_default), + LEVELS => GetTypedefLevelTable($d, $data, $pointer_default, $ms_union), DATA => $data, ORIGINAL => $d }; @@ -644,9 +648,9 @@ sub ParseConst($$) return $d; } -sub ParseFunction($$$) +sub ParseFunction($$$$) { - my ($ndr,$d,$opnum) = @_; + my ($ndr,$d,$opnum,$ms_union) = @_; my @elements = (); my $rettype = undef; my $thisopnum = undef; @@ -659,7 +663,7 @@ sub ParseFunction($$$) } foreach my $x (@{$d->{ELEMENTS}}) { - my $e = ParseElement($x, $ndr->{PROPERTIES}->{pointer_default}); + my $e = ParseElement($x, $ndr->{PROPERTIES}->{pointer_default}, $ms_union); push (@{$e->{DIRECTION}}, "in") if (has_property($x, "in")); push (@{$e->{DIRECTION}}, "out") if (has_property($x, "out")); @@ -720,6 +724,8 @@ sub ParseInterface($) my @endpoints; my $opnum = 0; my $version; + my $ms_union = 0; + $ms_union = 1 if has_property($idl, "ms_union"); if (not has_property($idl, "pointer_default")) { # MIDL defaults to "ptr" in DCE compatible mode (/osf) @@ -729,11 +735,11 @@ sub ParseInterface($) foreach my $d (@{$idl->{DATA}}) { if ($d->{TYPE} eq "FUNCTION") { - push (@functions, ParseFunction($idl, $d, \$opnum)); + push (@functions, ParseFunction($idl, $d, \$opnum, $ms_union)); } elsif ($d->{TYPE} eq "CONST") { push (@consts, ParseConst($idl, $d)); } else { - push (@types, ParseType($d, $idl->{PROPERTIES}->{pointer_default})); + push (@types, ParseType($d, $idl->{PROPERTIES}->{pointer_default}, $ms_union)); FindNestedTypes(\@types, $d); } } @@ -935,6 +941,7 @@ my %property_list = ( "switch_is" => ["ELEMENT"], "switch_type" => ["ELEMENT", "UNION"], "nodiscriminant" => ["UNION"], + "ms_union" => ["INTERFACE", "UNION"], "case" => ["ELEMENT"], "default" => ["ELEMENT"], diff --git a/pidl/tests/ndr.pl b/pidl/tests/ndr.pl index 9c301892ae..b6fd4899b0 100755 --- a/pidl/tests/ndr.pl +++ b/pidl/tests/ndr.pl @@ -22,7 +22,7 @@ my $e = { 'PARENT' => { TYPE => 'STRUCT' }, 'LINE' => 42 }; -is_deeply(GetElementLevelTable($e, "unique"), [ +is_deeply(GetElementLevelTable($e, "unique", 0), [ { 'IS_DEFERRED' => 0, 'LEVEL_INDEX' => 0, @@ -33,7 +33,7 @@ is_deeply(GetElementLevelTable($e, "unique"), [ } ]); -my $ne = ParseElement($e, "unique"); +my $ne = ParseElement($e, "unique", 0); is($ne->{ORIGINAL}, $e); is($ne->{NAME}, "v"); is($ne->{ALIGN}, 1); @@ -60,7 +60,7 @@ $e = { 'TYPE' => 'uint8', 'LINE' => 42 }; -is_deeply(GetElementLevelTable($e, "unique"), [ +is_deeply(GetElementLevelTable($e, "unique", 0), [ { LEVEL_INDEX => 0, IS_DEFERRED => 0, @@ -90,7 +90,7 @@ $e = { 'PARENT' => { TYPE => 'STRUCT' }, 'LINE' => 42 }; -is_deeply(GetElementLevelTable($e, "unique"), [ +is_deeply(GetElementLevelTable($e, "unique", 0), [ { LEVEL_INDEX => 0, IS_DEFERRED => 0, @@ -128,7 +128,7 @@ $e = { 'PARENT' => { TYPE => 'STRUCT' }, 'LINE' => 42 }; -is_deeply(GetElementLevelTable($e, "unique"), [ +is_deeply(GetElementLevelTable($e, "unique", 0), [ { LEVEL_INDEX => 0, IS_DEFERRED => 0, @@ -158,7 +158,7 @@ $e = { 'PARENT' => { TYPE => 'STRUCT' }, 'LINE' => 42 }; -is_deeply(GetElementLevelTable($e, "unique"), [ +is_deeply(GetElementLevelTable($e, "unique", 0), [ { LEVEL_INDEX => 0, IS_DEFERRED => 0, @@ -204,7 +204,7 @@ $e = { 'PARENT' => { TYPE => 'STRUCT' }, 'LINE' => 42 }; -is_deeply(GetElementLevelTable($e, "ref"), [ +is_deeply(GetElementLevelTable($e, "ref", 0), [ { LEVEL_INDEX => 0, IS_DEFERRED => 0, @@ -250,7 +250,7 @@ $e = { 'PARENT' => { TYPE => 'FUNCTION' }, 'LINE' => 42 }; -is_deeply(GetElementLevelTable($e, "unique"), [ +is_deeply(GetElementLevelTable($e, "unique", 0), [ { LEVEL_INDEX => 0, IS_DEFERRED => 0, @@ -280,7 +280,7 @@ $e = { 'PARENT' => { TYPE => 'FUNCTION' }, 'LINE' => 42 }; -is_deeply(GetElementLevelTable($e, "unique"), [ +is_deeply(GetElementLevelTable($e, "unique", 0), [ { LEVEL_INDEX => 0, IS_DEFERRED => 0, @@ -326,7 +326,7 @@ $e = { 'PARENT' => { TYPE => 'FUNCTION' }, 'LINE' => 42 }; -is_deeply(GetElementLevelTable($e, "unique"), [ +is_deeply(GetElementLevelTable($e, "unique", 0), [ { LEVEL_INDEX => 0, IS_DEFERRED => 0, @@ -372,7 +372,7 @@ $e = { 'PARENT' => { TYPE => 'FUNCTION' }, 'LINE' => 42 }; -is_deeply(GetElementLevelTable($e, "ref"), [ +is_deeply(GetElementLevelTable($e, "ref", 0), [ { LEVEL_INDEX => 0, IS_DEFERRED => 0, @@ -418,7 +418,7 @@ $e = { 'PARENT' => { TYPE => 'FUNCTION' }, 'LINE' => 42 }; -is_deeply(GetElementLevelTable($e, "ref"), [ +is_deeply(GetElementLevelTable($e, "ref", 0), [ { LEVEL_INDEX => 0, IS_DEFERRED => 0, @@ -463,7 +463,7 @@ $e = { 'PARENT' => { TYPE => 'STRUCT' }, 'LINE' => 42 }; -$ne = ParseElement($e, undef); +$ne = ParseElement($e, undef, 0); is($ne->{REPRESENTATION_TYPE}, "bar"); # representation_type @@ -476,7 +476,7 @@ $e = { 'PARENT' => { TYPE => 'STRUCT' }, 'LINE' => 42 }; -$ne = ParseElement($e, undef); +$ne = ParseElement($e, undef, 0); is($ne->{REPRESENTATION_TYPE}, "uint8"); is(align_type("hyper"), 8); @@ -521,7 +521,7 @@ $t = { }, ALIGN => undef }; -is_deeply(ParseType($t->{ORIGINAL}, "ref"), $t); +is_deeply(ParseType($t->{ORIGINAL}, "ref", 0), $t); $t = { TYPE => "UNION", @@ -530,13 +530,14 @@ $t = { ELEMENTS => undef, PROPERTIES => undef, HAS_DEFAULT => 0, + IS_MS_UNION => 0, ORIGINAL => { TYPE => "UNION", NAME => "foo" }, ALIGN => undef }; -is_deeply(ParseType($t->{ORIGINAL}, "ref"), $t); +is_deeply(ParseType($t->{ORIGINAL}, "ref", 0), $t); ok(not can_contain_deferred("uint32")); ok(can_contain_deferred("some_unknown_type")); @@ -553,8 +554,8 @@ ok(not can_contain_deferred({ TYPE => "TYPEDEF", ok(can_contain_deferred({ TYPE => "STRUCT", ELEMENTS => [ { TYPE => "someunknowntype" } ]})); # Make sure the elements for a enum without body aren't filled in -ok(not defined(ParseType({TYPE => "ENUM", NAME => "foo" }, "ref")->{ELEMENTS})); +ok(not defined(ParseType({TYPE => "ENUM", NAME => "foo" }, "ref", 0)->{ELEMENTS})); # Make sure the elements for a bitmap without body aren't filled in -ok(not defined(ParseType({TYPE => "BITMAP", NAME => "foo" }, "ref")->{ELEMENTS})); +ok(not defined(ParseType({TYPE => "BITMAP", NAME => "foo" }, "ref", 0)->{ELEMENTS})); # Make sure the elements for a union without body aren't filled in -ok(not defined(ParseType({TYPE => "UNION", NAME => "foo" }, "ref")->{ELEMENTS})); +ok(not defined(ParseType({TYPE => "UNION", NAME => "foo" }, "ref", 0)->{ELEMENTS})); |