• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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: print ('Output file: ', out_file)
17
18if debug: print (len(in_files), 'input files')
19
20for 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)
32
33file_output = 'G_GNUC_BEGIN_IGNORE_DEPRECATIONS\n'
34
35funcs = sorted(funcs)
36
37for 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)
40
41if debug: print (len(funcs), 'functions')
42
43ofile = open(out_file, "w")
44ofile.write(file_output)
45ofile.close()
46