summaryrefslogtreecommitdiff
path: root/source4/build
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2005-01-25 22:33:44 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:09:12 -0500
commit0e169886d3741b1f8bc1ac1eddac0699a8016c3e (patch)
tree093c2e1159f2c5df531432c660ba56fbdb5613bd /source4/build
parent72478f0bd8f4c78b96c0e34b36892f70c378c3a6 (diff)
downloadsamba-0e169886d3741b1f8bc1ac1eddac0699a8016c3e.tar.gz
samba-0e169886d3741b1f8bc1ac1eddac0699a8016c3e.tar.bz2
samba-0e169886d3741b1f8bc1ac1eddac0699a8016c3e.zip
r4990: Generate value strings for pidl enumerations.
(This used to be commit edaf81b6395e1af06e9546027f9a9c3c4975c4b4)
Diffstat (limited to 'source4/build')
-rw-r--r--source4/build/pidl/eparser.pm70
1 files changed, 57 insertions, 13 deletions
diff --git a/source4/build/pidl/eparser.pm b/source4/build/pidl/eparser.pm
index aa80e4d50c..43949fc766 100644
--- a/source4/build/pidl/eparser.pm
+++ b/source4/build/pidl/eparser.pm
@@ -290,7 +290,8 @@ sub NeededTypedef($)
$needed{"hf_$t->{NAME}"} = {
'name' => $t->{NAME},
'ft' => 'FT_UINT16',
- 'base' => 'BASE_DEC'
+ 'base' => 'BASE_DEC',
+ 'strings' => "VALS($t->{NAME}_vals)"
};
}
}
@@ -363,6 +364,25 @@ sub ParseHeader($$)
}
#####################################################################
+# generate code to parse an enum
+
+sub ParseEnum($)
+{
+ my ($e) = shift;
+ print Dumper($e);
+
+ pidl "static const value_string $e->{PARENT}{NAME}_vals[] =\n";
+ pidl "{\n";
+
+ foreach my $x (@{$e->{ELEMENTS}}) {
+ $x =~ /([^=]*)=(.*)/;
+ pidl "\t{ $1, \"$1\" },\n";
+ }
+
+ pidl "};\n\n";
+}
+
+#####################################################################
# rewrite autogenerated header file
sub RewriteHeader($$$)
{
@@ -475,11 +495,29 @@ sub RewriteC($$$)
#
# Regexps to do a first pass at removing stuff we aren't
- # interested in for ehtereal parsers.
+ # interested in for ethereal parsers.
#
next, if /^\#include \"includes.h\"/;
+ # Rewrite includes to packet-dcerpc-foo.h instead of ndr_foo.h
+
+ s/^\#include \".*?ndr_(.*?).h\"$/\#include \"packet-dcerpc-$1.h\"/smg;
+
+ if (/\.h\"$/) {
+ pidl $_;
+ foreach my $x (@{$idl}) {
+ if ($x->{TYPE} eq "INTERFACE") {
+ foreach my $y (@{$x->{INHERITED_DATA}}) {
+ if ($y->{TYPE} eq "TYPEDEF") {
+ ParseEnum($y->{DATA}), if $y->{DATA}{TYPE} eq "ENUM";
+ }
+ }
+ }
+ }
+ next;
+ }
+
# Remove the NDR_CHECK() macro calls. Ethereal take care of
# this for us as part of the tvbuff_t structure.
@@ -502,10 +540,6 @@ sub RewriteC($$$)
next, if /^static NTSTATUS dcerpc_ndr_[a-z]+_init/ .. /^}/;
next, if /^NTSTATUS dcerpc_[a-z]+_init/ .. /^}/;
- # Rewrite includes to packet-dcerpc-foo.h instead of ndr_foo.h
-
- s/^\#include \".*?ndr_(.*?).h\"$/\#include \"packet-dcerpc-$1.h\"/smg;
-
#
# Remember which structure or function we are processing.
#
@@ -587,12 +621,21 @@ sub RewriteC($$$)
# ndr_pull_uint32(ndr, &r->in.access_mask);
# ndr_pull_uint32(ndr, &r->idx);
- s/(ndr_pull_([^\)]*?)
- \(ndr,\
- (&?r->((in|out)\.)? # Function args contain leading junk
- ([^\)]*?)) # Element name
- \);)
- /ndr_pull_$2(ndr, tree, hf_${cur_fn}_$6, $3);/smgx;
+ if (/(ndr_pull_([^\)]*?)\(ndr, (&?r->((in|out)\.)?([^\)]*?))\);)/) {
+
+ my $pull_type = "${cur_fn}_$6";
+
+ if (defined($needed{"hf_$2"})) {
+ $pull_type = "$2";
+ }
+
+ s/(ndr_pull_([^\)]*?)
+ \(ndr,\
+ (&?r->((in|out)\.)? # Function args contain leading junk
+ ([^\)]*?)) # Element name
+ \);)
+ /ndr_pull_$2(ndr, tree, hf_$pull_type, $3);/smgx;
+ }
# Add tree and hf argument to pulls of "internal" scalars like
# array sizes, levels, etc.
@@ -723,7 +766,8 @@ sub RewriteC($$$)
foreach my $x (keys(%needed)) {
next, if !($x =~ /^hf_/);
pidl "\t{ &$x,\n";
- pidl "\t { \"$needed{$x}{name}\", \"$x\", $needed{$x}{ft}, $needed{$x}{base}, NULL, 0, \"$x\", HFILL }},\n";
+ $needed{$x}{strings} = "NULL", if !defined($needed{$x}{strings});
+ pidl "\t { \"$needed{$x}{name}\", \"$x\", $needed{$x}{ft}, $needed{$x}{base}, $needed{$x}{strings}, 0, \"$x\", HFILL }},\n";
}
pidl "\t};\n\n";