~ubuntu-branches/ubuntu/natty/empathy/natty-updates

« back to all changes in this revision

Viewing changes to tools/glib-signals-marshal-gen.py

  • Committer: Bazaar Package Importer
  • Author(s): Sjoerd Simons
  • Date: 2008-03-10 16:39:07 UTC
  • mfrom: (1.1.13 upstream)
  • Revision ID: james.westby@ubuntu.com-20080310163907-tv41g2zmf0qqgi85
Tags: 0.22.0-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
 
 
3
import sys
 
4
import xml.dom.minidom
 
5
from string import ascii_letters, digits
 
6
 
 
7
 
 
8
from libglibcodegen import signal_to_marshal_name, method_to_glue_marshal_name
 
9
 
 
10
 
 
11
class Generator(object):
 
12
 
 
13
    def __init__(self, dom):
 
14
        self.dom = dom
 
15
        self.marshallers = {}
 
16
 
 
17
    def do_method(self, method):
 
18
        marshaller = method_to_glue_marshal_name(method, 'PREFIX')
 
19
 
 
20
        assert '__' in marshaller
 
21
        rhs = marshaller.split('__', 1)[1].split('_')
 
22
 
 
23
        self.marshallers[marshaller] = rhs
 
24
 
 
25
    def do_signal(self, signal):
 
26
        marshaller = signal_to_marshal_name(signal, 'PREFIX')
 
27
 
 
28
        assert '__' in marshaller
 
29
        rhs = marshaller.split('__', 1)[1].split('_')
 
30
 
 
31
        self.marshallers[marshaller] = rhs
 
32
 
 
33
    def __call__(self):
 
34
        methods = self.dom.getElementsByTagName('method')
 
35
 
 
36
        for method in methods:
 
37
            self.do_method(method)
 
38
 
 
39
        signals = self.dom.getElementsByTagName('signal')
 
40
 
 
41
        for signal in signals:
 
42
            self.do_signal(signal)
 
43
 
 
44
        all = self.marshallers.keys()
 
45
        all.sort()
 
46
        for marshaller in all:
 
47
            rhs = self.marshallers[marshaller]
 
48
            if not marshaller.startswith('g_cclosure'):
 
49
                print 'VOID:' + ','.join(rhs)
 
50
 
 
51
if __name__ == '__main__':
 
52
    argv = sys.argv[1:]
 
53
    dom = xml.dom.minidom.parse(argv[0])
 
54
 
 
55
    Generator(dom)()