lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Issue 5309, take 2: find_global_context () and find_score_context ()


From: nine . fierce . ballads
Subject: Re: Issue 5309, take 2: find_global_context () and find_score_context () (issue 561290043 by address@hidden)
Date: Fri, 03 Jan 2020 08:34:13 -0800

Reviewers: lemzwerg,

Message:
On 2020/01/03 16:18:10, lemzwerg wrote:
lily/context.cc:116: if (Context *score = gthis->get_score_context ())
Not sure whether compilers warn about the `if (... = ...)` construct.
Perhaps
the `Context *` prevents it.  Otherwise I suggest another level of
parentheses.

I've compiled context.o with "-Wall -Wextra" with g++ 9.2.1, and there
is no complaint.

Description:
1: find_score_context ()

Translator::find_score_context () finds the Score context enclosing
the Translator in a way similar to (but slightly more direct than)
\set Score.whatever = ... rather than depending on the global context.

Global_context::get_score_context () returns the first child, as
before, but it is no longer a virtual method of Context, and it is used
in fewer places.

2: find_global_context ()

Replace c->get_global_context () with find_global_context (c).  This
function does not need to access any private information of Context, so
pulling it out simplifies the interface of Context.  Calling it "find"
rather than "get" is supposed to imply more work (walking the tree).

Implement find_global_context (c) as find_top_context (c) plus a type
check.  This increases code reuse and requires fewer dynamic casts.
Abort the program if the top context is not a Global context, otherwise
most callers would dereference null pointers.

* * *

These changes update and expand on changes previously reviewed in
http://codereview.appspot.com/346750043.

Please review this at https://codereview.appspot.com/561290043/

Affected files (+70, -81 lines):
  M lily/bar-engraver.cc
  M lily/completion-note-heads-engraver.cc
  M lily/completion-rest-engraver.cc
  M lily/context.cc
  M lily/context-property.cc
  M lily/double-percent-repeat-engraver.cc
  M lily/engraver-group.cc
  M lily/forbid-break-engraver.cc
  M lily/global-context.cc
  M lily/include/context.hh
  M lily/include/global-context.hh
  M lily/include/translator.hh
  M lily/ligature-engraver.cc
  M lily/measure-grouping-engraver.cc
  M lily/paper-column-engraver.cc
  M lily/partial-iterator.cc
  M lily/percent-repeat-engraver.cc
  M lily/spanner-break-forbid-engraver.cc
  M lily/timing-translator.cc
  M lily/translator.cc





reply via email to

[Prev in Thread] Current Thread [Next in Thread]