Update Greek translation
[empathy-mirror.git] / tools / glib-client-marshaller-gen.py
blobcd9823bdffb234730667f8ec1fbffee4ab1d017a
1 #!/usr/bin/python
3 import sys
4 import xml.dom.minidom
5 from string import ascii_letters, digits
8 from libglibcodegen import signal_to_marshal_name
11 NS_TP = "http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"
13 class Generator(object):
15 def __init__(self, dom, prefix):
16 self.dom = dom
17 self.marshallers = {}
18 self.prefix = prefix
20 def do_signal(self, signal):
21 marshaller = signal_to_marshal_name(signal, self.prefix)
23 assert '__' in marshaller
24 rhs = marshaller.split('__', 1)[1].split('_')
26 self.marshallers[marshaller] = rhs
28 def __call__(self):
29 signals = self.dom.getElementsByTagName('signal')
31 for signal in signals:
32 self.do_signal(signal)
34 print('void')
35 print('%s_register_dbus_glib_marshallers (void)' % self.prefix)
36 print('{')
38 all = list(self.marshallers.keys())
39 all.sort()
40 for marshaller in all:
41 rhs = self.marshallers[marshaller]
43 print(' dbus_g_object_register_marshaller (')
44 print(' g_cclosure_marshal_generic,')
45 print(' G_TYPE_NONE, /* return */')
46 for type in rhs:
47 print(' G_TYPE_%s,' % type.replace('VOID', 'NONE'))
48 print(' G_TYPE_INVALID);')
50 print('}')
53 def types_to_gtypes(types):
54 return [type_to_gtype(t)[1] for t in types]
56 if __name__ == '__main__':
57 argv = sys.argv[1:]
58 dom = xml.dom.minidom.parse(argv[0])
60 Generator(dom, argv[1])()