svn commit: samba r5464 - in branches/SAMBA_4_0/source/build/pidl: .

jelmer at samba.org jelmer at samba.org
Sun Feb 20 02:20:46 GMT 2005


Author: jelmer
Date: 2005-02-20 02:20:45 +0000 (Sun, 20 Feb 2005)
New Revision: 5464

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

Log:
Simplify print function generator code.

Modified:
   branches/SAMBA_4_0/source/build/pidl/ndr.pm


Changeset:
Modified: branches/SAMBA_4_0/source/build/pidl/ndr.pm
===================================================================
--- branches/SAMBA_4_0/source/build/pidl/ndr.pm	2005-02-19 23:46:52 UTC (rev 5463)
+++ branches/SAMBA_4_0/source/build/pidl/ndr.pm	2005-02-20 02:20:45 UTC (rev 5464)
@@ -654,15 +654,13 @@
 
 #####################################################################
 # print scalars in a structure element
-sub ParseElementPrintScalar($$)
+sub ParseElementPrint($$)
 {
 	my($e) = shift;
 	my($var_prefix) = shift;
 	my $cprefix = c_push_prefix($e);
 
-	if (util::has_property($e, "noprint")) {
-		return;
-	}
+	return if (util::has_property($e, "noprint"));
 
 	if (my $value = util::has_property($e, "value")) {
 		pidl "if (ndr->flags & LIBNDR_PRINT_SET_VALUES) {";
@@ -672,18 +670,33 @@
 		pidl "}";
 	}
 
-	if (is_fixed_array($e)) {
-		ParseElementPrintBuffer($e, $var_prefix);
-	} elsif ($e->{POINTERS} || util::array_size($e)) {
+	if (!is_fixed_array($e) and ($e->{POINTERS} or util::array_size($e))) {
 		pidl "ndr_print_ptr(ndr, \"$e->{NAME}\", $var_prefix$e->{NAME});";
 		pidl "ndr->depth++;";
-		ParseElementPrintBuffer($e, $var_prefix);
-		pidl "ndr->depth--;";
+	}
+	if (need_wire_pointer($e)) {
+		pidl "if ($var_prefix$e->{NAME}) {";
+		indent;
+	}
+
+	if (util::array_size($e)) {
+		ParseArrayPrint($e, $var_prefix)
 	} elsif (my $switch = util::has_property($e, "switch_is")) {
-		ParseElementPrintSwitch($e, $var_prefix, $switch);
+		my $switch_var = ParseExpr($e, $switch, $var_prefix);
+		check_null_pointer_void($switch_var);
+
+		pidl "ndr_print_$e->{TYPE}(ndr, \"$e->{NAME}\", $switch_var, $cprefix$var_prefix$e->{NAME});";
 	} else {
 		pidl "ndr_print_$e->{TYPE}(ndr, \"$e->{NAME}\", $cprefix$var_prefix$e->{NAME});";
 	}
+
+	if (need_wire_pointer($e)) {
+		deindent;
+		pidl "}";
+	}
+	if (!is_fixed_array($e) and ($e->{POINTERS} or util::array_size($e))) {
+		pidl "ndr->depth--;";
+	}
 }
 
 #####################################################################
@@ -784,22 +797,6 @@
 }
 
 #####################################################################
-# print scalars in a structure element 
-sub ParseElementPrintSwitch($$$)
-{
-	my($e) = shift;
-	my($var_prefix) = shift;
-	my $switch = shift;
-	my $switch_var = ParseExpr($e, $switch, $var_prefix);
-	my $cprefix = c_push_prefix($e);
-
-	check_null_pointer_void($switch_var);
-
-	pidl "ndr_print_$e->{TYPE}(ndr, \"$e->{NAME}\", $switch_var, $cprefix$var_prefix$e->{NAME});";
-}
-
-
-#####################################################################
 # parse scalars in a structure element - pull size
 sub ParseElementPullScalar($$$)
 {
@@ -908,33 +905,6 @@
 }
 
 #####################################################################
-# print buffers in a structure element
-sub ParseElementPrintBuffer($$)
-{
-	my($e) = shift;
-	my($var_prefix) = shift;
-	my $cprefix = c_push_prefix($e);
-
-	if (need_wire_pointer($e)) {
-		pidl "if ($var_prefix$e->{NAME}) {";
-		indent;
-	}
-	    
-	if (util::array_size($e)) {
-		ParseArrayPrint($e, $var_prefix)
-	} elsif (my $switch = util::has_property($e, "switch_is")) {
-		ParseElementPrintSwitch($e, $var_prefix, $switch);
-	} else {
-		pidl "ndr_print_$e->{TYPE}(ndr, \"$e->{NAME}\", $cprefix$var_prefix$e->{NAME});";
-	}
-
-	if (need_wire_pointer($e)) {
-		deindent;
-		pidl "}";
-	}	
-}
-
-#####################################################################
 # parse buffers in a structure element - pull side
 sub ParseElementPullBuffer($$$)
 {
@@ -1246,7 +1216,7 @@
 
 	pidl "ndr->depth++;";
 	foreach my $e (@{$struct->{ELEMENTS}}) {
-		ParseElementPrintScalar($e, "r->");
+		ParseElementPrint($e, "r->");
 	}
 	pidl "ndr->depth--;";
 
@@ -1478,7 +1448,7 @@
 		}
 		if ($el->{TYPE} ne "EMPTY") {
 			indent;
-			ParseElementPrintScalar($el, "r->");
+			ParseElementPrint($el, "r->");
 			deindent;
 		}
 		pidl "break;";
@@ -1688,7 +1658,7 @@
 
 	foreach my $e (@{$fn->{ELEMENTS}}) {
 		if (util::has_property($e, "in")) {
-			ParseElementPrintScalar($e, "r->in.");
+			ParseElementPrint($e, "r->in.");
 		}
 	}
 	pidl "ndr->depth--;";
@@ -1701,7 +1671,7 @@
 	pidl "ndr->depth++;";
 	foreach my $e (@{$fn->{ELEMENTS}}) {
 		if (util::has_property($e, "out")) {
-			ParseElementPrintScalar($e, "r->out.");
+			ParseElementPrint($e, "r->out.");
 		}
 	}
 	if ($fn->{RETURN_TYPE} && $fn->{RETURN_TYPE} ne "void") {



More information about the samba-cvs mailing list