]> git.donarmstrong.com Git - lilypond.git/commitdiff
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)
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

index 601f7bccb08df7d22a0f5a0ed4f2bd2cf0c85a90..d95ea1ae3c3920e5c3c1ed45a14df618a9e38fbc 100644 (file)
@@ -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);
index 540bcd5f7bd3bd71cfcaaa0a3506bab52ebc83e4..940a18d2010849e27ecf73b66f99361aa6a3260c 100644 (file)
@@ -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")))
index 416a5ccbcf9cba2d236b11ba8032bc7007f7c313..192cdaa3ee8e1a7b6eaa7cb2f18ee59c97165236 100644 (file)
@@ -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]);
index 1d5c759596b79fb1d8c027273e3423ea1db9b30b..8f938d6f91a8bcd86a3721128bf0ba5c11920619 100644 (file)
@@ -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 ("#<Dispatcher ", p);
-  scm_write (scm_call_1 (ly_lily_module_constant ("hash-table->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);
 }
 
index b38ff9268a29ba41e0d284386819c260db6e1971..5045a8276ebf4c460ec10e7c4e714c1b5cc17d2b 100644 (file)
@@ -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 *
index c9080f4fb7a6241865fb356c16e14370f9c88e6e..978cbeb76cdd471ef973bfa2a016994aa7f3a2a5 100644 (file)
@@ -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<Simple_closure> (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));
 }
 
index 2f5357a0aedfda212475b987322a0085022bac35..e43c71186c14f591251bc06907bdbfebfd9dc708 100644 (file)
@@ -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<Stencil> (scm_call_2 (wh_proc,
-                                                 retval.smobbed_copy (),
-                                                 scm_from_double (thickness)));
+          retval = *unsmob<Stencil>
+            (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<Stencil> (scm_call_1 (wh_proc,
-                                                 retval.smobbed_copy ()));
+          retval = *unsmob<Stencil>
+            (Lily::stencil_whiteout_box (retval.smobbed_copy ()));
         }
 
       if (transparent)
index 86a998e9ab5c71ab23fda0465067c33650ebf8b8..3259a465775cb5adab71b1a2409731e1f4d9c892 100644 (file)
@@ -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");
 }
index 44e908e6672abfaff89b24396b63a2b32f1e1366..eb7ebfbae0c91d4dadd35a33d4f600ddf4ed762b 100644 (file)
 // 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
index 9c6e59332fbf930615e95aee811078ae402e569e..869a52af327c137a72b634e8ac837630f94acfd8 100644 (file)
@@ -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
index e6a3d41483da9310e505ab3c55b0e65fcb379c51..34578511b8388700b38f7c4bacfe02605ded908f 100644 (file)
@@ -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 (file)
index 0000000..68b8102
--- /dev/null
@@ -0,0 +1,126 @@
+/*
+  This file is part of LilyPond, the GNU music typesetter.
+
+  Copyright (C) 2015 by David Kastrup <dak@gnu.org>
+
+  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 <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef LILY_IMPORTS_HH
+#define LILY_IMPORTS_HH
+
+#include "lily-modules.hh"
+
+namespace Guile_user {
+  extern Scm_module module;
+  typedef Module_variable<module> 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<module> Variable;
+
+  extern Variable value_to_lily_string;
+}
+
+namespace Lily {
+  extern Scm_module module;
+  typedef Module_variable<module> 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 (file)
index 0000000..1eb7cf7
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+  This file is part of LilyPond, the GNU music typesetter.
+
+  Copyright (C) 2015 by David Kastrup <dak@gnu.org>
+
+  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 <http://www.gnu.org/licenses/>.
+*/
+
+#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 <Scm_module &m>
+class Module_variable : public Scm_variable
+{
+public:
+  Module_variable (const char *name, SCM value = SCM_UNDEFINED)
+    : Scm_variable (m, name, value)
+  { }
+};
+
+#endif
index a76022b434095ecf6c54f5f0f351aa4e860887c0..afb6beba2a3bf3ac5947c1507003ff1d300c0c37 100644 (file)
@@ -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;
index fa76c883a47989f98e01c5778c386040ea451125..06666ac53257083095af1323b62df7ec531d0dfa 100644 (file)
@@ -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)),
index 89695f7c5f6d39247ee95e6011bbfae41f908019..56af49da39b9c4ce0bd789b14a1e812f5bac1e94 100644 (file)
@@ -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));
index 3c09299b4b857983fbeabfc5248efd38ff24c925..b8faf78e31ee7e9bf5ed8283bb721df090c52a97 100644 (file)
@@ -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.  */
index 3408291c663b88c85cc86ae1e41cd816f7ec8528..bde39214b39faff40af98548533a3ed7a6bb716b 100644 (file)
@@ -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 (file)
index 0000000..37a9257
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+  This file is part of LilyPond, the GNU music typesetter.
+
+  Copyright (C) 2015 by David Kastrup <dak@gnu.org>
+
+  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 <http://www.gnu.org/licenses/>.
+*/
+
+#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 (file)
index 0000000..f34e7e3
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+  This file is part of LilyPond, the GNU music typesetter.
+
+  Copyright (C) 2015 by David Kastrup <dak@gnu.org>
+
+  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 <http://www.gnu.org/licenses/>.
+*/
+
+#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<Scm_module *> (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 <void *> (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);
+}
index 4d922404ce6c4ce999486f0bd9c3f1a39ceba637..ea84aae41a247f99fb3151a1558337e9f8ae4886 100644 (file)
@@ -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<Lily_parser> (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_);
index 84b6858f75008485dda482b353724c286f2f92ce..2076168fda75ac9ad9c73004d611bb24ebc881af 100644 (file)
@@ -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! <mod> (module-public-interface <used>))'
   */
