-
Notifications
You must be signed in to change notification settings - Fork 81
/
list.pl
executable file
·41 lines (33 loc) · 1.15 KB
/
list.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
#!/usr/bin/perl
use strict;
use warnings;
use XML::LibXML;
my $input_dir = $ARGV[0] || '.';
my $output_dir = $ARGV[1] || 'codegen';
my $separator = $ARGV[2] || "\n";
print "$output_dir/static.inc";
print "$separator$output_dir/global_objects.h";
for my $file (qw(ctors enums fields)) {
print "$separator$output_dir/static.$file.inc";
}
for my $letter ('a' .. 'z') {
print "$separator$output_dir/static.fields-$letter.inc";
}
for my $filename (glob "$input_dir/*.xml") {
my $parser = XML::LibXML->new();
my $doc = $parser->parse_file($filename);
my @nodes = (
$doc->findnodes('/data-definition/enum-type'),
$doc->findnodes('/data-definition/bitfield-type'),
$doc->findnodes('/data-definition/struct-type'),
$doc->findnodes('/data-definition/class-type'),
$doc->findnodes('/data-definition/df-linked-list-type'),
$doc->findnodes('/data-definition/df-other-vectors-type')
);
for my $node (@nodes) {
my $name = $node->getAttribute('type-name')
or die "Unnamed type in $filename\n";
print "$separator$output_dir/$name.h";
}
}
print $separator if $separator eq "\n";