diff options
author | Stefan Metzmacher <metze@samba.org> | 2008-02-01 09:49:54 +0100 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2008-02-02 11:15:52 +0100 |
commit | 9475a76afc41675a9c6a9b42d618a49821a8a5b4 (patch) | |
tree | 9b9586047cec8afc82d62c1b0f40e9517ac8a5ef /source4/pidl | |
parent | e22c627ea1e700c30568399cf94df5b88b05f216 (diff) | |
download | samba-9475a76afc41675a9c6a9b42d618a49821a8a5b4.tar.gz samba-9475a76afc41675a9c6a9b42d618a49821a8a5b4.tar.bz2 samba-9475a76afc41675a9c6a9b42d618a49821a8a5b4.zip |
pidl/Samba4::NDR::Parser: move logic for extra get_pointer_of() into a function
metze
(This used to be commit 26d7f5bf96cd7e950ceb532402afd6b8a58871ea)
Diffstat (limited to 'source4/pidl')
-rw-r--r-- | source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm | 59 |
1 files changed, 34 insertions, 25 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm index 8326ce5fb6..81e8a21625 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm @@ -669,23 +669,39 @@ sub ParsePtrPush($$$$) } } +sub need_pointer_to($$$) +{ + my ($e, $l, $scalar_only) = @_; + + my $t; + if (ref($l->{DATA_TYPE})) { + $t = "$l->{DATA_TYPE}->{TYPE}_$l->{DATA_TYPE}->{NAME}"; + } else { + $t = $l->{DATA_TYPE}; + } + + if (not Parse::Pidl::Typelist::is_scalar($t)) { + return 1 if $scalar_only; + } + + if (Parse::Pidl::Typelist::scalar_is_reference($t)) { + return 1; + } + + return 0; +} + sub ParseDataPrint($$$$) { my ($self, $e, $l, $var_name) = @_; - if (not ref($l->{DATA_TYPE}) or - defined($l->{DATA_TYPE}->{NAME})) { - my $t; - if (ref($l->{DATA_TYPE})) { - $t = "$l->{DATA_TYPE}->{TYPE}_$l->{DATA_TYPE}->{NAME}"; - } else { - $t = $l->{DATA_TYPE}; - } - if (not Parse::Pidl::Typelist::is_scalar($t) or - Parse::Pidl::Typelist::scalar_is_reference($t)) { + if (not ref($l->{DATA_TYPE}) or defined($l->{DATA_TYPE}->{NAME})) { + + if (need_pointer_to($e, $l, 1)) { $var_name = get_pointer_to($var_name); } - $self->pidl("ndr_print_$t(ndr, \"$e->{NAME}\", $var_name);"); + + $self->pidl(TypeFunctionName("ndr_print", $l->{DATA_TYPE})."(ndr, \"$e->{NAME}\", $var_name);"); } else { $self->ParseTypePrint($l->{DATA_TYPE}, $var_name); } @@ -815,12 +831,11 @@ sub ParseDataPull($$$$$$$) { my ($self,$e,$l,$ndr,$var_name,$primitives,$deferred) = @_; - if (not ref($l->{DATA_TYPE}) or - defined($l->{DATA_TYPE}->{NAME})) { + if (not ref($l->{DATA_TYPE}) or defined($l->{DATA_TYPE}->{NAME})) { my $ndr_flags = CalcNdrFlags($l, $primitives, $deferred); - if (Parse::Pidl::Typelist::scalar_is_reference($l->{DATA_TYPE})) { + if (need_pointer_to($e, $l, 0)) { $var_name = get_pointer_to($var_name); } @@ -845,21 +860,15 @@ sub ParseDataPush($$$$$$$) my ($self,$e,$l,$ndr,$var_name,$primitives,$deferred) = @_; if (not ref($l->{DATA_TYPE}) or defined($l->{DATA_TYPE}->{NAME})) { - my $t; - if (ref($l->{DATA_TYPE}) eq "HASH") { - $t = "$l->{DATA_TYPE}->{TYPE}_$l->{DATA_TYPE}->{NAME}"; - } else { - $t = $l->{DATA_TYPE}; - } - + + my $ndr_flags = CalcNdrFlags($l, $primitives, $deferred); + # strings are passed by value rather than reference - if (not Parse::Pidl::Typelist::is_scalar($t) or - Parse::Pidl::Typelist::scalar_is_reference($t)) { + if (need_pointer_to($e, $l, 1)) { $var_name = get_pointer_to($var_name); } - my $ndr_flags = CalcNdrFlags($l, $primitives, $deferred); - $self->pidl("NDR_CHECK(ndr_push_$t($ndr, $ndr_flags, $var_name));"); + $self->pidl("NDR_CHECK(".TypeFunctionName("ndr_push", $l->{DATA_TYPE})."($ndr, $ndr_flags, $var_name));"); } else { $self->ParseTypePush($l->{DATA_TYPE}, $var_name, $primitives, $deferred); } |