svn commit: samba r21428 - in branches/SAMBA_4_0: . source/pidl/lib/Parse/Pidl source/pidl/lib/Parse/Pidl/Samba4/NDR source/pidl/tests

jelmer at samba.org jelmer at samba.org
Sun Feb 18 13:44:05 GMT 2007


Author: jelmer
Date: 2007-02-18 13:44:01 +0000 (Sun, 18 Feb 2007)
New Revision: 21428

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=21428

Log:
Handle representation types in Needed().

Modified:
   branches/SAMBA_4_0/
   branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/NDR.pm
   branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
   branches/SAMBA_4_0/source/pidl/tests/ndr.pl
   branches/SAMBA_4_0/source/pidl/tests/samba-ndr.pl


Changeset:

Property changes on: branches/SAMBA_4_0
___________________________________________________________________
Name: bzr:merge
   - jelmer at samba.org-20060824212938-5923465160f6ab63
jelmer at samba.org-20060830112659-186f132eebc987cc
jelmer at samba.org-20060904121718-63b73248146c14f8
jelmer at samba.org-20060904124721-5e70ab0bd405f748
metze at samba.org-20061010151401-45a5a2ed52cfe172
jelmer at samba.org-20061016130323-400ce51ee51ab30e
jelmer at samba.org-20061016195822-c7783d3ea1a56a53
jelmer at samba.org-20061016230421-75bca2ad62945ede
jelmer at samba.org-20061017145110-8c83a3dd979f6a6a
jelmer at samba.org-20061029173623-eb0459f1d3eb5720
jelmer at samba.org-20070115022006-h5ef1deqflt940b6
jelmer at samba.org-20070116142934-hv99dpwbnq2znh8f
jelmer at samba.org-20070116144126-70rip3bppmvgs3t6
jelmer at samba.org-20070116151516-imvui4r33cj850j9
jelmer at samba.org-20070116154739-3tji4fft7964qgrj
jelmer at samba.org-20070116173900-iasa25stcfty6pbr
jelmer at samba.org-20070117144550-te3o0iy10y14iyo4
jelmer at samba.org-20070122000024-q911packyrjk69ud
jelmer at samba.org-20070122181120-3n8ah238pjbzylyo
jelmer at samba.org-20070122182054-6b26fqrdqyjhyeuc
jelmer at samba.org-20070122233549-k085tfo2o1eqz7mm
jelmer at samba.org-20070123002251-0smz35eva10x84tc
jelmer at samba.org-20070123003546-p0jl6j9tw79q5j1k
jelmer at samba.org-20070123012404-o9w5pmgkm94zsxlu
jelmer at samba.org-20070123094731-ns7dzzzqtb0dlcod
jelmer at samba.org-20070125123431-g3pqm92r31ez9xyc
jelmer at samba.org-20070126125959-3w3t26aps9hmwukv
jelmer at samba.org-20070126132607-64kt7rc2wtqh0c7u
jelmer at samba.org-20070126133903-onfotbg1051ktojo
jelmer at samba.org-20070126144259-171b4t0744jigs5x
jelmer at samba.org-20070126152205-xj7j1avc7683rjy5
jelmer at samba.org-20070128010235-e8st47gcy00ii8kc
jelmer at samba.org-20070128130853-xjjrlrtf830pwnx6
jelmer at samba.org-20070130120806-gfqshokma9j6j3uv
jelmer at samba.org-20070131002510-55yxynmb1o4zvx0x
jelmer at samba.org-20070131115042-oocen3olfgu53jlm
jelmer at samba.org-20070206235608-980jutwyp43708k6
jelmer at samba.org-20070207185718-i1xx6bvmdeeii72p
jelmer at samba.org-20070208234639-i0h5mfefbn1a1lkl
jelmer at samba.org-20070209001154-lol5huzwdq9jw2e7
jelmer at samba.org-20070209093351-buzkh0t55nt863gw
jelmer at samba.org-20070212120516-lwfxtpxx1lerwro2
jelmer at samba.org-20070212130037-e7t2bh0ufajvi8m6
jelmer at samba.org-20070212173050-hpr37tn9ws2zhfko
jelmer at samba.org-20070214123932-nmsy6lnin8gtzxrn
jelmer at samba.org-20070214141810-0df8ykq1d0dl6yia
jelmer at samba.org-20070214143534-pc63vqrp827s6sdo
jelmer at samba.org-20070214145213-idzserezbwc2alty
jelmer at samba.org-20070214150805-zjdhqbtwy28fac3c
jelmer at samba.org-20070214192135-0yxxt5pto2lv4p4h
jelmer at samba.org-20070214213108-id4l0x9g95v6i060
jelmer at samba.org-20070215192824-a13ptx6qq150shoq
jelmer at samba.org-20070215210330-ve8q1mdkjymv6fr1
jelmer at samba.org-20070215220450-avh0rwc0ce0x7gja
jelmer at samba.org-20070215225539-cy8w0815ygz1wa0c
jelmer at samba.org-20070215234924-5u8bqtdp3ha66015
jelmer at samba.org-20070216003036-0ghop153wj46jjwe
jelmer at samba.org-20070216010504-03udexhmrhje5w5c
jelmer at samba.org-20070216124407-uwk21820sjr6n46p
jelmer at samba.org-20070216141029-nf84hlj2tr39ealw
jelmer at samba.org-20070216151123-m8lw5r1ebhymw8ba
jelmer at samba.org-20070217013108-znc8d1w6rtx0kaqf
jelmer at samba.org-20070217135603-92hi5qaxrxwoqulu
jelmer at samba.org-20070217233534-x58078kx0zci6831
jelmer at samba.org-20070218003055-80z3rswwe279yelu
jelmer at samba.org-20070218003815-07xijfqrcx3tybfi
jelmer at samba.org-20070218010222-fe4oase328jeg840
jelmer at samba.org-20070218115359-jytly04u0aufe8vn
jelmer at samba.org-20070218115806-9h8thqvb95iffgh5
jelmer at samba.org-20070218120236-9q5wvlctgevr438d
jelmer at samba.org-20070218120857-cg7f6ppc1b3jd2nj
jelmer at samba.org-20070218122007-5c147i8tk17nh31s
jelmer at samba.org-20070218125126-mq0gsnn6mdt0dr5p

   + jelmer at samba.org-20060824212938-5923465160f6ab63
