summaryrefslogtreecommitdiff
path: root/source4/build
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-02-20 02:20:45 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:10:48 -0500
commit111b6c2b9a4695369815d71a0c06f931778228b0 (patch)
tree52b50ff3356b54c23af7a7ea81fdf114bdb1ee8a /source4/build
parent840bb19dcd0f4929396109f629b24dc4165dec7d (diff)
downloadsamba-111b6c2b9a4695369815d71a0c06f931778228b0.tar.gz
samba-111b6c2b9a4695369815d71a0c06f931778228b0.tar.bz2
samba-111b6c2b9a4695369815d71a0c06f931778228b0.zip
r5464: Simplify print function generator code.
(This used to be commit 6d1ad1ce7a327d016636d8b374bfbe9ec2052d1c)
Diffstat (limited to 'source4/build')
-rw-r--r--source4/build/pidl/ndr.pm84
1 files changed, 27 insertions, 57 deletions
diff --git a/source4/build/pidl/ndr.pm b/source4/build/pidl/ndr.pm
index f953445e89..2d885ca455 100644
--- a/source4/build/pidl/ndr.pm
+++ b/source4/build/pidl/ndr.pm
@@ -654,15 +654,13 @@ sub ParseElementPushPtr($$$)
#####################################################################
# 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 @@ sub ParseElementPrintScalar($$)
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 @@ sub ParseElementPushSwitch($$$$)
}
#####################################################################
-# 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 @@ sub ParseElementPushBuffer($$$)
}
#####################################################################
-# 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 @@ sub ParseStructPrint($)
pidl "ndr->depth++;";
foreach my $e (@{$struct->{ELEMENTS}}) {
- ParseElementPrintScalar($e, "r->");
+ ParseElementPrint($e, "r->");
}
pidl "ndr->depth--;";
@@ -1478,7 +1448,7 @@ sub ParseUnionPrint($)
}
if ($el->{TYPE} ne "EMPTY") {
indent;
- ParseElementPrintScalar($el, "r->");
+ ParseElementPrint($el, "r->");
deindent;
}
pidl "break;";
@@ -1688,7 +1658,7 @@ sub ParseFunctionPrint($)
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 @@ sub ParseFunctionPrint($)
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") {