comparison libpurple/dbus-analyze-signals.py @ 27373:3a0552df3379

Add auto-generated D-Bus signals introspection, though parameter names are not included at the moment. Closes #3243.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Sun, 05 Jul 2009 05:41:00 +0000
parents
children 9f6b8e5998ec
comparison
equal deleted inserted replaced
27372:c900484e41c0 27373:3a0552df3379
1 # This program takes a C source as the input and produces the list of
2 # all signals registered.
3 #
4 # Output is:
5 # <signal name="Changed">
6 # <arg name="new_value" type="b"/>
7 # </signal>
8
9 import re
10 import sys
11
12 # List "excluded" contains signals that shouldn't be exported via
13 # DBus. If you remove a signal from this list, please make sure
14 # that it does not break "make" with the configure option
15 # "--enable-dbus" turned on.
16
17 excluded = [\
18 # purple_dbus_signal_emit_purple prevents our "dbus-method-called"
19 # signal from being propagated to dbus.
20 "dbus-method-called",
21 ]
22
23 registerregex = re.compile("purple_signal_register[^;]+\"([\w\-]+)\"[^;]+(purple_marshal_\w+)[^;]+;")
24 nameregex = re.compile('[-_][a-z]')
25
26 print "/* Generated by %s. Do not edit! */" % sys.argv[0]
27 print "const char *dbus_signals = "
28 for match in registerregex.finditer(sys.stdin.read()):
29 signal = match.group(1)
30 marshal = match.group(2)
31 if signal in excluded:
32 continue
33
34 signal = nameregex.sub(lambda x:x.group()[1].upper(), '-'+signal)
35 print "\"<signal name='%s'>\\n\""%signal
36
37 args = marshal.split('_')
38 # ['purple', 'marshal', <return type>, '', args...]
39 if len(args) > 4:
40 for arg in args[4:]:
41 if arg == "POINTER":
42 type = 'p'
43 elif arg == "ENUM":
44 type = 'i'
45 elif arg == "INT":
46 type = 'i'
47 elif arg == "UINT":
48 type = 'u'
49 elif arg == "INT64":
50 type = 'x'
51 elif arg == "UINT64":
52 type = 't'
53 elif arg == "BOOLEAN":
54 type = 'b'
55 print "\"<arg type='%s'/>\\n\""%type
56
57 print "\"</signal>\\n\""
58
59 print ";"
60