Mercurial > pidgin
comparison src/dbus-analyze-types.py @ 11146:1c5398ccbeb0
[gaim-migrate @ 13217]
Gaim-DBUS signal export works with DBUS >= 0.35
Various gaim API functions available through DBUS
committer: Tailor Script <tailor@pidgin.im>
author | Piotr Zielinski <zielaj> |
---|---|
date | Fri, 22 Jul 2005 19:47:29 +0000 |
parents | |
children | ebb02ea3c789 |
comparison
equal
deleted
inserted
replaced
11145:dbc518c453f2 | 11146:1c5398ccbeb0 |
---|---|
1 # This program takes a C header/source as the input and produces | |
2 # | |
3 # with --keyword=enum: the list of all enums | |
4 # with --keyword=struct: the list of all structs | |
5 # | |
6 # the output styles: | |
7 # | |
8 # --enum DBUS_POINTER_NAME1, | |
9 # DBUS_POINTER_NAME2, | |
10 # DBUS_POINTER_NAME3, | |
11 # | |
12 # --list NAME1 | |
13 # NAME2 | |
14 # NAME3 | |
15 # | |
16 | |
17 | |
18 import re | |
19 import sys | |
20 | |
21 myinput = iter(sys.stdin) | |
22 | |
23 def outputenum(name): | |
24 print "DBUS_POINTER_%s," % name | |
25 | |
26 def outputdeclare(name): | |
27 print "DECLARE_TYPE(%s, NONE);" % name | |
28 | |
29 def outputtext(name): | |
30 print name | |
31 | |
32 myoutput = outputtext | |
33 keyword = "struct" | |
34 | |
35 for arg in sys.argv[1:]: | |
36 if arg[0:2] == "--": | |
37 mylist = arg[2:].split("=") | |
38 command = mylist[0] | |
39 if len(mylist) > 1: | |
40 value = mylist[1] | |
41 else: | |
42 value = None | |
43 | |
44 if command == "enum": | |
45 myoutput = outputenum | |
46 if command == "declare": | |
47 myoutput = outputdeclare | |
48 if command == "list": | |
49 myoutput = outputtext | |
50 if command == "keyword": | |
51 keyword = value | |
52 | |
53 | |
54 structregexp1 = re.compile(r"^(typedef\s+)?%s\s+\w+\s+(\w+)\s*;" % keyword) | |
55 structregexp2 = re.compile(r"^(typedef\s+)?%s" % keyword) | |
56 structregexp3 = re.compile(r"^}\s+(\w+)\s*;") | |
57 | |
58 for line in myinput: | |
59 match = structregexp1.match(line) | |
60 if match is not None: | |
61 myoutput(match.group(2)) | |
62 continue | |
63 | |
64 match = structregexp2.match(line) | |
65 if match is not None: | |
66 while True: | |
67 line = myinput.next() | |
68 match = structregexp3.match(line) | |
69 if match is not None: | |
70 myoutput(match.group(1)) | |
71 break | |
72 if line[0] not in [" ", "\t", "{", "\n"]: | |
73 break | |
74 | |
75 | |
76 | |
77 | |
78 | |
79 |