1#!/usr/bin/env python3 2# -*- coding: utf-8 -*- 3 4import sys 5import re 6import os 7 8debug = os.getenv("GIO_GENTYPEFUNCS_DEBUG") is not None 9 10out_file = sys.argv[1] 11in_files = sys.argv[2:] 12 13funcs = [] 14 15 16if debug: 17 print("Output file: ", out_file) 18 19if debug: 20 print(len(in_files), "input files") 21 22for filename in in_files: 23 if debug: 24 print("Input file: ", filename) 25 with open(filename, "rb") as f: 26 for line in f: 27 line = line.rstrip(b"\n").rstrip(b"\r") 28 # print line 29 match = re.search(b"\bg_[a-zA-Z0-9_]*_get_type\b", line) 30 if match: 31 func = match.group(0) 32 if func not in funcs: 33 funcs.append(func) 34 if debug: 35 print("Found ", func) 36 37file_output = "G_GNUC_BEGIN_IGNORE_DEPRECATIONS\n" 38 39funcs = sorted(funcs) 40 41for f in funcs: 42 if f not in ["g_io_extension_get_type", "g_settings_backend_get_type"]: 43 file_output += "*tp++ = {0} ();\n".format(f) 44 45if debug: 46 print(len(funcs), "functions") 47 48ofile = open(out_file, "w") 49ofile.write(file_output) 50ofile.close() 51