Rev 11394: Update environment code to use inout. in
file:///home/jelmer/bzr.samba/pidl-fixes/
Jelmer Vernooij
jelmer at samba.org
Thu Feb 8 12:28:55 GMT 2007
At file:///home/jelmer/bzr.samba/pidl-fixes/
------------------------------------------------------------
revno: 11394
revision-id: jelmer at samba.org-20070208122837-6mqdgszfi7ivlg7c
parent: jelmer at samba.org-20070208113014-hn0t8z5s0y1jfryz
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: pidl-fixes
timestamp: Thu 2007-02-08 13:28:37 +0100
message:
Update environment code to use inout.
modified:
source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm svn-v2:12463 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0-source%2fpidl%2flib%2fParse%2fPidl%2fSamba4%2fNDR%2fParser.pm
source/pidl/tests/samba-ndr.pl svn-v2:20637 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0-source%2fpidl%2ftests%2fsamba%2dndr.pl
=== modified file 'source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm'
--- a/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm 2007-02-07 19:03:19 +0000
+++ b/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm 2007-02-08 12:28:37 +0000
@@ -10,7 +10,7 @@
require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(is_charset_array);
- at EXPORT_OK = qw(check_null_pointer);
+ at EXPORT_OK = qw(check_null_pointer GenerateFunctionInEnv GenerateFunctionOutEnv);
use strict;
use Parse::Pidl::Typelist qw(hasType getType mapType);
@@ -248,24 +248,28 @@
my %env;
foreach my $e (@{$fn->{ELEMENTS}}) {
+ next unless (grep (/in/, @{$e->{DIRECTION}}));
+ if (grep(/out/, @{$e->{DIRECTION}})) {
+ $env{$e->{NAME}} = "r->inout.$e->{NAME}";
+ } else {
+ $env{$e->{NAME}} = "r->in.$e->{NAME}";
+ }
+ }
+
+ return \%env;
+}
+
+sub GenerateFunctionOutEnv($)
+{
+ my $fn = shift;
+ my %env;
+
+ foreach my $e (@{$fn->{ELEMENTS}}) {
+ next unless (grep (/out/, @{$e->{DIRECTION}}));
if (grep (/in/, @{$e->{DIRECTION}})) {
- $env{$e->{NAME}} = "r->in.$e->{NAME}";
- }
- }
-
- return \%env;
-}
-
-sub GenerateFunctionOutEnv($)
-{
- my $fn = shift;
- my %env;
-
- foreach my $e (@{$fn->{ELEMENTS}}) {
- if (grep (/out/, @{$e->{DIRECTION}})) {
+ $env{$e->{NAME}} = "r->inout.$e->{NAME}";
+ } else {
$env{$e->{NAME}} = "r->out.$e->{NAME}";
- } elsif (grep (/in/, @{$e->{DIRECTION}})) {
- $env{$e->{NAME}} = "r->in.$e->{NAME}";
}
}
@@ -1993,7 +1997,7 @@
foreach my $e (@{$fn->{ELEMENTS}}) {
if (grep(/in/,@{$e->{DIRECTION}})) {
- ParseElementPrint($e, "r->in.$e->{NAME}", $env);
+ ParseElementPrint($e, $env->{$e->{NAME}}, $env);
}
}
pidl "ndr->depth--;";
@@ -2008,7 +2012,7 @@
$env = GenerateFunctionOutEnv($fn);
foreach my $e (@{$fn->{ELEMENTS}}) {
if (grep(/out/,@{$e->{DIRECTION}})) {
- ParseElementPrint($e, "r->out.$e->{NAME}", $env);
+ ParseElementPrint($e, $env->{$e->{NAME}}, $env);
}
}
if ($fn->{RETURN_TYPE}) {
=== modified file 'source/pidl/tests/samba-ndr.pl'
--- a/source/pidl/tests/samba-ndr.pl 2007-01-10 00:37:30 +0000
+++ b/source/pidl/tests/samba-ndr.pl 2007-02-08 12:28:37 +0000
@@ -4,12 +4,12 @@
use strict;
use warnings;
-use Test::More tests => 10;
+use Test::More tests => 14;
use FindBin qw($RealBin);
use lib "$RealBin";
use Util;
use Parse::Pidl::Util qw(MyDumper);
-use Parse::Pidl::Samba4::NDR::Parser qw(check_null_pointer);
+use Parse::Pidl::Samba4::NDR::Parser qw(check_null_pointer GenerateFunctionInEnv GenerateFunctionOutEnv);
my $output;
sub print_fn($) { my $x = shift; $output.=$x; }
@@ -133,3 +133,16 @@
sub { $fn->("r->in.bla"); });
is($output, "if (r->in.bla == NULL) return;");
+
+# Make sure GenerateFunctionInEnv and GenerateFunctionOutEnv work
+$fn = { ELEMENTS => [ { DIRECTION => ["in"], NAME => "foo" } ] };
+is_deeply({ "foo" => "r->in.foo" }, GenerateFunctionInEnv($fn));
+
+$fn = { ELEMENTS => [ { DIRECTION => ["out"], NAME => "foo" } ] };
+is_deeply({ "foo" => "r->out.foo" }, GenerateFunctionOutEnv($fn));
+
+$fn = { ELEMENTS => [ { DIRECTION => ["out", "in"], NAME => "foo" } ] };
+is_deeply({ "foo" => "r->inout.foo" }, GenerateFunctionInEnv($fn));
+
+$fn = { ELEMENTS => [ { DIRECTION => ["out", "in"], NAME => "foo" } ] };
+is_deeply({ "foo" => "r->inout.foo" }, GenerateFunctionOutEnv($fn));
More information about the samba-cvs
mailing list