Rev 11522: More tests,
work on support in wireshark for tagged types. in
file:///home/jelmer/bzr.samba/SAMBA_4_0/
Jelmer Vernooij
jelmer at samba.org
Sun Feb 18 16:44:06 GMT 2007
At file:///home/jelmer/bzr.samba/SAMBA_4_0/
------------------------------------------------------------
revno: 11522
revision-id: jelmer at samba.org-20070218164355-wcsqzlh7s37se8xk
parent: svn-v2:21430 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: SAMBA_4_0
timestamp: Sun 2007-02-18 17:43:55 +0100
message:
More tests, work on support in wireshark for tagged types.
added:
source/pidl/tests/dump.pl dump.pl-20070218163258-vsedroj2jl5xz45z-1
modified:
source/pidl/lib/Parse/Pidl/Dump.pm svn-v2:9460 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0-source%2fpidl%2flib%2fParse%2fPidl%2fDump.pm
source/pidl/lib/Parse/Pidl/Wireshark/NDR.pm svn-v2:16824 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0-source%2fpidl%2flib%2fParse%2fPidl%2fWireshark%2fNDR.pm
=== added file 'source/pidl/tests/dump.pl'
--- a/source/pidl/tests/dump.pl 1970-01-01 00:00:00 +0000
+++ b/source/pidl/tests/dump.pl 2007-02-18 16:43:55 +0000
@@ -0,0 +1,15 @@
+#!/usr/bin/perl
+# (C) 2007 Jelmer Vernooij <jelmer at samba.org>
+# Published under the GNU General Public License
+use strict;
+use warnings;
+
+use Test::More tests => 1;
+use FindBin qw($RealBin);
+use lib "$RealBin";
+use Util;
+use Parse::Pidl::Dump qw(DumpStruct);
+
+is (DumpStruct({ NAME => "foo", ELEMENTS => []}),
+ "struct foo {\n}");
+
=== modified file 'source/pidl/lib/Parse/Pidl/Dump.pm'
--- a/source/pidl/lib/Parse/Pidl/Dump.pm 2006-05-16 22:21:44 +0000
+++ b/source/pidl/lib/Parse/Pidl/Dump.pm 2007-02-18 16:43:55 +0000
@@ -24,7 +24,7 @@
use vars qw($VERSION);
$VERSION = '0.01';
@ISA = qw(Exporter);
- at EXPORT_OK = qw(DumpTypedef DumpStruct DumpEnum DumpBitmap DumpUnion DumpFunction);
+ at EXPORT_OK = qw(DumpType DumpTypedef DumpStruct DumpEnum DumpBitmap DumpUnion DumpFunction);
use strict;
use Parse::Pidl::Util qw(has_property);
@@ -87,7 +87,12 @@
my($struct) = shift;
my($res);
- $res .= "struct {\n";
+ $res .= "struct ";
+ if ($struct->{NAME}) {
+ $res.="$struct->{NAME} ";
+ }
+
+ $res.="{\n";
if (defined $struct->{ELEMENTS}) {
foreach (@{$struct->{ELEMENTS}}) {
$res .= "\t" . DumpElement($_) . ";\n";
@@ -185,18 +190,15 @@
sub DumpType($)
{
my($data) = shift;
- my($res);
if (ref($data) eq "HASH") {
- ($data->{TYPE} eq "STRUCT") && ($res .= DumpStruct($data));
- ($data->{TYPE} eq "UNION") && ($res .= DumpUnion($data));
- ($data->{TYPE} eq "ENUM") && ($res .= DumpEnum($data));
- ($data->{TYPE} eq "BITMAP") && ($res .= DumpBitmap($data));
+ return DumpStruct($data) if ($data->{TYPE} eq "STRUCT");
+ return DumpUnion($data) if ($data->{TYPE} eq "UNION");
+ return DumpEnum($data) if ($data->{TYPE} eq "ENUM");
+ return DumpBitmap($data) if ($data->{TYPE} eq "BITMAP");
} else {
- $res .= "$data";
+ return $data;
}
-
- return $res;
}
#####################################################################
=== modified file 'source/pidl/lib/Parse/Pidl/Wireshark/NDR.pm'
--- a/source/pidl/lib/Parse/Pidl/Wireshark/NDR.pm 2007-02-17 23:38:57 +0000
+++ b/source/pidl/lib/Parse/Pidl/Wireshark/NDR.pm 2007-02-18 16:43:55 +0000
@@ -25,7 +25,7 @@
use Parse::Pidl::Typelist qw(getType);
use Parse::Pidl::Util qw(has_property property_matches make_str);
use Parse::Pidl::NDR qw(ContainsString GetNextLevel);
-use Parse::Pidl::Dump qw(DumpTypedef DumpFunction);
+use Parse::Pidl::Dump qw(DumpType DumpFunction);
use Parse::Pidl::Wireshark::Conformance qw(ReadConformance);
use File::Basename;
@@ -127,7 +127,7 @@
{
my($interface) = @_;
Const($_,$interface->{NAME}) foreach (@{$interface->{CONSTS}});
- Typedef($_,$interface->{NAME}) foreach (@{$interface->{TYPES}});
+ Type($_, $_->{NAME}, $interface->{NAME}) foreach (@{$interface->{TYPES}});
Function($_,$interface->{NAME}) foreach (@{$interface->{FUNCTIONS}});
}
@@ -637,18 +637,26 @@
}
}
-sub Typedef($$)
-{
- my ($e,$ifname) = @_;
-
- PrintIdl DumpTypedef($e->{ORIGINAL});
+sub Typedef($$$)
+{
+ my ($e,$name,$ifname) = @_;
+
+ Type($e->{DATA}, $name, $ifname);
+}
+
+sub Type($$$)
+{
+ my ($e, $name, $ifname) = @_;
+
+ PrintIdl DumpType($e->{ORIGINAL});
{
ENUM => \&Enum,
STRUCT => \&Struct,
UNION => \&Union,
- BITMAP => \&Bitmap
- }->{$e->{DATA}->{TYPE}}->($e->{DATA}, $e->{NAME}, $ifname);
+ BITMAP => \&Bitmap,
+ TYPEDEF => \&Typedef
+ }->{$e->{TYPE}}->($e, $name, $ifname);
}
sub RegisterInterface($)
More information about the samba-cvs
mailing list