1 # This program takes a C header/source as the input and produces
3 # with --keyword=enum: the list of all enums
4 # with --keyword=struct: the list of all structs
8 # --enum DBUS_POINTER_NAME1,
23 def toprint(match
, line
):
27 return pattern
% match
29 for arg
in sys
.argv
[1:]:
31 mylist
= arg
[2:].split("=",1)
34 options
[command
] = mylist
[1]
36 options
[command
] = None
38 keyword
= options
.get("keyword", "struct")
39 pattern
= options
.get("pattern", "%s")
40 verbatim
= options
.has_key("verbatim")
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*;")
46 print "/* Generated by %s. Do not edit! */" % sys
.argv
[0]
48 myinput
= iter(sys
.stdin
)
51 match
= structregexp1
.match(line
)
53 print toprint(match
.group(2), line
)
56 match
= structregexp2
.match(line
)
62 match
= structregexp3
.match(line
)
64 print toprint(match
.group(1), line
)
66 if line
[0] not in [" ", "\t", "{", "\n"]: