1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-28 07:21:54 +03:00

r21440: Support different variables in environments.

This commit is contained in:
Jelmer Vernooij 2007-02-18 23:57:26 +00:00 committed by Gerald (Jerry) Carter
parent ac347d7aa5
commit 1702a663ba
2 changed files with 19 additions and 12 deletions

View File

@ -216,16 +216,16 @@ sub end_flags($)
}
}
sub GenerateStructEnv($)
sub GenerateStructEnv($$)
{
my $x = shift;
my ($x, $v) = @_;
my %env;
foreach my $e (@{$x->{ELEMENTS}}) {
$env{$e->{NAME}} = "r->$e->{NAME}";
$env{$e->{NAME}} = "$v->$e->{NAME}";
}
$env{"this"} = "r";
$env{"this"} = $v;
return \%env;
}
@ -1198,7 +1198,7 @@ sub ParseStructPush($$)
return unless defined($struct->{ELEMENTS});
my $env = GenerateStructEnv($struct);
my $env = GenerateStructEnv($struct, "r");
EnvSubstituteValue($env, $struct);
@ -1440,7 +1440,7 @@ sub ParseStructPrint($$)
return unless defined $struct->{ELEMENTS};
my $env = GenerateStructEnv($struct);
my $env = GenerateStructEnv($struct, "r");
EnvSubstituteValue($env, $struct);
@ -1521,7 +1521,7 @@ sub ParseStructPull($$)
return unless defined $struct->{ELEMENTS};
my $env = GenerateStructEnv($struct);
my $env = GenerateStructEnv($struct, "r");
# declare any internal pointers we need
foreach my $e (@{$struct->{ELEMENTS}}) {

View File

@ -4,7 +4,7 @@
use strict;
use warnings;
use Test::More tests => 31;
use Test::More tests => 32;
use FindBin qw($RealBin);
use lib "$RealBin";
use Util;
@ -156,22 +156,29 @@ $fn = { ELEMENTS => [ { DIRECTION => ["out"], NAME => "foo" } ] };
is_deeply({ }, GenerateFunctionInEnv($fn));
$fn = { ELEMENTS => [ { NAME => "foo" }, { NAME => "bar" } ] };
is_deeply({ foo => "r->foo", bar => "r->bar", this => "r" }, GenerateStructEnv($fn));
is_deeply({ foo => "r->foo", bar => "r->bar", this => "r" },
GenerateStructEnv($fn, "r"));
$fn = { ELEMENTS => [ { NAME => "foo" }, { NAME => "bar" } ] };
is_deeply({ foo => "some->complex.variable->foo",
bar => "some->complex.variable->bar",
this => "some->complex.variable" },
GenerateStructEnv($fn, "some->complex.variable"));
$fn = { ELEMENTS => [ { NAME => "foo", PROPERTIES => { value => 3 }} ] };
my $env = GenerateStructEnv($fn);
my $env = GenerateStructEnv($fn, "r");
EnvSubstituteValue($env, $fn);
is_deeply($env, { foo => 3, this => "r" });
$fn = { ELEMENTS => [ { NAME => "foo" }, { NAME => "bar" } ] };
$env = GenerateStructEnv($fn);
$env = GenerateStructEnv($fn, "r");
EnvSubstituteValue($env, $fn);
is_deeply($env, { foo => 'r->foo', bar => 'r->bar', this => "r" });
$fn = { ELEMENTS => [ { NAME => "foo", PROPERTIES => { value => 0 }} ] };
$env = GenerateStructEnv($fn);
$env = GenerateStructEnv($fn, "r");
EnvSubstituteValue($env, $fn);
is_deeply($env, { foo => 0, this => "r" });