Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
htop
Commits
425d48dc
Commit
425d48dc
authored
Mar 23, 2006
by
Hisham Muhammad
Browse files
Add header generator script.
parent
2ef1847a
Changes
1
Hide whitespace changes
Inline
Side-by-side
scripts/MakeHeader.py
0 → 100644
View file @
425d48dc
#!/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"
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment