From ae88822b8c7fd45d9d96ef0d08f9d39ecaf3ba83 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 23 Aug 2005 13:19:33 +0000 Subject: r9519: Use the value() value of an element when that element is used in limited expressions (size_is,length_is,subcontext_size,etc) (This used to be commit 886780c298a794f304b0fce851bbb58c53605d17) --- source4/pidl/lib/Parse/Pidl/Samba/NDR/Parser.pm | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'source4/pidl/lib') diff --git a/source4/pidl/lib/Parse/Pidl/Samba/NDR/Parser.pm b/source4/pidl/lib/Parse/Pidl/Samba/NDR/Parser.pm index ef22ff9788..513fa0826d 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba/NDR/Parser.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba/NDR/Parser.pm @@ -235,6 +235,20 @@ sub GenerateStructEnv($) return \%env; } +sub EnvSubstituteValue($$) +{ + my ($env,$s) = @_; + + # Substitute the value() values in the env + foreach my $e (@{$s->{ELEMENTS}}) { + next unless (my $v = has_property($e, "value")); + + $env->{$e->{NAME}} = ParseExpr($v, $env); + } + + return $env; +} + sub GenerateFunctionInEnv($) { my $fn = shift; @@ -1095,6 +1109,8 @@ sub ParseStructPush($$) my $env = GenerateStructEnv($struct); + EnvSubstituteValue($env, $struct); + # save the old relative_base_offset pidl "uint32_t _save_relative_base_offset = ndr_push_get_relative_base_offset(ndr);" if defined($struct->{PROPERTIES}{relative_base}); @@ -1326,6 +1342,8 @@ sub ParseStructPrint($$) my $env = GenerateStructEnv($struct); + EnvSubstituteValue($env, $struct); + foreach my $e (@{$struct->{ELEMENTS}}) { DeclareArrayVariables($e); } @@ -1870,6 +1888,7 @@ sub ParseFunctionPrint($) pidl "ndr->depth++;"; my $env = GenerateFunctionInEnv($fn); + EnvSubstituteValue($env, $fn); foreach my $e (@{$fn->{ELEMENTS}}) { if (grep(/in/,@{$e->{DIRECTION}})) { @@ -1925,6 +1944,8 @@ sub ParseFunctionPush($) my $env = GenerateFunctionInEnv($fn); + EnvSubstituteValue($env, $fn); + foreach my $e (@{$fn->{ELEMENTS}}) { if (grep(/in/,@{$e->{DIRECTION}})) { ParseElementPush($e, "ndr", "r->in.", $env, 1, 1); -- cgit