Mercurial > pidgin
comparison libpurple/dbus-analyze-types.py @ 15373:5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Sat, 20 Jan 2007 02:32:10 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
15372:f79e0f4df793 | 15373:5fe8042783c1 |
---|---|
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 options = {} | |
22 | |
23 def toprint(match, line): | |
24 if verbatim: | |
25 return line | |
26 else: | |
27 return pattern % match | |
28 | |
29 for arg in sys.argv[1:]: | |
30 if arg[0:2] == "--": | |
31 mylist = arg[2:].split("=",1) | |
32 command = mylist[0] | |
33 if len(mylist) > 1: | |
34 options[command] = mylist[1] | |
35 else: | |
36 options[command] = None | |
37 | |
38 keyword = options.get("keyword", "struct") | |
39 pattern = options.get("pattern", "%s") | |
40 verbatim = options.has_key("verbatim") | |
41 | |
42 structregexp1 = re.compile(r"^(typedef\s+)?%s\s+\w+\s+(\w+)\s*;" % keyword) | |
43 structregexp2 = re.compile(r"^(typedef\s+)?%s" % keyword) | |
44 structregexp3 = re.compile(r"^}\s+(\w+)\s*;") | |
45 | |
46 print "/* Generated by %s. Do not edit! */" % sys.argv[0] | |
47 | |
48 myinput = iter(sys.stdin) | |
49 | |
50 for line in myinput: | |
51 match = structregexp1.match(line) | |
52 if match is not None: | |
53 print toprint(match.group(2), line) | |
54 continue | |
55 | |
56 match = structregexp2.match(line) | |
57 if match is not None: | |
58 while True: | |
59 if verbatim: | |
60 print line.rstrip() | |
61 line = myinput.next() | |
62 match = structregexp3.match(line) | |
63 if match is not None: | |
64 print toprint(match.group(1), line) | |
65 break | |
66 if line[0] not in [" ", "\t", "{", "\n"]: | |
67 if verbatim: | |
68 print line | |
69 break | |
70 | |
71 | |
72 | |
73 | |
74 | |
75 |