]> git.donarmstrong.com Git - lilypond.git/commit
Issue 4377: Run a script for using derived_unsmob where obvious
authorDavid Kastrup <dak@gnu.org>
Thu, 7 May 2015 19:22:20 +0000 (21:22 +0200)
committerDavid Kastrup <dak@gnu.org>
Tue, 12 May 2015 10:28:26 +0000 (12:28 +0200)
commit809acd76be2af232cb4cbc43f86dad820bf97ae0
tree92a37316c8d16da0ffe38f77f647c9635c3402e1
parent428488bdc1a29c40b7b2326be3587270c49ff86a
Issue 4377: Run a script for using derived_unsmob where obvious

Script is:

matched="[^()]*"
for i in 1 2 3 4 5
do
    matched="\\(($matched)\\|[^()]\\)*"
done
filelist="$(git grep -l '\<dynamic_cast[^>]*> ([_a-zA-Z]*::unsmob\>')"
typelist="$(sed -n 's/^.*\<dynamic_cast\s*<\([_a-zA-Z]\+\)\s*\*> (\([_a-zA-Z]*\)::unsmob\>.*$/\1/p' $filelist | sort -u )"
for typ in $typelist
do
    # crazy: we have unsmob definitions that are not even used
    if git grep -q "$typ::unsmob" || git grep -q "\\<$typ"'\s*\*\s*unsmob\s*(SCM'
    then
echo "There already is $typ::unsmob"
sed -i '/unsmob (SCM/,/;/!s/\<dynamic_cast\s*<\('"$typ"'\)\s*\*> (\([_a-zA-Z]*\)::unsmob\s*(\('"$matched"'\))\s*)/\1::unsmob (\3)/g' $filelist
    else
sed -i 's/\<dynamic_cast\s*<\('"$typ"'\)\s*\*> (\([_a-zA-Z]*\)::unsmob\s*(\('"$matched"'\))\s*)/derived_unsmob<\1> (\3)/g' $filelist
    fi
done

The awkward bit at the start of the script is for matching matched
parentheses.  This replaces the construct

    dynamic_cast<T *>(xxx::unsmob (yyy))

with

    derived_unsmob<T> (yyy)

where appropriate.  If T::unsmob already exists, it is used
instead (apart from inside of its own definition, of course).
29 files changed:
lily/all-font-metrics.cc
lily/break-align-engraver.cc
lily/break-substitution.cc
lily/figured-bass-continuation.cc
lily/figured-bass-engraver.cc
lily/global-context-scheme.cc
lily/key-signature-interface.cc
lily/ledger-line-spanner.cc
lily/line-spanner.cc
lily/measure-grouping-spanner.cc
lily/open-type-font-scheme.cc
lily/ottava-bracket.cc
lily/page-breaking.cc
lily/pango-font-scheme.cc
lily/paper-book.cc
lily/paper-column-engraver.cc
lily/paper-column.cc
lily/paper-score-scheme.cc
lily/performer-group.cc
lily/piano-pedal-bracket.cc
lily/score.cc
lily/spacing-engraver.cc
lily/spacing-loose-columns.cc
lily/spanner-scheme.cc
lily/stem.cc
lily/system.cc
lily/tie-column.cc
lily/translator-dispatch-list.cc
lily/translator-group.cc