annotate src/dbus-analyze-types.py @ 19791:bddd32f36bde

[gaim-migrate @ 16653] a version can show the windows Live ID's Info correctly ready to send the oim,need to check committed by Ma Yuan<mayuan2006@gmail.com> committer: Ethan Blanton <elb@pidgin.im>
author Ma Yuan <mayuan2006@gmail.com>
date Sun, 06 Aug 2006 15:16:46 +0000
parents 64fadbf3810f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11146
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
1 # This program takes a C header/source as the input and produces
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
2 #
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
3 # with --keyword=enum: the list of all enums
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
4 # with --keyword=struct: the list of all structs
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
5 #
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
6 # the output styles:
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
7 #
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
8 # --enum DBUS_POINTER_NAME1,
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
9 # DBUS_POINTER_NAME2,
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
10 # DBUS_POINTER_NAME3,
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
11 #
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
12 # --list NAME1
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
13 # NAME2
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
14 # NAME3
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
15 #
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
16
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
17
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
18 import re
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
19 import sys
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
20
11331
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11171
diff changeset
21 options = {}
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11171
diff changeset
22
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11171
diff changeset
23 def toprint(match, line):
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11171
diff changeset
24 if verbatim:
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11171
diff changeset
25 return line
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11171
diff changeset
26 else:
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11171
diff changeset
27 return pattern % match
11146
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
28
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
29 for arg in sys.argv[1:]:
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
30 if arg[0:2] == "--":
11171
ebb02ea3c789 [gaim-migrate @ 13272]
Piotr Zielinski <zielaj>
parents: 11146
diff changeset
31 mylist = arg[2:].split("=",1)
11146
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
32 command = mylist[0]
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
33 if len(mylist) > 1:
11331
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11171
diff changeset
34 options[command] = mylist[1]
11146
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
35 else:
11331
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11171
diff changeset
36 options[command] = None
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11171
diff changeset
37
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11171
diff changeset
38 keyword = options.get("keyword", "struct")
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11171
diff changeset
39 pattern = options.get("pattern", "%s")
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11171
diff changeset
40 verbatim = options.has_key("verbatim")
11146
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
41
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
42 structregexp1 = re.compile(r"^(typedef\s+)?%s\s+\w+\s+(\w+)\s*;" % keyword)
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
43 structregexp2 = re.compile(r"^(typedef\s+)?%s" % keyword)
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
44 structregexp3 = re.compile(r"^}\s+(\w+)\s*;")
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
45
11331
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11171
diff changeset
46 print "/* Generated by %s. Do not edit! */" % sys.argv[0]
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11171
diff changeset
47
11171
ebb02ea3c789 [gaim-migrate @ 13272]
Piotr Zielinski <zielaj>
parents: 11146
diff changeset
48 myinput = iter(sys.stdin)
ebb02ea3c789 [gaim-migrate @ 13272]
Piotr Zielinski <zielaj>
parents: 11146
diff changeset
49
11146
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
50 for line in myinput:
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
51 match = structregexp1.match(line)
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
52 if match is not None:
11331
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11171
diff changeset
53 print toprint(match.group(2), line)
11146
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
54 continue
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
55
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
56 match = structregexp2.match(line)
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
57 if match is not None:
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
58 while True:
11331
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11171
diff changeset
59 if verbatim:
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11171
diff changeset
60 print line.rstrip()
11146
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
61 line = myinput.next()
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
62 match = structregexp3.match(line)
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
63 if match is not None:
11331
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11171
diff changeset
64 print toprint(match.group(1), line)
11146
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
65 break
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
66 if line[0] not in [" ", "\t", "{", "\n"]:
11331
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11171
diff changeset
67 if verbatim:
64fadbf3810f [gaim-migrate @ 13544]
Piotr Zielinski <zielaj>
parents: 11171
diff changeset
68 print line
11146
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
69 break
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
70
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
71
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
72
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
73
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
74
1c5398ccbeb0 [gaim-migrate @ 13217]
Piotr Zielinski <zielaj>
parents:
diff changeset
75