summaryrefslogtreecommitdiffstats
path: root/lasso/extract_types.py
blob: a54baa0f0d1cd6bea115b61a299a9ea290809ce7 (plain)
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
#! /usr/bin/env python

import glob
import re
import sys

if len(sys.argv) == 2:
    srcdir = sys.argv[1]
else:
    srcdir = '.'

fd = open('types.c', 'w')

print >> fd, "/* This file has been autogenerated; changes will be lost */"
print >> fd, ""
print >> fd, "typedef GType (*type_function) (void);"
print >> fd, ""

for header_file in glob.glob('%s/*/*.h' % srcdir):
    try:
        type = re.findall('lasso_.*get_type', open(header_file).read())[0]
    except IndexError:
        continue
    print >> fd, "extern GType %s();" % type

print >> fd, ""
print >> fd, "type_function functions[] = {"
for header_file in glob.glob('%s/*/*.h' % srcdir):
    try:
        type = re.findall('lasso_.*get_type', open(header_file).read())[0]
    except IndexError:
        continue
    print >> fd, "\t%s," % type
print >> fd, "\tNULL"
print >> fd, "};"