forked from DFHack/df-structures
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make-keybindings.pl
executable file
·57 lines (46 loc) · 1.06 KB
/
make-keybindings.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/perl
use strict;
use warnings;
print <<'__END__';
<data-definition>
WARNING: THIS FILE IS AUTO-GENERATED - DO NOT EDIT
<enum-type type-name='interface_key' base-type='long'>
__END__
my $startname;
my $after_start;
while(<>) {
my ($name, $val);
if ($after_start) {
$after_start = 0;
if (/^\s+([A-Z_0-9]+)=$startname,\s*$/) {
$name = $1;
} else {
$startname =~ s/^INTERFACEKEY_//;
print " <enum-item name='$startname'/>\n";
redo;
}
} else {
next unless /^\s+([A-Z_0-9]+)(?:=(\d+))?,\s*$/;
($name, $val) = ($1, $2);
}
if ($name =~ /_START$/) {
$startname = $name;
$after_start = 1;
next;
}
last if $name eq 'INTERFACEKEYNUM';
$name =~ s/^INTERFACEKEY_//;
print " <enum-item name='$name'";
print " value='$val'" if defined $val;
print "/>\n";
}
print <<'__END__';
</enum-type>
</data-definition>
<!--
Local Variables:
indent-tabs-mode: nil
nxml-child-indent: 4
End:
-->
__END__