Rev 11392: Fix handling of elements without [in,
out] in file:///home/jelmer/bzr.samba/pidl-fixes/
Jelmer Vernooij
jelmer at samba.org
Thu Feb 8 11:25:29 GMT 2007
At file:///home/jelmer/bzr.samba/pidl-fixes/
------------------------------------------------------------
revno: 11392
revision-id: jelmer at samba.org-20070208112519-x9ru04sml0g8wq4x
parent: jelmer at samba.org-20070208104200-7iq7uyqo7h7fohgk
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: pidl-fixes
timestamp: Thu 2007-02-08 12:25:19 +0100
message:
Fix handling of elements without [in,out]
modified:
source/pidl/lib/Parse/Pidl/Samba4/Header.pm svn-v2:12463 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0-source%2fpidl%2flib%2fParse%2fPidl%2fSamba4%2fHeader.pm
source/pidl/tests/header.pl header.pl-20070208094205-onb80lvoyh5ciw5r-1
=== modified file 'source/pidl/lib/Parse/Pidl/Samba4/Header.pm'
--- a/source/pidl/lib/Parse/Pidl/Samba4/Header.pm 2007-02-08 10:42:00 +0000
+++ b/source/pidl/lib/Parse/Pidl/Samba4/Header.pm 2007-02-08 11:25:19 +0000
@@ -235,15 +235,25 @@
}
}
+sub ElementDirection($)
+{
+ my ($e) = @_;
+
+ return "inout" if (has_property($e, "in") and has_property($e, "out"));
+ return "in" if (has_property($e, "in"));
+ return "out" if (has_property($e, "out"));
+ return "inout";
+}
+
#####################################################################
# parse a function
sub HeaderFunctionInOut($$)
{
my($fn,$prop) = @_;
- foreach (@{$fn->{ELEMENTS}}) {
- HeaderElement($_) if (has_property($_, $prop));
- }
+ foreach (@{$fn->{ELEMENTS}}) {
+ HeaderElement($_) if (ElementDirection($_) eq $prop);
+ }
}
#####################################################################
@@ -254,8 +264,8 @@
return 1 if ($prop eq "out" && $fn->{RETURN_TYPE} ne "void");
- foreach (@{$fn->{ELEMENTS}}) {
- return 1 if (has_property($_, $prop));
+ foreach (@{$fn->{ELEMENTS}}) {
+ return 1 if (ElementDirection($_) eq $prop);
}
return undef;
@@ -277,19 +287,23 @@
$tab_depth++;
my $needed = 0;
- if (HeaderFunctionInOut_needed($fn, "in")) {
+ if (HeaderFunctionInOut_needed($fn, "in") or
+ HeaderFunctionInOut_needed($fn, "inout")) {
pidl tabs()."struct {\n";
$tab_depth++;
HeaderFunctionInOut($fn, "in");
+ HeaderFunctionInOut($fn, "inout");
$tab_depth--;
pidl tabs()."} in;\n\n";
$needed++;
}
- if (HeaderFunctionInOut_needed($fn, "out")) {
+ if (HeaderFunctionInOut_needed($fn, "out") or
+ HeaderFunctionInOut_needed($fn, "inout")) {
pidl tabs()."struct {\n";
$tab_depth++;
HeaderFunctionInOut($fn, "out");
+ HeaderFunctionInOut($fn, "inout");
if ($fn->{RETURN_TYPE} ne "void") {
pidl tabs().mapType($fn->{RETURN_TYPE}) . " result;\n";
}
@@ -298,7 +312,7 @@
$needed++;
}
- if (! $needed) {
+ if (!$needed) {
# sigh - some compilers don't like empty structures
pidl tabs()."int _dummy_element;\n";
}
=== modified file 'source/pidl/tests/header.pl'
--- a/source/pidl/tests/header.pl 2007-02-08 10:42:00 +0000
+++ b/source/pidl/tests/header.pl 2007-02-08 11:25:19 +0000
@@ -4,7 +4,7 @@
use strict;
use warnings;
-use Test::More tests => 8;
+use Test::More tests => 9;
use FindBin qw($RealBin);
use lib "$RealBin";
use Util;
@@ -33,4 +33,4 @@
qr/struct foo.*{.*struct\s+{\s+uint32_t x;\s+} out;.*};/sm, "fn out arg works");
like(parse_idl("interface x { void foo ([in,out] uint32 x); };"),
qr/struct foo.*{.*struct\s+{\s+uint32_t x;\s+} in;\s+struct\s+{\s+uint32_t x;\s+} out;.*};/sm, "fn in,out arg works");
-#like(parse_idl("interface x { void foo (uint32 x); };"), qr/struct foo.*{.*struct\s+{\s+uint32_t x;\s+} in;\s+struct\s+{\s+uint32_t x;\s+} out;.*};/sm, "fn with no props implies in,out");
+like(parse_idl("interface x { void foo (uint32 x); };"), qr/struct foo.*{.*struct\s+{\s+uint32_t x;\s+} in;\s+struct\s+{\s+uint32_t x;\s+} out;.*};/sm, "fn with no props implies in,out");
More information about the samba-cvs
mailing list