Mercurial > pidgin
comparison libpurple/dbus-analyze-signals.py @ 31185:1e5654e2928d
propagate from branch 'im.pidgin.pidgin' (head ea17b906d0f9b7422adfebcbec58d7c06d3bd8bc)
to branch 'im.pidgin.pidgin.openq' (head 0f8a2684fb6f0f7221bde3bedd5734241bfb7ff5)
author | SHiNE CsyFeK <csyfek@gmail.com> |
---|---|
date | Sat, 18 Jul 2009 15:15:45 +0000 |
parents | 3a0552df3379 |
children | 9f6b8e5998ec |
comparison
equal
deleted
inserted
replaced
31184:a1e92a4d99b9 | 31185:1e5654e2928d |
---|---|
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 |