Rev 11519: Handle representation types in Needed(). in
file:///home/jelmer/bzr.samba/SAMBA_4_0/
Jelmer Vernooij
jelmer at samba.org
Sun Feb 18 13:40:16 GMT 2007
At file:///home/jelmer/bzr.samba/SAMBA_4_0/
------------------------------------------------------------
revno: 11519
revision-id: jelmer at samba.org-20070218133855-zz8l3b16rc7rh5n9
parent: svn-v2:21427 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: SAMBA_4_0
timestamp: Sun 2007-02-18 14:38:55 +0100
message:
Handle representation types in Needed().
modified:
source/pidl/lib/Parse/Pidl/NDR.pm svn-v2:9460 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0-source%2fpidl%2flib%2fParse%2fPidl%2fNDR.pm
source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm svn-v2:12463 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0-source%2fpidl%2flib%2fParse%2fPidl%2fSamba4%2fNDR%2fParser.pm
source/pidl/tests/ndr.pl svn-v2:20631 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0-source%2fpidl%2ftests%2fndr.pl
source/pidl/tests/samba-ndr.pl svn-v2:20637 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0-source%2fpidl%2ftests%2fsamba%2dndr.pl
=== modified file 'source/pidl/lib/Parse/Pidl/NDR.pm'
--- a/source/pidl/lib/Parse/Pidl/NDR.pm 2007-02-07 19:03:19 +0000
+++ b/source/pidl/lib/Parse/Pidl/NDR.pm 2007-02-18 13:38:55 +0000
@@ -371,7 +371,7 @@
TYPE => $e->{TYPE},
PROPERTIES => $e->{PROPERTIES},
LEVELS => GetElementLevelTable($e),
- REPRESENTATION_TYPE => $e->{PROPERTIES}->{represent_as},
+ REPRESENTATION_TYPE => ($e->{PROPERTIES}->{represent_as} or $e->{TYPE}),
ALIGN => align_type($e->{TYPE}),
ORIGINAL => $e
};
@@ -388,7 +388,7 @@
my $e = ParseElement($x);
if ($x != $struct->{ELEMENTS}[-1] and
$e->{LEVELS}[0]->{IS_SURROUNDING}) {
- print "$x->{FILE}:$x->{LINE}: error: conformant member not at end of struct\n";
+ fatal($x, "conformant member not at end of struct");
}
push @elements, $e;
}
=== modified file 'source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm'
--- a/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm 2007-02-18 12:54:03 +0000
+++ b/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm 2007-02-18 13:38:55 +0000
@@ -703,7 +703,7 @@
return unless $primitives or ($deferred and ContainsDeferred($e, $e->{LEVELS}[0]));
# Representation type is different from transmit_as
- if ($e->{REPRESENTATION_TYPE}) {
+ if ($e->{REPRESENTATION_TYPE} ne $e->{TYPE}) {
pidl "{";
indent;
my $transmit_name = "_transmit_$e->{NAME}";
@@ -724,7 +724,7 @@
end_flags($e);
- if ($e->{REPRESENTATION_TYPE}) {
+ if ($e->{REPRESENTATION_TYPE} ne $e->{TYPE}) {
deindent;
pidl "}";
}
@@ -760,7 +760,7 @@
return if (has_property($e, "noprint"));
- if ($e->{REPRESENTATION_TYPE}) {
+ if ($e->{REPRESENTATION_TYPE} ne $e->{TYPE}) {
pidl "ndr_print_$e->{REPRESENTATION_TYPE}(ndr, \"$e->{NAME}\", $var_name);";
return;
}
@@ -1110,7 +1110,7 @@
return unless $primitives or ($deferred and ContainsDeferred($e, $e->{LEVELS}[0]));
- if ($e->{REPRESENTATION_TYPE}) {
+ if ($e->{REPRESENTATION_TYPE} ne $e->{TYPE}) {
pidl "{";
indent;
$represent_name = $var_name;
@@ -1128,7 +1128,7 @@
end_flags($e);
# Representation type is different from transmit_as
- if ($e->{REPRESENTATION_TYPE}) {
+ if ($e->{REPRESENTATION_TYPE} ne $e->{TYPE}) {
pidl "NDR_CHECK(ndr_$e->{TYPE}_to_$e->{REPRESENTATION_TYPE}($transmit_name, ".get_pointer_to($represent_name)."));";
deindent;
pidl "}";
@@ -2488,8 +2488,28 @@
{
my ($e, $dir, $needed) = @_;
- return if (defined($needed->{"$dir\_$e->{TYPE}"}));
- $needed->{"$dir\_$e->{TYPE}"} = 1;
+ return if ($e->{TYPE} eq "EMPTY");
+
+ my @fn = ();
+ if ($dir eq "print") {
+ push(@fn, "print_$e->{REPRESENTATION_TYPE}");
+ } elsif ($dir eq "pull") {
+ push (@fn, "pull_$e->{TYPE}");
+ push (@fn, "ndr_$e->{TYPE}_to_$e->{REPRESENTATION_TYPE}")
+ if ($e->{REPRESENTATION_TYPE} ne $e->{TYPE});
+ } elsif ($dir eq "push") {
+ push (@fn, "push_$e->{TYPE}");
+ push (@fn, "ndr_$e->{REPRESENTATION_TYPE}_to_$e->{TYPE}")
+ if ($e->{REPRESENTATION_TYPE} ne $e->{TYPE});
+ } else {
+ die("invalid direction `$dir'");
+ }
+
+ foreach (@fn) {
+ unless (defined($needed->{$_})) {
+ $needed->{$_} = 1;
+ }
+ }
}
sub NeededFunction($$)
=== modified file 'source/pidl/tests/ndr.pl'
--- a/source/pidl/tests/ndr.pl 2007-01-09 15:54:36 +0000
+++ b/source/pidl/tests/ndr.pl 2007-02-18 13:38:55 +0000
@@ -4,7 +4,7 @@
use strict;
use warnings;
-use Test::More tests => 10;
+use Test::More tests => 12;
use FindBin qw($RealBin);
use lib "$RealBin";
use Util;
@@ -189,3 +189,29 @@
'CONVERT_TO' => undef
}
]);
+
+# representation_type
+$e = {
+ 'FILE' => 'foo.idl',
+ 'NAME' => 'v',
+ 'PROPERTIES' => { represent_as => "bar" },
+ 'POINTERS' => 0,
+ 'TYPE' => 'uint8',
+ 'PARENT' => { TYPE => 'STRUCT' },
+ 'LINE' => 42 };
+
+$ne = ParseElement($e);
+is($ne->{REPRESENTATION_TYPE}, "bar");
+
+# representation_type
+$e = {
+ 'FILE' => 'foo.idl',
+ 'NAME' => 'v',
+ 'PROPERTIES' => { },
+ 'POINTERS' => 0,
+ 'TYPE' => 'uint8',
+ 'PARENT' => { TYPE => 'STRUCT' },
+ 'LINE' => 42 };
+
+$ne = ParseElement($e);
+is($ne->{REPRESENTATION_TYPE}, "uint8");
=== modified file 'source/pidl/tests/samba-ndr.pl'
--- a/source/pidl/tests/samba-ndr.pl 2007-02-18 12:54:03 +0000
+++ b/source/pidl/tests/samba-ndr.pl 2007-02-18 13:38:55 +0000
@@ -4,7 +4,7 @@
use strict;
use warnings;
-use Test::More tests => 29;
+use Test::More tests => 31;
use FindBin qw($RealBin);
use lib "$RealBin";
use Util;
@@ -176,27 +176,27 @@
is_deeply($env, { foo => 0, this => "r" });
my $needed = {};
-NeededElement({ TYPE => "foo" }, "pull", $needed);
+NeededElement({ TYPE => "foo", REPRESENTATION_TYPE => "foo" }, "pull", $needed);
is_deeply($needed, { pull_foo => 1 });
# old settings should be kept
$needed = { pull_foo => 0 };
-NeededElement({ TYPE => "foo" }, "pull", $needed);
+NeededElement({ TYPE => "foo", REPRESENTATION_TYPE => "foo" }, "pull", $needed);
is_deeply($needed, { pull_foo => 0 });
# print/pull/push are independent of each other
$needed = { pull_foo => 0 };
-NeededElement({ TYPE => "foo" }, "print", $needed);
+NeededElement({ TYPE => "foo", REPRESENTATION_TYPE => "foo" }, "print", $needed);
is_deeply($needed, { pull_foo => 0, print_foo => 1 });
$needed = { };
-NeededFunction({ NAME => "foo", ELEMENTS => [ { TYPE => "bar" } ] }, $needed);
+NeededFunction({ NAME => "foo", ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "bar" } ] }, $needed);
is_deeply($needed, { pull_foo => 1, print_foo => 1, push_foo => 1,
pull_bar => 1, print_bar => 1, push_bar => 1});
# push/pull/print are always set for functions
$needed = { pull_foo => 0 };
-NeededFunction({ NAME => "foo", ELEMENTS => [ { TYPE => "bar" } ] }, $needed);
+NeededFunction({ NAME => "foo", ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "bar" } ] }, $needed);
is_deeply($needed, { pull_foo => 1, print_foo => 1, push_foo => 1,
pull_bar => 1, push_bar => 1, print_bar => 1});
@@ -216,7 +216,7 @@
$needed = {};
NeededTypedef({ PROPERTIES => { public => 1 }, NAME => "bla",
DATA => { TYPE => "STRUCT",
- ELEMENTS => [ { TYPE => "bar" } ] } },
+ ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "bar" } ] } },
$needed);
is_deeply($needed, { pull_bla => 1, print_bla => 1, push_bla => 1,
pull_bar => 1, print_bar => 1, push_bar => 1});
@@ -224,7 +224,25 @@
$needed = {};
NeededTypedef({ PROPERTIES => { gensize => 1}, NAME => "bla",
DATA => { TYPE => "STRUCT",
- ELEMENTS => [ { TYPE => "bar" } ] } },
+ ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "bar" } ] } },
$needed);
is_deeply($needed, { ndr_size_bla => 1 });
+# make sure types for elements are set too
+$needed = { pull_bla => 1 };
+NeededTypedef({ NAME => "bla",
+ DATA => { TYPE => "STRUCT",
+ ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "bar" } ] } },
+ $needed);
+is_deeply($needed, { pull_bla => 1, pull_bar => 1 });
+
+$needed = {};
+NeededTypedef({ PROPERTIES => { public => 1},
+ NAME => "bla",
+ DATA => { TYPE => "STRUCT",
+ ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "rep" } ] } },
+ $needed);
+is_deeply($needed, { pull_bla => 1, push_bla => 1, print_bla => 1, print_rep => 1,
+ pull_bar => 1, push_bar => 1,
+ ndr_bar_to_rep => 1, ndr_rep_to_bar => 1});
+
More information about the samba-cvs
mailing list