Merge branch '976-disable-assert-checks' into 'master'
[glib.git] / gio / tests / gengiotypefuncs.py
blob47219f3574d386d4523c98efa3c7c08eb9504b3b
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
4 import sys
5 import re
6 import os
8 debug = os.getenv('GIO_GENTYPEFUNCS_DEBUG') is not None
10 out_file = sys.argv[1]
11 in_files = sys.argv[2:]
13 funcs = []
16 if debug: print ('Output file: ', out_file)
18 if debug: print (len(in_files), 'input files')
20 for filename in in_files:
21 if debug: print ('Input file: ', filename)
22 with open(filename, 'rb') as f:
23 for line in f:
24 line = line.rstrip(b'\n').rstrip(b'\r')
25 # print line
26 match = re.search(b'\bg_[a-zA-Z0-9_]*_get_type\b', line)
27 if match:
28 func = match.group(0)
29 if not func in funcs:
30 funcs.append(func)
31 if debug: print ('Found ', func)
33 file_output = 'G_GNUC_BEGIN_IGNORE_DEPRECATIONS\n'
35 funcs = sorted(funcs)
37 for f in funcs:
38 if f not in ['g_io_extension_get_type', 'g_settings_backend_get_type']:
39 file_output += '*tp++ = {0} ();\n'.format(f)
41 if debug: print (len(funcs), 'functions')
43 ofile = open(out_file, "w")
44 ofile.write(file_output)
45 ofile.close()