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

Issue 249920043: Create a module variable access system for C++ (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
8 years, 10 months ago by dak
Modified:
8 years, 7 months ago
Reviewers:
Dan Eble
CC:
lilypond-devel_gnu.org
Visibility:
Public.

Description

Create a module variable access system for C++ This replaces the previous "memoizing" ly_lily_module_constant with a rather rigid system for importing/exporting/accessing module variables. As opposed to the system used by ly_lily_module_constant, access will continue to go through the respective module variables, making it possible to also write to the respective variables. In addition, this ensures that any changes to the variables from the Scheme side will get properly reflected in the C++ side, allowing for redefinitions when debugging. In a nutshell, ly_lily_module_constant ("ly:music?") would generally be replaced with Lily::ly_music_p, a declaration of it looking like extern Variable ly_music_p; would be placed in namespace Lily in lily/include/lily-imports.hh, and a corresponding definition Variable ly_music_p ("ly:music?"); in namespace Lily in lily/lily-imports.cc . The type Scm_module where variables are organized can use pre-existing modules (in which case it is initialized by calling the member function import ()) or are can bring up a fresh module (in which case it is initialized by calling the member function boot ()). The startup is done in lily/guile-init.cc . Since one of the most frequent uses of imported variables is for function calls, the Scm_variable type (underlying the module-local Variable type) has operator () defined to allow calling as a function. So the previous scm_call_1 (ly_lily_module_constant ("ly:music?"), x); can now be expressed as Lily::ly_music_p (x); In order to avoid Srfi_1 import for a single function, also contains Issue 4461: Don't use drop-right from (srfi srfi-1) in C++ It can perfectly amicably be replaced by more efficient code readily available in the core.

Patch Set 1 #

Patch Set 2 : Fix several inaccurate variable imports #

Patch Set 3 : Fix value->lily-string import, make Scm_module::import honor public interface #

Total comments: 3
Unified diffs Side-by-side diffs Delta from patch set Stats (+664 lines, -264 lines) Patch
M lily/chord-tremolo-iterator.cc View 2 chunks +2 lines, -3 lines 0 comments Download
M lily/clef-engraver.cc View 2 chunks +2 lines, -2 lines 0 comments Download
M lily/context.cc View 1 2 2 chunks +2 lines, -3 lines 0 comments Download
M lily/dispatcher.cc View 1 2 3 chunks +3 lines, -3 lines 0 comments Download
M lily/font-select.cc View 2 chunks +2 lines, -2 lines 0 comments Download
M lily/grob.cc View 2 chunks +6 lines, -7 lines 0 comments Download
M lily/grob-closure.cc View 2 chunks +2 lines, -3 lines 0 comments Download
M lily/guile-init.cc View 1 2 3 chunks +7 lines, -4 lines 0 comments Download
M lily/include/fluid.hh View 1 2 1 chunk +3 lines, -5 lines 0 comments Download
M lily/include/lily-guile.hh View 1 chunk +0 lines, -2 lines 0 comments Download
M lily/include/lily-guile-macros.hh View 1 chunk +0 lines, -22 lines 0 comments Download
A lily/include/lily-imports.hh View 1 2 1 chunk +126 lines, -0 lines 0 comments Download
A lily/include/lily-modules.hh View 1 chunk +99 lines, -0 lines 3 comments Download
M lily/include/lily-proto.hh View 1 chunk +2 lines, -0 lines 0 comments Download
M lily/key-performer.cc View 2 chunks +2 lines, -2 lines 0 comments Download
M lily/key-signature-interface.cc View 2 chunks +3 lines, -3 lines 0 comments Download
M lily/lexer.ll View 4 chunks +7 lines, -8 lines 0 comments Download
M lily/lily-guile.cc View 3 chunks +3 lines, -4 lines 0 comments Download
A lily/lily-imports.cc View 1 2 1 chunk +118 lines, -0 lines 0 comments Download
A lily/lily-modules.cc View 1 2 1 chunk +108 lines, -0 lines 0 comments Download
M lily/lily-parser-scheme.cc View 11 chunks +11 lines, -10 lines 0 comments Download
M lily/ly-module.cc View 5 chunks +14 lines, -23 lines 0 comments Download
M lily/main.cc View 2 chunks +3 lines, -2 lines 0 comments Download
M lily/midi-item.cc View 2 chunks +2 lines, -2 lines 0 comments Download
M lily/module-scheme.cc View 1 chunk +3 lines, -3 lines 0 comments Download
M lily/music.cc View 3 chunks +3 lines, -3 lines 0 comments Download
M lily/music-function.cc View 1 2 4 chunks +6 lines, -7 lines 0 comments Download
M lily/page-layout-problem.cc View 4 chunks +4 lines, -6 lines 0 comments Download
M lily/paper-book.cc View 1 2 5 chunks +11 lines, -18 lines 0 comments Download
M lily/paper-def.cc View 2 chunks +2 lines, -2 lines 0 comments Download
M lily/paper-outputter.cc View 1 2 3 chunks +3 lines, -4 lines 0 comments Download
M lily/parse-scm.cc View 3 chunks +3 lines, -3 lines 0 comments Download
M lily/parser.yy View 1 2 38 chunks +61 lines, -65 lines 0 comments Download
M lily/part-combine-iterator.cc View 2 chunks +2 lines, -2 lines 0 comments Download
M lily/partial-iterator.cc View 3 chunks +4 lines, -6 lines 0 comments Download
M lily/percent-repeat-iterator.cc View 2 chunks +2 lines, -3 lines 0 comments Download
M lily/program-option-scheme.cc View 3 chunks +2 lines, -2 lines 0 comments Download
M lily/rest-collision.cc View 2 chunks +2 lines, -1 line 0 comments Download
M lily/span-bar-engraver.cc View 2 chunks +2 lines, -1 line 0 comments Download
M lily/staff-performer.cc View 2 chunks +2 lines, -2 lines 0 comments Download
M lily/system.cc View 2 chunks +3 lines, -2 lines 0 comments Download
M lily/text-interface.cc View 3 chunks +3 lines, -3 lines 0 comments Download
M lily/timing-translator.cc View 5 chunks +11 lines, -15 lines 0 comments Download
M lily/tuplet-iterator.cc View 2 chunks +3 lines, -3 lines 0 comments Download
M lily/volta-bracket.cc View 2 chunks +3 lines, -2 lines 0 comments Download
M lily/volta-repeat-iterator.cc View 2 chunks +2 lines, -1 line 0 comments Download

Messages

Total messages: 8
dak
Fix several inaccurate variable imports
8 years, 10 months ago (2015-06-25 16:18:29 UTC) #1
dak
Fix value->lily-string import, make Scm_module::import honor public interface
8 years, 10 months ago (2015-06-26 14:22:37 UTC) #2
Dan Eble
I'd like to study this more, but I don't think I have the time to ...
8 years, 10 months ago (2015-06-29 23:54:31 UTC) #3
dak
https://codereview.appspot.com/249920043/diff/40001/lily/include/lily-modules.hh File lily/include/lily-modules.hh (right): https://codereview.appspot.com/249920043/diff/40001/lily/include/lily-modules.hh#newcode39 lily/include/lily-modules.hh:39: Scm_module (const char *name); On 2015/06/29 23:54:30, Dan Eble ...
8 years, 10 months ago (2015-06-30 00:30:15 UTC) #4
Dan Eble
On 2015/06/30 00:30:15, dak wrote: > I don't understand what you are trying to say ...
8 years, 10 months ago (2015-06-30 00:49:33 UTC) #5
dak
On 2015/06/30 00:49:33, Dan Eble wrote: > On 2015/06/30 00:30:15, dak wrote: > > I ...
8 years, 10 months ago (2015-06-30 01:02:31 UTC) #6
Dan Eble
On 2015/06/30 01:02:31, dak wrote: > I vaguely remember that stuff could become a nuisance ...
8 years, 10 months ago (2015-06-30 01:16:10 UTC) #7
dak
8 years, 10 months ago (2015-06-30 08:15:02 UTC) #8
On 2015/06/30 01:16:10, Dan Eble wrote:
>
> Neither one seems to be a problem with your change, although adding "explicit"
> anyway shouldn't hurt.

Ok, I checked that neither in assignments nor initializations "ccc" goes to SCM,
and GCC does not even mention considering it: it just says that it cannot
convert const char * to SCM.  Neither does GCC consider the use of a const char
* as a function, and again the error message does not even mention considering
it.  So there does not appear to be _any_ actual improvement to be gained by
using "explicit" apart from feeling safer without reading through 3 chapters of
the standard.  Which _is_ a tangible benefit for the programmers if not the
program.

However, "shouldn't hurt" is nice, but we don't have "explicit" anywhere else in
our code base and it is probably C++98 or something, not "classic" C++.  That
always has a bit of a risk for crossbuilding LilyPond with GUB, or for others
compiling it with older or different compilers.  When using it because of the
presence of operator SCM, there would be several other unrelated classes which
should also be getting it.

So I'll leave this as a topic for a different issue.  It does not seem
necessary, carries some risk of problems of its own, and it would warrant using
across the board in our codebase, not just in this new addition.
Sign in to reply to this message.

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