From: Han-Wen Nienhuys Date: Sun, 10 Jul 2005 11:25:24 +0000 (+0000) Subject: * scm/define-music-types.scm (music-descriptions): don't use X-Git-Tag: release/2.7.1~49 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=7c93f8e815a77c7735d0ab0f3cc4b21c19a10199;p=lilypond.git * scm/define-music-types.scm (music-descriptions): don't use Music_wrapper type. * lily/paper-column.cc (print): print moment too. * scripts/mup2ly.py (cp_to_dir): remove 1.5.2 compat glue. remove compatibility cruft. * lily/parser.yy (score_body): \score can only begin with Music. * lily/score-scheme.cc (LY_DEFINE): rename scorify to make-score. Take music argument only. Move parser interaction to Scheme. * scm/lily-library.scm (scorify-music): new function. * python/lilylib.py (datadir): remove 2.1 compat kludge. (datadir): remove resource import. (print_environment): remove get_bbox() (cp_to_dir): remove pre 1.5.2 compat glue. --- diff --git a/ChangeLog b/ChangeLog index 5356f333dd..227490fee4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,26 @@ +2005-07-10 Han-Wen Nienhuys + + * scm/define-music-types.scm (music-descriptions): don't use + Music_wrapper type. + + * lily/paper-column.cc (print): print moment too. + + * scripts/mup2ly.py (cp_to_dir): remove 1.5.2 compat glue. + remove compatibility cruft. + + * lily/parser.yy (score_body): \score can only begin with Music. + + * lily/score-scheme.cc (LY_DEFINE): rename scorify to + make-score. Take music argument only. Move parser interaction to + Scheme. + + * scm/lily-library.scm (scorify-music): new function. + + * python/lilylib.py (datadir): remove 2.1 compat kludge. + (datadir): remove resource import. + (print_environment): remove get_bbox() + (cp_to_dir): remove pre 1.5.2 compat glue. + 2005-07-09 Han-Wen Nienhuys * lily/include/simple-spacer.hh (Module): idem. diff --git a/lily/include/music-wrapper.hh b/lily/include/music-wrapper.hh index 05ba1ae390..ca57666779 100644 --- a/lily/include/music-wrapper.hh +++ b/lily/include/music-wrapper.hh @@ -9,23 +9,13 @@ #ifndef MUSIC_WRAPPER_HH #define MUSIC_WRAPPER_HH -#include "music.hh" -#include "pitch.hh" +#include "lily-guile.hh" -/** A Music that modifies an existing Music. This data structure - corresponds to a production that takes a single Music argument, - - Music: STUFF Music -*/ -class Music_wrapper : public Music +struct Music_wrapper { public: - Music_wrapper (SCM); - VIRTUAL_COPY_CONSTRUCTOR (Music, Music_wrapper); DECLARE_SCHEME_CALLBACK (length_callback, (SCM)); DECLARE_SCHEME_CALLBACK (start_callback, (SCM)); - - Music *element () const; }; #endif /* MUSIC_WRAPPER_HH */ diff --git a/lily/include/score.hh b/lily/include/score.hh index ed6aecddd2..91facb5abf 100644 --- a/lily/include/score.hh +++ b/lily/include/score.hh @@ -34,14 +34,13 @@ public: Score (Score const &); SCM get_music () const; - void set_music (SCM music, SCM parser); + void set_music (SCM music); SCM book_rendering (Output_def *, Output_def *, Object_key *); }; DECLARE_UNSMOB (Score, score); void default_rendering (SCM, SCM, SCM, SCM, SCM, SCM); -SCM ly_music_scorify (SCM, SCM); SCM ly_render_output (SCM, SCM); SCM ly_run_translator (SCM, SCM, SCM); diff --git a/lily/music-wrapper-iterator.cc b/lily/music-wrapper-iterator.cc index e20a6261f5..15dde8a3d5 100644 --- a/lily/music-wrapper-iterator.cc +++ b/lily/music-wrapper-iterator.cc @@ -37,8 +37,9 @@ Music_wrapper_iterator::derived_substitute (Context *f, Context *t) void Music_wrapper_iterator::construct_children () { - Music *m = dynamic_cast (get_music ())->element (); - child_iter_ = unsmob_iterator (get_iterator (m)); + Music *my_music = get_music (); + Music *child = unsmob_music (my_music->get_property ("element")); + child_iter_ = unsmob_iterator (get_iterator (child)); } bool diff --git a/lily/music-wrapper.cc b/lily/music-wrapper.cc index 7106707d5a..8123897171 100644 --- a/lily/music-wrapper.cc +++ b/lily/music-wrapper.cc @@ -8,14 +8,8 @@ #include "music-wrapper.hh" -Music_wrapper::Music_wrapper (SCM x) - : Music (x) -{ - if (!ly_c_procedure_p (length_callback_)) - length_callback_ = length_callback_proc; - if (!ly_c_procedure_p (start_callback_)) - start_callback_ = length_callback_proc; -} +#include "music.hh" + MAKE_SCHEME_CALLBACK (Music_wrapper, start_callback, 1); SCM @@ -35,11 +29,3 @@ Music_wrapper::length_callback (SCM m) return elt->get_length ().smobbed_copy (); } -Music * -Music_wrapper::element () const -{ - return unsmob_music (get_property ("element")); -} - -ADD_MUSIC (Music_wrapper); - diff --git a/lily/music.cc b/lily/music.cc index 2c631d25d1..304f658e4b 100644 --- a/lily/music.cc +++ b/lily/music.cc @@ -112,7 +112,7 @@ Music::get_length () const Moment Music::start_mom () const { - SCM lst = get_property ("start-callback"); + SCM lst = start_callback_; if (ly_c_procedure_p (lst)) { SCM res = scm_call_1 (lst, self_scm ()); diff --git a/lily/paper-column.cc b/lily/paper-column.cc index 26e7f5d0b6..a518e02c8f 100644 --- a/lily/paper-column.cc +++ b/lily/paper-column.cc @@ -118,12 +118,20 @@ Paper_column::print (SCM p) Grob *me = unsmob_grob (p); String r = to_string (Paper_column::get_rank (me)); + + Moment *mom = unsmob_moment (me->get_property ("when")); + String when = mom ? mom->to_string () : "?/?"; + SCM properties = Font_interface::text_font_alist_chain (me); SCM scm_mol = Text_interface::interpret_markup (me->get_layout ()->self_scm (), properties, scm_makfrom0str (r.to_str0 ())); + SCM when_mol = Text_interface::interpret_markup (me->get_layout ()->self_scm (), + properties, + scm_makfrom0str (when.to_str0 ())); Stencil t = *unsmob_stencil (scm_mol); + t.add_at_edge (Y_AXIS, DOWN, *unsmob_stencil (when_mol), 0.1, 0.1); t.align_to (X_AXIS, CENTER); t.align_to (Y_AXIS, DOWN); diff --git a/lily/parser.yy b/lily/parser.yy index 4d73b39b5d..b12b03e796 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -787,8 +787,15 @@ score_block: ; score_body: - /**/ { - $$ = new Score; + Music { + SCM m = $1->self_scm (); + scm_gc_unprotect_object (m); + SCM scorify = ly_lily_module_constant ("scorify-music"); + SCM score = scm_call_2 (scorify, m, THIS->self_scm ()); + + // pass ownernship to C++ again. + scm_gc_protect_object (score); + $$ = unsmob_score (score); $$->set_spot (@$); } | SCORE_IDENTIFIER { @@ -798,11 +805,6 @@ score_body: | score_body object_id_setting { $$->user_key_ = ly_scm2string ($2); } - | score_body Music { - SCM m = $2->self_scm (); - scm_gc_unprotect_object (m); - $$->set_music (m, THIS->self_scm ()); - } | score_body lilypond_header { $$->header_ = $2; } diff --git a/lily/score-scheme.cc b/lily/score-scheme.cc index fce8296dc9..19bac6c48a 100644 --- a/lily/score-scheme.cc +++ b/lily/score-scheme.cc @@ -11,16 +11,16 @@ #include "output-def.hh" #include "global-context.hh" -LY_DEFINE (ly_music_scorify, "ly:music-scorify", - 2, 0, 0, - (SCM music, SCM parser), - "Return @var{music} with @var{texts} encapsulated in @var{score}.") +LY_DEFINE (ly_make_score, "ly:make-score", + 1, 0, 0, + (SCM music), + "Return score with @var{music} encapsulated in @var{score}.") { Music *mus = unsmob_music (music); SCM_ASSERT_TYPE (mus, music, SCM_ARG1, __FUNCTION__, "music"); Score *score = new Score; - score->set_music (music, parser); + score->set_music (music); SCM self = score->self_scm (); scm_gc_unprotect_object (self); diff --git a/lily/score.cc b/lily/score.cc index a9029cb21f..6d86607e68 100644 --- a/lily/score.cc +++ b/lily/score.cc @@ -205,13 +205,8 @@ Score::book_rendering (Output_def *layoutbook, } void -Score::set_music (SCM music, SCM parser) +Score::set_music (SCM music) { - /* URG? */ - SCM check_funcs = ly_lily_module_constant ("toplevel-music-functions"); - for (; scm_is_pair (check_funcs); check_funcs = scm_cdr (check_funcs)) - music = scm_call_2 (scm_car (check_funcs), music, parser); - if (unsmob_music (music_)) { unsmob_music (music)->origin ()->error (_ ("already have music in score")); diff --git a/lily/unfolded-repeat-iterator.cc b/lily/unfolded-repeat-iterator.cc index c7a5db97f7..a0fef55567 100644 --- a/lily/unfolded-repeat-iterator.cc +++ b/lily/unfolded-repeat-iterator.cc @@ -1,9 +1,8 @@ /* - unfolded-repeat-iterator.cc -- implement Unfolded_repeat_iterator, Volta_repeat_iterator - + unfolded-repeat-iterator.cc -- implement Unfolded_repeat_iterator + source file of the GNU LilyPond music typesetter - (c) 2002--2005 Han-Wen Nienhuys */ @@ -50,114 +49,4 @@ Unfolded_repeat_iterator::get_music_list () const return l; } -class Volta_repeat_iterator : public Sequential_iterator -{ -public: - DECLARE_SCHEME_CALLBACK (constructor, ()); - Volta_repeat_iterator (); - - void add_repeat_command (SCM); -protected: - virtual SCM get_music_list () const; - virtual void next_element (bool); - virtual void construct_children (); - virtual void process (Moment); - - bool first_time_; - int alt_count_; - int rep_count_; - int done_count_; -}; - -Volta_repeat_iterator::Volta_repeat_iterator () -{ - done_count_ = alt_count_ = rep_count_ = 0; - first_time_ = true; -} - -SCM -Volta_repeat_iterator::get_music_list ()const -{ - return scm_cons (get_music ()->get_property ("element"), - get_music ()->get_property ("elements")); -} - -void -Volta_repeat_iterator::construct_children () -{ - Sequential_iterator::construct_children (); - - SCM alts = get_music ()->get_property ("elements"); - - alt_count_ = scm_ilength (alts); - rep_count_ = scm_to_int (get_music ()->get_property ("repeat-count")); - done_count_ = 0; -} - -/* - TODO: add source information for debugging -*/ -void -Volta_repeat_iterator::add_repeat_command (SCM what) -{ - SCM reps = ly_symbol2scm ("repeatCommands"); - SCM current_reps = get_outlet ()->internal_get_property (reps); - - Context *where = get_outlet ()->where_defined (reps); - if (where - && current_reps == SCM_EOL || scm_is_pair (current_reps)) - { - current_reps = scm_cons (what, current_reps); - where->internal_set_property (reps, current_reps); - } -} - -void -Volta_repeat_iterator::next_element (bool side_effect) -{ - done_count_++; - - Sequential_iterator::next_element (side_effect); - - if (side_effect) - { - if (alt_count_) - { - String repstr = to_string (rep_count_ - alt_count_ + done_count_) + "."; - if (done_count_ > 1) - { - add_repeat_command (scm_list_n (ly_symbol2scm ("volta"), SCM_BOOL_F, SCM_UNDEFINED)); - - if (done_count_ - 1 < alt_count_) - add_repeat_command (ly_symbol2scm ("end-repeat")); - } - - if (done_count_ == 1 && alt_count_ < rep_count_) - { - repstr = "1.--" + to_string (rep_count_ - alt_count_ + done_count_) + "."; - } - - if (done_count_ <= alt_count_) - add_repeat_command (scm_list_n (ly_symbol2scm ("volta"), - scm_makfrom0str (repstr.to_str0 ()), SCM_UNDEFINED)); - } - else - { - add_repeat_command (ly_symbol2scm ("end-repeat")); - } - } -} - -void -Volta_repeat_iterator::process (Moment m) -{ - if (first_time_) - { - add_repeat_command (ly_symbol2scm ("start-repeat")); - first_time_ = false; - } - Sequential_iterator::process (m); -} - -IMPLEMENT_CTOR_CALLBACK (Volta_repeat_iterator); IMPLEMENT_CTOR_CALLBACK (Unfolded_repeat_iterator); diff --git a/lily/volta-repeat-iterator.cc b/lily/volta-repeat-iterator.cc new file mode 100644 index 0000000000..9e37056089 --- /dev/null +++ b/lily/volta-repeat-iterator.cc @@ -0,0 +1,124 @@ +/* + volta-repeat-iterator.cc -- implement Volta_repeat_iterator + + source file of the GNU LilyPond music typesetter + + + (c) 2002--2005 Han-Wen Nienhuys +*/ + + +#include "music.hh" +#include "sequential-iterator.hh" +#include "context.hh" + +class Volta_repeat_iterator : public Sequential_iterator +{ +public: + DECLARE_SCHEME_CALLBACK (constructor, ()); + Volta_repeat_iterator (); + + void add_repeat_command (SCM); +protected: + virtual SCM get_music_list () const; + virtual void next_element (bool); + virtual void construct_children (); + virtual void process (Moment); + + bool first_time_; + int alt_count_; + int rep_count_; + int done_count_; +}; + +Volta_repeat_iterator::Volta_repeat_iterator () +{ + done_count_ = alt_count_ = rep_count_ = 0; + first_time_ = true; +} + +SCM +Volta_repeat_iterator::get_music_list ()const +{ + return scm_cons (get_music ()->get_property ("element"), + get_music ()->get_property ("elements")); +} + +void +Volta_repeat_iterator::construct_children () +{ + Sequential_iterator::construct_children (); + + SCM alts = get_music ()->get_property ("elements"); + + alt_count_ = scm_ilength (alts); + rep_count_ = scm_to_int (get_music ()->get_property ("repeat-count")); + done_count_ = 0; +} + +/* + TODO: add source information for debugging +*/ +void +Volta_repeat_iterator::add_repeat_command (SCM what) +{ + SCM reps = ly_symbol2scm ("repeatCommands"); + SCM current_reps = get_outlet ()->internal_get_property (reps); + + Context *where = get_outlet ()->where_defined (reps); + if (where + && current_reps == SCM_EOL || scm_is_pair (current_reps)) + { + current_reps = scm_cons (what, current_reps); + where->internal_set_property (reps, current_reps); + } +} + +void +Volta_repeat_iterator::next_element (bool side_effect) +{ + done_count_++; + + Sequential_iterator::next_element (side_effect); + + if (side_effect) + { + if (alt_count_) + { + String repstr = to_string (rep_count_ - alt_count_ + done_count_) + "."; + if (done_count_ > 1) + { + add_repeat_command (scm_list_n (ly_symbol2scm ("volta"), SCM_BOOL_F, SCM_UNDEFINED)); + + if (done_count_ - 1 < alt_count_) + add_repeat_command (ly_symbol2scm ("end-repeat")); + } + + if (done_count_ == 1 && alt_count_ < rep_count_) + { + repstr = "1.--" + to_string (rep_count_ - alt_count_ + done_count_) + "."; + } + + if (done_count_ <= alt_count_) + add_repeat_command (scm_list_n (ly_symbol2scm ("volta"), + scm_makfrom0str (repstr.to_str0 ()), SCM_UNDEFINED)); + } + else + { + add_repeat_command (ly_symbol2scm ("end-repeat")); + } + } +} + +void +Volta_repeat_iterator::process (Moment m) +{ + if (first_time_) + { + add_repeat_command (ly_symbol2scm ("start-repeat")); + first_time_ = false; + } + Sequential_iterator::process (m); +} + +IMPLEMENT_CTOR_CALLBACK (Volta_repeat_iterator); diff --git a/python/lilylib.py b/python/lilylib.py index e56fa6d9d7..82b3818966 100644 --- a/python/lilylib.py +++ b/python/lilylib.py @@ -12,11 +12,14 @@ ### subst: \(help_summary\|keep_temp_dir_p\|option_definitions\|original_dir\|program_name\|pseudo_filter_p\|temp_dir\|verbose_p\) import __main__ +import getopt +import glob +import os +import re import shutil import string import sys import tempfile -import glob ################################################################ # Users of python modules should include this snippet @@ -30,9 +33,6 @@ import glob # If set, LILYPONDPREFIX must take prevalence # if datadir is not set, we're doing a build and LILYPONDPREFIX -import getopt -import os -import sys datadir = '@local_lilypond_datadir@' if not os.path.isdir (datadir): datadir = '@lilypond_datadir@' @@ -45,59 +45,6 @@ sys.path.insert (0, os.path.join (datadir, 'python')) -# Customize these - -# UGH. - why? Py2exe barfs -if __name__ == '__main__': - import lilylib as ly - global _;_=ly._ - global re;re = ly.re - - # lilylib globals - program_name = 'unset' - pseudo_filter_p = 0 - original_dir = os.getcwd () - temp_dir = os.path.join (original_dir, '%s.dir' % program_name) - keep_temp_dir_p = 0 - verbose_p = 0 - - help_summary = _ ("lilylib module") - - option_definitions = [ - ('', 'h', 'help', _ ("print this help")), - ] - - from lilylib import * -################################################################ - -# Handle bug in Python 1.6-2.1 -# -# there are recursion limits for some patterns in Python 1.6 til 2.1. -# fix this by importing pre instead. Fix by Mats. - - -# Ugh. py2exe barfs on conditional imports -if float (sys.version[0:3]) <= 2.1: - try: - import pre - re = pre - del pre - except ImportError: - import re -else: - import re - -# Attempt to fix problems with limited stack size set by Python! -# Sets unlimited stack size. Note that the resource module only -# is available on UNIX. - - -# Ugh. py2exe barfs on conditional imports -try: - import resource - resource.setrlimit (resource.RLIMIT_STACK, (-1, -1)) -except: - pass localedir = '@localedir@' try: @@ -157,7 +104,7 @@ def getopt_args (opts): return (short, long) def option_help_str (o): - '''Transform one option description (4-tuple ) into neatly formatted string''' + '''Transform one option description (4-tuple) into neatly formatted string''' sh = ' ' if o[1]: sh = '-%s' % o[1] @@ -382,25 +329,6 @@ def cp_to_dir (pattern, dir): map (lambda x, d=dir: shutil.copy2 (x, os.path.join (d, x)), files) -# Python < 1.5.2 compatibility -# -# On most platforms, this is equivalent to -#`normpath(join(os.getcwd()), PATH)'. *Added in Python version 1.5.2* - -if os.path.__dict__.has_key ('abspath'): - abspath = os.path.abspath -else: - def abspath (path): - return os.path.normpath (os.path.join (os.getcwd (), path)) - -if os.__dict__.has_key ('makedirs'): - makedirs = os.makedirs -else: - def makedirs (dir, mode=0777): - system ('mkdir -p %s' % dir) - - - def search_exe_path (name): p = os.environ['PATH'] exe_paths = string.split (p, ':') @@ -419,21 +347,6 @@ def print_environment (): for (k,v) in os.environ.items (): sys.stderr.write ("%s=\"%s\"\n" % (k, v)) -BOUNDING_BOX_RE = '^%%BoundingBox: (-?[0-9]+) (-?[0-9]+) (-?[0-9]+) (-?[0-9]+)' -def get_bbox (filename): - bbox = filename + '.bbox' - ## -sOutputFile does not work with bbox? - cmd = 'gs -sDEVICE=bbox -q -dNOPAUSE %s -c showpage -c quit 2>%s' % \ - (filename, bbox) - system (cmd, progress_p = 1) - box = open (bbox).read () - m = re.match (BOUNDING_BOX_RE, box) - gr = [] - if m: - gr = map (string.atoi, m.groups ()) - - return gr - def make_ps_images (ps_name, resolution = 90, papersize = "a4", rename_page1_p = 0): diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index a1d6cb361b..60ca3f1170 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -836,7 +836,8 @@ (before-line-breaking-callback . ,Paper_column::before_line_breaking) (X-extent-callback . ,Axis_group_interface::group_extent_callback) -; (print-function . ,Paper_column::print) (font-name . "ecrm8") (Y-extent-callback . #f) + ;; debugging +;; (print-function . ,Paper_column::print) (font-size . -6) (font-name . "sans") (Y-extent-callback . #f) (meta . ((interfaces . (paper-column-interface axis-group-interface spaceable-grob-interface item-interface )))) )) @@ -859,8 +860,9 @@ (X-extent-callback . ,Axis_group_interface::group_extent_callback) (before-line-breaking-callback . ,Paper_column::before_line_breaking) (breakable . #t) + ;; debugging stuff: print column number. -; (print-function . ,Paper_column::print) (font-name . "ecrm8") (Y-extent-callback . #f) +;; (print-function . ,Paper_column::print) (font-size . -6) (font-name . "sans") (Y-extent-callback . #f) (meta . ((interfaces . (paper-column-interface axis-group-interface spaceable-grob-interface item-interface )))) diff --git a/scm/define-music-types.scm b/scm/define-music-types.scm index 4593aba5a8..f0d555743b 100644 --- a/scm/define-music-types.scm +++ b/scm/define-music-types.scm @@ -70,9 +70,10 @@ is an articulation (such as @code{-.}, @code{->}, @code{\\tenuto}, (AutoChangeMusic . ( (description . "Used for making voices that switch between piano staves automatically.") - - (internal-class-name . "Music_wrapper") + (internal-class-name . "Music") (iterator-ctor . ,Auto_change_iterator::constructor) + (start-callback . ,Music_wrapper::start_callback) + (length-callback . ,Music_wrapper::length_callback) (types . (general-music music-wrapper-music auto-change-instruction)) )) (BarCheck @@ -146,7 +147,9 @@ Syntax @code{\\translator Staff = @var{new-id}}.") . ( (description . "Interpret the argument music within a specific context.") (iterator-ctor . ,Context_specced_music_iterator::constructor) - (internal-class-name . "Music_wrapper") + (length-callback . ,Music_wrapper::length_callback) + (start-callback . ,Music_wrapper::start_callback) + (internal-class-name . "Music") (types . (context-specification general-music music-wrapper-music)) )) @@ -210,7 +213,7 @@ Syntax: @var{note}\\cr (GraceMusic . ( (description . "Interpret the argument as grace notes. ") - (internal-class-name . "Music_wrapper") + (internal-class-name . "Music") (start-callback . ,Grace_music::start_callback) (length . ,(ly:make-moment 0 1)) (iterator-ctor . ,Grace_iterator::constructor) @@ -437,7 +440,7 @@ goes down).") (QuoteMusic . ( (description . "Quote preprocessed snippets of music. ") - (internal-class-name . "Music_wrapper") + (internal-class-name . "Music") (iterator-ctor . ,Quote_iterator::constructor) (types . (general-music)) )) @@ -578,7 +581,9 @@ Syntax NOTE( and )NOTE") Syntax @code{\\times @var{fraction} @var{music}}, e.g. @code{\\times 2/3 @{ ... @}} for triplets. ") - (internal-class-name . "Music_wrapper") + (internal-class-name . "Music") + (length-callback . ,Music_wrapper::length_callback) + (start-callback . ,Music_wrapper::start_callback) (iterator-ctor . ,Time_scaled_music_iterator::constructor) (types . (time-scaled-music music-wrapper-music general-music)) )) @@ -586,7 +591,10 @@ Syntax @code{\\times @var{fraction} @var{music}}, e.g. (TransposedMusic . ( (description . "Music that has been transposed.") - (internal-class-name . "Music_wrapper") + (internal-class-name . "Music") + (iterator-ctor . ,Music_wrapper_iterator::constructor) + (start-callback . ,Music_wrapper::start_callback) + (length-callback . ,Music_wrapper::length_callback) (to-relative-callback . ,Relative_octave_music::no_relative_callback) (types . (music-wrapper-music general-music transposed-music)) )) @@ -596,7 +604,9 @@ Syntax @code{\\times @var{fraction} @var{music}}, e.g. (description . "Music that can not be converted from relative to absolute notation. For example, transposed music.") (to-relative-callback . ,Relative_octave_music::no_relative_callback) - (internal-class-name . "Music_wrapper") + (iterator-ctor . ,Music_wrapper_iterator::constructor) + (length-callback . ,Music_wrapper::length_callback) + (internal-class-name . "Music") (types . (music-wrapper-music general-music unrelativable-music)) )) @@ -604,7 +614,10 @@ For example, transposed music.") . ( (description . "Music that was entered in relative octave notation.") (to-relative-callback . ,Relative_octave_music::relative_callback) - (internal-class-name . "Music_wrapper") + (iterator-ctor . ,Music_wrapper_iterator::constructor) + (length-callback . ,Music_wrapper::length_callback) + (start-callback . ,Music_wrapper::start_callback) + (internal-class-name . "Music") (types . (music-wrapper-music general-music relative-octave-music)) )) (ScriptEvent diff --git a/scm/lily-library.scm b/scm/lily-library.scm index 5b08393b80..b9e326cae7 100644 --- a/scm/lily-library.scm +++ b/scm/lily-library.scm @@ -64,9 +64,20 @@ (ly:parser-define parser 'toplevel-scores (cons score (ly:parser-lookup parser 'toplevel-scores)))) - + + +(define-public (scorify-music music parser) + + (for-each (lambda (func) + (set! music (func music parser))) + toplevel-music-functions) + +; (display-scheme-music music) + (ly:make-score music)) + + (define-public (collect-music-for-book parser music) - (collect-scores-for-book parser (ly:music-scorify music parser))) + (collect-scores-for-book parser (scorify-music music parser))) ;;;;;;;;;;;;;;;; diff --git a/scm/music-functions.scm b/scm/music-functions.scm index d2a0c04a23..84ac716f19 100644 --- a/scm/music-functions.scm +++ b/scm/music-functions.scm @@ -744,7 +744,7 @@ Syntax: ;; switch-on-debugging (lambda (x parser) (music-map cue-substitute x)) -; (lambda (x parser) (music-map display-scheme-music x)) + )) diff --git a/scm/safe-lily.scm b/scm/safe-lily.scm index e45d2ef646..0e0fb0d9cf 100644 --- a/scm/safe-lily.scm +++ b/scm/safe-lily.scm @@ -85,7 +85,7 @@ ly:music-mutable-properties ly:music-name ly:music-property - ly:music-scorify + ly:make-score ly:music-set-property! ly:music-transpose ly:music? diff --git a/scripts/lilypond-book.py b/scripts/lilypond-book.py index ccc873c41c..692790bf3c 100644 --- a/scripts/lilypond-book.py +++ b/scripts/lilypond-book.py @@ -106,7 +106,7 @@ option_definitions = [ _ ("show warranty and copyright")), ] -include_path = [ly.abspath (os.getcwd ())] +include_path = [os.path.abspath (os.getcwd ())] lilypond_binary = os.path.join ('@bindir@', 'lilypond') # Only use installed binary when we are installed too. @@ -554,7 +554,7 @@ PREAMBLE_LY = r'''%%%% Generated by %(program_name)s #(set! toplevel-score-handler ly:parser-print-score) #(set! toplevel-music-handler (lambda (p m) (ly:parser-print-score - p (ly:music-scorify m p)))) + p (scorify-music m p)))) #(ly:set-option (quote no-point-and-click)) @@ -1531,7 +1531,7 @@ def do_options (): sys.exit (0) elif o == '--include' or o == '-I': include_path.append (os.path.join (original_dir, - ly.abspath (a))) + os.path.abspath (a))) elif o == '--output' or o == '-o': output_name = a elif o == '--process' or o == '-P': diff --git a/scripts/mup2ly.py b/scripts/mup2ly.py index d9154fe079..59810972ee 100644 --- a/scripts/mup2ly.py +++ b/scripts/mup2ly.py @@ -86,28 +86,6 @@ option_definitions = [ # # source file of the GNU LilyPond music typesetter -# Handle bug in Python 1.6-2.1 -# -# there are recursion limits for some patterns in Python 1.6 til 2.1. -# fix this by importing pre instead. Fix by Mats. - -# todo: should check Python version first. -try: - import pre - re = pre - del pre -except ImportError: - import re - -# Attempt to fix problems with limited stack size set by Python! -# Sets unlimited stack size. Note that the resource module only -# is available on UNIX. -try: - import resource - resource.setrlimit (resource.RLIMIT_STACK, (-1, -1)) -except: - pass - try: import gettext gettext.bindtextdomain ('lilypond', localedir) @@ -289,23 +267,6 @@ def cp_to_dir (pattern, dir): map (lambda x, d=dir: shutil.copy2 (x, os.path.join (d, x)), files) -# Python < 1.5.2 compatibility -# -# On most platforms, this is equivalent to -#`normpath(join(os.getcwd()), PATH)'. *Added in Python version 1.5.2* -if os.path.__dict__.has_key ('abspath'): - abspath = os.path.abspath -else: - def abspath (path): - return os.path.normpath (os.path.join (os.getcwd (), path)) - -if os.__dict__.has_key ('makedirs'): - makedirs = os.makedirs -else: - def makedirs (dir, mode=0777): - system ('mkdir -p %s' % dir) - - def mkdir_p (dir, mode=0777): if not os.path.isdir (dir): makedirs (dir, mode)