1 # IMPORTANT: Keep in sync with make-cairo-boilerplate-constructors.sh
2 # and test/make-cairo-test-constructors.py!
7 if __name__
=='__main__':
8 parser
= argparse
.ArgumentParser()
9 parser
.add_argument('output')
10 parser
.add_argument('input', nargs
='+')
11 args
= parser
.parse_args()
13 boilerplate_names
= []
15 match_boilerplate_line
= re
.compile(r
'^CAIRO_BOILERPLATE.*')
16 match_boilerplate_name
= re
.compile(r
'^CAIRO_BOILERPLATE.*\((.*),.*')
18 for fname
in args
.input:
19 with
open(fname
, 'r', encoding
='utf-8') as f
:
20 for l
in f
.readlines():
21 if match_boilerplate_line
.match(l
):
22 boilerplate_names
.append(match_boilerplate_name
.match(l
).group(1))
24 with
open(args
.output
, 'w', encoding
='utf-8') as f
:
25 f
.write('/* WARNING: Autogenerated file - see %s! */\n\n' % sys
.argv
[0])
26 f
.write('#include "cairo-boilerplate-private.h"\n\n')
27 f
.write('void _cairo_boilerplate_register_all (void);\n\n')
29 for boilerplate_name
in boilerplate_names
:
30 f
.write('extern void _register_%s (void);\n' % boilerplate_name
)
33 f
.write('_cairo_boilerplate_register_all (void)\n')
36 for boilerplate_name
in boilerplate_names
:
37 f
.write(' _register_%s ();\n' % boilerplate_name
)