-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate.pl.in
92 lines (65 loc) · 2.02 KB
/
generate.pl.in
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
BEGIN {
$srcdir = shift;
};
if( /LIBSPECTRUM_AUTOGEN_WARNING/ ) {
$_ = << "CODE";
/* NB: This file is autogenerated from libspectrum.h.in. Do not edit
unless you know what you're doing */
CODE
}
if( /LIBSPECTRUM_SNAP_ACCESSORS/ ) {
open( DATAFILE, '<' . "${srcdir}/snap_accessors.txt" ) or die "Couldn't open `snap_accessors.txt': $!";
$_ = '';
while( <DATAFILE> ) {
next if /^\s*$/; next if /^\s*#/;
my( $type, $name, $indexed ) = split;
my $return_type;
if( $type =~ /^(.*)\*/ ) {
$return_type = "WIN32_DLL $1 *";
} else {
$return_type = "WIN32_DLL $type";
}
if( $indexed ) {
print << "CODE";
$return_type libspectrum_snap_$name( libspectrum_snap *snap, int idx );
WIN32_DLL void libspectrum_snap_set_$name( libspectrum_snap *snap, int idx, $type $name );
CODE
} else {
print << "CODE";
$return_type libspectrum_snap_$name( libspectrum_snap *snap );
WIN32_DLL void libspectrum_snap_set_$name( libspectrum_snap *snap, $type $name );
CODE
}
}
}
if( /LIBSPECTRUM_TAPE_ACCESSORS/ ) {
open( DATAFILE, '<' . "${srcdir}/tape_accessors.txt" )
or die "Couldn't open `tape_accessors.txt': $!";
$_ = '';
while( <DATAFILE> ) {
# Remove comments and blank lines
s/#.*//;
next if /^\s*$/;
# Skip which block types each accessor applies to
next if /^\s/;
my( $type, $name, $indexed, undef ) = split;
my $return_type;
if( $type =~ /^(.*)\*/ ) {
$return_type = "WIN32_DLL $1 *";
} else {
$return_type = "WIN32_DLL $type";
}
if( $indexed ) {
print << "CODE";
$return_type libspectrum_tape_block_$name( libspectrum_tape_block *block, size_t idx );
WIN32_DLL libspectrum_error libspectrum_tape_block_set_$name( libspectrum_tape_block *block, $type \*$name );
CODE
} else {
print << "CODE";
$return_type libspectrum_tape_block_$name( libspectrum_tape_block *block );
WIN32_DLL libspectrum_error libspectrum_tape_block_set_$name( libspectrum_tape_block *block, $type $name );
CODE
}
}
close DATAFILE or die "Couldn't close `tape_accessors.txt': $!";
}