File: creg.sh

package info (click to toggle)
spring 106.0%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 55,316 kB
  • sloc: cpp: 543,954; ansic: 44,800; python: 12,575; java: 12,201; awk: 5,889; sh: 1,796; asm: 1,546; xml: 655; perl: 405; php: 211; objc: 194; makefile: 76; sed: 2
file content (31 lines) | stat: -rwxr-xr-x 1,313 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/sh
# Author: Tobi Vollebregt
#
# Simple helper script to quickly make creg metadata register tables.
# Usage: run the script, paste a class in it, press ctrl+D, copy the metadata
# from stdout, paste the next class, etc.
# Use ctrl+C to quit.
#
# It should work on most types, including pointers, multidimensional arrays,
# template types (e.g. STL), extra qualifiers (mutable, volatile, unsigned, etc.)
# Function pointers, method pointers and references don't work.
#
# Commented out members are included commented out in the member table.
# (Only C++ style "//" comments supported).
#
# Explanation of the script:
# 1) [egrep] Lines matching the pattern for a member declaration are filtered out,
# 2) [egrep] Exclude typedefs.
# 3) [sed] The part before member name is replaced with "CR_MEMBER(", the part
#    after member name is replaced with "),".
# 4) [sed] The same for commented out members (except that the part after the
#    member name is already done by the other sed).
#

while true; do
cat | \
	egrep '(([A-Za-z_][A-Za-z_0-9:<>]*)[ \t*&]+)+[A-Za-z_][A-Za-z_0-9]*(\[[A-Za-z_0-9]*\])*;' | \
	egrep -v 'typedef' | \
	sed -r 's#^[ \t]*(([A-Za-z_0-9:<>]+)[ \t*&]+)+#CR_MEMBER(#g; s#(\[[A-Za-z_0-9]*\])*;.*#),#g' | \
	sed -r 's#^[ \t]*//[ \t]*(([A-Za-z_0-9:<>]+)[ \t*&]+)+#//CR_MEMBER(#g'
done