aboutsummaryrefslogtreecommitdiffstats
path: root/tools/process-x11-xcb.pl
diff options
context:
space:
mode:
authorPeter Harris <pharris@opentext.com>2014-08-20 11:29:35 -0400
committerJeff Morriss <jeff.morriss.ws@gmail.com>2014-08-22 00:04:52 +0000
commit331d87e303c009e60d2b2ce85a2554c8eb0231f3 (patch)
treebf98721ff4b97ae037b7e2ba4044b1c0e6289a1c /tools/process-x11-xcb.pl
parent0c38cf3c7bdd21da0f08a0d46bfa5afc98d70f40 (diff)
X11: Support xcb's new <case>
Change-Id: I32c6ab15d6dc7a67cdb50c4187e2752730315588 Reviewed-on: https://code.wireshark.org/review/3751 Reviewed-by: Jeff Morriss <jeff.morriss.ws@gmail.com>
Diffstat (limited to 'tools/process-x11-xcb.pl')
-rwxr-xr-xtools/process-x11-xcb.pl37
1 files changed, 22 insertions, 15 deletions
diff --git a/tools/process-x11-xcb.pl b/tools/process-x11-xcb.pl
index 9c99fa405d..503403732c 100755
--- a/tools/process-x11-xcb.pl
+++ b/tools/process-x11-xcb.pl
@@ -622,7 +622,7 @@ sub reference_elements($$)
}
}
- my @elements = $e->children('bitcase');
+ my @elements = $e->children(qr/(bit)?case/);
for my $case (@elements) {
my @sub_elements = $case->children(qr/list|switch/);
@@ -871,28 +871,33 @@ sub dissect_element($$$$$;$$)
my $switchtype = $e->first_child() or die("Switch element not defined");
my $switchon = get_ref($switchtype, {});
- my @elements = $e->children('bitcase');
+ my @elements = $e->children(qr/(bit)?case/);
for my $case (@elements) {
my @refs = $case->children('enumref');
- my @bits;
+ my @test;
my $fieldname;
foreach my $ref (@refs) {
my $enum_ref = $ref->att('ref');
my $field = $ref->text();
$fieldname //= $field; # Use first named field
- my $bit = $enum{$enum_name{$enum_ref}}{rbit}{$field};
- if (! defined($bit)) {
- for my $foo (keys %{$enum{$enum_name{$enum_ref}}{rbit}}) { say "'$foo'"; }
- die ("Field '$field' not found in '$enum_ref'");
+ if ($case->name() eq 'bitcase') {
+ my $bit = $enum{$enum_name{$enum_ref}}{rbit}{$field};
+ if (! defined($bit)) {
+ for my $foo (keys %{$enum{$enum_name{$enum_ref}}{rbit}}) { say "'$foo'"; }
+ die ("Field '$field' not found in '$enum_ref'");
+ }
+ push @test , "($switchon & (1 << $bit))";
+ } else {
+ my $val = $enum{$enum_name{$enum_ref}}{rvalue}{$field};
+ if (! defined($val)) {
+ for my $foo (keys %{$enum{$enum_name{$enum_ref}}{rvalue}}) { say "'$foo'"; }
+ die ("Field '$field' not found in '$enum_ref'");
+ }
+ push @test , "($switchon == $val)";
}
- push @bits , "(1 << $bit)";
- }
- if (scalar @bits == 1) {
- say $impl $indent."if (($switchon & $bits[0]) != 0) {";
- } else {
- my $list = join '|', @bits;
- say $impl $indent."if (($switchon & ($list)) != 0) {";
}
+ my $list = join ' || ', @test;
+ say $impl $indent."if ($list) {";
my $vp = $varpat;
my $hp = $humanpat;
@@ -1220,8 +1225,9 @@ sub enum {
my $value = {};
my $bit = {};
+ my $rvalue = {};
my $rbit = {};
- $enum{$fullname} = { value => $value, bit => $bit, rbit => $rbit };
+ $enum{$fullname} = { value => $value, bit => $bit, rbit => $rbit, rvalue => $rvalue };
my $nextvalue = 0;
@@ -1233,6 +1239,7 @@ sub enum {
given ($valtype->name()) {
when ('value') {
$$value{$val} = $n;
+ $$rvalue{$n} = $val;
$nextvalue = $val + 1;
# Ugly hack to support (temporary, hopefully) ugly