From 645e87281c78f944fd6fe2ae52c6e0f058c665ff Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 15 Aug 2007 06:08:02 +0000 Subject: r24446: We only need one genric GenerateFunctionInEnv function metze (This used to be commit 0c5be644ba13c68b7378a6ae9dcd314018ece25d) --- source4/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm | 17 ++--------------- source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm | 18 +++++++++++------- 2 files changed, 13 insertions(+), 22 deletions(-) (limited to 'source4/pidl/lib') diff --git a/source4/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm b/source4/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm index 27b71053fb..5352e41f24 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm @@ -16,6 +16,7 @@ use Parse::Pidl::Typelist qw(hasType getType mapTypeName scalar_is_reference); use Parse::Pidl::Util qw(has_property is_constant ParseExpr); use Parse::Pidl::NDR qw(GetPrevLevel GetNextLevel ContainsDeferred); use Parse::Pidl::Samba4 qw(DeclLong); +use Parse::Pidl::Samba4::NDR::Parser qw(GenerateFunctionInEnv); use vars qw($VERSION); $VERSION = '0.01'; @@ -33,20 +34,6 @@ sub new($) bless($self, $class); } -sub GenerateFunctionInEnv($) -{ - my $fn = shift; - my %env; - - foreach my $e (@{$fn->{ELEMENTS}}) { - if (grep (/in/, @{$e->{DIRECTION}})) { - $env{$e->{NAME}} = "r.in.$e->{NAME}"; - } - } - - return \%env; -} - sub ParseFunction($$$) { my ($self, $uif, $fn) = @_; @@ -110,7 +97,7 @@ sub ParseFunction($$$) # Since the data is being copied into a user-provided data # structure, the user should be able to know the size beforehand # to allocate a structure of the right size. - my $env = GenerateFunctionInEnv($fn); + my $env = GenerateFunctionInEnv($fn, "r."); my $size_is = ParseExpr($e->{LEVELS}[0]->{SIZE_IS}, $env, $e); $self->pidl("memcpy($e->{NAME}, r.out.$e->{NAME}, $size_is);"); } else { diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm index b65df06884..73ff28eed0 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm @@ -243,30 +243,34 @@ sub EnvSubstituteValue($$) return $env; } -sub GenerateFunctionInEnv($) +sub GenerateFunctionInEnv($;$) { - my $fn = shift; + my ($fn, $base) = @_; my %env; + $base = "r->" unless defined($base); + foreach my $e (@{$fn->{ELEMENTS}}) { if (grep (/in/, @{$e->{DIRECTION}})) { - $env{$e->{NAME}} = "r->in.$e->{NAME}"; + $env{$e->{NAME}} = $base."in.$e->{NAME}"; } } return \%env; } -sub GenerateFunctionOutEnv($) +sub GenerateFunctionOutEnv($;$) { - my $fn = shift; + my ($fn, $base) = @_; my %env; + $base = "r->" unless defined($base); + foreach my $e (@{$fn->{ELEMENTS}}) { if (grep (/out/, @{$e->{DIRECTION}})) { - $env{$e->{NAME}} = "r->out.$e->{NAME}"; + $env{$e->{NAME}} = $base."out.$e->{NAME}"; } elsif (grep (/in/, @{$e->{DIRECTION}})) { - $env{$e->{NAME}} = "r->in.$e->{NAME}"; + $env{$e->{NAME}} = $base."in.$e->{NAME}"; } } -- cgit