| 3 # |
3 # |
| 4 # Output is: |
4 # Output is: |
| 5 # <signal name="Changed"> |
5 # <signal name="Changed"> |
| 6 # <arg name="new_value" type="b"/> |
6 # <arg name="new_value" type="b"/> |
| 7 # </signal> |
7 # </signal> |
| 8 |
8 from __future__ import print_function |
| 9 import re |
9 import re |
| 10 import sys |
10 import sys |
| 11 |
11 |
| 12 # List "excluded" contains signals that shouldn't be exported via |
12 # List "excluded" contains signals that shouldn't be exported via |
| 13 # DBus. If you remove a signal from this list, please make sure |
13 # DBus. If you remove a signal from this list, please make sure |
| 21 ] |
21 ] |
| 22 |
22 |
| 23 registerregex = re.compile("purple_signal_register[^;]+\"([\w\-]+)\"[^;]+(purple_marshal_\w+)[^;]+;") |
23 registerregex = re.compile("purple_signal_register[^;]+\"([\w\-]+)\"[^;]+(purple_marshal_\w+)[^;]+;") |
| 24 nameregex = re.compile('[-_][a-z]') |
24 nameregex = re.compile('[-_][a-z]') |
| 25 |
25 |
| 26 print "/* Generated by %s. Do not edit! */" % sys.argv[0] |
26 print("/* Generated by %s. Do not edit! */" % sys.argv[0]) |
| 27 print "const char *dbus_signals = " |
27 print("const char *dbus_signals = ") |
| 28 for match in registerregex.finditer(sys.stdin.read()): |
28 for match in registerregex.finditer(sys.stdin.read()): |
| 29 signal = match.group(1) |
29 signal = match.group(1) |
| 30 marshal = match.group(2) |
30 marshal = match.group(2) |
| 31 if signal in excluded: |
31 if signal in excluded: |
| 32 continue |
32 continue |
| 33 |
33 |
| 34 signal = nameregex.sub(lambda x:x.group()[1].upper(), '-'+signal) |
34 signal = nameregex.sub(lambda x:x.group()[1].upper(), '-'+signal) |
| 35 print "\" <signal name='%s'>\\n\""%signal |
35 print("\" <signal name='%s'>\\n\"" % signal) |
| 36 |
36 |
| 37 args = marshal.split('_') |
37 args = marshal.split('_') |
| 38 # ['purple', 'marshal', <return type>, '', args...] |
38 # ['purple', 'marshal', <return type>, '', args...] |
| 39 if len(args) > 4: |
39 if len(args) > 4: |
| 40 for arg in args[4:]: |
40 for arg in args[4:]: |