diff options
Diffstat (limited to 'source4')
-rw-r--r-- | source4/build/pidl/dump.pm | 4 | ||||
-rw-r--r-- | source4/build/pidl/header.pm | 5 | ||||
-rw-r--r-- | source4/build/pidl/ndr.pm | 63 |
3 files changed, 49 insertions, 23 deletions
diff --git a/source4/build/pidl/dump.pm b/source4/build/pidl/dump.pm index 00a57b10b4..9e896cd256 100644 --- a/source4/build/pidl/dump.pm +++ b/source4/build/pidl/dump.pm @@ -47,10 +47,8 @@ sub DumpElement($) ($res .= DumpProperties($element->{PROPERTIES})); $res .= DumpType($element->{TYPE}); $res .= " "; - if ($element->{POINTERS}) { - for (my($i)=0; $i < $element->{POINTERS}; $i++) { + for my $i (1..$element->{POINTERS}) { $res .= "*"; - } } $res .= "$element->{NAME}"; (defined $element->{ARRAY_LEN}) && ($res .= "[$element->{ARRAY_LEN}]"); diff --git a/source4/build/pidl/header.pm b/source4/build/pidl/header.pm index c49f60ce8b..00321fef93 100644 --- a/source4/build/pidl/header.pm +++ b/source4/build/pidl/header.pm @@ -185,7 +185,10 @@ sub HeaderType($$$) return; } - my $dt = $NdrParser::typedefs{$e->{TYPE}}->{DATA}; + my $dt; + if (my $t = NdrParser::get_typedef($e->{TYPE})) { + $dt = $t->{DATA}; + } if ($data =~ "string") { pidl "const char *"; 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")) { @@ -549,6 +555,18 @@ sub ParseElementPushScalar($$$) } ##################################################################### +# 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,9 +741,7 @@ 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 "}"; } @@ -745,6 +749,27 @@ sub ParseElementPullScalar($$$) } ##################################################################### +# 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($$$) { |