diff options
author | loderunner <loderunner@63cc0a6c-1f0e-0410-841e-f6a342073da8> | 2006-03-23 18:45:14 +0000 |
---|---|---|
committer | loderunner <loderunner@63cc0a6c-1f0e-0410-841e-f6a342073da8> | 2006-03-23 18:45:14 +0000 |
commit | b2fb8f419e4ef7ceb06e0d47e0e57630b2254ae8 (patch) | |
tree | b25cc76ff1490fe3e7779116f193194374e9a7b8 | |
parent | 3ca3427dc4060c1a67a7fb44d037be967e821b32 (diff) | |
download | htop-b2fb8f419e4ef7ceb06e0d47e0e57630b2254ae8.tar.gz |
Add header generator script.
git-svn-id: svn://svn.code.sf.net/p/htop/code/trunk@5 63cc0a6c-1f0e-0410-841e-f6a342073da8
-rw-r--r-- | scripts/MakeHeader.py | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/scripts/MakeHeader.py b/scripts/MakeHeader.py new file mode 100644 index 0000000..2268fcf --- /dev/null +++ b/scripts/MakeHeader.py @@ -0,0 +1,60 @@ +#!/usr/bin/python + +import os, sys, string + +ANY=1 +COPY=2 +SKIP=3 +SKIPONE=4 + +state = ANY + +file = open(sys.argv[1]) +name = sys.argv[1][:-2] + +out = open(name + ".h", "w") +class writer: + def __init__(self, file): + self.file = file + def write(self, text): + self.file.write(text + "\n") +out = writer(out) + +selfheader = '#include "' + name + '.h"' + +out.write( "/* Do not edit this file. It was automatically generated. */" ) +out.write( "" ) + +out.write( "#ifndef HEADER_" + name ) +out.write( "#define HEADER_" + name ) +for line in file.readlines(): + line = line[:-1] + if state == ANY: + if line == '/*{': + state = COPY + elif line == selfheader: + pass + elif string.find(line, "typedef") == 0 or line == "/* private */": + state = SKIP + elif string.find(line, "/* private property */") == 0: + state = SKIPONE + elif len(line) > 1 and line[-1] == "{": + out.write( line[:-2] + ";" ) + state = SKIP + elif line == "": + out.write( "" ) + else: + out.write( line ) + elif state == COPY: + if line == "}*/": + state = ANY + else: + out.write( line ) + elif state == SKIP: + if len(line) >= 1 and line[0] == "}": + state = ANY + elif state == SKIPONE: + state = ANY + +out.write( "" ) +out.write( "#endif" ) |