mirror of
https://github.com/samba-team/samba.git
synced 2025-01-12 09:18:10 +03:00
r21431: More tests, work on support in wireshark for tagged types.
(This used to be commit a91e624af2
)
This commit is contained in:
parent
8cf122c2d2
commit
f988568787
@ -24,7 +24,7 @@ use Exporter;
|
||||
use vars qw($VERSION);
|
||||
$VERSION = '0.01';
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT_OK = qw(DumpTypedef DumpStruct DumpEnum DumpBitmap DumpUnion DumpFunction);
|
||||
@EXPORT_OK = qw(DumpType DumpTypedef DumpStruct DumpEnum DumpBitmap DumpUnion DumpFunction);
|
||||
|
||||
use strict;
|
||||
use Parse::Pidl::Util qw(has_property);
|
||||
@ -87,7 +87,12 @@ sub DumpStruct($)
|
||||
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 DumpUnion($)
|
||||
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;
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
|
@ -25,7 +25,7 @@ use Parse::Pidl qw(error warning);
|
||||
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 @@ sub Interface($)
|
||||
{
|
||||
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 Const($$)
|
||||
}
|
||||
}
|
||||
|
||||
sub Typedef($$)
|
||||
sub Typedef($$$)
|
||||
{
|
||||
my ($e,$ifname) = @_;
|
||||
my ($e,$name,$ifname) = @_;
|
||||
|
||||
PrintIdl DumpTypedef($e->{ORIGINAL});
|
||||
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($)
|
||||
|
15
source4/pidl/tests/dump.pl
Executable file
15
source4/pidl/tests/dump.pl
Executable file
@ -0,0 +1,15 @@
|
||||
#!/usr/bin/perl
|
||||
# (C) 2007 Jelmer Vernooij <jelmer@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}");
|
||||
|
Loading…
Reference in New Issue
Block a user