Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(2176)

Issue 238020043: Implement and use "derived_unsmob" (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
8 years, 11 months ago by dak
Modified:
8 years, 10 months ago
Reviewers:
Dan Eble
Visibility:
Public.

Description

Changed commit message containing the fixed sed script: 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).

Patch Set 1 #

Patch Set 2 : Script around recursive and preexisting definitions #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+57 lines, -49 lines) Patch
M lily/all-font-metrics.cc View 2 chunks +2 lines, -2 lines 0 comments Download
M lily/break-align-engraver.cc View 1 1 chunk +1 line, -1 line 0 comments Download
M lily/break-substitution.cc View 1 chunk +1 line, -1 line 0 comments Download
M lily/figured-bass-continuation.cc View 1 2 chunks +2 lines, -2 lines 0 comments Download
M lily/figured-bass-engraver.cc View 1 1 chunk +1 line, -1 line 0 comments Download
M lily/global-context-scheme.cc View 1 3 chunks +3 lines, -3 lines 0 comments Download
M lily/include/smobs.hh View 1 chunk +8 lines, -0 lines 2 comments Download
M lily/key-signature-interface.cc View 1 1 chunk +1 line, -1 line 0 comments Download
M lily/ledger-line-spanner.cc View 1 2 chunks +2 lines, -2 lines 0 comments Download
M lily/line-spanner.cc View 1 1 chunk +1 line, -1 line 0 comments Download
M lily/measure-grouping-spanner.cc View 1 1 chunk +1 line, -1 line 0 comments Download
M lily/open-type-font-scheme.cc View 5 chunks +10 lines, -10 lines 0 comments Download
M lily/ottava-bracket.cc View 1 1 chunk +1 line, -1 line 0 comments Download
M lily/page-breaking.cc View 1 1 chunk +1 line, -1 line 0 comments Download
M lily/pango-font-scheme.cc View 2 chunks +2 lines, -2 lines 0 comments Download
M lily/paper-book.cc View 1 3 chunks +3 lines, -3 lines 0 comments Download
M lily/paper-column.cc View 1 chunk +1 line, -1 line 0 comments Download
M lily/paper-column-engraver.cc View 1 chunk +1 line, -1 line 0 comments Download
M lily/paper-score-scheme.cc View 1 1 chunk +1 line, -1 line 0 comments Download
M lily/performer-group.cc View 1 1 chunk +1 line, -1 line 0 comments Download
M lily/piano-pedal-bracket.cc View 1 1 chunk +1 line, -1 line 0 comments Download
M lily/score.cc View 1 1 chunk +1 line, -1 line 0 comments Download
M lily/spacing-engraver.cc View 1 chunk +1 line, -1 line 0 comments Download
M lily/spacing-loose-columns.cc View 1 chunk +2 lines, -2 lines 0 comments Download
M lily/spanner-scheme.cc View 1 1 chunk +1 line, -1 line 0 comments Download
M lily/stem.cc View 1 1 chunk +1 line, -1 line 0 comments Download
M lily/system.cc View 2 chunks +2 lines, -2 lines 0 comments Download
M lily/tie-column.cc View 1 1 chunk +2 lines, -2 lines 0 comments Download
M lily/translator-dispatch-list.cc View 1 1 chunk +1 line, -1 line 0 comments Download
M lily/translator-group.cc View 1 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 7
dak
Script around recursive and preexisting definitions
8 years, 11 months ago (2015-05-08 14:15:24 UTC) #1
Dan Eble
LGTM. This is indeed good to commit before issue 4365. Thanks.
8 years, 11 months ago (2015-05-08 22:50:32 UTC) #2
Dan Eble
https://codereview.appspot.com/238020043/diff/20001/lily/include/smobs.hh File lily/include/smobs.hh (right): https://codereview.appspot.com/238020043/diff/20001/lily/include/smobs.hh#newcode240 lily/include/smobs.hh:240: inline T *derived_unsmob (SCM arg) But don't you need ...
8 years, 11 months ago (2015-05-08 23:10:24 UTC) #3
dak
https://codereview.appspot.com/238020043/diff/20001/lily/include/smobs.hh File lily/include/smobs.hh (right): https://codereview.appspot.com/238020043/diff/20001/lily/include/smobs.hh#newcode240 lily/include/smobs.hh:240: inline T *derived_unsmob (SCM arg) On 2015/05/08 23:10:24, Dan ...
8 years, 11 months ago (2015-05-09 05:29:29 UTC) #4
dak
On 2015/05/09 05:29:29, dak wrote: > https://codereview.appspot.com/238020043/diff/20001/lily/include/smobs.hh > File lily/include/smobs.hh (right): > > https://codereview.appspot.com/238020043/diff/20001/lily/include/smobs.hh#newcode240 > ...
8 years, 11 months ago (2015-05-09 06:56:54 UTC) #5
Dan Eble
On 2015/05/09 06:56:54, dak wrote: > I think I might understand the problem you have ...
8 years, 11 months ago (2015-05-09 13:25:11 UTC) #6
dak
8 years, 11 months ago (2015-05-09 20:38:11 UTC) #7
On 2015/05/09 13:25:11, Dan Eble wrote:
> On 2015/05/09 06:56:54, dak wrote:
> > I think I might understand the problem you have with this line: the
"functions
> > may only be defined in one compilation unit" decree.  But these days, pretty
> 
> That's it.
> 
> > So "inline" is not as much an optimization instruction (GCC makes its own
> > decisions about that) but rather "may be defined in more than one
compilation
> > unit, please merge".
> 
> Yes, I knew that "inline" is just a request, but I vaguely recall that leaving
> off "static" has caused problems in my professional work (in the past few
> years?).  Could be my memory is faulty.   If you're not worried about it in
this
> context, then I won't either.

Without "inline", you will indeed get compilation errors precisely because of
the "one definition only" rule.  In that respect, "inline" is _not_ just a
request.  The difference between static inline and inline is that the former
will, if you take the address of the function, generate one callable function
per compilation unit while the latter will only generate one callable function
across the whole compilation.  In either case (and actually even when inline is
left off) the compiler may feel free to not actually call that function but
rather substitute it inline: only any explicitly taken function pointer is
guaranteed to be associated with a callable version of the function.

Removing the "inline" here will get you the errors at link time you probably
were expecting.

So in short: the declaration is very much intentional.  Adding "static" here
would work also but cause problems in case we start adding those kind of
function pointers to function-documentation.cc.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b