]> git.donarmstrong.com Git - lilypond.git/commit
Issue 4462/1: Create a module variable access system for C++
authorDavid Kastrup <dak@gnu.org>
Thu, 25 Jun 2015 11:04:50 +0000 (13:04 +0200)
committerDavid Kastrup <dak@gnu.org>
Thu, 2 Jul 2015 10:40:32 +0000 (12:40 +0200)
commit652f454fae6ed31ced7f9c3ce22dbc5752460a8c
tree46b163755ebe54f5b5160cc64b2dbd141da2c119
parentfe4893be240c78a35deff5e86af3d7d1200a478b
Issue 4462/1: 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);
46 files changed:
lily/chord-tremolo-iterator.cc
lily/clef-engraver.cc
lily/context.cc
lily/dispatcher.cc
lily/font-select.cc
lily/grob-closure.cc
lily/grob.cc
lily/guile-init.cc
lily/include/fluid.hh
lily/include/lily-guile-macros.hh
lily/include/lily-guile.hh
lily/include/lily-imports.hh [new file with mode: 0644]
lily/include/lily-modules.hh [new file with mode: 0644]
lily/include/lily-proto.hh
lily/key-performer.cc
lily/key-signature-interface.cc
lily/lexer.ll
lily/lily-guile.cc
lily/lily-imports.cc [new file with mode: 0644]
lily/lily-modules.cc [new file with mode: 0644]
lily/lily-parser-scheme.cc
lily/ly-module.cc
lily/main.cc
lily/midi-item.cc
lily/module-scheme.cc
lily/music-function.cc
lily/music.cc
lily/page-layout-problem.cc
lily/paper-book.cc
lily/paper-def.cc
lily/paper-outputter.cc
lily/parse-scm.cc
lily/parser.yy
lily/part-combine-iterator.cc
lily/partial-iterator.cc
lily/percent-repeat-iterator.cc
lily/program-option-scheme.cc
lily/rest-collision.cc
lily/span-bar-engraver.cc
lily/staff-performer.cc
lily/system.cc
lily/text-interface.cc
lily/timing-translator.cc
lily/tuplet-iterator.cc
lily/volta-bracket.cc
lily/volta-repeat-iterator.cc