File tree 1 file changed +25
-2
lines changed
1 file changed +25
-2
lines changed Original file line number Diff line number Diff line change 1
1
#! /usr/bin/env bash
2
2
3
+ # ARGUMENTS
4
+ REMOVE_COMMENTS=YES
5
+ while getopts " :c" opt; do
6
+ case $opt in
7
+ c)
8
+ # keep comments
9
+ REMOVE_COMMENTS=NO
10
+ ;;
11
+ \? )
12
+ echo " Invalid option: -$OPTARG " >&2
13
+ exit 1
14
+ ;;
15
+ esac
16
+ done
17
+ shift $( expr $OPTIND - 1)
18
+
3
19
# GNU prefix command for mac os support (gsed, gsplit)
4
20
GP=
5
21
if [[ " $OSTYPE " =~ darwin* ]]; then
@@ -15,7 +31,11 @@ for file in $*; do
15
31
tempfile=$( ${GP} mktemp ${f} XXXX --suffix=.h)
16
32
17
33
# Remove comments
18
- ${GP} sed ' s/a/aA/g;s/__/aB/g;s/#/aC/g' " src/$d /$f .h" | cpp -E $arg - | ${GP} sed ' s/aC/#/g;s/aB/__/g;s/aA/a/g' > $tempfile
34
+ if [[ " $REMOVE_COMMENTS " =~ YES ]]; then
35
+ ${GP} sed ' s/a/aA/g;s/__/aB/g;s/#/aC/g' " src/$d /$f .h" | cpp -E $arg - | ${GP} sed ' s/aC/#/g;s/aB/__/g;s/aA/a/g' > $tempfile
36
+ else
37
+ cp " src/$d /$f .h" $tempfile
38
+ fi
19
39
20
40
# Remove override keyword
21
41
${GP} sed -i ' s/ override;/;/g' $tempfile
@@ -33,11 +53,14 @@ for file in $*; do
33
53
${GP} sed -i -r ' /^\s*Q_(OBJECT|ENUMS|PROPERTY).*?$/d' $tempfile
34
54
35
55
# Remove function definition in header
36
- ${GP} sed -i -r ' s/^(\s*)?(inline )?(void|bool|int|double|Q\w+)(\s+[^ ]*?\(.*?\)( const)?)\s*\{.*?\}$/\1\3\4 ;/g' $tempfile
56
+ ${GP} sed -i -r ' s/^(\s*)?(virtual |static )?( inline )?(void|bool|int|double|Q\w+)(\s+[^ ]*?\(.*?\)( const)?)\s*\{.*?\}$/\1\2\4\5 ;/g' $tempfile
37
57
38
58
# Remove nullptr
39
59
${GP} sed -i ' s/nullptr/0/g' $tempfile
40
60
61
+ # Remove forward declarations
62
+ ${GP} sed -i -r ' /^\s*class Q\w+;$/d' $tempfile
63
+
41
64
vimdiff $tempfile python/$d /$f .sip
42
65
43
66
rm $tempfile
You can’t perform that action at this time.
0 commit comments