jelmer at samba.org-20060830112659-186f132eebc987cc
jelmer at samba.org-20060904121718-63b73248146c14f8
jelmer at samba.org-20060904124721-5e70ab0bd405f748
metze at samba.org-20061010151401-45a5a2ed52cfe172
jelmer at samba.org-20061016130323-400ce51ee51ab30e
jelmer at samba.org-20061016195822-c7783d3ea1a56a53
jelmer at samba.org-20061016230421-75bca2ad62945ede
jelmer at samba.org-20061017145110-8c83a3dd979f6a6a
jelmer at samba.org-20061029173623-eb0459f1d3eb5720
jelmer at samba.org-20070115022006-h5ef1deqflt940b6
jelmer at samba.org-20070116142934-hv99dpwbnq2znh8f
jelmer at samba.org-20070116144126-70rip3bppmvgs3t6
jelmer at samba.org-20070116151516-imvui4r33cj850j9
jelmer at samba.org-20070116154739-3tji4fft7964qgrj
jelmer at samba.org-20070116173900-iasa25stcfty6pbr
jelmer at samba.org-20070117144550-te3o0iy10y14iyo4
jelmer at samba.org-20070122000024-q911packyrjk69ud
jelmer at samba.org-20070122181120-3n8ah238pjbzylyo
jelmer at samba.org-20070122182054-6b26fqrdqyjhyeuc
jelmer at samba.org-20070122233549-k085tfo2o1eqz7mm
jelmer at samba.org-20070123002251-0smz35eva10x84tc
jelmer at samba.org-20070123003546-p0jl6j9tw79q5j1k
jelmer at samba.org-20070123012404-o9w5pmgkm94zsxlu
jelmer at samba.org-20070123094731-ns7dzzzqtb0dlcod
jelmer at samba.org-20070125123431-g3pqm92r31ez9xyc
jelmer at samba.org-20070126125959-3w3t26aps9hmwukv
jelmer at samba.org-20070126132607-64kt7rc2wtqh0c7u
jelmer at samba.org-20070126133903-onfotbg1051ktojo
jelmer at samba.org-20070126144259-171b4t0744jigs5x
jelmer at samba.org-20070126152205-xj7j1avc7683rjy5
jelmer at samba.org-20070128010235-e8st47gcy00ii8kc
jelmer at samba.org-20070128130853-xjjrlrtf830pwnx6
jelmer at samba.org-20070130120806-gfqshokma9j6j3uv
jelmer at samba.org-20070131002510-55yxynmb1o4zvx0x
jelmer at samba.org-20070131115042-oocen3olfgu53jlm
jelmer at samba.org-20070206235608-980jutwyp43708k6
jelmer at samba.org-20070207185718-i1xx6bvmdeeii72p
jelmer at samba.org-20070208234639-i0h5mfefbn1a1lkl
jelmer at samba.org-20070209001154-lol5huzwdq9jw2e7
jelmer at samba.org-20070209093351-buzkh0t55nt863gw
jelmer at samba.org-20070212120516-lwfxtpxx1lerwro2
jelmer at samba.org-20070212130037-e7t2bh0ufajvi8m6
jelmer at samba.org-20070212173050-hpr37tn9ws2zhfko
jelmer at samba.org-20070214123932-nmsy6lnin8gtzxrn
jelmer at samba.org-20070214141810-0df8ykq1d0dl6yia
jelmer at samba.org-20070214143534-pc63vqrp827s6sdo
jelmer at samba.org-20070214145213-idzserezbwc2alty
jelmer at samba.org-20070214150805-zjdhqbtwy28fac3c
jelmer at samba.org-20070214192135-0yxxt5pto2lv4p4h
jelmer at samba.org-20070214213108-id4l0x9g95v6i060
jelmer at samba.org-20070215192824-a13ptx6qq150shoq
jelmer at samba.org-20070215210330-ve8q1mdkjymv6fr1
jelmer at samba.org-20070215220450-avh0rwc0ce0x7gja
jelmer at samba.org-20070215225539-cy8w0815ygz1wa0c
jelmer at samba.org-20070215234924-5u8bqtdp3ha66015
jelmer at samba.org-20070216003036-0ghop153wj46jjwe
jelmer at samba.org-20070216010504-03udexhmrhje5w5c
jelmer at samba.org-20070216124407-uwk21820sjr6n46p
jelmer at samba.org-20070216141029-nf84hlj2tr39ealw
jelmer at samba.org-20070216151123-m8lw5r1ebhymw8ba
jelmer at samba.org-20070217013108-znc8d1w6rtx0kaqf
jelmer at samba.org-20070217135603-92hi5qaxrxwoqulu
jelmer at samba.org-20070217233534-x58078kx0zci6831
jelmer at samba.org-20070218003055-80z3rswwe279yelu
jelmer at samba.org-20070218003815-07xijfqrcx3tybfi
jelmer at samba.org-20070218010222-fe4oase328jeg840
jelmer at samba.org-20070218115359-jytly04u0aufe8vn
jelmer at samba.org-20070218115806-9h8thqvb95iffgh5
jelmer at samba.org-20070218120236-9q5wvlctgevr438d
jelmer at samba.org-20070218120857-cg7f6ppc1b3jd2nj
jelmer at samba.org-20070218122007-5c147i8tk17nh31s
jelmer at samba.org-20070218125126-mq0gsnn6mdt0dr5p
jelmer at samba.org-20070218133855-zz8l3b16rc7rh5n9


Modified: branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/NDR.pm
===================================================================
--- branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/NDR.pm	2007-02-18 12:54:03 UTC (rev 21427)
+++ branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/NDR.pm	2007-02-18 13:44:01 UTC (rev 21428)
@@ -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: branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
===================================================================
--- branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm	2007-02-18 12:54:03 UTC (rev 21427)
+++ branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm	2007-02-18 13:44:01 UTC (rev 21428)
@@ -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: branches/SAMBA_4_0/source/pidl/tests/ndr.pl
===================================================================
--- branches/SAMBA_4_0/source/pidl/tests/ndr.pl	2007-02-18 12:54:03 UTC (rev 21427)
+++ branches/SAMBA_4_0/source/pidl/tests/ndr.pl	2007-02-18 13:44:01 UTC (rev 21428)
@@ -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: branches/SAMBA_4_0/source/pidl/tests/samba-ndr.pl
===================================================================
--- branches/SAMBA_4_0/source/pidl/tests/samba-ndr.pl	2007-02-18 12:54:03 UTC (rev 21427)
+++ branches/SAMBA_4_0/source/pidl/tests/samba-ndr.pl	2007-02-18 13:44:01 UTC (rev 21428)
@@ -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