From 652f454fae6ed31ced7f9c3ce22dbc5752460a8c Mon Sep 17 00:00:00 2001 From: David Kastrup Date: Thu, 25 Jun 2015 13:04:50 +0200 Subject: [PATCH] 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); --- lily/chord-tremolo-iterator.cc | 5 +- lily/clef-engraver.cc | 4 +- lily/context.cc | 5 +- lily/dispatcher.cc | 6 +- lily/font-select.cc | 4 +- lily/grob-closure.cc | 5 +- lily/grob.cc | 13 ++- lily/guile-init.cc | 11 ++- lily/include/fluid.hh | 8 +- lily/include/lily-guile-macros.hh | 22 ------ lily/include/lily-guile.hh | 2 - lily/include/lily-imports.hh | 126 ++++++++++++++++++++++++++++++ lily/include/lily-modules.hh | 99 +++++++++++++++++++++++ lily/include/lily-proto.hh | 2 + lily/key-performer.cc | 4 +- lily/key-signature-interface.cc | 6 +- lily/lexer.ll | 15 ++-- lily/lily-guile.cc | 7 +- lily/lily-imports.cc | 118 ++++++++++++++++++++++++++++ lily/lily-modules.cc | 101 ++++++++++++++++++++++++ lily/lily-parser-scheme.cc | 21 ++--- lily/ly-module.cc | 37 ++++----- lily/main.cc | 5 +- lily/midi-item.cc | 4 +- lily/module-scheme.cc | 6 +- lily/music-function.cc | 13 ++- lily/music.cc | 6 +- lily/page-layout-problem.cc | 10 +-- lily/paper-book.cc | 30 +++---- lily/paper-def.cc | 4 +- lily/paper-outputter.cc | 7 +- lily/parse-scm.cc | 6 +- lily/parser.yy | 126 +++++++++++++++--------------- lily/part-combine-iterator.cc | 4 +- lily/partial-iterator.cc | 10 +-- lily/percent-repeat-iterator.cc | 5 +- lily/program-option-scheme.cc | 4 +- lily/rest-collision.cc | 3 +- lily/span-bar-engraver.cc | 3 +- lily/staff-performer.cc | 4 +- lily/system.cc | 5 +- lily/text-interface.cc | 6 +- lily/timing-translator.cc | 26 +++--- lily/tuplet-iterator.cc | 6 +- lily/volta-bracket.cc | 5 +- lily/volta-repeat-iterator.cc | 3 +- 46 files changed, 658 insertions(+), 264 deletions(-) create mode 100644 lily/include/lily-imports.hh create mode 100644 lily/include/lily-modules.hh create mode 100644 lily/lily-imports.cc create mode 100644 lily/lily-modules.cc diff --git a/lily/chord-tremolo-iterator.cc b/lily/chord-tremolo-iterator.cc index 601f7bccb0..d95ea1ae3c 100644 --- a/lily/chord-tremolo-iterator.cc +++ b/lily/chord-tremolo-iterator.cc @@ -21,6 +21,7 @@ #include "chord-tremolo-iterator.hh" #include "repeated-music.hh" +#include "lily-imports.hh" Chord_tremolo_iterator::Chord_tremolo_iterator () { @@ -29,9 +30,7 @@ Chord_tremolo_iterator::Chord_tremolo_iterator () SCM Chord_tremolo_iterator::get_music_list () const { - Music *mus = get_music (); - SCM proc = ly_lily_module_constant ("tremolo::get-music-list"); - return scm_call_1 (proc, mus->self_scm ()); + return Lily::tremolo_get_music_list (get_music ()->self_scm ()); } IMPLEMENT_CTOR_CALLBACK (Chord_tremolo_iterator); diff --git a/lily/clef-engraver.cc b/lily/clef-engraver.cc index 540bcd5f7b..940a18d201 100644 --- a/lily/clef-engraver.cc +++ b/lily/clef-engraver.cc @@ -29,6 +29,7 @@ using namespace std; #include "side-position-interface.hh" #include "translator.icc" +#include "lily-imports.hh" class Clef_engraver : public Engraver { @@ -162,8 +163,7 @@ Clef_engraver::inspect_clef_properties () || !ly_is_equal (transposition, prev_transposition_) || to_boolean (force_clef)) { - apply_on_children (context (), - ly_lily_module_constant ("invalidate-alterations")); + apply_on_children (context (), Lily::invalidate_alterations); set_glyph (); if (scm_is_true (prev_cpos_) || to_boolean (get_property ("firstClef"))) diff --git a/lily/context.cc b/lily/context.cc index 416a5ccbcf..192cdaa3ee 100644 --- a/lily/context.cc +++ b/lily/context.cc @@ -30,6 +30,7 @@ #include "scm-hash.hh" #include "translator-group.hh" #include "warn.hh" +#include "lily-imports.hh" bool Context::is_removable () const @@ -491,9 +492,7 @@ be called from any other place than the send_stream_event macro. void Context::internal_send_stream_event (SCM type, Input *origin, SCM props[]) { - Stream_event *e = new Stream_event - (scm_call_1 (ly_lily_module_constant ("ly:make-event-class"), type), - origin); + Stream_event *e = new Stream_event (Lily::ly_make_event_class (type), origin); for (int i = 0; props[i]; i += 2) { e->set_property (props[i], props[i + 1]); diff --git a/lily/dispatcher.cc b/lily/dispatcher.cc index 1d5c759596..8f938d6f91 100644 --- a/lily/dispatcher.cc +++ b/lily/dispatcher.cc @@ -21,6 +21,7 @@ #include "input.hh" #include "international.hh" #include "warn.hh" +#include "lily-imports.hh" const char Dispatcher::type_p_name_[] = "ly:dispatcher?"; @@ -52,8 +53,7 @@ int Dispatcher::print_smob (SCM p, scm_print_state *) const { scm_puts ("#alist"), - listeners_), p); + scm_write (Lily::hash_table_to_alist (listeners_), p); scm_puts (">", p); return 1; } @@ -242,7 +242,7 @@ Dispatcher::internal_add_listener (SCM callback, SCM ev_class, int priority) listen_classes_ = scm_cons (ev_class, listen_classes_); } SCM entry = scm_cons (scm_from_int (priority), callback); - list = scm_merge (list, scm_list_1 (entry), ly_lily_module_constant ("car<")); + list = scm_merge (list, scm_list_1 (entry), Lily::car_less); scm_set_cdr_x (handle, list); } diff --git a/lily/font-select.cc b/lily/font-select.cc index b38ff9268a..5045a8276e 100644 --- a/lily/font-select.cc +++ b/lily/font-select.cc @@ -24,6 +24,7 @@ #include "warn.hh" #include "pango-font.hh" #include "main.hh" +#include "lily-imports.hh" Font_metric * get_font_by_design_size (Output_def *layout, Real requested, @@ -103,8 +104,7 @@ get_font_by_mag_step (Output_def *layout, Real requested_step, SCM properties_to_font_size_family (SCM fonts, SCM alist_chain) { - return scm_call_2 (ly_lily_module_constant ("lookup-font"), fonts, - alist_chain); + return Lily::lookup_font (fonts, alist_chain); } Font_metric * diff --git a/lily/grob-closure.cc b/lily/grob-closure.cc index c9080f4fb7..978cbeb76c 100644 --- a/lily/grob-closure.cc +++ b/lily/grob-closure.cc @@ -1,6 +1,7 @@ #include "grob.hh" #include "simple-closure.hh" #include "unpure-pure-container.hh" +#include "lily-imports.hh" SCM axis_offset_symbol (Axis a) @@ -44,12 +45,10 @@ add_offset_callback (Grob *g, SCM proc, Axis a) else if (Simple_closure *sc = unsmob (data)) data = sc->expression (); - SCM plus = ly_lily_module_constant ("+"); - if (ly_is_procedure (proc)) proc = Simple_closure::make_smob (scm_list_1 (proc)); - SCM expr = scm_list_3 (plus, proc, data); + SCM expr = scm_list_3 (Guile_user::plus, proc, data); g->set_property (axis_offset_symbol (a), Simple_closure::make_smob (expr)); } diff --git a/lily/grob.cc b/lily/grob.cc index 2f5357a0ae..e43c71186c 100644 --- a/lily/grob.cc +++ b/lily/grob.cc @@ -38,6 +38,7 @@ #include "system.hh" #include "unpure-pure-container.hh" #include "warn.hh" +#include "lily-imports.hh" Grob * @@ -148,20 +149,18 @@ Grob::get_print_stencil () const if (!transparent && (scm_is_number (get_property("whiteout")) || to_boolean (get_property ("whiteout")))) { - SCM wh_proc = ly_lily_module_constant ("stencil-whiteout"); Real thickness = robust_scm2double (get_property("whiteout"), 3.0) * layout ()->get_dimension (ly_symbol2scm ("line-thickness")); - retval = *unsmob (scm_call_2 (wh_proc, - retval.smobbed_copy (), - scm_from_double (thickness))); + retval = *unsmob + (Lily::stencil_whiteout (retval.smobbed_copy (), + scm_from_double (thickness))); } /* Calls the scheme procedure stencil-whiteout-box in scm/stencils.scm */ if (!transparent && to_boolean (get_property ("whiteout-box"))) { - SCM wh_proc = ly_lily_module_constant ("stencil-whiteout-box"); - retval = *unsmob (scm_call_1 (wh_proc, - retval.smobbed_copy ())); + retval = *unsmob + (Lily::stencil_whiteout_box (retval.smobbed_copy ())); } if (transparent) diff --git a/lily/guile-init.cc b/lily/guile-init.cc index 86a998e9ab..3259a46577 100644 --- a/lily/guile-init.cc +++ b/lily/guile-init.cc @@ -22,6 +22,7 @@ #include "main.hh" #include "warn.hh" #include "smobs.hh" +#include "lily-imports.hh" /* INIT @@ -47,7 +48,7 @@ void add_scm_init_func (void (*f) ()) scm_init_funcs_->push_back (f); } -void +SCM ly_init_ly_module (void *) { // Start up type system first. @@ -64,13 +65,15 @@ ly_init_ly_module (void *) } scm_primitive_load_path (scm_from_ascii_string ("lily.scm")); + return SCM_UNDEFINED; } -SCM global_lily_module; - void ly_c_init_guile () { - global_lily_module = scm_c_define_module ("lily", ly_init_ly_module, 0); + Guile_user::module.import (); + Lily::module.boot (); + scm_c_call_with_current_module (Lily::module, ly_init_ly_module, 0); + Display::module.import (); scm_c_use_module ("lily"); } diff --git a/lily/include/fluid.hh b/lily/include/fluid.hh index 44e908e667..eb7ebfbae0 100644 --- a/lily/include/fluid.hh +++ b/lily/include/fluid.hh @@ -25,13 +25,11 @@ // Fluid is a wrapper class for cached storage of GUILE fluids. // You use it like // -// Fluid parser (ly_lily_module_constant ("%parser")); +// Fluid parser (Lily::f_parser); // // and when you first access `parser' as an SCM value, its value is -// fetched from the respective fluid (in this case `%parser') and -// cached for future accesses. Be sure to use ly_lily_module_constant -// for the argument in order to have the SCM for the fluid itself only -// looked up once per run. +// fetched from the respective fluid (in this case `%parser', cf +// lily/lily-imports.cc) and cached for future accesses. // // Since fluids act as implicit function parameters, it can only be // meaningfully employed for variables of automatic diff --git a/lily/include/lily-guile-macros.hh b/lily/include/lily-guile-macros.hh index 9c6e59332f..869a52af32 100644 --- a/lily/include/lily-guile-macros.hh +++ b/lily/include/lily-guile-macros.hh @@ -99,28 +99,6 @@ scm_or_str2symbol (SCM s) inline SCM ly_symbol2scm (char const *x) { return scm_from_utf8_symbol ((x)); } #endif -/* - we don't have to protect the result; it's already part of the - exports list of the module. -*/ - -#define ly_lily_module_constant(x) \ - ({ \ - static SCM cached; \ - /* We store this one locally, since G++ -O2 fucks up else */ \ - SCM value = cached; \ - if (__builtin_constant_p ((x))) \ - { \ - if (!SCM_UNPACK (cached)) \ - value = cached = \ - scm_variable_ref (scm_c_module_lookup (global_lily_module, (x))); \ - } \ - else \ - value = \ - scm_variable_ref (scm_c_module_lookup (global_lily_module, (x))); \ - value; \ - }) - /* Adds the NAME as a Scheme function, and a variable to store the SCM version of the function in the static variable NAME_proc diff --git a/lily/include/lily-guile.hh b/lily/include/lily-guile.hh index e6a3d41483..34578511b8 100644 --- a/lily/include/lily-guile.hh +++ b/lily/include/lily-guile.hh @@ -47,8 +47,6 @@ string ly_scm_write_string (SCM s); SCM ly_deep_copy (SCM); SCM ly_truncate_list (int k, SCM lst); -extern SCM global_lily_module; - string gulp_file_to_string (const string &fn, bool must_exist, int size); SCM ly_string2scm (string const &s); diff --git a/lily/include/lily-imports.hh b/lily/include/lily-imports.hh new file mode 100644 index 0000000000..68b8102444 --- /dev/null +++ b/lily/include/lily-imports.hh @@ -0,0 +1,126 @@ +/* + This file is part of LilyPond, the GNU music typesetter. + + Copyright (C) 2015 by David Kastrup + + LilyPond is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + LilyPond is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LilyPond. If not, see . +*/ + +#ifndef LILY_IMPORTS_HH +#define LILY_IMPORTS_HH + +#include "lily-modules.hh" + +namespace Guile_user { + extern Scm_module module; + typedef Module_variable Variable; + + extern Variable plus; + extern Variable make_module; +#if GUILEV2 + extern Variable module_export_all_x; +#endif + extern Variable module_export_x; + extern Variable module_public_interface; + extern Variable module_use_x; + extern Variable symbol_p; + extern Variable the_root_module; +} + +namespace Display { + extern Scm_module module; + typedef Module_variable Variable; + + extern Variable value_to_lily_string; +} + +namespace Lily { + extern Scm_module module; + typedef Module_variable Variable; + + extern Variable all_music_font_encodings; + extern Variable alterations_in_key; + extern Variable backend_testing; + extern Variable base_length; + extern Variable beam_exceptions; + extern Variable beat_structure; + extern Variable calc_repeat_slash_count; + extern Variable car_less; + extern Variable construct_chord_elements; + extern Variable default_time_signature_settings; + extern Variable hash_table_to_alist; + extern Variable interpret_markup_list; + extern Variable invalidate_alterations; + extern Variable key_signature_interface_alteration_positions; + extern Variable layout_extract_page_properties; + extern Variable lilypond_main; + extern Variable line_markup; + extern Variable f_location; + extern Variable lookup_font; + extern Variable lookup_markup_command; + extern Variable lookup_markup_list_command; + extern Variable ly_context_find; + extern Variable ly_context_set_property_x; + extern Variable ly_event_p; + extern Variable ly_make_event_class; + extern Variable ly_music_p; + extern Variable make_music; + extern Variable make_safe_lilypond_module; + extern Variable make_span_event; + extern Variable markup_p; + extern Variable markup_list_p; + extern Variable midi_program; +#if !GUILEV2 + extern Variable module_export_all_x; +#endif + extern Variable f_parser; + extern Variable percussion_p; + extern Variable pure_chain_offset_callback; + extern Variable remove_stencil_warnings; + extern Variable scale_layout; + extern Variable scm_to_string; + extern Variable score_lines_markup_list; + extern Variable score_markup; + extern Variable scorify_music; + extern Variable span_bar_notify_grobs_of_my_existence; + extern Variable stencil_whiteout; + extern Variable stencil_whiteout_box; + extern Variable symbol_list_p; + extern Variable tremolo_get_music_list; + extern Variable type_name; + extern Variable volta_bracket_calc_hook_visibility; + extern Variable write_performances_midis; + + extern Variable add_lyrics; + extern Variable argument_error; + extern Variable composed_markup_list; + extern Variable context_change; + extern Variable context_specification; + extern Variable event_chord; + extern Variable lyric_combine; + extern Variable lyric_event; + extern Variable multi_measure_rest; + extern Variable music_function; + extern Variable music_function_call_error; + extern Variable property_operation; + extern Variable repeat; + extern Variable repetition_chord; + extern Variable sequential_music; + extern Variable simultaneous_music; + extern Variable tempo; + extern Variable unrelativable_music; + extern Variable void_music; +}; + +#endif diff --git a/lily/include/lily-modules.hh b/lily/include/lily-modules.hh new file mode 100644 index 0000000000..1eb7cf7354 --- /dev/null +++ b/lily/include/lily-modules.hh @@ -0,0 +1,99 @@ +/* + This file is part of LilyPond, the GNU music typesetter. + + Copyright (C) 2015 by David Kastrup + + LilyPond is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + LilyPond is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LilyPond. If not, see . +*/ + +#ifndef LILY_MODULES_HH +#define LILY_MODULES_HH + +#include "lily-guile.hh" + +class Scm_variable; + +class Scm_module +{ + const char *name_; + SCM module_; + class Variable_record; + Variable_record *variables_; + static void boot_init (void *); +public: + void boot (); + void import (); + void register_variable (const char *name, Scm_variable *var); + + Scm_module (const char *name); + + operator SCM () + { + assert (SCM_MODULEP (module_)); + return module_; + } +}; + +class Scm_variable +{ + SCM var_; + friend Scm_module; + void boot (const char *name); + void import (SCM module, const char *name); +public: + operator SCM & () + { +#if 0 + // One could conceivably work with variables even before the + // module is initialized + return SCM_VARIABLEP (var_) ? *SCM_VARIABLE_LOC (var_) : var_; +#endif +#if DEBUG + assert (SCM_VARIABLEP (var_)); +#endif + return *SCM_VARIABLE_LOC (var_); + } + SCM operator () () + { + return scm_call_0 (*this); + } + SCM operator () (SCM arg1) + { + return scm_call_1 (*this, arg1); + } + SCM operator () (SCM arg1, SCM arg2) + { + return scm_call_2 (*this, arg1, arg2); + } + SCM operator () (SCM arg1, SCM arg2, SCM arg3) + { + return scm_call_3 (*this, arg1, arg2, arg3); + } + SCM operator () (SCM arg1, SCM arg2, SCM arg3, SCM arg4) + { + return scm_call_4 (*this, arg1, arg2, arg3, arg4); + } + Scm_variable (Scm_module &m, const char *name, SCM value = SCM_UNDEFINED); +}; + +template +class Module_variable : public Scm_variable +{ +public: + Module_variable (const char *name, SCM value = SCM_UNDEFINED) + : Scm_variable (m, name, value) + { } +}; + +#endif diff --git a/lily/include/lily-proto.hh b/lily/include/lily-proto.hh index a76022b434..afb6beba2a 100644 --- a/lily/include/lily-proto.hh +++ b/lily/include/lily-proto.hh @@ -141,6 +141,8 @@ class Rhythmic_music_iterator; class Scale; class Scheme_hash_table; class Scheme_engraver; +class Scm_module; +class Scm_variable; class Score; class Score_engraver; class Score_performer; diff --git a/lily/key-performer.cc b/lily/key-performer.cc index fa76c883a4..06666ac532 100644 --- a/lily/key-performer.cc +++ b/lily/key-performer.cc @@ -22,6 +22,7 @@ #include "performer.hh" #include "stream-event.hh" #include "warn.hh" +#include "lily-imports.hh" #include "translator.icc" @@ -57,9 +58,8 @@ Key_performer::process_music () if (key_ev_) { SCM pitchlist = key_ev_->get_property ("pitch-alist"); - SCM proc = ly_lily_module_constant ("alterations-in-key"); - SCM acc = scm_call_1 (proc, pitchlist); + SCM acc = Lily::alterations_in_key (pitchlist); Pitch key_do (0, scm_to_int (scm_caar (pitchlist)), diff --git a/lily/key-signature-interface.cc b/lily/key-signature-interface.cc index 89695f7c5f..56af49da39 100644 --- a/lily/key-signature-interface.cc +++ b/lily/key-signature-interface.cc @@ -27,6 +27,7 @@ #include "output-def.hh" #include "staff-symbol-referencer.hh" #include "rational.hh" +#include "lily-imports.hh" struct Key_signature_interface { @@ -87,11 +88,10 @@ Key_signature_interface::print (SCM smob) me->warning (_ ("alteration not found")); else { - SCM proc = ly_lily_module_constant ("key-signature-interface::alteration-positions"); - pos.set_empty (); Stencil column; - for (SCM pos_list = scm_call_3 (proc, scm_car (s), c0s, smob); + for (SCM pos_list = Lily::key_signature_interface_alteration_positions + (scm_car (s), c0s, smob); scm_is_pair (pos_list); pos_list = scm_cdr (pos_list)) { int p = scm_to_int (scm_car (pos_list)); diff --git a/lily/lexer.ll b/lily/lexer.ll index 3c09299b4b..b8faf78e31 100644 --- a/lily/lexer.ll +++ b/lily/lexer.ll @@ -71,6 +71,7 @@ using namespace std; #include "std-string.hh" #include "version.hh" #include "warn.hh" +#include "lily-imports.hh" /* RH 7 fix (?) @@ -688,9 +689,9 @@ BOM_UTF8 \357\273\277 for (; scm_is_pair(s); s = scm_cdr(s)) { SCM predicate = scm_car(s); - if (predicate == ly_lily_module_constant ("markup-list?")) + if (predicate == Lily::markup_list_p) push_extra_token (here_input (), EXPECT_MARKUP_LIST); - else if (predicate == ly_lily_module_constant ("markup?")) + else if (predicate == Lily::markup_p) push_extra_token (here_input (), EXPECT_MARKUP); else push_extra_token (here_input (), EXPECT_SCM, predicate); @@ -966,9 +967,9 @@ Lily_lexer::scan_scm_id (SCM sid) cs = SCM_CAR (cs); } - if (scm_is_eq (cs, ly_lily_module_constant ("ly:music?"))) + if (scm_is_eq (cs, Lily::ly_music_p)) funtype = MUSIC_FUNCTION; - else if (scm_is_eq (cs, ly_lily_module_constant ("ly:event?"))) + else if (scm_is_eq (cs, Lily::ly_event_p)) funtype = EVENT_FUNCTION; else if (ly_is_procedure (cs)) funtype = SCM_FUNCTION; @@ -1327,15 +1328,13 @@ scan_fraction (string frac) SCM lookup_markup_command (string s) { - SCM proc = ly_lily_module_constant ("lookup-markup-command"); - return scm_call_1 (proc, ly_string2scm (s)); + return Lily::lookup_markup_command (ly_string2scm (s)); } SCM lookup_markup_list_command (string s) { - SCM proc = ly_lily_module_constant ("lookup-markup-list-command"); - return scm_call_1 (proc, ly_string2scm (s)); + return Lily::lookup_markup_list_command (ly_string2scm (s)); } /* Shut up lexer warnings. */ diff --git a/lily/lily-guile.cc b/lily/lily-guile.cc index 3408291c66..bde39214b3 100644 --- a/lily/lily-guile.cc +++ b/lily/lily-guile.cc @@ -40,6 +40,7 @@ using namespace std; #include "source-file.hh" #include "version.hh" #include "warn.hh" +#include "lily-imports.hh" /* symbols/strings. @@ -436,8 +437,7 @@ type_check_assignment (SCM sym, SCM val, SCM type_symbol) && ly_is_procedure (type) && scm_is_false (scm_call_1 (type, val))) { - SCM typefunc = ly_lily_module_constant ("type-name"); - SCM type_name = scm_call_1 (typefunc, type); + SCM type_name = Lily::type_name (type); warning (_f ("type check for `%s' failed; value `%s' must be of type `%s'", ly_symbol2string (sym).c_str (), @@ -672,8 +672,7 @@ alist_to_hashq (SCM alist) SCM ly_hash2alist (SCM tab) { - SCM func = ly_lily_module_constant ("hash-table->alist"); - return scm_call_1 (func, tab); + return Lily::hash_table_to_alist (tab); } /* diff --git a/lily/lily-imports.cc b/lily/lily-imports.cc new file mode 100644 index 0000000000..37a92578d4 --- /dev/null +++ b/lily/lily-imports.cc @@ -0,0 +1,118 @@ +/* + This file is part of LilyPond, the GNU music typesetter. + + Copyright (C) 2015 by David Kastrup + + LilyPond is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + LilyPond is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LilyPond. If not, see . +*/ + +#include "lily-imports.hh" + +namespace Guile_user { + Scm_module module ("guile-user"); + + Variable plus ("+"); + Variable make_module ("make-module"); +#if GUILEV2 + Variable module_export_all_x ("module-export-all!"); +#endif + Variable module_export_x ("module-export!"); + Variable module_public_interface ("module-public-interface"); + Variable module_use_x ("module-use!"); + Variable symbol_p ("symbol?"); + Variable the_root_module ("the-root-module"); +} + +namespace Display { + Scm_module module ("scm display-lily"); + + Variable value_to_lily_string ("value->lily-string"); +} + +namespace Lily { + Scm_module module ("lily"); + + Variable all_music_font_encodings ("all-music-font-encodings"); + Variable alterations_in_key ("alterations-in-key"); + Variable backend_testing ("backend-testing"); + Variable base_length ("base-length"); + Variable beam_exceptions ("beam-exceptions"); + Variable beat_structure ("beat-structure"); + Variable calc_repeat_slash_count ("calc-repeat-slash-count"); + Variable car_less ("car<"); + Variable construct_chord_elements ("construct-chord-elements"); + Variable default_time_signature_settings ("default-time-signature-settings"); + Variable hash_table_to_alist ("hash-table->alist"); + Variable interpret_markup_list ("interpret-markup-list"); + Variable invalidate_alterations ("invalidate-alterations"); + Variable key_signature_interface_alteration_positions ("key-signature-interface::alteration-positions"); + Variable layout_extract_page_properties ("layout-extract-page-properties"); + Variable lilypond_main ("lilypond-main"); + Variable line_markup ("line-markup"); + Variable f_location ("%location"); + Variable lookup_font ("lookup-font"); + Variable lookup_markup_command ("lookup-markup-command"); + Variable lookup_markup_list_command ("lookup-markup-list-command"); + Variable ly_context_find ("ly:context-find"); + Variable ly_context_set_property_x ("ly:context-set-property!"); + Variable ly_event_p ("ly:event?"); + Variable ly_make_event_class ("ly:make-event-class"); + Variable ly_music_p ("ly:music?"); + Variable make_music ("make-music"); + Variable make_safe_lilypond_module ("make-safe-lilypond-module"); + Variable make_span_event ("make-span-event"); + Variable markup_p ("markup?"); + Variable markup_list_p ("markup-list?"); + Variable midi_program ("midi-program"); +#if !GUILEV2 + Variable module_export_all_x ("module-export-all!"); +#endif + Variable f_parser ("%parser"); + Variable percussion_p ("percussion?"); + Variable pure_chain_offset_callback ("pure-chain-offset-callback"); + Variable remove_stencil_warnings ("remove-stencil-warnings"); + Variable scale_layout ("scale-layout"); + Variable scm_to_string ("scm->string"); + Variable score_lines_markup_list ("score-lines-markup-list"); + Variable score_markup ("score-markup"); + Variable scorify_music ("scorify-music"); + Variable span_bar_notify_grobs_of_my_existence ("span-bar::notify-grobs-of-my-existence"); + Variable stencil_whiteout ("stencil-whiteout"); + Variable stencil_whiteout_box ("stencil-whiteout-box"); + Variable symbol_list_p ("symbol-list?"); + Variable tremolo_get_music_list ("tremolo::get-music-list"); + Variable type_name ("type-name"); + Variable volta_bracket_calc_hook_visibility ("volta-bracket::calc-hook-visibility"); + Variable write_performances_midis ("write-performances-midis"); + + Variable add_lyrics ("add-lyrics"); + Variable argument_error ("argument-error"); + Variable composed_markup_list ("composed-markup-list"); + Variable context_change ("context-change"); + Variable context_specification ("context-specification"); + Variable event_chord ("event-chord"); + Variable lyric_combine ("lyric-combine"); + Variable lyric_event ("lyric-event"); + Variable multi_measure_rest ("multi-measure-rest"); + Variable music_function ("music-function"); + Variable music_function_call_error ("music-function-call-error"); + Variable property_operation ("property-operation"); + Variable repeat ("repeat"); + Variable repetition_chord ("repetition-chord"); + Variable sequential_music ("sequential-music"); + Variable simultaneous_music ("simultaneous-music"); + Variable tempo ("tempo"); + Variable unrelativable_music ("unrelativable-music"); + Variable void_music ("void-music"); +} diff --git a/lily/lily-modules.cc b/lily/lily-modules.cc new file mode 100644 index 0000000000..f34e7e3041 --- /dev/null +++ b/lily/lily-modules.cc @@ -0,0 +1,101 @@ +/* + This file is part of LilyPond, the GNU music typesetter. + + Copyright (C) 2015 by David Kastrup + + LilyPond is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + LilyPond is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LilyPond. If not, see . +*/ + +#include "lily-modules.hh" + +struct Scm_module::Variable_record +{ + const char *name_; + Scm_variable *var_; + Variable_record *next_; + Variable_record (const char *name, Scm_variable *var, Variable_record *next_) + : name_ (name), var_ (var), next_ (next_) + { } +}; + +void +Scm_module::register_variable (const char *name, Scm_variable *var) +{ + variables_ = new Variable_record (name, var, variables_); +} + +Scm_module::Scm_module (const char *name) + : name_ (name), module_ (SCM_UNDEFINED), variables_ (0) +{ +} + +void +Scm_module::boot_init (void *arg) +{ + Scm_module *self = static_cast (arg); + + // Establish variables first + for (Variable_record *p = self->variables_; p;) + { + Variable_record *next = p->next_; + p->var_->boot (p->name_); + delete p; + p = next; + } + self->variables_ = 0; +} + +void +Scm_module::boot () +{ + assert (SCM_UNBNDP (module_)); + module_ = scm_c_define_module (name_, boot_init, static_cast (this)); +} + +void +Scm_module::import () +{ + assert (SCM_UNBNDP (module_)); + module_ = scm_c_resolve_module (name_); + for (Variable_record *p = variables_; p;) + { + Variable_record *next = p->next_; + p->var_->import (module_, p->name_); + delete p; + p = next; + } + variables_ = 0; +} + +void +Scm_variable::boot (const char *name) +{ + assert (!SCM_VARIABLEP (var_)); + var_ = scm_c_define (name, var_); +} + +void +Scm_variable::import (SCM module, const char *name) +{ + assert (SCM_UNBNDP (var_)); + var_ = scm_c_module_lookup (module, name); +} + + +Scm_variable::Scm_variable (Scm_module &m, const char *name, SCM value) + : var_ (value) +{ + assert (SCM_IMP (value)); + m.register_variable (name, this); +} diff --git a/lily/lily-parser-scheme.cc b/lily/lily-parser-scheme.cc index 4d922404ce..ea84aae41a 100644 --- a/lily/lily-parser-scheme.cc +++ b/lily/lily-parser-scheme.cc @@ -30,6 +30,7 @@ #include "program-option.hh" #include "sources.hh" #include "warn.hh" +#include "lily-imports.hh" LY_DEFINE (ly_parse_file, "ly:parse-file", 1, 0, 0, (SCM name), @@ -141,7 +142,7 @@ LY_DEFINE (ly_parser_lexer, "ly:parser-lexer", "Return the lexer for @var{parser}, defaulting to current parser") { if (SCM_UNBNDP (parser)) - parser = scm_fluid_ref (ly_lily_module_constant ("%parser")); + parser = scm_fluid_ref (Lily::f_parser); Lily_parser *p = LY_ASSERT_SMOB (Lily_parser, parser, 1); return p->lexer_->self_scm (); } @@ -154,7 +155,7 @@ LY_DEFINE (ly_parser_clone, "ly:parser-clone", " lexical environment. If @var{location} is a valid location," " it becomes the source of all music expressions inside.") { - SCM parser = scm_fluid_ref (ly_lily_module_constant("%parser")); + SCM parser = scm_fluid_ref (Lily::f_parser); Lily_parser *p = LY_ASSERT_SMOB (Lily_parser, parser, 0); if (SCM_UNBNDP (closures)) @@ -170,7 +171,7 @@ LY_DEFINE (ly_parser_define_x, "ly:parser-define!", 2, 0, 0, (SCM symbol, SCM val), "Bind @var{symbol} to @var{val} in current parser's module.") { - SCM parser = scm_fluid_ref (ly_lily_module_constant ("%parser")); + SCM parser = scm_fluid_ref (Lily::f_parser); Lily_parser *p = LY_ASSERT_SMOB (Lily_parser, parser, 0); LY_ASSERT_TYPE (ly_is_symbol, symbol, 1); @@ -184,7 +185,7 @@ LY_DEFINE (ly_parser_lookup, "ly:parser-lookup", "Look up @var{symbol} in current parser's module." " Return @code{'()} if not defined.") { - SCM parser = scm_fluid_ref (ly_lily_module_constant ("%parser")); + SCM parser = scm_fluid_ref (Lily::f_parser); Lily_parser *p = LY_ASSERT_SMOB (Lily_parser, parser, 0); LY_ASSERT_TYPE (ly_is_symbol, symbol, 1); @@ -252,7 +253,7 @@ LY_DEFINE (ly_parser_include_string, "ly:parser-include-string", " for current parser. Can only be used in immediate" " Scheme expressions (@code{$} instead of @code{#}).") { - SCM parser = scm_fluid_ref (ly_lily_module_constant ("%parser")); + SCM parser = scm_fluid_ref (Lily::f_parser); Lily_parser *p = LY_ASSERT_SMOB (Lily_parser, parser, 0); LY_ASSERT_TYPE (scm_is_string, ly_code, 1); @@ -268,7 +269,7 @@ LY_DEFINE (ly_parser_set_note_names, "ly:parser-set-note-names", " @var{names} is an alist of symbols. This only has effect" " if the current mode is notes.") { - SCM parser = scm_fluid_ref (ly_lily_module_constant ("%parser")); + SCM parser = scm_fluid_ref (Lily::f_parser); Lily_parser *p = LY_ASSERT_SMOB (Lily_parser, parser, 0); if (p->lexer_->is_note_state ()) @@ -285,7 +286,7 @@ LY_DEFINE (ly_parser_output_name, "ly:parser-output-name", "Return the base name of the output file. If @code{parser} is left off, use currently active parser.") { if (SCM_UNBNDP (parser)) - parser = scm_fluid_ref (ly_lily_module_constant ("%parser")); + parser = scm_fluid_ref (Lily::f_parser); Lily_parser *p = LY_ASSERT_SMOB (Lily_parser, parser, 1); @@ -297,7 +298,7 @@ LY_DEFINE (ly_parser_error, "ly:parser-error", "Display an error message and make current parser fail." " Without a current parser, trigger an ordinary error.") { - SCM parser = scm_fluid_ref (ly_lily_module_constant ("%parser")); + SCM parser = scm_fluid_ref (Lily::f_parser); Lily_parser *p = unsmob (parser); @@ -327,7 +328,7 @@ LY_DEFINE (ly_parser_clear_error, "ly:parser-clear-error", "Clear error flag for @var{parser}, defaulting to current parser.") { if (SCM_UNBNDP (parser)) - parser = scm_fluid_ref (ly_lily_module_constant ("%parser")); + parser = scm_fluid_ref (Lily::f_parser); Lily_parser *p = LY_ASSERT_SMOB (Lily_parser, parser, 1); @@ -342,7 +343,7 @@ LY_DEFINE (ly_parser_has_error_p, "ly:parser-has-error?", "Does @var{parser} (defaulting to current parser) have an error flag?") { if (SCM_UNBNDP (parser)) - parser = scm_fluid_ref (ly_lily_module_constant ("%parser")); + parser = scm_fluid_ref (Lily::f_parser); Lily_parser *p = LY_ASSERT_SMOB (Lily_parser, parser, 1); return scm_from_bool (p->error_level_ || p->lexer_->error_level_); diff --git a/lily/ly-module.cc b/lily/ly-module.cc index 84b6858f75..2076168fda 100644 --- a/lily/ly-module.cc +++ b/lily/ly-module.cc @@ -22,6 +22,7 @@ #include "warn.hh" #include "main.hh" #include "protected-scm.hh" +#include "lily-imports.hh" SCM ly_make_module (bool safe) @@ -31,14 +32,16 @@ ly_make_module (bool safe) { /* Look up (evaluate) Scheme make-module function and call it */ - SCM maker = ly_lily_module_constant ("make-module"); - mod = scm_call_0 (maker); + mod = Guile_user::make_module (); /* Look up and call Guile module-export-all! or, when using Guile V1.8, the compatible shim defined in lily.scm. */ - SCM module_export_all_x = ly_lily_module_constant ("module-export-all!"); - scm_call_1 (module_export_all_x, mod); +#if GUILEV2 + Guile_user::module_export_all_x (mod); +#else + Lily::module_export_all_x (mod); +#endif /* Evaluate Guile module "the-root-module", @@ -46,15 +49,14 @@ ly_make_module (bool safe) N.B. this used to be "the-scm-module" and is deprecated in Guile V1.9/2.0 */ - SCM scm_module = ly_lily_module_constant ("the-root-module"); - ly_use_module (mod, scm_module); - ly_use_module (mod, global_lily_module); + + ly_use_module (mod, Guile_user::the_root_module); + ly_use_module (mod, Lily::module); } else { /* Evaluate and call make-safe-lilypond-module */ - SCM proc = ly_lily_module_constant ("make-safe-lilypond-module"); - mod = scm_call_0 (proc); + mod = Lily::make_safe_lilypond_module (); } return mod; @@ -68,19 +70,12 @@ ly_use_module (SCM mod, SCM used) TODO - Replace inline evaluations (interpreted) with guile API calls if these become available. */ - SCM scm_module_use = ly_symbol2scm ("module-use!"); - SCM scm_module_public_interface = ly_symbol2scm ("module-public-interface"); - SCM iface = scm_list_2 (scm_module_public_interface, used); /* Set up to interpret '(module_use! (module-public-interface ))' */ - SCM expr = scm_list_3 (scm_module_use, mod, iface); - /* - Now return SCM value, this is the result of interpreting - '(eval (module-use! (module-public-interface )) "lily")' - */ - return scm_eval (expr, global_lily_module); + return Guile_user::module_use_x (mod, + Guile_user::module_public_interface (used)); } #define FUNC_NAME __FUNCTION__ @@ -120,11 +115,7 @@ LY_DEFINE (ly_module_2_alist, "ly:module->alist", void ly_export (SCM module, SCM namelist) { - static SCM export_function; - if (!export_function) - export_function = scm_permanent_object (scm_c_lookup ("module-export!")); - - scm_call_2 (SCM_VARIABLE_REF (export_function), module, namelist); + Guile_user::module_export_x (module, namelist); } void diff --git a/lily/main.cc b/lily/main.cc index 69af225c76..d84f90ebd8 100644 --- a/lily/main.cc +++ b/lily/main.cc @@ -55,6 +55,7 @@ using namespace std; #include "string-convert.hh" #include "version.hh" #include "warn.hh" +#include "lily-imports.hh" /* * Global options that can be overridden through command line. @@ -532,8 +533,8 @@ main_with_guile (void *, int, char **) // SCM result = scm_call_1 ( // scm_variable_ref (call_with_error_handling), // scm_call_1 (ly_lily_module_constant ("lilypond-main"), files)); - SCM result = scm_call_1 (ly_lily_module_constant ("lilypond-main"), files); - (void) result; + + Lily::lilypond_main (files); /* Unreachable. */ exit (0); diff --git a/lily/midi-item.cc b/lily/midi-item.cc index d85161676c..a08c60b89a 100644 --- a/lily/midi-item.cc +++ b/lily/midi-item.cc @@ -28,6 +28,7 @@ #include "program-option.hh" #include "string-convert.hh" #include "warn.hh" +#include "lily-imports.hh" #define PITCH_WHEEL_CENTER 0x2000 #define PITCH_WHEEL_SEMITONE 0X1000 @@ -84,8 +85,7 @@ Midi_instrument::to_string () const Byte program_byte = 0; bool found = false; - SCM proc = ly_lily_module_constant ("midi-program"); - SCM program = scm_call_1 (proc, ly_symbol2scm (audio_->str_.c_str ())); + SCM program = Lily::midi_program (ly_symbol2scm (audio_->str_.c_str ())); found = (scm_is_true (program)); if (found) program_byte = (Byte) scm_to_int (program); diff --git a/lily/module-scheme.cc b/lily/module-scheme.cc index f926c44c02..8ea17ddb26 100644 --- a/lily/module-scheme.cc +++ b/lily/module-scheme.cc @@ -67,9 +67,9 @@ ly_module_lookup (SCM module, SCM sym) /* Issue 2758: Guile V2 onward has a scm_module_variable API module. - Guile V1.8.7 only has a (module-variable) REPL function, however - using ly_lily_module_constant ("module-variable") and calling - the memoized result is slow. + Guile V1.8.7 only has a (module-variable) REPL function and we + can't import this via Scm_variable since that needs + ly_module_lookup itself. */ #if GUILEV1 return scm_sym2var (sym, scm_module_lookup_closure (module), SCM_BOOL_F); diff --git a/lily/music-function.cc b/lily/music-function.cc index d8f7d3a27c..d58e324590 100644 --- a/lily/music-function.cc +++ b/lily/music-function.cc @@ -22,6 +22,7 @@ #include "input.hh" #include "music.hh" #include "fluid.hh" +#include "lily-imports.hh" const char Music_function::type_p_name_[] = "ly:music-function?"; @@ -79,7 +80,7 @@ with_loc (SCM arg, Fluid &loc, bool clone = true) SCM Music_function::call (SCM rest) { - Fluid location (ly_lily_module_constant ("%location")); + Fluid location (Lily::f_location); // (car (ly:music-signature self_scm())) is the return type, skip it SCM signature = scm_cdr (get_signature ()); @@ -142,10 +143,9 @@ Music_function::call (SCM rest) if (scm_is_false (scm_call_1 (pred, arg))) { - scm_call_4 (ly_lily_module_constant ("argument-error"), - location, - scm_from_int (scm_ilength (args)), - pred, arg); + Lily::argument_error (location, + scm_from_int (scm_ilength (args)), + pred, arg); SCM val = scm_car (get_signature ()); val = scm_is_pair (val) ? scm_cdr (val) : SCM_BOOL_F; return with_loc (val, location); @@ -168,6 +168,5 @@ Music_function::call (SCM rest) if (scm_is_true (scm_call_1 (pred, res))) return with_loc (res, location, false); - return scm_call_2 (ly_lily_module_constant ("music-function-call-error"), - self_scm (), res); + return Lily::music_function_call_error (self_scm (), res); } diff --git a/lily/music.cc b/lily/music.cc index 613b5387ff..a1accb9c3d 100644 --- a/lily/music.cc +++ b/lily/music.cc @@ -28,6 +28,7 @@ #include "music-sequence.hh" #include "score.hh" #include "warn.hh" +#include "lily-imports.hh" /* Music is anything that has (possibly zero) duration and supports @@ -269,7 +270,7 @@ Music::to_event () const programming_error ("Not a music type"); Stream_event *e = new Stream_event - (scm_call_1 (ly_lily_module_constant ("ly:make-event-class"), class_name), + (Lily::ly_make_event_class (class_name), mutable_property_alist_); Moment length = get_length (); if (length.to_bool ()) @@ -308,8 +309,7 @@ Music::send_to_context (Context *c) Music * make_music_by_name (SCM sym) { - SCM make_music_proc = ly_lily_module_constant ("make-music"); - SCM rv = scm_call_1 (make_music_proc, sym); + SCM rv = Lily::make_music (sym); /* UGH. */ Music *m = unsmob (rv); diff --git a/lily/page-layout-problem.cc b/lily/page-layout-problem.cc index 1e79ba0ec5..3f4fca05f1 100644 --- a/lily/page-layout-problem.cc +++ b/lily/page-layout-problem.cc @@ -33,6 +33,7 @@ #include "skyline-pair.hh" #include "system.hh" #include "text-interface.hh" +#include "lily-imports.hh" /* Returns the number of footnotes associated with a given line. @@ -140,8 +141,7 @@ Page_layout_problem::add_footnotes_to_lines (SCM lines, int counter, Paper_book number_footnote_table = SCM_EOL; SCM numbering_function = paper->c_variable ("footnote-numbering-function"); SCM layout = paper->self_scm (); - SCM props = scm_call_1 (ly_lily_module_constant ("layout-extract-page-properties"), - paper->self_scm ()); + SCM props = Lily::layout_extract_page_properties (layout); Real padding = robust_scm2double (paper->c_variable ("footnote-padding"), 0.0); Real number_raise = robust_scm2double (paper->c_variable ("footnote-number-raise"), 0.0); @@ -232,8 +232,7 @@ Page_layout_problem::add_footnotes_to_lines (SCM lines, int counter, Paper_book if (orig->is_broken ()) footnote_markup = orig->broken_intos_[0]->get_property ("footnote-text"); - SCM props = scm_call_1 (ly_lily_module_constant ("layout-extract-page-properties"), - paper->self_scm ()); + SCM props = Lily::layout_extract_page_properties (paper->self_scm ()); SCM footnote_stl = Text_interface::interpret_markup (paper->self_scm (), props, footnote_markup); @@ -324,8 +323,7 @@ Page_layout_problem::add_footnotes_to_lines (SCM lines, int counter, Paper_book Stencil Page_layout_problem::get_footnote_separator_stencil (Output_def *paper) { - SCM props = scm_call_1 (ly_lily_module_constant ("layout-extract-page-properties"), - paper->self_scm ()); + SCM props = Lily::layout_extract_page_properties (paper->self_scm ()); SCM markup = paper->c_variable ("footnote-separator-markup"); diff --git a/lily/paper-book.cc b/lily/paper-book.cc index 78d51a0caa..e23ef52777 100644 --- a/lily/paper-book.cc +++ b/lily/paper-book.cc @@ -31,6 +31,8 @@ #include "program-option.hh" #include "page-marker.hh" #include "ly-module.hh" +#include "lily-imports.hh" + Paper_book::Paper_book () { @@ -116,12 +118,9 @@ Paper_book::output_aux (SCM output_channel, long page_nb = 0; if (scm_is_pair (performances_)) { - SCM proc = ly_lily_module_constant ("write-performances-midis"); - - scm_call_3 (proc, - performances (), - output_channel, - scm_from_long (*first_performance_number)); + Lily::write_performances_midis (performances (), + output_channel, + scm_from_long (*first_performance_number)); *first_performance_number += scm_ilength (performances_); } @@ -228,11 +227,9 @@ Paper_book::classic_output_aux (SCM output, { if (scm_is_pair (performances_)) { - SCM proc = ly_lily_module_constant ("write-performances-midis"); - scm_call_3 (proc, - performances (), - output, - scm_from_long (*first_performance_number)); + Lily::write_performances_midis (performances (), + output, + scm_from_long (*first_performance_number)); *first_performance_number += scm_ilength (performances_); } @@ -433,10 +430,8 @@ Paper_book::get_system_specs () } SCM page_properties - = scm_call_1 (ly_lily_module_constant ("layout-extract-page-properties"), - paper_->self_scm ()); + = Lily::layout_extract_page_properties (paper_->self_scm ()); - SCM interpret_markup_list = ly_lily_module_constant ("interpret-markup-list"); SCM header = SCM_EOL; SCM labels = SCM_EOL; for (SCM s = scm_reverse (scores_); scm_is_pair (s); s = scm_cdr (s)) @@ -497,10 +492,9 @@ Paper_book::get_system_specs () } else if (Text_interface::is_markup_list (scm_car (s))) { - SCM texts = scm_call_3 (interpret_markup_list, - paper_->self_scm (), - page_properties, - scm_car (s)); + SCM texts = Lily::interpret_markup_list (paper_->self_scm (), + page_properties, + scm_car (s)); Prob *first = 0; Prob *last = 0; for (SCM list = texts; scm_is_pair (list); list = scm_cdr (list)) diff --git a/lily/paper-def.cc b/lily/paper-def.cc index 5329d30555..0f6efc6b75 100644 --- a/lily/paper-def.cc +++ b/lily/paper-def.cc @@ -23,6 +23,7 @@ #include "modified-font-metric.hh" #include "pango-font.hh" #include "all-font-metrics.hh" +#include "lily-imports.hh" Real output_scale (Output_def *od) @@ -114,8 +115,7 @@ find_pango_font (Output_def *layout, SCM descr, Real factor) Output_def * scale_output_def (Output_def *o, Real amount) { - SCM proc = ly_lily_module_constant ("scale-layout"); - SCM new_pap = scm_call_2 (proc, o->self_scm (), scm_from_double (amount)); + SCM new_pap = Lily::scale_layout (o->self_scm (), scm_from_double (amount)); o = unsmob (new_pap); o->protect (); diff --git a/lily/paper-outputter.cc b/lily/paper-outputter.cc index 5da493ba48..a72ea59ccd 100644 --- a/lily/paper-outputter.cc +++ b/lily/paper-outputter.cc @@ -37,6 +37,7 @@ using namespace std; #include "scm-hash.hh" #include "string-convert.hh" #include "warn.hh" +#include "lily-imports.hh" Paper_outputter::Paper_outputter (SCM port, const string &format) @@ -52,8 +53,7 @@ Paper_outputter::Paper_outputter (SCM port, const string &format) Enable errors for undefined stencil routines if -dwarning-as-error is specified; else enable warnings. */ - SCM proc = ly_lily_module_constant ("backend-testing"); - scm_call_1 (proc, output_module_); + Lily::backend_testing (output_module_); } Paper_outputter::~Paper_outputter () @@ -126,7 +126,6 @@ Paper_outputter::close () expressions so that we start fresh with the next \book block. --pmccarty */ - SCM proc = ly_lily_module_constant ("remove-stencil-warnings"); - scm_call_1 (proc, output_module_); + Lily::remove_stencil_warnings (output_module_); } } diff --git a/lily/parse-scm.cc b/lily/parse-scm.cc index 9db184c2ae..576591dc97 100644 --- a/lily/parse-scm.cc +++ b/lily/parse-scm.cc @@ -28,6 +28,7 @@ using namespace std; #include "main.hh" #include "paper-book.hh" #include "source-file.hh" +#include "lily-imports.hh" /* Pass string to scm parser, read one expression. Return result value and #chars read. @@ -94,8 +95,7 @@ internal_ly_eval_scm (Parse_start *ps) static SCM module = SCM_BOOL_F; if (scm_is_false (module)) { - SCM function = ly_lily_module_constant ("make-safe-lilypond-module"); - module = scm_gc_protect_object (scm_call_0 (function)); + module = scm_gc_protect_object (Lily::make_safe_lilypond_module ()); } return scm_eval (ps->form_, module); @@ -175,7 +175,7 @@ ly_eval_scm (SCM form, Input i, bool safe, Lily_parser *parser) Parse_start ps (form, i, safe, parser); SCM ans = scm_c_with_fluid - (ly_lily_module_constant ("%location"), + (Lily::f_location, i.smobbed_copy (), parse_protect_global ? protected_ly_eval_scm : catch_protected_eval_body, (void *) &ps); diff --git a/lily/parser.yy b/lily/parser.yy index 8d8d7de150..8c08819d7d 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -41,8 +41,7 @@ do { \ if (scm_is_eq (value, SCM_UNSPECIFIED)) \ break; \ - SCM s = scm_call_1 (ly_lily_module_constant ("value->lily-string"), \ - value); \ + SCM s = Display::value_to_lily_string (value); \ char *p = scm_to_locale_string (s); \ fputs (p, file); \ free (p); \ @@ -139,6 +138,7 @@ using namespace std; #include "score.hh" #include "text-interface.hh" #include "warn.hh" +#include "lily-imports.hh" void Lily_parser::parser_error (Input const *i, Lily_parser *parser, SCM *, const string &s) @@ -200,7 +200,7 @@ syntax_call (void *arg) #define LOWLEVEL_MAKE_SYNTAX(location, args) \ scm_c_with_fluid \ - (ly_lily_module_constant ("%location"), \ + (Lily::f_location, \ parser->lexer_->override_input (location).smobbed_copy (), \ syntax_call, \ reinterpret_cast (args)) @@ -208,11 +208,11 @@ syntax_call (void *arg) /* Syntactic Sugar. */ #define MAKE_SYNTAX(name, location, ...) \ LOWLEVEL_MAKE_SYNTAX (location, \ - scm_list_n (ly_lily_module_constant (name), \ + scm_list_n (Lily::name, \ ##__VA_ARGS__, SCM_UNDEFINED)) #define START_MAKE_SYNTAX(name, ...) \ - scm_list_n (ly_lily_module_constant (name), \ + scm_list_n (Lily::name, \ ##__VA_ARGS__, SCM_UNDEFINED) #define FINISH_MAKE_SYNTAX(start, location, ...) \ @@ -551,8 +551,8 @@ embedded_scm_arg: scm_function_call: SCM_FUNCTION function_arglist { - $$ = MAKE_SYNTAX ("music-function", @$, - $1, $2); + $$ = MAKE_SYNTAX (music_function, @$, + $1, $2); } ; @@ -575,7 +575,7 @@ embedded_lilypond: // for empty rules, and the only token in the whole // production, EMBEDDED_LILY, is synthetic and also // contains no source location. - $$ = MAKE_SYNTAX ("void-music", @$); + $$ = MAKE_SYNTAX (void_music, @$); } | identifier_init_nonumber | embedded_lilypond_number @@ -608,7 +608,7 @@ embedded_lilypond: $3 = scm_cons ($2, $3); if (unsmob ($1)) $3 = scm_cons ($1, $3); - $$ = MAKE_SYNTAX ("sequential-music", @$, $3); + $$ = MAKE_SYNTAX (sequential_music, @$, $3); } | error { parser->error_level_ = 1; @@ -1015,8 +1015,7 @@ score_items: } } else if (!unsmob ($$)) { if (unsmob ($2)) { - SCM scorify = ly_lily_module_constant ("scorify-music"); - $2 = scm_call_1 (scorify, $2); + $2 = Lily::scorify_music ($2); } if (unsmob ($2)) { @@ -1202,13 +1201,13 @@ output_def_body: tempo_event: TEMPO steno_duration '=' tempo_range { - $$ = MAKE_SYNTAX ("tempo", @$, SCM_EOL, $2, $4); + $$ = MAKE_SYNTAX (tempo, @$, SCM_EOL, $2, $4); } | TEMPO scalar steno_duration '=' tempo_range { - $$ = MAKE_SYNTAX ("tempo", @$, $2, $3, $5); + $$ = MAKE_SYNTAX (tempo, @$, $2, $3, $5); } | TEMPO scalar { - $$ = MAKE_SYNTAX ("tempo", @$, $2); + $$ = MAKE_SYNTAX (tempo, @$, $2); } %prec ':' ; @@ -1251,7 +1250,7 @@ pitch_as_music: if (!unsmob ($$)) { parser->parser_error (@1, _ ("music expected")); - $$ = MAKE_SYNTAX ("void-music", @$); + $$ = MAKE_SYNTAX (void_music, @$); } } ; @@ -1318,29 +1317,29 @@ music_assign: repeated_music: REPEAT simple_string unsigned_number music { - $$ = MAKE_SYNTAX ("repeat", @$, $2, $3, $4, SCM_EOL); + $$ = MAKE_SYNTAX (repeat, @$, $2, $3, $4, SCM_EOL); } | REPEAT simple_string unsigned_number music ALTERNATIVE braced_music_list { - $$ = MAKE_SYNTAX ("repeat", @$, $2, $3, $4, $6); + $$ = MAKE_SYNTAX (repeat, @$, $2, $3, $4, $6); } ; sequential_music: SEQUENTIAL braced_music_list { - $$ = MAKE_SYNTAX ("sequential-music", @$, $2); + $$ = MAKE_SYNTAX (sequential_music, @$, $2); } | braced_music_list { - $$ = MAKE_SYNTAX ("sequential-music", @$, $1); + $$ = MAKE_SYNTAX (sequential_music, @$, $1); } ; simultaneous_music: SIMULTANEOUS braced_music_list { - $$ = MAKE_SYNTAX ("simultaneous-music", @$, $2); + $$ = MAKE_SYNTAX (simultaneous_music, @$, $2); } | DOUBLE_ANGLE_OPEN music_list DOUBLE_ANGLE_CLOSE { - $$ = MAKE_SYNTAX ("simultaneous-music", @$, scm_reverse_x ($2, SCM_EOL)); + $$ = MAKE_SYNTAX (simultaneous_music, @$, scm_reverse_x ($2, SCM_EOL)); } ; @@ -1433,14 +1432,14 @@ context_prefix: SCM mods = SCM_EOL; if (ctxmod) mods = ctxmod->get_mods (); - $$ = START_MAKE_SYNTAX ("context-specification", $2, $3, mods, SCM_BOOL_F); + $$ = START_MAKE_SYNTAX (context_specification, $2, $3, mods, SCM_BOOL_F); } | NEWCONTEXT symbol optional_id optional_context_mod { Context_mod *ctxmod = unsmob ($4); SCM mods = SCM_EOL; if (ctxmod) mods = ctxmod->get_mods (); - $$ = START_MAKE_SYNTAX ("context-specification", $2, $3, mods, SCM_BOOL_T); + $$ = START_MAKE_SYNTAX (context_specification, $2, $3, mods, SCM_BOOL_T); } ; @@ -1474,11 +1473,11 @@ basic_music: | repeated_music | music_bare | LYRICSTO simple_string lyric_mode_music { - $$ = MAKE_SYNTAX ("lyric-combine", @$, $2, SCM_EOL, $3); + $$ = MAKE_SYNTAX (lyric_combine, @$, $2, SCM_EOL, $3); } | LYRICSTO symbol '=' simple_string lyric_mode_music { - $$ = MAKE_SYNTAX ("lyric_combine", @$, $3, $2, $4); + $$ = MAKE_SYNTAX (lyric_combine, @$, $3, $2, $4); } ; @@ -1494,7 +1493,7 @@ contexted_basic_music: Input i; i.set_location (@1, @2); $$ = FINISH_MAKE_SYNTAX ($1, i, $2); - $$ = MAKE_SYNTAX ("add-lyrics", @$, $$, scm_reverse_x ($3, SCM_EOL)); + $$ = MAKE_SYNTAX (add_lyrics, @$, $$, scm_reverse_x ($3, SCM_EOL)); } %prec COMPOSITE | context_prefix contextable_music { @@ -1511,7 +1510,7 @@ composite_music: | contexted_basic_music | basic_music new_lyrics { - $$ = MAKE_SYNTAX ("add-lyrics", @$, $1, scm_reverse_x ($2, SCM_EOL)); + $$ = MAKE_SYNTAX (add_lyrics, @$, $1, scm_reverse_x ($2, SCM_EOL)); } %prec COMPOSITE ; @@ -1600,8 +1599,7 @@ symbol_list_rev: symbol_list_part: symbol_list_element { - SCM sym_l_p = ly_lily_module_constant ("symbol-list?"); - $$ = try_string_variants (sym_l_p, $1); + $$ = try_string_variants (Lily::symbol_list_p, $1); if (SCM_UNBNDP ($$)) { parser->parser_error (@1, _("not a symbol")); $$ = SCM_EOL; @@ -2214,8 +2212,8 @@ function_arglist_skip_backup: music_function_call: MUSIC_FUNCTION function_arglist { - $$ = MAKE_SYNTAX ("music-function", @$, - $1, $2); + $$ = MAKE_SYNTAX (music_function, @$, + $1, $2); } ; @@ -2248,7 +2246,7 @@ mode_changed_music: mode_changing_head grouped_music_list { if (scm_is_eq ($1, ly_symbol2scm ("chords"))) { - $$ = MAKE_SYNTAX ("unrelativable-music", @$, $2); + $$ = MAKE_SYNTAX (unrelativable_music, @$, $2); } else { @@ -2261,10 +2259,10 @@ mode_changed_music: SCM mods = SCM_EOL; if (ctxmod) mods = ctxmod->get_mods (); - $$ = MAKE_SYNTAX ("context-specification", @$, $1, SCM_EOL, mods, SCM_BOOL_T, $3); + $$ = MAKE_SYNTAX (context_specification, @$, $1, SCM_EOL, mods, SCM_BOOL_T, $3); if (scm_is_eq ($1, ly_symbol2scm ("ChordNames"))) { - $$ = MAKE_SYNTAX ("unrelativable-music", @$, $$); + $$ = MAKE_SYNTAX (unrelativable_music, @$, $$); } parser->lexer_->pop_state (); } @@ -2330,7 +2328,7 @@ mode_changing_head_with_context: context_change: CHANGE symbol '=' simple_string { - $$ = MAKE_SYNTAX ("context-change", @$, $2, $4); + $$ = MAKE_SYNTAX (context_change, @$, $2, $4); } ; @@ -2551,9 +2549,9 @@ simple_revert_context: music_property_def: OVERRIDE grob_prop_path '=' scalar { if (SCM_UNBNDP ($2)) - $$ = MAKE_SYNTAX ("void-music", @$); + $$ = MAKE_SYNTAX (void_music, @$); else { - $$ = MAKE_SYNTAX ("property-operation", @$, + $$ = MAKE_SYNTAX (property_operation, @$, scm_car ($2), ly_symbol2scm ("OverrideProperty"), scm_cadr ($2), @@ -2562,7 +2560,7 @@ music_property_def: } } | REVERT simple_revert_context revert_arg { - $$ = MAKE_SYNTAX ("property-operation", @$, + $$ = MAKE_SYNTAX (property_operation, @$, $2, ly_symbol2scm ("RevertProperty"), scm_car ($3), @@ -2570,9 +2568,9 @@ music_property_def: } | SET context_prop_spec '=' scalar { if (SCM_UNBNDP ($2)) - $$ = MAKE_SYNTAX ("void-music", @$); + $$ = MAKE_SYNTAX (void_music, @$); else - $$ = MAKE_SYNTAX ("property-operation", @$, + $$ = MAKE_SYNTAX (property_operation, @$, scm_car ($2), ly_symbol2scm ("PropertySet"), scm_cadr ($2), @@ -2580,9 +2578,9 @@ music_property_def: } | UNSET context_prop_spec { if (SCM_UNBNDP ($2)) - $$ = MAKE_SYNTAX ("void-music", @$); + $$ = MAKE_SYNTAX (void_music, @$); else - $$ = MAKE_SYNTAX ("property-operation", @$, + $$ = MAKE_SYNTAX (property_operation, @$, scm_car ($2), ly_symbol2scm ("PropertyUnset"), scm_cadr ($2)); @@ -2618,8 +2616,7 @@ symbol: { // This is a bit of overkill but makes the same // routine responsible for all symbol interpretations. - $$ = try_string_variants (ly_lily_module_constant ("symbol?"), - $1); + $$ = try_string_variants (Guile_user::symbol_p, $1); if (SCM_UNBNDP ($$)) { parser->parser_error (@1, (_ ("symbol expected"))); @@ -2660,13 +2657,13 @@ event_chord: | CHORD_REPETITION optional_notemode_duration post_events { Input i; i.set_location (@1, @3); - $$ = MAKE_SYNTAX ("repetition-chord", i, + $$ = MAKE_SYNTAX (repetition_chord, i, $2, scm_reverse_x ($3, SCM_EOL)); } %prec ':' | MULTI_MEASURE_REST optional_notemode_duration post_events { Input i; i.set_location (@1, @3); - $$ = MAKE_SYNTAX ("multi-measure-rest", i, $2, + $$ = MAKE_SYNTAX (multi_measure_rest, i, $2, scm_reverse_x ($3, SCM_EOL)); } %prec ':' | tempo_event @@ -2695,11 +2692,11 @@ note_chord_element: chord_body: ANGLE_OPEN chord_body_elements ANGLE_CLOSE { - $$ = MAKE_SYNTAX ("event-chord", @$, scm_reverse_x ($2, SCM_EOL)); + $$ = MAKE_SYNTAX (event_chord, @$, scm_reverse_x ($2, SCM_EOL)); } | FIGURE_OPEN figure_list FIGURE_CLOSE { - $$ = MAKE_SYNTAX ("event-chord", @$, scm_reverse_x ($2, SCM_EOL)); + $$ = MAKE_SYNTAX (event_chord, @$, scm_reverse_x ($2, SCM_EOL)); } ; @@ -2772,8 +2769,8 @@ music_function_chord_body: event_function_event: EVENT_FUNCTION function_arglist { - $$ = MAKE_SYNTAX ("music-function", @$, - $1, $2); + $$ = MAKE_SYNTAX (music_function, @$, + $1, $2); } ; @@ -3279,9 +3276,9 @@ pitch_or_music: SCM elts = ly_append2 ($1, scm_reverse_x ($2, SCM_EOL)); - $$ = MAKE_SYNTAX ("event-chord", @1, elts); + $$ = MAKE_SYNTAX (event_chord, @1, elts); } else if (!unsmob ($1)) - $$ = MAKE_SYNTAX ("event-chord", @1, $1); + $$ = MAKE_SYNTAX (event_chord, @1, $1); // A mere pitch drops through. } %prec ':' ; @@ -3325,7 +3322,7 @@ lyric_element: lyric_element_music: lyric_element optional_notemode_duration post_events { - $$ = MAKE_SYNTAX ("lyric-event", @$, $1, $2); + $$ = MAKE_SYNTAX (lyric_event, @$, $1, $2); if (scm_is_pair ($3)) unsmob ($$)->set_property ("articulations", scm_reverse_x ($3, SCM_EOL)); @@ -3532,11 +3529,11 @@ full_markup: markup_top: markup_list { - $$ = scm_list_2 (ly_lily_module_constant ("line-markup"), $1); + $$ = scm_list_2 (Lily::line_markup, $1); } | markup_head_1_list simple_markup { - $$ = scm_car (MAKE_SYNTAX ("composed-markup-list", + $$ = scm_car (MAKE_SYNTAX (composed_markup_list, @2, $1, scm_list_1 ($2))); } | simple_markup { @@ -3588,14 +3585,14 @@ markup_uncomposed_list: sc->add_output_def (od); od->unprotect (); } - $$ = scm_list_1 (scm_list_2 (ly_lily_module_constant ("score-lines-markup-list"), $4)); + $$ = scm_list_1 (scm_list_2 (Lily::score_lines_markup_list, $4)); parser->lexer_->pop_state (); } ; markup_composed_list: markup_head_1_list markup_uncomposed_list { - $$ = MAKE_SYNTAX ("composed-markup-list", + $$ = MAKE_SYNTAX (composed_markup_list, @2, $1, $2); } ; @@ -3671,7 +3668,7 @@ simple_markup: sc->add_output_def (od); od->unprotect (); } - $$ = scm_list_2 (ly_lily_module_constant ("score-markup"), $4); + $$ = scm_list_2 (Lily::score_markup, $4); parser->lexer_->pop_state (); } | MARKUP_FUNCTION markup_command_basic_arguments { @@ -3686,7 +3683,7 @@ simple_markup: markup: markup_head_1_list simple_markup { - $$ = scm_car (MAKE_SYNTAX ("composed-markup-list", + $$ = scm_car (MAKE_SYNTAX (composed_markup_list, @2, $1, scm_list_1 ($2))); } | simple_markup { @@ -3705,7 +3702,7 @@ Lily_parser::set_yydebug (bool x) SCM Lily_parser::do_yyparse () { - return scm_c_with_fluid (ly_lily_module_constant ("%parser"), + return scm_c_with_fluid (Lily::f_parser, self_scm (), do_yyparse_trampoline, static_cast (this)); @@ -3811,7 +3808,7 @@ SCM check_scheme_arg (Lily_parser *parser, Input loc, return args; } scm_set_cdr_x (scm_last_pair (args), SCM_EOL); - MAKE_SYNTAX ("argument-error", loc, scm_length (args), pred, + MAKE_SYNTAX (argument_error, loc, scm_length (args), pred, SCM_UNBNDP (disp) ? arg : disp); scm_set_cdr_x (scm_last_pair (args), SCM_BOOL_F); return args; @@ -3916,12 +3913,12 @@ make_music_from_simple (Lily_parser *parser, Input loc, SCM simple) return simple; } else if (parser->lexer_->is_lyric_state ()) { if (Text_interface::is_markup (simple)) - return MAKE_SYNTAX ("lyric-event", loc, simple, + return MAKE_SYNTAX (lyric_event, loc, simple, parser->default_duration_.smobbed_copy ()); } else if (parser->lexer_->is_chord_state ()) { if (unsmob (simple)) return MAKE_SYNTAX - ("event-chord", + (event_chord, loc, make_chord_elements (loc, simple, parser->default_duration_.smobbed_copy (), @@ -3972,8 +3969,7 @@ make_chord_step (SCM step_scm, Rational alter) SCM make_chord_elements (Input loc, SCM pitch, SCM dur, SCM modification_list) { - SCM chord_ctor = ly_lily_module_constant ("construct-chord-elements"); - SCM res = scm_call_3 (chord_ctor, pitch, dur, modification_list); + SCM res = Lily::construct_chord_elements (pitch, dur, modification_list); for (SCM s = res; scm_is_pair (s); s = scm_cdr (s)) { unsmob (scm_car (s))->set_spot (loc); diff --git a/lily/part-combine-iterator.cc b/lily/part-combine-iterator.cc index beffa45135..8754effd29 100644 --- a/lily/part-combine-iterator.cc +++ b/lily/part-combine-iterator.cc @@ -24,6 +24,7 @@ #include "music-iterator.hh" #include "music-sequence.hh" #include "warn.hh" +#include "lily-imports.hh" static const char *const CONTEXT_ONE = "one"; static const char *const CONTEXT_TWO = "two"; @@ -201,8 +202,7 @@ Part_combine_iterator::kill_mmrest (Context *c) if (!mmrest_event_) { mmrest_event_ = new Stream_event - (scm_call_1 (ly_lily_module_constant ("ly:make-event-class"), - ly_symbol2scm ("multi-measure-rest-event"))); + (Lily::ly_make_event_class (ly_symbol2scm ("multi-measure-rest-event"))); mmrest_event_->set_property ("duration", SCM_EOL); mmrest_event_->unprotect (); } diff --git a/lily/partial-iterator.cc b/lily/partial-iterator.cc index 798dd3f069..80048d827c 100644 --- a/lily/partial-iterator.cc +++ b/lily/partial-iterator.cc @@ -24,6 +24,7 @@ #include "moment.hh" #include "music.hh" #include "simple-music-iterator.hh" +#include "lily-imports.hh" class Partial_iterator : public Simple_music_iterator { @@ -53,9 +54,8 @@ Partial_iterator::process (Moment m) // measurePosition when initializing. Context *timing = unsmob - (scm_call_2 (ly_lily_module_constant ("ly:context-find"), - get_outlet ()->self_scm (), - ly_symbol2scm ("Timing"))); + (Lily::ly_context_find (get_outlet ()->self_scm (), + ly_symbol2scm ("Timing"))); if (!timing) programming_error ("missing Timing in \\partial"); @@ -92,9 +92,7 @@ Partial_iterator::finalization (SCM ctx, SCM length) LY_ASSERT_SMOB (Context, ctx, 1); LY_ASSERT_SMOB (Moment, length, 2); Context *timing = unsmob - (scm_call_2 (ly_lily_module_constant ("ly:context-find"), - ctx, - ly_symbol2scm ("Timing"))); + (Lily::ly_context_find (ctx, ly_symbol2scm ("Timing"))); if (!timing) { programming_error ("missing Timing in \\partial"); return SCM_UNSPECIFIED; diff --git a/lily/percent-repeat-iterator.cc b/lily/percent-repeat-iterator.cc index 9d64e65561..00f21af4d6 100644 --- a/lily/percent-repeat-iterator.cc +++ b/lily/percent-repeat-iterator.cc @@ -22,6 +22,7 @@ #include "input.hh" #include "repeated-music.hh" #include "sequential-iterator.hh" +#include "lily-imports.hh" class Percent_repeat_iterator : public Sequential_iterator { @@ -59,9 +60,7 @@ Percent_repeat_iterator::get_music_list () const event_type = "DoublePercentEvent"; else { - slash_count - = scm_call_1 (ly_lily_module_constant ("calc-repeat-slash-count"), - child->self_scm ()); + slash_count = Lily::calc_repeat_slash_count (child->self_scm ()); event_type = "RepeatSlashEvent"; } diff --git a/lily/program-option-scheme.cc b/lily/program-option-scheme.cc index 80cd0e4e2f..3934217fb3 100644 --- a/lily/program-option-scheme.cc +++ b/lily/program-option-scheme.cc @@ -29,6 +29,7 @@ using namespace std; #include "parse-scm.hh" #include "string-convert.hh" #include "warn.hh" +#include "lily-imports.hh" bool debug_skylines; bool debug_property_callbacks; @@ -136,7 +137,6 @@ static string get_help_string () { SCM alist = ly_hash2alist (option_hash); - SCM converter = ly_lily_module_constant ("scm->string"); vector opts; @@ -147,7 +147,7 @@ get_help_string () string opt_spec = String_convert::char_string (' ', INDENT) + ly_symbol2string (sym) + " (" - + ly_scm2string (scm_call_1 (converter, val)) + + ly_scm2string (Lily::scm_to_string (val)) + ")"; if (opt_spec.length () + SEPARATION > HELP_INDENT) diff --git a/lily/rest-collision.cc b/lily/rest-collision.cc index 86de7a9c3d..300dcfc3c4 100644 --- a/lily/rest-collision.cc +++ b/lily/rest-collision.cc @@ -36,6 +36,7 @@ using namespace std; #include "grob.hh" #include "unpure-pure-container.hh" #include "warn.hh" +#include "lily-imports.hh" MAKE_SCHEME_CALLBACK_WITH_OPTARGS (Rest_collision, force_shift_callback_rest, 2, 1, ""); SCM @@ -75,7 +76,7 @@ Rest_collision::add_column (Grob *me, Grob *p) chain_offset_callback (rest, Unpure_pure_container::make_smob (Rest_collision::force_shift_callback_rest_proc, - ly_lily_module_constant ("pure-chain-offset-callback")), + Lily::pure_chain_offset_callback), Y_AXIS); } } diff --git a/lily/span-bar-engraver.cc b/lily/span-bar-engraver.cc index 732c206f3c..d8f7590ea5 100644 --- a/lily/span-bar-engraver.cc +++ b/lily/span-bar-engraver.cc @@ -20,6 +20,7 @@ #include "item.hh" #include "engraver.hh" #include "pointer-group-interface.hh" +#include "lily-imports.hh" /** @@ -85,7 +86,7 @@ Span_bar_engraver::stop_translation_timestep () SCM vis = bars_[0]->get_property ("break-visibility"); if (ly_is_equal (spanbar_->get_property ("break-visibility"), vis)) spanbar_->set_property ("break-visibility", vis); - scm_call_1 (ly_lily_module_constant ("span-bar::notify-grobs-of-my-existence"), spanbar_->self_scm ()); + Lily::span_bar_notify_grobs_of_my_existence (spanbar_->self_scm ()); spanbar_ = 0; } bars_.resize (0); diff --git a/lily/staff-performer.cc b/lily/staff-performer.cc index f635130b70..7874e50db3 100644 --- a/lily/staff-performer.cc +++ b/lily/staff-performer.cc @@ -27,6 +27,7 @@ #include "international.hh" #include "performer-group.hh" #include "warn.hh" +#include "lily-imports.hh" /* Perform a staff. Individual notes should have their instrument (staff-wide) set, so we override play_element () @@ -199,8 +200,7 @@ Staff_performer::set_instrument (int channel, const string &voice) announce_element (Audio_element_info (instrument_, 0)); Audio_staff *audio_staff = get_audio_staff (voice); audio_staff->add_audio_item (instrument_); - SCM proc = ly_lily_module_constant ("percussion?"); - SCM drums = scm_call_1 (proc, ly_symbol2scm (instrument_string_.c_str ())); + SCM drums = Lily::percussion_p (ly_symbol2scm (instrument_string_.c_str ())); audio_staff->percussion_ = to_boolean (drums); } diff --git a/lily/system.cc b/lily/system.cc index d30a5f3429..528135ad60 100644 --- a/lily/system.cc +++ b/lily/system.cc @@ -40,6 +40,7 @@ #include "text-interface.hh" #include "warn.hh" #include "unpure-pure-container.hh" +#include "lily-imports.hh" System::System (System const &src) : Spanner (src) @@ -327,8 +328,8 @@ System::internal_get_note_heights_in_range (vsize start, vsize end, bool foot) if (!Text_interface::is_markup (footnote_markup)) continue; - SCM props = scm_call_1 (ly_lily_module_constant ("layout-extract-page-properties"), - pscore_->layout ()->self_scm ()); + SCM props = + Lily::layout_extract_page_properties (pscore_->layout ()->self_scm ()); SCM footnote_stl = Text_interface::interpret_markup (pscore_->layout ()->self_scm (), props, footnote_markup); diff --git a/lily/text-interface.cc b/lily/text-interface.cc index 138ede129e..4598246163 100644 --- a/lily/text-interface.cc +++ b/lily/text-interface.cc @@ -33,6 +33,7 @@ #include "program-option.hh" #include "international.hh" #include "warn.hh" +#include "lily-imports.hh" static void replace_special_characters (string &str, SCM props) @@ -89,7 +90,7 @@ Text_interface::interpret_string (SCM layout_smob, SCM encoding = ly_chain_assoc_get (ly_symbol2scm ("font-encoding"), props, SCM_BOOL_F); - SCM music_encodings = ly_lily_module_constant ("all-music-font-encodings"); + SCM music_encodings = Lily::all_music_font_encodings; bool is_music = scm_is_true (scm_memq (encoding, music_encodings)); return fm->text_stencil (layout, str, is_music).smobbed_copy (); @@ -183,8 +184,7 @@ Text_interface::is_markup (SCM x) bool Text_interface::is_markup_list (SCM x) { - SCM music_list_p = ly_lily_module_constant ("markup-list?"); - return scm_is_true (scm_call_1 (music_list_p, x)); + return scm_is_true (Lily::markup_list_p (x)); } ADD_INTERFACE (Text_interface, diff --git a/lily/timing-translator.cc b/lily/timing-translator.cc index a041bfff84..06d7da7916 100644 --- a/lily/timing-translator.cc +++ b/lily/timing-translator.cc @@ -23,6 +23,7 @@ #include "translator-group.hh" #include "global-context.hh" #include "moment.hh" +#include "lily-imports.hh" void Timing_translator::stop_translation_timestep () @@ -47,9 +48,8 @@ Timing_translator::stop_translation_timestep () void Timing_translator::initialize () { - Context *timing = unsmob (scm_call_2 (ly_lily_module_constant ("ly:context-find"), - context ()->self_scm (), - ly_symbol2scm ("Timing"))); + Context *timing = unsmob + (Lily::ly_context_find (context ()->self_scm (), ly_symbol2scm ("Timing"))); if (timing != context ()) { context ()->add_alias (ly_symbol2scm ("Timing")); @@ -100,17 +100,15 @@ Timing_translator::initialize () // since it does not track changes of the variable. However, // this is still better than nothing, and we already complained // via a programming_error - timeSignatureSettings = ly_lily_module_constant ("default-time-signature-settings"); + timeSignatureSettings = Lily::default_time_signature_settings; } context ()->set_property ("timeSignatureSettings", timeSignatureSettings); SCM beamExceptions = timing->get_property ("beamExceptions"); if (!scm_is_pair (beamExceptions)) { - beamExceptions = - scm_call_2 (ly_lily_module_constant ("beam-exceptions"), - timeSignatureFraction, - timeSignatureSettings); + beamExceptions = Lily::beam_exceptions (timeSignatureFraction, + timeSignatureSettings); } context ()->set_property ("beamExceptions", beamExceptions); @@ -119,9 +117,8 @@ Timing_translator::initialize () { baseMoment = Moment (ly_scm2rational - (scm_call_2 (ly_lily_module_constant ("base-length"), - timeSignatureFraction, - timeSignatureSettings))).smobbed_copy (); + (Lily::base_length (timeSignatureFraction, + timeSignatureSettings))).smobbed_copy (); } context ()->set_property ("baseMoment", baseMoment); @@ -129,10 +126,9 @@ Timing_translator::initialize () if (!scm_is_pair (beatStructure)) { beatStructure = - scm_call_3 (ly_lily_module_constant ("beat-structure"), - ly_rational2scm (unsmob (baseMoment)->main_part_), - timeSignatureFraction, - timeSignatureSettings); + Lily::beat_structure (ly_rational2scm (unsmob (baseMoment)->main_part_), + timeSignatureFraction, + timeSignatureSettings); } context ()->set_property ("beatStructure", beatStructure); diff --git a/lily/tuplet-iterator.cc b/lily/tuplet-iterator.cc index 79ee9241b4..c43e630c43 100644 --- a/lily/tuplet-iterator.cc +++ b/lily/tuplet-iterator.cc @@ -24,6 +24,7 @@ #include "music.hh" #include "music-wrapper-iterator.hh" #include "stream-event.hh" +#include "lily-imports.hh" /* Iterates \times, by sending TupletSpanEvents at the start/end of each @@ -62,9 +63,8 @@ private: Music * Tuplet_iterator::create_event (Direction d) { - SCM ev_scm = scm_call_2 (ly_lily_module_constant ("make-span-event"), - ly_symbol2scm ("TupletSpanEvent"), - scm_from_int (d)); + SCM ev_scm = Lily::make_span_event (ly_symbol2scm ("TupletSpanEvent"), + scm_from_int (d)); Music *mus = get_music (); diff --git a/lily/volta-bracket.cc b/lily/volta-bracket.cc index 08a578de75..9ac2b44637 100644 --- a/lily/volta-bracket.cc +++ b/lily/volta-bracket.cc @@ -32,6 +32,7 @@ using namespace std; #include "directional-element-interface.hh" #include "lookup.hh" #include "tuplet-bracket.hh" +#include "lily-imports.hh" /* this is too complicated. Yet another version of side-positioning, @@ -137,8 +138,8 @@ Volta_bracket_interface::modify_edge_height (Spanner *me) else str = "|"; - no_vertical_end |= ly_scm2bool (scm_call_1 (ly_lily_module_constant ("volta-bracket::calc-hook-visibility"), - ly_string2scm (str))); + no_vertical_end |= ly_scm2bool (Lily::volta_bracket_calc_hook_visibility + (ly_string2scm (str))); if (no_vertical_end || no_vertical_start) { diff --git a/lily/volta-repeat-iterator.cc b/lily/volta-repeat-iterator.cc index bcbc34f8cb..85a2c127ab 100644 --- a/lily/volta-repeat-iterator.cc +++ b/lily/volta-repeat-iterator.cc @@ -20,6 +20,7 @@ #include "music.hh" #include "sequential-iterator.hh" #include "context.hh" +#include "lily-imports.hh" class Volta_repeat_iterator : public Sequential_iterator { @@ -137,7 +138,7 @@ Volta_repeat_iterator::next_element (bool side_effect) if (to_boolean (get_outlet ()->get_property ("timing"))) { for (SCM p = alt_restores_; scm_is_pair (p); p = scm_cdr (p)) - scm_apply_0 (ly_lily_module_constant ("ly:context-set-property!"), + scm_apply_0 (Lily::ly_context_set_property_x, scm_car (p)); } } -- 2.39.2