summaryrefslogtreecommitdiff
path: root/qt4/tools/glib-signals-marshal-gen.py
blob: 0d02c1341c920b043bd0ced37bef5a3293126559 (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/python

import sys
import xml.dom.minidom
from string import ascii_letters, digits


from libglibcodegen import signal_to_marshal_name, method_to_glue_marshal_name


class Generator(object):

    def __init__(self, dom):
        self.dom = dom
        self.marshallers = {}

    def do_method(self, method):
        marshaller = method_to_glue_marshal_name(method, 'PREFIX')

        assert '__' in marshaller
        rhs = marshaller.split('__', 1)[1].split('_')

        self.marshallers[marshaller] = rhs

    def do_signal(self, signal):
        marshaller = signal_to_marshal_name(signal, 'PREFIX')

        assert '__' in marshaller
        rhs = marshaller.split('__', 1)[1].split('_')

        self.marshallers[marshaller] = rhs

    def __call__(self):
        methods = self.dom.getElementsByTagName('method')

        for method in methods:
            self.do_method(method)

        signals = self.dom.getElementsByTagName('signal')

        for signal in signals:
            self.do_signal(signal)

        all = self.marshallers.keys()
        all.sort()
        for marshaller in all:
            rhs = self.marshallers[marshaller]
            if not marshaller.startswith('g_cclosure'):
                print 'VOID:' + ','.join(rhs)

if __name__ == '__main__':
    argv = sys.argv[1:]
    dom = xml.dom.minidom.parse(argv[0])

    Generator(dom)()