!ChangeLog that. Refs #10733.
[pidgin-git.git] / libpurple / dbus-analyze-signals.py
blobc60c46dc8b3168cacb964014b16300f3589e0033
1 # This program takes a C source as the input and produces the list of
2 # all signals registered.
4 # Output is:
5 # <signal name="Changed">
6 # <arg name="new_value" type="b"/>
7 # </signal>
9 import re
10 import sys
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.
17 excluded = [\
18 # purple_dbus_signal_emit_purple prevents our "dbus-method-called"
19 # signal from being propagated to dbus.
20 "dbus-method-called",
23 registerregex = re.compile("purple_signal_register[^;]+\"([\w\-]+)\"[^;]+(purple_marshal_\w+)[^;]+;")
24 nameregex = re.compile('[-_][a-z]')
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
34 signal = nameregex.sub(lambda x:x.group()[1].upper(), '-'+signal)
35 print "\"<signal name='%s'>\\n\""%signal
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
57 print "\"</signal>\\n\""
59 print ";"