-  SCM expr = scm_list_3 (scm_module_use, mod, iface);
-  /*
-    Now return SCM value, this is the result of interpreting
-    '(eval (module-use! <mod> (module-public-interface <used>)) "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
index 69af225c7651f4c117b34b050abcea564aa1a1d2..d84f90ebd8ab55c85395adbdd6b750bb0d334f19 100644 (file)
@@ -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);
index d85161676cc3943e42a669b56d88ba2e187c80c4..a08c60b89a4c7ccfc80c6265f8ed84cfa2686e5d 100644 (file)
@@ -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);
index f926c44c0265e4992efb92a63b7f8886fe91d8c0..8ea17ddb26d6d434594ac59e4459669ed0972190 100644 (file)
@@ -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);
index d8f7d3a27cde9768bb489431ef62def04da65e26..d58e324590f12c6abaf770d6235ec5f900d288d6 100644 (file)
@@ -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);
 }
index 613b5387ff772989ad19adf62b0338c89ba33553..a1accb9c3d4a8fb5485a5a06d4c832fa445eb898 100644 (file)
@@ -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<Music> (rv);
index 1e79ba0ec528386e740dc879239321b4e33267d4..3f4fca05f1fddfb8be11561dc51a71154b465bdb 100644 (file)
@@ -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");
 
index 78d51a0caacc78f5ab6fc4861452db73a50ab118..e23ef527772cbe2dc61d192ab2485673e8d0f7ab 100644 (file)
@@ -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))
index 5329d305553f19909bccdfdd1dfaa7f619c6c84d..0f6efc6b75ca457b821c2c718e379531d2c02aab 100644 (file)
@@ -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<Output_def> (new_pap);
   o->protect ();
index 5da493ba48e2a0fbf6bb43782424eee3f9f64d4c..a72ea59ccdef770d8f70c32f942a42ee4fe8a6d9 100644 (file)
@@ -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_);
     }
 }
index 9db184c2ae0f107fcad38f2e13151a95d94a7c2d..576591dc97265e2a77dd93bcfa7c61b7ee48ecba 100644 (file)
@@ -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);
index 8d8d7de15035b2c5c4e49a169c14818739798523..8c08819d7dd9b52aaea3568ae2bcdf8604671796 100644 (file)
@@ -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 <void*> (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<Music> ($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<Score> ($$)) {
                        if (unsmob<Music> ($2)) {
-                               SCM scorify = ly_lily_module_constant ("scorify-music");
-                               $2 = scm_call_1 (scorify, $2);
+                               $2 = Lily::scorify_music ($2);
                        }
                        if (unsmob<Score> ($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<Music> ($$))
                {
                         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<Context_mod> ($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<Pitch> ($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<Music> ($$)->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 <void *>(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<Pitch> (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<Music> (scm_car (s))->set_spot (loc);
index beffa45135acc941b9825c2e6c5551045fce12a7..8754effd295eef87581097a558f97a0626a7f967 100644 (file)
@@ -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 ();
     }
index 798dd3f069017a313911a937643e4cd7bb1dae15..80048d827c87bcec64bdefc0615e041d93409533 100644 (file)
@@ -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<Context>
-                        (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<Context>
-    (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;
index 9d64e6556153ee476e988b40bf054cd22a45dbdb..00f21af4d6969f60f7190f4914c95f0683639b38 100644 (file)
@@ -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";
     }
 
index 80cd0e4e2fc25193c5ecc327c726a626700db83f..3934217fb3c9b64ade82becc20aaff47e036ef6d 100644 (file)
@@ -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<string> 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)
index 86de7a9c3d7f2588880a64a0d1862ebf4a81f3ad..300dcfc3c40d160238f8c4bcc3f00a55667916cb 100644 (file)
@@ -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);
     }
 }
index 732c206f3c0dc0a404f34916a68f95c9df6eec52..d8f7590ea551248d35174a87875d63f074e4fbe3 100644 (file)
@@ -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);
index f635130b70267db6d154432c18447a3dc76acd92..7874e50db38230f697479a376c23eeec35da902a 100644 (file)
@@ -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);
 }
 
index d30a5f342909fedf384769e446c7a471b1acbf73..528135ad60d046b2b02d7f77640381450f368664 100644 (file)
@@ -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);
index 138ede129ebbec443bd9942b300d259c8ab2fd28..4598246163af04abbab830d2e6bf23f0186aaa9a 100644 (file)
@@ -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,
index a041bfff843c444344aa2ac3522d80dcd7e394a0..06d7da791663ac1f8f9e83d6efbab4ca7d874916 100644 (file)
@@ -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<Context> (scm_call_2 (ly_lily_module_constant ("ly:context-find"),
-                                                context ()->self_scm (),
-                                                ly_symbol2scm ("Timing")));
+  Context *timing = unsmob<Context>
+    (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<Moment> (baseMoment)->main_part_),
-                    timeSignatureFraction,
-                    timeSignatureSettings);
+        Lily::beat_structure (ly_rational2scm (unsmob<Moment> (baseMoment)->main_part_),
+                              timeSignatureFraction,
+                              timeSignatureSettings);
     }
   context ()->set_property ("beatStructure", beatStructure);
 
index 79ee9241b4b9974251b60ba4dd8497669b1f9ac6..c43e630c4384e51f4c0acf44a158918fb5467df8 100644 (file)
@@ -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 ();
 
index 08a578de75e0bd04d7e2a878f181e621a9a62c86..9ac2b44637f5fab3d24cd0d6235ea384d6faada9 100644 (file)
@@ -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)
     {
index bcbc34f8cb3b9d3800436d495ac33c8ce65cc6e9..85a2c127ab6b570da98256a930b9e1d0bd0bd794 100644 (file)
@@ -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));
                     }
                 }