Commit 35afc13e authored by Hisham Muhammad's avatar Hisham Muhammad
Browse files

New version of MakeHeader. Does not use 'private' comment annotation,

using the 'static' storage class instead. Automatically generates
'extern' declarations in headers for non-static data.
parent 5d07013e
...@@ -8,6 +8,7 @@ SKIP=3 ...@@ -8,6 +8,7 @@ SKIP=3
SKIPONE=4 SKIPONE=4
state = ANY state = ANY
static = 0
file = open(sys.argv[1]) file = open(sys.argv[1])
name = sys.argv[1][:-2] name = sys.argv[1][:-2]
...@@ -34,15 +35,27 @@ for line in file.readlines(): ...@@ -34,15 +35,27 @@ for line in file.readlines():
state = COPY state = COPY
elif line == selfheader: elif line == selfheader:
pass pass
elif string.find(line, "typedef") == 0 or line == "/* private */": elif line.find("htop - ") == 0 and line[-2:] == ".c":
state = SKIP out.write(line[:-2] + ".h")
elif string.find(line, "/* private property */") == 0: elif line.find("static ") != -1:
state = SKIPONE if line[-1] == "{":
elif len(line) > 1 and line[-1] == "{": state = SKIP
out.write( line[:-2] + ";" ) static = 1
state = SKIP else:
elif line == "": state = SKIPONE
out.write( "" ) elif len(line) > 1:
static = 0
equals = line.find(" = ")
if line[-3:] == "= {":
out.write( "extern " + line[:-4] + ";" )
state = SKIP
elif equals != -1:
out.write("extern " + line[:equals] + ";" )
elif line[-1] == "{":
out.write( line[:-2] + ";" )
state = SKIP
else:
out.write( line )
else: else:
out.write( line ) out.write( line )
elif state == COPY: elif state == COPY:
...@@ -52,7 +65,11 @@ for line in file.readlines(): ...@@ -52,7 +65,11 @@ for line in file.readlines():
out.write( line ) out.write( line )
elif state == SKIP: elif state == SKIP:
if len(line) >= 1 and line[0] == "}": if len(line) >= 1 and line[0] == "}":
state = ANY if static == 1:
state = SKIPONE
else:
state = ANY
static = 0
elif state == SKIPONE: elif state == SKIPONE:
state = ANY state = ANY
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment