blob: 5aec759614ad5a30dd7270a3bbe37ece4cac1d7e [file] [log] [blame]
#!/bin/sed -f
# Skip anything that is not a struct
/^struct[ \t]/!d
/;[ \t]*$/d
# Add opening brace if not present on the 'struct' line
/{/ !{ s/$/ {/ }
:next_struct_line
# Remove opening brace if present in column 1
s/^{//
# Split any single lines into multiple lines
s/; /;\n/g
# Delete macros (lines starting with #)
s/\W*\#.*//
# Delete C++ style comments (starting with //)
s/\/\/.*//
# Delete C style comments (/* ... */)
# - skip this loop unless it contains the start of a C comment (/*)
# - if '/*' is found, join lines until the corresponding '*/'
# - on exiting the loop, delete the joined line
/\/\*/ !{ b not_in_comment }
:in_comment
/\*\// !{ N; b in_comment }
s/\/\*.*\*\///
:not_in_comment
# Read the next line of the struct
/}/ !{n; b next_struct_line}
# Remove special attributes
s/}.*__attribute__.*;/};/
# Finished reading a struct - print