From a0667e11ae2c92850919a1568ca47fa83d29af6f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 16 Feb 2005 11:09:10 +0000 Subject: r5417: Add wrapper function for typedefs hash rather then using the "our" keyword, move pointer parsing to seperate function. (This used to be commit ea872b9a2b9a51ba9f6c2842303d067e9e85d11a) --- source4/build/pidl/ndr.pm | 63 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 44 insertions(+), 19 deletions(-) (limited to 'source4/build/pidl/ndr.pm') diff --git a/source4/build/pidl/ndr.pm b/source4/build/pidl/ndr.pm index 81a909c472..961f32e333 100644 --- a/source4/build/pidl/ndr.pm +++ b/source4/build/pidl/ndr.pm @@ -11,8 +11,14 @@ use strict; use needed; # list of known types -our %typedefs; -our %typefamily; +my %typedefs; +my %typefamily; + +sub get_typedef($) +{ + my $n = shift; + return $typedefs{$n}; +} sub RegisterPrimitives() { @@ -534,7 +540,7 @@ sub ParseElementPushScalar($$$) } elsif (util::is_inline_array($e)) { ParseArrayPush($e, "r->", "NDR_SCALARS"); } elsif (need_wire_pointer($e)) { - pidl "NDR_CHECK(ndr_push_unique_ptr(ndr, $var_prefix$e->{NAME}));"; + ParseElementPushPtr($e, $var_prefix, $ndr_flags); } elsif (need_alloc($e)) { # no scalar component } elsif (my $switch = util::has_property($e, "switch_is")) { @@ -548,6 +554,18 @@ sub ParseElementPushScalar($$$) end_flags($e); } +##################################################################### +# parse a pointer in a struct element or function +sub ParseElementPushPtr($$$) +{ + my $e = shift; + my $var_prefix = shift; + my $ndr_flags = shift; + + pidl "NDR_CHECK(ndr_push_unique_ptr(ndr, $var_prefix$e->{NAME}));"; +} + + ##################################################################### # print scalars in a structure element sub ParseElementPrintScalar($$) @@ -710,19 +728,7 @@ sub ParseElementPullScalar($$$) if (util::is_inline_array($e)) { ParseArrayPull($e, "r->", "NDR_SCALARS"); } elsif (need_wire_pointer($e)) { - pidl "NDR_CHECK(ndr_pull_unique_ptr(ndr, &_ptr_$e->{NAME}));"; - pidl "if (_ptr_$e->{NAME}) {"; - indent; - pidl "NDR_ALLOC(ndr, $var_prefix$e->{NAME});"; - if (util::has_property($e, "relative")) { - pidl "NDR_CHECK(ndr_pull_relative_ptr1(ndr, $var_prefix$e->{NAME}, _ptr_$e->{NAME}));"; - } - deindent; - pidl "} else {"; - indent; - pidl "$var_prefix$e->{NAME} = NULL;"; - deindent; - pidl "}"; + ParseElementPullPtr($e, $var_prefix, $ndr_flags); } elsif (need_alloc($e)) { # no scalar component } elsif (my $switch = util::has_property($e, "switch_is")) { @@ -735,15 +741,34 @@ sub ParseElementPullScalar($$$) if (my $range = util::has_property($e, "range")) { my ($low, $high) = split(/ /, $range, 2); pidl "if ($var_prefix$e->{NAME} < $low || $var_prefix$e->{NAME} > $high) {"; - indent; - pidl "return ndr_pull_error(ndr, NDR_ERR_RANGE, \"value out of range\");"; - deindent; + pidl "\treturn ndr_pull_error(ndr, NDR_ERR_RANGE, \"value out of range\");"; pidl "}"; } end_flags($e); } +##################################################################### +# parse a pointer in a struct element or function +sub ParseElementPullPtr($$$) +{ + my($e) = shift; + my($var_prefix) = shift; + my($ndr_flags) = shift; + + pidl "NDR_CHECK(ndr_pull_unique_ptr(ndr, &_ptr_$e->{NAME}));"; + pidl "if (_ptr_$e->{NAME}) {"; + indent; + pidl "NDR_ALLOC(ndr, $var_prefix$e->{NAME});"; + if (util::has_property($e, "relative")) { + pidl "NDR_CHECK(ndr_pull_relative_ptr1(ndr, $var_prefix$e->{NAME}, _ptr_$e->{NAME}));"; + } + deindent; + pidl "} else {"; + pidl "\t$var_prefix$e->{NAME} = NULL;"; + pidl "}"; +} + ##################################################################### # parse buffers in a structure element sub ParseElementPushBuffer($$$) -- cgit