From 492f3643bd2a86956201c3e0c93bb1b65bcdea4e Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Sat, 18 May 2002 23:45:18 +0000 Subject: [PATCH] '' --- ChangeLog | 8 + Documentation/user/internals.itely | 272 ----------------------------- Documentation/user/refman.itely | 8 +- lily/chord.cc | 18 +- lily/cxx-function-smob.cc | 8 +- lily/duration.cc | 32 ++-- lily/font-interface.cc | 30 ++-- lily/font-metric.cc | 23 +-- lily/grob-interface.cc | 21 +-- lily/grob.cc | 68 +++----- lily/include/lily-guile.hh | 20 +++ lily/include/lookup.hh | 2 +- lily/include/ly-smobs.icc | 1 + lily/include/molecule.hh | 5 +- lily/include/music-iterator.hh | 11 +- lily/include/pitch.hh | 4 +- lily/include/translator.hh | 2 - lily/input-smob.cc | 14 +- lily/lily-guile.cc | 59 +++---- lily/lookup.cc | 35 ++-- lily/molecule.cc | 70 ++++---- lily/moment.cc | 20 +-- lily/music.cc | 45 ++--- lily/pitch.cc | 76 ++++---- lily/scm-option.cc | 24 +-- lily/system.cc | 19 +- lily/translator-ctors.cc | 14 +- lily/translator-group.cc | 30 ++-- lily/translator.cc | 39 ++--- scm/backend-documentation-lib.scm | 9 +- scm/engraver-documentation-lib.scm | 16 +- scm/generate-documentation.scm | 43 +++-- scm/molecule.scm | 4 +- scripts/convert-ly.py | 9 + 34 files changed, 391 insertions(+), 668 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2c935ac275..34f3a76a4a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2002-05-19 Han-Wen + + * lily/*.cc: use LY_DEFINE everywhere. Move doc strings from + Documentation/user/internals.itely. + + * lily/function-documentation.cc: new file. Infrastructure for + self documenting Scheme functions. + 2002-05-18 Han-Wen * lily/stem.cc (calc_stem_info): bugfix for less ugly knees. diff --git a/Documentation/user/internals.itely b/Documentation/user/internals.itely index a22b7acf3b..9ecae65478 100644 --- a/Documentation/user/internals.itely +++ b/Documentation/user/internals.itely @@ -76,176 +76,10 @@ The data types that are mentioned here are all discussed in this section. @menu -* Input location:: -* Moment:: -* Duration:: -* Pitch data type:: -* Music:: -* Music_iterator:: -* Translator:: * Grobs:: Graphical object * Molecules:: Molecules are stand-alone descriptions of output -* Font metrics:: Font metrics -* Miscellaneous Scheme functions:: @end menu -@ignore - Why not use Scheme syntax for the functions below, such as - (ly-input-location? obj) and (ly-get-mus-property m sym) ? - - /MB -@end ignore - -@node Input location -@section Input location - -@c The parser generates - -Input location objects point to a location in the input file. This -location is used to generate error messages and to enable the point and -click output. - -@defun ly-input-location? obj -Type predicate, return true if @var{obj} is an input location. -@end defun - - - - -@node Moment -@section Moment - -Moment is a point in musical time. It is consists of a pair of -rationals (@var{m},@var{g}), where @var{m} is the timing for the main -notes, and @var{g} the timing for grace notes. In absence of grace -notes, @var{g} is zero. - -@defun moment? obj -Type predicate, return true if @var{obj} is a moment. -@end defun - -@defun make-moment num den -create the rational number with main timing @var{num}/@var{den}. -@end defun - -@node Duration -@section Duration - -A duration is a musical duration, i.e. a length of time described by a -power of two (whole, half, quarter, etc.) and a number of augmentation -dots. - -@defun make-duration length dotcount - -@var{length} is the negative logarithm (base 2) of the duration: -1 is a half note, 2 is a quarter note, 3 is an eighth -note, etc. The number of dots after the note is given by -@var{dotcount}. -@end defun - - -@defun duration? obj -Type predicate, return true if @var{obj} is a duration. -@end defun - -@node Pitch data type -@section Pitch data type - - - -@defun make-pitch octave note shift - -@var{octave} is specified by an integer, zero for the octave containing -middle C. @var{note} is a number from 0 to 6, with 0 corresponding to C -and 6 corresponding to B. The shift is zero for a natural, negative for -flats, or positive for sharps. -@end defun - -@defun pitch-octave p -extract the octave from pitch @var{p}. -@end defun - -@defun pitch-notename p -extract the note name from pitch @var{p}. -@end defun - -@defun pitch-alteration p -extract the alteration from pitch @var{p}. -@end defun - -@defun pitch-semitones p -calculate the number of semitones of @var{p} from central C. -@end defun - -@defun Pitch@code{:}@code{:}transpose t p -Transpose @var{p} by the amount @var{t}, where @var{t} is the pitch that -central C is transposed to. -@end defun - - -@node Music -@section Music - -Music is the data type that music expressions are stored in. The data -type does not yet offer many manipulations. - -@defun ly-get-mus-property m sym -Get the property @var{sym} of music expression @var{m}. -@end defun - -@defun ly-set-mus-property m sym val -Set property @var{sym} in music expression @var{m} to @var{val}. -@end defun - -@defun ly-make-music name -Make a music object/expression of type @var{name}. Warning: this -interface will likely change in the near future. -@end defun - -@defun music? obj -Type predicate, return true if @var{obj} is a music object. -@end defun - -@defun ly-music-name music -Print the name of @var{music}. -@end defun - - -@node Music_iterator -@section Music_iterator - -Music_iterator is an object type that traverses the Music structure and -reports the events it finds to interpretation contexts. It is not yet -user-serviceable. - -@defun c++-function? obj -Type predicate, return true if @var{obj} is a c++-function. -Music_iterator are created from schemified C++ constructors. Such a -constructor is a @code{c++-function}. -@end defun - -@node Translator -@section Translator - -Translators are the building blocks of contexts. They are not yet user -accessible. - -@defun ly-get-trans-property tr sym -retrieve the value of @var{sym} from context @var{tr} -@end defun - -@defun ly-set-trans-property tr sym val -set value of property @var{sym} in context @var{tr} to @var{val}. -@end defun - -@defun Translator@code{:}@code{:}name tr -Return the type name of the translator @var{tr}. -@end defun - -@defun Translator@code{:}@code{:}description tr -Return an alist of properties of translator @var{tr}. -@end defun - @node Grobs @section Grobs @@ -519,25 +353,6 @@ no extent. Grob properties can be manipulated from Scheme. In practice, most manipulations are coded in C++ because of tradition. -@defun ly-get-grob-property g sym - Get the value of a value in grob @var{g} of property @var{sym}. It -will return @code{'()} (end-of-list) if @var{g} doesn't have @var{sym} set. -@end defun - -@defun ly-set-grob-property g sym val -Set @var{sym} in grob @var{g} to value @var{val} -@end defun - -@defun ly-get-spanner-bound spanner dir -Get one of the bounds of @var{spanner}. @var{dir} may be @code{-1} for -left, and @code{1} for right. -@end defun - -@defun ly-grob? g -Typecheck: is @var{g} a grob? -@end defun - - @node Molecules @@ -588,92 +403,5 @@ returning a Molecule. Most molecule callbacks are written in C++, but you can also write them in Scheme. An example is provided in @code{input/regression/molecule-hacking.ly}. - -@defun molecule? m -type predicate. -@end defun - -@defun ly-combine-molecule-at-edge mol1 axis dir mol2 padding -Construct a molecule by putting @var{mol2} next to -@var{mol1}. @var{axis} can be 0 (x-axis) or 1 (y-axis), @var{dir} can be --1 (left or down) or 1 (right or up). @var{padding} specifies extra -space to add in between measured in global staff space. -@end defun - -@defun ly-get-molecule-extent! mol axis -Return a pair of numbers signifying the extent of @var{mol} in -@var{axis} direction (0 or 1 for x and y axis respectively). -@end defun - -@defun ly-set-molecule-extent! mol axis extent -Set the extent (@var{extent} must be a pair of numbers) of @var{mol} in -@var{axis} direction (0 or 1 for x- and y-axis respectively). - -Note that an extent @code{(A . B)} is an interval and hence @code{A} is -smaller than @code{B}, and is often negative. - -@end defun - -@node Font metrics -@section Font metrics - -The font object represents the metric information of a font. Every font -that is loaded into LilyPond can be accessed via Scheme. - -LilyPond only needs to know the dimension of glyph to be able to process -them. This information is stored in font metric files. LilyPond can read -two types of font-metrics: @TeX{} Font Metric files (TFM files) and -Adobe Font Metric files (AFM files). LilyPond will always try to load -AFM files first since they are more versatile. - -@defun ly-get-default-font gr -This returns the default font for grob @var{gr}. -@end defun - -@defun ly-find-glyph-by-name font name -This function retrieves a Molecule for the glyph named @var{name} in -@var{font}. The font must be available as an AFM file. -@cindex afm file - -@end defun - -@node Miscellaneous Scheme functions -@section Miscellaneous Scheme functions - -@defun ly-warn msg -Scheme callable function to issue the warning @code{msg}. -@end defun - -@defun ly-version -Return the current lilypond version as a list, e.g. -@code{(1 3 127 uu1)}. -@end defun - -@defun ly-gulp-file name -Read the file named @var{name}, and return its contents in a string. The -file is looked up using the lilypond search path. - -@end defun - -@defun dir? -type predicate. A direction is a -1, 0 or 1, where -1 represents left or -down and 1 represents right or up. -@end defun - -@defun ly-number->string num - converts @var{num} to a string without generating many decimals. It -leaves a space at the end. -@end defun - -@defun set-lily-option sym val - Set a global option for the program. Supported options include -@table @code -@item midi-debug -If set to true, generate human readable MIDI -@end table - -This function is useful to call from the command line: @code{lilypond -e -"(set-lily-option 'midi-debug #t)"} -@end defun diff --git a/Documentation/user/refman.itely b/Documentation/user/refman.itely index 139209c90d..ea6a73ff37 100644 --- a/Documentation/user/refman.itely +++ b/Documentation/user/refman.itely @@ -196,7 +196,7 @@ The verbose syntax for pitch specification is \pitch @var{scmpitch} @end example -@var{scmpitch} is a pitch scheme object, see @ref{Pitch data type}. +@var{scmpitch} is a pitch scheme object. In Note and Chord mode, pitches may be designated by names. The default names are the Dutch note names. The notes are specified by the letters @@ -320,8 +320,7 @@ The syntax for a verbose duration specification is @example \duration @var{scmduration} @end example -Here, @var{scmduration} is a Scheme object of type @code{Duration}. See -@ref{Duration} for more information. +Here, @var{scmduration} is a Scheme object of type @code{Duration}. In Note, Chord, and Lyrics mode, durations may be designated by numbers @@ -4676,8 +4675,7 @@ including dimensions. Produced by some Grob functions See @ref{Molecules} @item Translator: object that produces audio objects or Grobs. This is not yet user accessible. -@item Font_metric: object representing a font. (See @ref{Font metrics}) - +@item Font_metric: object representing a font. @end itemize diff --git a/lily/chord.cc b/lily/chord.cc index e76549a49e..bb41246ffa 100644 --- a/lily/chord.cc +++ b/lily/chord.cc @@ -23,8 +23,8 @@ Chord::base_pitches (SCM tonic) SCM minor = Pitch (0, 2, -1).smobbed_copy (); base = gh_cons (tonic, base); - base = gh_cons (pitch_transpose (ly_car (base), major), base); - base = gh_cons (pitch_transpose (ly_car (base), minor), base); + base = gh_cons (ly_pitch_transpose (ly_car (base), major), base); + base = gh_cons (ly_pitch_transpose (ly_car (base), minor), base); return scm_reverse_x (base, SCM_EOL); } @@ -38,7 +38,7 @@ Chord::transpose_pitches (SCM tonic, SCM pitches) SCM transposed = SCM_EOL; for (SCM i = pitches; gh_pair_p (i); i = ly_cdr (i)) { - transposed = gh_cons (pitch_transpose (tonic, ly_car (i)), + transposed = gh_cons (ly_pitch_transpose (tonic, ly_car (i)), transposed); } return scm_reverse_x (transposed, SCM_EOL); @@ -60,7 +60,7 @@ Chord::lower_step (SCM tonic, SCM pitches, SCM step) if (gh_equal_p (step_scm (tonic, ly_car (i)), step) || gh_scm2int (step) == 0) { - p = pitch_transpose (p, Pitch (0, 0, -1).smobbed_copy ()); + p = ly_pitch_transpose (p, Pitch (0, 0, -1).smobbed_copy ()); } lowered = gh_cons (p, lowered); } @@ -169,7 +169,7 @@ Chord::missing_thirds (SCM pitches) { int third = (unsmob_pitch (last)->notename_i_ - unsmob_pitch (tonic)-> notename_i_ + 7) % 7; - last = pitch_transpose (last, scm_vector_ref (thirds, gh_int2scm (third))); + last = ly_pitch_transpose (last, scm_vector_ref (thirds, gh_int2scm (third))); } if (step > gh_scm2int (step_scm (tonic, last))) @@ -179,7 +179,7 @@ Chord::missing_thirds (SCM pitches) missing = gh_cons (last, missing); int third = (unsmob_pitch (last)->notename_i_ - unsmob_pitch (tonic)->notename_i_ + 7) % 7; - last = pitch_transpose (last, scm_vector_ref (thirds, + last = ly_pitch_transpose (last, scm_vector_ref (thirds, gh_int2scm (third))); } } @@ -199,7 +199,7 @@ Chord::add_above_tonic (SCM pitch, SCM pitches) /* Should we maybe first make sure that PITCH is below tonic? */ if (pitches != SCM_EOL) while (Pitch::less_p (pitch, ly_car (pitches)) == SCM_BOOL_T) - pitch = pitch_transpose (pitch, Pitch (1, 0, 0).smobbed_copy ()); + pitch = ly_pitch_transpose (pitch, Pitch (1, 0, 0).smobbed_copy ()); pitches = gh_cons (pitch, pitches); return scm_sort_list (pitches, Pitch::less_p_proc); @@ -211,7 +211,7 @@ Chord::add_below_tonic (SCM pitch, SCM pitches) { if (pitches != SCM_EOL) while (Pitch::less_p (ly_car (pitches), pitch) == SCM_BOOL_T) - pitch = Pitch::transpose (pitch, Pitch (-1, 0, 0).smobbed_copy ()); + pitch = ly_pitch_transpose (pitch, Pitch (-1, 0, 0).smobbed_copy ()); return gh_cons (pitch, pitches); } @@ -284,7 +284,7 @@ Chord::tonic_add_sub_to_pitches (SCM tonic, SCM add, SCM sub) /* if additions include any 4, assume sus4 and don't add third implicitely C-sus (4) = c f g (1 4 5) */ - SCM sus = Pitch::transpose (tonic, Pitch (0, 3, 0).smobbed_copy ()); + SCM sus = ly_pitch_transpose (tonic, Pitch (0, 3, 0).smobbed_copy ()); if (member_notename (sus, add) != SCM_BOOL_F) missing = scm_delete (third, missing); diff --git a/lily/cxx-function-smob.cc b/lily/cxx-function-smob.cc index 0c4f04aeef..603a16203e 100644 --- a/lily/cxx-function-smob.cc +++ b/lily/cxx-function-smob.cc @@ -31,9 +31,8 @@ free_smob (SCM) return 0; } - -SCM -cxx_function_type_p (SCM x) +LY_DEFINE(cxx_function_type_p, "c++-function?", 1, 0, 0, (SCM x), + "Is this an encapsulated C++ function ?") { return (SCM_CELL_TYPE (x)) == callback_tag ? SCM_BOOL_T : SCM_BOOL_F; } @@ -45,9 +44,6 @@ void init_cxx_function_smobs () scm_set_smob_free (callback_tag, free_smob); scm_set_smob_print (callback_tag, print_smob); scm_set_smob_equalp (callback_tag, 0); - - scm_c_define_gsubr ("c++-function?", 1, 0, 0, - (Scheme_function_unknown) cxx_function_type_p); } SCM diff --git a/lily/duration.cc b/lily/duration.cc index c46afab108..2ba674802e 100644 --- a/lily/duration.cc +++ b/lily/duration.cc @@ -128,25 +128,29 @@ Duration::less_p (SCM p1, SCM p2) return SCM_BOOL_F; } -static SCM -make_duration (SCM l, SCM d) + +LY_DEFINE(make_duration, + "make-duration", 2, 0, 0, (SCM length, SCM dotcount), + " +@var{length} is the negative logarithm (base 2) of the duration: +1 is a half note, 2 is a quarter note, 3 is an eighth +note, etc. The number of dots after the note is given by +@var{dotcount}. + + +A duration is a musical duration, i.e. a length of time described by a +power of two (whole, half, quarter, etc.) and a number of augmentation +dots. + +") { - SCM_ASSERT_TYPE(gh_number_p(l), l, SCM_ARG1, __FUNCTION__, "integer"); - SCM_ASSERT_TYPE(gh_number_p(d), d, SCM_ARG2, __FUNCTION__, "integer"); + SCM_ASSERT_TYPE(gh_number_p(length), length, SCM_ARG1, __FUNCTION__, "integer"); + SCM_ASSERT_TYPE(gh_number_p(dotcount), dotcount, SCM_ARG2, __FUNCTION__, "integer"); - Duration p (gh_scm2int (l), gh_scm2int (d)); + Duration p (gh_scm2int (length), gh_scm2int (dotcount)); return p.smobbed_copy (); } -static void -add_funcs () -{ - scm_c_define_gsubr ("make-duration", 2, 0, 0, - (Scheme_function_unknown)make_duration); -} - -ADD_SCM_INIT_FUNC (duration, add_funcs); - SCM Duration::smobbed_copy ()const { diff --git a/lily/font-interface.cc b/lily/font-interface.cc index 09275dc19d..57cf99679e 100644 --- a/lily/font-interface.cc +++ b/lily/font-interface.cc @@ -65,8 +65,9 @@ Font_interface::get_default_font (Grob*me) } -SCM -ly_font_interface_get_default_font (SCM grob) +LY_DEFINE(ly_font_interface_get_default_font, + "ly-get-default-font", 1 , 0, 0, + (SCM grob), "Return the default font for grob @var{gr}.") { Grob * gr = unsmob_grob (grob); SCM_ASSERT_TYPE(gr, grob, SCM_ARG1, __FUNCTION__, "grob"); @@ -74,8 +75,21 @@ ly_font_interface_get_default_font (SCM grob) return Font_interface::get_default_font (gr)->self_scm (); } -SCM -ly_font_interface_get_font (SCM grob, SCM alist) +LY_DEFINE(ly_font_interface_get_font,"ly-get-font", 2, 0, 0, + (SCM grob, SCM alist), + "Return a font metric satisfying the font-qualifiers in @var{alist}. + + +The font object represents the metric information of a font. Every font +that is loaded into LilyPond can be accessed via Scheme. + +LilyPond only needs to know the dimension of glyph to be able to process +them. This information is stored in font metric files. LilyPond can read +two types of font-metrics: @TeX{} Font Metric files (TFM files) and +Adobe Font Metric files (AFM files). LilyPond will always try to load +AFM files first since they are more versatile. + +") { Grob * gr = unsmob_grob (grob); SCM_ASSERT_TYPE(gr, grob, SCM_ARG1, __FUNCTION__, "grob"); @@ -162,13 +176,9 @@ init_syms () rel_sz_sym = scm_permanent_object (ly_symbol2scm ("font-relative-size")); design_sz_sym = scm_permanent_object (ly_symbol2scm ("font-design-size")); wild_sym = scm_permanent_object (ly_symbol2scm ("*")); - - scm_c_define_gsubr ("ly-get-default-font", 1 , 0, 0, - (Scheme_function_unknown) ly_font_interface_get_default_font); - scm_c_define_gsubr ("ly-get-font", 2, 0, 0, - (Scheme_function_unknown) ly_font_interface_get_font); } +ADD_SCM_INIT_FUNC(fi_init_syms, init_syms); bool Font_interface::wild_compare (SCM field_val, SCM val) @@ -176,8 +186,6 @@ Font_interface::wild_compare (SCM field_val, SCM val) return (val == SCM_BOOL_F || field_val == wild_sym || field_val == val); } -ADD_SCM_INIT_FUNC (Font_interface_syms,init_syms); - MAKE_SCHEME_CALLBACK (Font_interface,properties_to_font_name,2); SCM diff --git a/lily/font-metric.cc b/lily/font-metric.cc index 84c1cd1045..c2c9999d8f 100644 --- a/lily/font-metric.cc +++ b/lily/font-metric.cc @@ -134,8 +134,10 @@ Font_metric::find_by_name (String) const } -SCM -ly_find_glyph_by_name (SCM font, SCM name) +LY_DEFINE(ly_find_glyph_by_name, "ly-find-glyph-by-name", 2 , 0, 0, + (SCM font, SCM name), + "This function retrieves a Molecule for the glyph named @var{name} in +@var{font}. The font must be available as an AFM file.") { Font_metric *fm = unsmob_metrics (font); SCM_ASSERT_TYPE(fm, font, SCM_ARG1, __FUNCTION__, "font-metric"); @@ -145,8 +147,11 @@ ly_find_glyph_by_name (SCM font, SCM name) } -SCM -ly_text_dimension (SCM font, SCM text) +LY_DEFINE(ly_text_dimension,"ly-text-dimension", 2 , 0, 0, + (SCM font, SCM text), + "Given the font metric in @var{font} and the string @var{text}, compute +the extents of that text in that font. The return value is a pair of +number-pairs.") { Box b; Font_metric *fm = unsmob_metrics (font); @@ -159,13 +164,3 @@ ly_text_dimension (SCM font, SCM text) } -static void -font_metric_init () -{ - scm_c_define_gsubr ("ly-find-glyph-by-name", 2 , 0, 0, - (Scheme_function_unknown) ly_find_glyph_by_name); - scm_c_define_gsubr ("ly-text-dimension", 2 , 0, 0, - (Scheme_function_unknown) ly_text_dimension); -} - -ADD_SCM_INIT_FUNC (font_metric_init, font_metric_init); diff --git a/lily/grob-interface.cc b/lily/grob-interface.cc index b6fd450b3f..572e858c31 100644 --- a/lily/grob-interface.cc +++ b/lily/grob-interface.cc @@ -18,8 +18,9 @@ void add_interface (const char * symbol, ly_add_interface(s,d,l); } -SCM -ly_add_interface (SCM a, SCM b, SCM c) + +LY_DEFINE(ly_add_interface, "ly-add-interface", 3,0,0, (SCM a, SCM b, SCM c), + "Add an interface description.") { SCM_ASSERT_TYPE (gh_symbol_p(a), a, SCM_ARG1, __FUNCTION__, "symbol"); SCM_ASSERT_TYPE (gh_string_p(b), b, SCM_ARG2, __FUNCTION__, "string"); @@ -38,23 +39,13 @@ ly_add_interface (SCM a, SCM b, SCM c) } -SCM -ly_all_grob_interfaces () +LY_DEFINE(ly_all_grob_interfaces, "ly-all-grob-interfaces", + 0,0,0, (), + "Get a hash table with all interface descriptions.") { return all_ifaces; } -void -init_iface_funcs () -{ - scm_c_define_gsubr ("ly-add-interface", 3, 0, 0, - (Scheme_function_unknown)ly_add_interface); - scm_c_define_gsubr ("ly-all-grob-interfaces", 0, 0, 0, - (Scheme_function_unknown)ly_all_grob_interfaces); -} - -ADD_SCM_INIT_FUNC(giface, init_iface_funcs); - void check_interfaces_for_property (Grob const *me, SCM sym) { diff --git a/lily/grob.cc b/lily/grob.cc index 814aeee638..8e64b58098 100644 --- a/lily/grob.cc +++ b/lily/grob.cc @@ -490,7 +490,7 @@ Grob::handle_broken_dependencies () dependencies, so let's junk the element itself. do not do this for System, since that would remove - references to the originals of score-elts, which get then GC'd + references to the originals of score-grobs, which get then GC'd (a bad thing.) */ suicide (); @@ -851,12 +851,13 @@ Grob::do_derived_mark () return SCM_EOL; } - -SCM -ly_set_grob_property (SCM elt, SCM sym, SCM val) +LY_DEFINE(ly_set_grob_property,"ly-set-grob-property", 3, 0, 0, +(SCM grob, SCM sym, SCM val), +" +Set @var{sym} in grob @var{grob} to value @var{val}") { - Grob * sc = unsmob_grob (elt); - SCM_ASSERT_TYPE(sc, elt, SCM_ARG1, __FUNCTION__, "grob"); + Grob * sc = unsmob_grob (grob); + SCM_ASSERT_TYPE(sc, grob, SCM_ARG1, __FUNCTION__, "grob"); SCM_ASSERT_TYPE(gh_symbol_p(sym), sym, SCM_ARG2, __FUNCTION__, "symbol"); if (!type_check_assignment (sym, val, ly_symbol2scm ("backend-type?"))) @@ -866,12 +867,14 @@ ly_set_grob_property (SCM elt, SCM sym, SCM val) return SCM_UNSPECIFIED; } - -SCM -ly_get_grob_property (SCM elt, SCM sym) +LY_DEFINE(ly_get_grob_property, + "ly-get-grob-property", 2, 0, 0, (SCM grob, SCM sym), + " Get the value of a value in grob @var{g} of property @var{sym}. It +will return @code{'()} (end-of-list) if @var{g} doesn't have @var{sym} set. +") { - Grob * sc = unsmob_grob (elt); - SCM_ASSERT_TYPE(sc, elt, SCM_ARG1, __FUNCTION__, "grob"); + Grob * sc = unsmob_grob (grob); + SCM_ASSERT_TYPE(sc, grob, SCM_ARG1, __FUNCTION__, "grob"); SCM_ASSERT_TYPE(gh_symbol_p(sym), sym, SCM_ARG2, __FUNCTION__, "symbol"); return sc->internal_get_grob_property (sym); @@ -884,9 +887,11 @@ Grob::discretionary_processing () } - -SCM -spanner_get_bound (SCM slur, SCM dir) +LY_DEFINE(spanner_get_bound, "ly-get-spanner-bound", 2 , 0, 0, + (SCM slur, SCM dir), + "Get one of the bounds of @var{spanner}. @var{dir} may be @code{-1} for +left, and @code{1} for right. +") { Spanner * sl = dynamic_cast (unsmob_grob (slur)); SCM_ASSERT_TYPE(sl, slur, SCM_ARG1, __FUNCTION__, "spanner grob"); @@ -894,8 +899,9 @@ spanner_get_bound (SCM slur, SCM dir) return sl->get_bound (to_dir (dir))->self_scm (); } -SCM -ly_get_paper_var (SCM grob, SCM sym) +LY_DEFINE(ly_get_paper_var,"ly-get-paper-variable", 2, 0, 0, + (SCM grob, SCM sym), + "Get a variable from the \\paper block.") { Grob * sc = unsmob_grob (grob); SCM_ASSERT_TYPE(sc, grob, SCM_ARG1, __FUNCTION__, "grob"); @@ -906,8 +912,10 @@ ly_get_paper_var (SCM grob, SCM sym) -SCM -ly_get_extent (SCM grob, SCM refp, SCM axis) +LY_DEFINE(ly_get_extent, "ly-get-extent", 3, 0, 0, + (SCM grob, SCM refp, SCM axis), + "Get the extent in @var{axis} direction of @var{grob} relative to the +grob @var{refp}") { Grob * sc = unsmob_grob (grob); Grob * ref = unsmob_grob (refp); @@ -919,8 +927,9 @@ ly_get_extent (SCM grob, SCM refp, SCM axis) return ly_interval2scm ( sc->extent (ref, Axis (gh_scm2int (axis)))); } -SCM -ly_get_parent (SCM grob, SCM axis) +LY_DEFINE (ly_get_parent, "ly-get-parent", 2, 0, 0, (SCM grob, SCM axis), + "Get the parent of @var{grob}. @var{axis} can be 0 for the X-axis, 1 +for the Y-axis.") { Grob * sc = unsmob_grob (grob); SCM_ASSERT_TYPE(sc, grob, SCM_ARG1, __FUNCTION__, "grob"); @@ -930,23 +939,6 @@ ly_get_parent (SCM grob, SCM axis) } -static void -init_functions () -{ - scm_c_define_gsubr ("ly-get-grob-property", 2, 0, 0, - (Scheme_function_unknown)ly_get_grob_property); - scm_c_define_gsubr ("ly-set-grob-property", 3, 0, 0, - (Scheme_function_unknown)ly_set_grob_property); - scm_c_define_gsubr ("ly-get-spanner-bound", 2 , 0, 0, - (Scheme_function_unknown) spanner_get_bound); - scm_c_define_gsubr ("ly-get-paper-variable", 2, 0, 0, - (Scheme_function_unknown) ly_get_paper_var); - scm_c_define_gsubr ("ly-get-extent", 3, 0, 0, - (Scheme_function_unknown) ly_get_extent); - scm_c_define_gsubr ("ly-get-parent", 2, 0, 0, - (Scheme_function_unknown) ly_get_parent); -} - bool Grob::internal_has_interface (SCM k) { @@ -955,8 +947,6 @@ Grob::internal_has_interface (SCM k) return scm_memq (k, ifs) != SCM_BOOL_F; } - -ADD_SCM_INIT_FUNC (scoreelt, init_functions); IMPLEMENT_TYPE_P (Grob, "ly-grob?"); ADD_INTERFACE (Grob, "grob-interface", diff --git a/lily/include/lily-guile.hh b/lily/include/lily-guile.hh index 62a00dec4c..7fb9c8025b 100644 --- a/lily/include/lily-guile.hh +++ b/lily/include/lily-guile.hh @@ -244,6 +244,10 @@ TYPE ## _ ## FUNC ## _init_functions () \ ADD_SCM_INIT_FUNC (TYPE ## _ ## FUNC ## _callback, TYPE ## _ ## FUNC ## _init_functions); \ +void ly_add_function_documentation (char const * fname, + char const * varlist, + char const * doc); + #define ADD_SCM_INIT_FUNC(name, func)\ class name ## _scm_initter { \ public:\ @@ -254,4 +258,20 @@ public:\ } _ ## name ## _scm_initter; \ /* end define */ +#define LY_DEFINE(FNAME, PRIMNAME, REQ, OPT, VAR, ARGLIST, DOCSTRING) \ +SCM FNAME ARGLIST ; \ +SCM FNAME ## _proc;\ +void \ +FNAME ## init ()\ +{\ + FNAME ## _proc \ + = scm_c_define_gsubr (PRIMNAME,REQ, OPT, VAR, (Scheme_function_unknown) FNAME);\ + ly_add_function_documentation (PRIMNAME, #ARGLIST, DOCSTRING);\ +}\ +ADD_SCM_INIT_FUNC (FNAME ## init_unique_prefix, FNAME ## init);\ +SCM \ +FNAME ARGLIST\ + + + #endif // LILY_GUILE_HH diff --git a/lily/include/lookup.hh b/lily/include/lookup.hh index 246cf4ba21..b81c610f31 100644 --- a/lily/include/lookup.hh +++ b/lily/include/lookup.hh @@ -18,7 +18,7 @@ struct Lookup { - static Molecule bracket (Axis a, Interval iv, Direction d, Real thick, Real protude); + static Molecule bracket (Axis a, Interval iv, Real thick, Real protude); static Molecule accordion (SCM arg, Real interline_f, Font_metric*fm); static Molecule frame (Box b, Real thick); static Molecule slur (Bezier controls, Real cthick, Real thick); diff --git a/lily/include/ly-smobs.icc b/lily/include/ly-smobs.icc index f5b8f62c10..b82378dc1b 100644 --- a/lily/include/ly-smobs.icc +++ b/lily/include/ly-smobs.icc @@ -17,6 +17,7 @@ void init_type_p_ ## CL ()\ {\ scm_c_define_gsubr (FUNCNAME, 1, 0, 0, (Scheme_function_unknown) CL::smob_p);\ + ly_add_function_documentation (FUNCNAME, "(SCM x)", "Check if @var{x} is a " #CL " object");\ }\ ADD_SCM_INIT_FUNC (init_type_p_ ## CL, init_type_p_ ## CL) diff --git a/lily/include/molecule.hh b/lily/include/molecule.hh index 9d9ac24b94..fd4833d71f 100644 --- a/lily/include/molecule.hh +++ b/lily/include/molecule.hh @@ -39,7 +39,10 @@ init the molecule, we assume that DIMENSIONS = (Interval (0,0),Interval (0,0) */ -class Molecule { +class Molecule +{ + friend SCM ly_set_molecule_extent_x (SCM, SCM, SCM); + Box dim_; SCM expr_; diff --git a/lily/include/music-iterator.hh b/lily/include/music-iterator.hh index 7bcb40fc8a..6d1bfe878b 100644 --- a/lily/include/music-iterator.hh +++ b/lily/include/music-iterator.hh @@ -17,7 +17,16 @@ #include "interpretation-context-handle.hh" #include "cxx-function-smob.hh" -/** +/** + --- + + Music_iterator is an object type that traverses the Music structure and + reports the events it finds to interpretation contexts. It is not yet + user-serviceable. + + + --- + Conceptually a music-iterator operates on a queue of musical events that are pending. This queue does not actually exist, but it is a way of viewing and traversing music-expressions. diff --git a/lily/include/pitch.hh b/lily/include/pitch.hh index d734189314..fca3791ee9 100644 --- a/lily/include/pitch.hh +++ b/lily/include/pitch.hh @@ -62,7 +62,7 @@ public: /// return pitch from central c (in halfnotes) int semitone_pitch () const; String str () const; - static SCM transpose (SCM,SCM); + SCM smobbed_copy () const; @@ -71,7 +71,7 @@ public: }; -SCM pitch_transpose (SCM p, SCM delta); +SCM ly_pitch_transpose (SCM p, SCM delta); DECLARE_UNSMOB(Pitch,pitch); #include "compare.hh" diff --git a/lily/include/translator.hh b/lily/include/translator.hh index fa08548668..ff707e9218 100644 --- a/lily/include/translator.hh +++ b/lily/include/translator.hh @@ -46,8 +46,6 @@ public: Translator_group * daddy_trans_l_ ; - DECLARE_SCHEME_CALLBACK(name, (SCM trans)); - DECLARE_SCHEME_CALLBACK(description,(SCM trans)); void announces (); void removal_processing (); diff --git a/lily/input-smob.cc b/lily/input-smob.cc index af9180a744..bbd6f34dc3 100644 --- a/lily/input-smob.cc +++ b/lily/input-smob.cc @@ -39,14 +39,16 @@ free_smob (SCM s) We don't use IMPLEMENT_TYPE_P, since the smobification part is implemented separately from the class. */ -SCM -ly_input_p (SCM x) +LY_DEFINE(ly_input_p, "ly-input-location?", 1, 0, 0, + (SCM x), + "Return whether @var{x} is an input location") { return unsmob_input (x) ? SCM_BOOL_T : SCM_BOOL_F ; } -SCM -ly_input_message (SCM sip, SCM msg) +LY_DEFINE(ly_input_message, "ly-input-message", 2, 0, 0, (SCM sip, SCM msg), + "Print @var{msg} as a GNU compliant error message, pointing to the +location in @var{sip}.") { Input *ip = unsmob_input(sip); @@ -70,10 +72,6 @@ start_input_smobs () scm_set_smob_equalp (input_tag, 0); - scm_c_define_gsubr ("ly-input-location?", 1, 0, 0, - (Scheme_function_unknown)ly_input_p); - scm_c_define_gsubr ("ly-input-message", 2, 0, 0, - (Scheme_function_unknown)ly_input_message); } SCM diff --git a/lily/lily-guile.cc b/lily/lily-guile.cc index b9915bcc6f..ac8bc5fd3b 100644 --- a/lily/lily-guile.cc +++ b/lily/lily-guile.cc @@ -148,10 +148,14 @@ gulp_file_to_string (String fn) return result; } -SCM -ly_gulp_file (SCM fn) +LY_DEFINE(ly_gulp_file, "ly-gulp-file", 1,0, 0, + (SCM name), + "Read the file named @var{name}, and return its contents in a string. The +file is looked up using the lilypond search path. + +") { - return ly_str02scm (gulp_file_to_string (ly_scm2string (fn)).ch_C ()); + return ly_str02scm (gulp_file_to_string (ly_scm2string (name)).ch_C ()); } @@ -206,16 +210,19 @@ index_set_cell (SCM s, Direction d, SCM v) return s; } -SCM -ly_warning (SCM str) +LY_DEFINE(ly_warning,"ly-warn", 1, 0, 0, + (SCM str),"Scheme callable function to issue the warning @code{msg}. +") { assert (gh_string_p (str)); warning ("lily-guile: " + ly_scm2string (str)); return SCM_BOOL_T; } -SCM -ly_isdir_p (SCM s) +LY_DEFINE(ly_isdir_p, "dir?", 1,0, 0, (SCM s), + "type predicate. A direction is a -1, 0 or 1, where -1 represents left or +down and 1 represents right or up. +") { if (gh_number_p (s)) { @@ -405,8 +412,11 @@ ly_type (SCM exp) */ -SCM -ly_number2string (SCM s) +LY_DEFINE(ly_number2string, "ly-number->string", 1, 0,0, + (SCM s), + " converts @var{num} to a string without generating many decimals. It +leaves a space at the end. +") { assert (gh_number_p (s)); @@ -456,23 +466,24 @@ wave_sweep_goodbye (void *dummy1, void *dummy2, void *dummy3) #include "version.hh" -SCM -ly_version () +LY_DEFINE(ly_version, "ly-version", 0, 0, 0, (), + "Return the current lilypond version as a list, e.g. +@code{(1 3 127 uu1)}. +") { char const* vs = "\' (" MAJOR_VERSION " " MINOR_VERSION " " PATCH_LEVEL " " MY_PATCH_LEVEL ")" ; return gh_eval_str ((char*)vs); } -SCM -ly_unit () +LY_DEFINE(ly_unit, "ly-unit", 0, 0, 0, (), + "Return the unit used for lengths as a string.") { return ly_str02scm (INTERNAL_UNIT); } - -SCM -ly_verbose () +LY_DEFINE(ly_verbose, "ly-verbose", 0, 0, 0, (), + "Return whether lilypond is being run in verbose mode.") { return gh_bool2scm (verbose_global_b); } @@ -480,21 +491,6 @@ ly_verbose () static void init_functions () { - scm_c_define_gsubr ("ly-warn", 1, 0, 0, - (Scheme_function_unknown)ly_warning); - scm_c_define_gsubr ("ly-verbose", 0, 0, 0, - (Scheme_function_unknown)ly_verbose); - scm_c_define_gsubr ("ly-version", 0, 0, 0, - (Scheme_function_unknown)ly_version); - scm_c_define_gsubr ("ly-unit", 0, 0, 0, - (Scheme_function_unknown)ly_unit); - scm_c_define_gsubr ("ly-gulp-file", 1,0, 0, - (Scheme_function_unknown)ly_gulp_file); - scm_c_define_gsubr ("dir?", 1,0, 0, (Scheme_function_unknown)ly_isdir_p); - scm_c_define_gsubr ("ly-number->string", 1, 0,0, - (Scheme_function_unknown) ly_number2string); - - #ifdef TEST_GC scm_c_hook_add (&scm_before_mark_c_hook, greet_sweep, 0, 0); scm_c_hook_add (&scm_before_sweep_c_hook, wave_sweep_goodbye, 0, 0); @@ -738,3 +734,4 @@ ly_split_list (SCM s, SCM list) return gh_cons ( scm_reverse_x (before, SCM_EOL), after); } + diff --git a/lily/lookup.cc b/lily/lookup.cc index 7c26235b37..e59699292d 100644 --- a/lily/lookup.cc +++ b/lily/lookup.cc @@ -531,7 +531,7 @@ Lookup::repeat_slash (Real w, Real s, Real t) } Molecule -Lookup::bracket (Axis a, Interval iv, Direction d, Real thick, Real protude) +Lookup::bracket (Axis a, Interval iv, Real thick, Real protude) { Box b; Axis other = Axis((a+1)%2); @@ -541,8 +541,8 @@ Lookup::bracket (Axis a, Interval iv, Direction d, Real thick, Real protude) Molecule m = filledbox (b); b[a] = Interval (iv[UP] - thick, iv[UP]); - Interval oi = Interval (-thick/2, thick/2 + protude) ; - oi *= d; + Interval oi = Interval (-thick/2, thick/2 + fabs (protude)) ; + oi *= sign (protude); b[other] = oi; m.add_molecule (filledbox (b)); b[a] = Interval (iv[DOWN], iv[DOWN] +thick); @@ -551,25 +551,24 @@ Lookup::bracket (Axis a, Interval iv, Direction d, Real thick, Real protude) return m; } -SCM -ly_bracket (SCM a, SCM iv, SCM d, SCM t, SCM p) +/* + TODO: use rounded boxes. + */ +LY_DEFINE(ly_bracket ,"ly-bracket", + 4, 0, 0, + (SCM a, SCM iv, SCM t, SCM p), + "Make a bracket in direction @var{a}. The extent of the bracket is +given by @var{iv}. The wings protude by an amount of @var{p}, which +may be negative. The thickness is given by @var{t}.") { SCM_ASSERT_TYPE(ly_axis_p (a), a, SCM_ARG1, __FUNCTION__, "axis") ; - SCM_ASSERT_TYPE(ly_number_pair_p (iv), iv, SCM_ARG1, __FUNCTION__, "number pair") ; - SCM_ASSERT_TYPE(ly_dir_p (d), a, SCM_ARG1, __FUNCTION__, "direction") ; - SCM_ASSERT_TYPE(gh_number_p (t), a, SCM_ARG1, __FUNCTION__, "number") ; - SCM_ASSERT_TYPE(gh_number_p(p), a, SCM_ARG1, __FUNCTION__, "number") ; + SCM_ASSERT_TYPE(ly_number_pair_p (iv), iv, SCM_ARG2, __FUNCTION__, "number pair") ; + SCM_ASSERT_TYPE(gh_number_p (t), a, SCM_ARG3, __FUNCTION__, "number") ; + SCM_ASSERT_TYPE(gh_number_p(p), a, SCM_ARG4, __FUNCTION__, "number") ; return Lookup::bracket ((Axis)gh_scm2int (a), ly_scm2interval (iv), - (Direction)gh_scm2int (d), gh_scm2double (t), gh_scm2double (p)).smobbed_copy (); + gh_scm2double (t), + gh_scm2double (p)).smobbed_copy (); } -static void -lookup_init () -{ - scm_c_define_gsubr ("ly-bracket", 5, 0, 0, (Scheme_function_unknown) ly_bracket); -} - -ADD_SCM_INIT_FUNC (lookup,lookup_init); - diff --git a/lily/molecule.cc b/lily/molecule.cc index e45bddbcae..9814fc2e04 100644 --- a/lily/molecule.cc +++ b/lily/molecule.cc @@ -135,9 +135,14 @@ Molecule::add_at_edge (Axis a, Direction d, Molecule const &m, Real padding) add_molecule (toadd); } -/* ly_? Thought we had the ly_ prefix for wrapping/adding to gh_ */ -SCM -Molecule::ly_set_molecule_extent_x (SCM mol, SCM axis, SCM np) +LY_DEFINE(ly_set_molecule_extent_x,"ly-set-molecule-extent!", 3 , 0, 0, + (SCM mol, SCM axis, SCM np), + "Set the extent (@var{extent} must be a pair of numbers) of @var{mol} in +@var{axis} direction (0 or 1 for x- and y-axis respectively). + +Note that an extent @code{(A . B)} is an interval and hence @code{A} is +smaller than @code{B}, and is often negative. +5") { Molecule* m = unsmob_molecule (mol); SCM_ASSERT_TYPE (m, mol, SCM_ARG1, __FUNCTION__, "molecule"); @@ -150,8 +155,11 @@ Molecule::ly_set_molecule_extent_x (SCM mol, SCM axis, SCM np) return SCM_UNDEFINED; } -SCM -Molecule::ly_get_molecule_extent (SCM mol, SCM axis) +LY_DEFINE(ly_get_molecule_extent, + "ly-get-molecule-extent", 2 , 0, 0, (SCM mol, SCM axis), + "Return a pair of numbers signifying the extent of @var{mol} in +@var{axis} direction (0 or 1 for x and y axis respectively). +") { Molecule *m = unsmob_molecule (mol); SCM_ASSERT_TYPE (m, mol, SCM_ARG1, __FUNCTION__, "molecule"); @@ -161,9 +169,14 @@ Molecule::ly_get_molecule_extent (SCM mol, SCM axis) } -SCM -Molecule::ly_molecule_combined_at_edge (SCM first, SCM axis, SCM direction, - SCM second, SCM padding) +LY_DEFINE(ly_molecule_combined_at_edge, + "ly-combine-molecule-at-edge", + 5 , 0, 0, (SCM first, SCM axis, SCM direction, + SCM second, SCM padding), + "Construct a molecule by putting @var{second} next to +@var{first}. @var{axis} can be 0 (x-axis) or 1 (y-axis), @var{direction} can be +-1 (left or down) or 1 (right or up). @var{padding} specifies extra +space to add in between measured in global staff space.") { Molecule * m1 = unsmob_molecule (first); @@ -184,8 +197,13 @@ Molecule::ly_molecule_combined_at_edge (SCM first, SCM axis, SCM direction, return result.smobbed_copy (); } -SCM -ly_add_molecule (SCM first, SCM second) +/* + FIXME: support variable number of arguments " + */ +LY_DEFINE(ly_add_molecule , + "ly-add-molecule", 2, 0,0,(SCM first, SCM second), + "Combine two molecules." + ) { Molecule * m1 = unsmob_molecule (first); Molecule * m2 = unsmob_molecule (second); @@ -200,9 +218,9 @@ ly_add_molecule (SCM first, SCM second) return result.smobbed_copy (); } - -SCM -ly_make_molecule (SCM expr, SCM xext, SCM yext) +LY_DEFINE(ly_make_molecule, + "ly-make-molecule", 3, 0, 0, (SCM expr, SCM xext, SCM yext), + "") { SCM_ASSERT_TYPE (ly_number_pair_p (xext), xext, SCM_ARG2, __FUNCTION__, "number pair"); SCM_ASSERT_TYPE (ly_number_pair_p (yext), yext, SCM_ARG3, __FUNCTION__, "number pair"); @@ -222,16 +240,16 @@ fontify_atom (Font_metric * met, SCM f) ly_quote_scm (met->description_), f, SCM_UNDEFINED); } -SCM -ly_fontify_atom (SCM met, SCM f) +LY_DEFINE(ly_fontify_atom,"ly-fontify-atom", 2, 0, 0, + (SCM met, SCM f), + "Add a font selection command for the font metric @var{met} to @var{f}.") { SCM_ASSERT_TYPE(unsmob_metrics (met), met, SCM_ARG1, __FUNCTION__, "font metric"); return fontify_atom (unsmob_metrics (met), f); } - -SCM -ly_align_to_x (SCM mol, SCM axis, SCM dir) +LY_DEFINE(ly_align_to_x,"ly-align-to!", 3, 0, 0, (SCM mol, SCM axis, SCM dir), + "Align @var{mol} using its own extents.") { SCM_ASSERT_TYPE(unsmob_molecule (mol), mol, SCM_ARG1, __FUNCTION__, "molecule"); SCM_ASSERT_TYPE(ly_axis_p(axis), axis, SCM_ARG2, __FUNCTION__, "axis"); @@ -243,19 +261,6 @@ ly_align_to_x (SCM mol, SCM axis, SCM dir) } -static void -molecule_init () -{ - scm_c_define_gsubr ("ly-make-molecule", 3, 0, 0, (Scheme_function_unknown) ly_make_molecule); - scm_c_define_gsubr ("ly-fontify-atom", 2, 0, 0, (Scheme_function_unknown) ly_fontify_atom); - scm_c_define_gsubr ("ly-align-to!", 3, 0, 0, (Scheme_function_unknown) ly_align_to_x); - scm_c_define_gsubr ("ly-add-molecule", 2, 0,0,(Scheme_function_unknown) ly_add_molecule); - scm_c_define_gsubr ("ly-combine-molecule-at-edge", 5 , 0, 0, (Scheme_function_unknown) Molecule::ly_molecule_combined_at_edge); - scm_c_define_gsubr ("ly-set-molecule-extent!", 3 , 0, 0, (Scheme_function_unknown) Molecule::ly_set_molecule_extent_x); - scm_c_define_gsubr ("ly-get-molecule-extent", 2 , 0, 0, (Scheme_function_unknown) Molecule::ly_get_molecule_extent); -} -ADD_SCM_INIT_FUNC (molecule,molecule_init); - /* Hmm... maybe this is not such a good idea ; stuff can be empty, @@ -284,9 +289,8 @@ IMPLEMENT_SIMPLE_SMOBS (Molecule); int -Molecule::print_smob (SCM s, SCM port, scm_print_state *) +Molecule::print_smob (SCM , SCM port, scm_print_state *) { - scm_puts ("# const &breaking) } -#define GLOBAL_SYMBOL(cname, name) \ -SCM cname ; \ -void \ -cname ## _init_func () \ -{ \ - cname = ly_symbol2scm (name); \ - scm_permanent_object (cname); \ -} \ -ADD_SCM_INIT_FUNC (cname,cname ## _init_func);\ - - -GLOBAL_SYMBOL (offset_sym , "translate-molecule"); -GLOBAL_SYMBOL (placebox_sym , "placebox"); -GLOBAL_SYMBOL (combine_sym , "combine-molecule"); - - - void System::output_molecule (SCM expr, Offset o) { @@ -317,7 +300,7 @@ System::output_molecule (SCM expr, Offset o) else { pscore_l_->outputter_l_-> - output_scheme (scm_list_n (placebox_sym, + output_scheme (scm_list_n (ly_symbol2scm ("placebox"), gh_double2scm (o[X_AXIS]), gh_double2scm (o[Y_AXIS]), expr, diff --git a/lily/translator-ctors.cc b/lily/translator-ctors.cc index 9f2f4aa317..849a732485 100644 --- a/lily/translator-ctors.cc +++ b/lily/translator-ctors.cc @@ -19,9 +19,9 @@ */ Dictionary *global_translator_dict_p=0; - -SCM -ly_get_all_translators () +LY_DEFINE(ly_get_all_translators,"ly-get-all-translators", 0, 0, 0, (), + "Return an list of a all translator objects that may be instantiated +during a lilypond run.") { SCM l = SCM_EOL; for (std::map::const_iterator (ci (global_translator_dict_p->begin())); @@ -32,14 +32,6 @@ ly_get_all_translators () return l; } -static void -all_trans_init() -{ - scm_c_define_gsubr ("ly-get-all-translators", 0, 0, 0, (Scheme_function_unknown) ly_get_all_translators); -} - -ADD_SCM_INIT_FUNC(all_trans_init,all_trans_init); - void add_translator (Translator *t) { diff --git a/lily/translator-group.cc b/lily/translator-group.cc index aee0c2309c..3ce7279c41 100644 --- a/lily/translator-group.cc +++ b/lily/translator-group.cc @@ -418,9 +418,10 @@ Translator_group::finalize () each (&Translator::removal_processing); } - -SCM -ly_get_trans_property (SCM context, SCM name) +LY_DEFINE(ly_get_context_property, + "ly-get-context-property", 2, 0, 0, + (SCM context, SCM name), + "retrieve the value of @var{sym} from context @var{tr}") { Translator *t = unsmob_translator (context); Translator_group* tr= dynamic_cast (t); @@ -430,27 +431,18 @@ ly_get_trans_property (SCM context, SCM name) return tr->internal_get_property (name); } -SCM -ly_set_trans_property (SCM context, SCM name, SCM val) + +LY_DEFINE(ly_set_context_property, + "ly-set-context-property", 3, 0, 0, + (SCM context, SCM name, SCM val), + "set value of property @var{sym} in context @var{tr} to @var{val}. +") { Translator *t = unsmob_translator (context); Translator_group* tr= dynamic_cast (t); - SCM_ASSERT_TYPE(tr, context, SCM_ARG1, __FUNCTION__, "Translator group"); + SCM_ASSERT_TYPE(tr, context, SCM_ARG1, __FUNCTION__, "Context"); tr->internal_set_property (name, val); return SCM_UNSPECIFIED; } - - - - -void -add_trans_scm_funcs () -{ - scm_c_define_gsubr ("ly-get-trans-property", 2, 0, 0, (Scheme_function_unknown)ly_get_trans_property); - scm_c_define_gsubr ("ly-set-trans-property", 3, 0, 0, (Scheme_function_unknown)ly_set_trans_property); -} - -ADD_SCM_INIT_FUNC (trans_scm, add_trans_scm_funcs); - diff --git a/lily/translator.cc b/lily/translator.cc index 8ccda6bb79..bdd21e5863 100644 --- a/lily/translator.cc +++ b/lily/translator.cc @@ -139,30 +139,27 @@ Translator::mark_smob (SCM sm) return me->properties_scm_; } -MAKE_SCHEME_CALLBACK(Translator,name,1); -SCM -Translator::name (SCM trans) +LY_DEFINE(ly_translator_name, + "ly-translator-name", 1,0,0, (SCM trans), + "Return the type name of the translator @var{trans}. +") { - if (unsmob_translator (trans)) - { - char const* nm = classname (unsmob_translator (trans)); - return ly_str02scm (nm); - } - return - SCM_EOL; + Translator* tr = unsmob_translator (trans); + SCM_ASSERT_TYPE(tr, trans, SCM_ARG1, __FUNCTION__, "Context"); + + char const* nm = classname (tr); + return ly_str02scm (nm); } -MAKE_SCHEME_CALLBACK(Translator,description,1) -SCM -Translator::description (SCM me) +LY_DEFINE(ly_translator_description, + "ly-translator-description", + 1,0,0, (SCM me), + "Return an alist of properties of translator @var{me}.") { - if (unsmob_translator (me)) - return unsmob_translator(me)->translator_description (); - else - { - programming_error ("Translator::description ()"); - return SCM_EOL; - } + Translator *tr =unsmob_translator (me); + SCM_ASSERT_TYPE (tr, me, SCM_ARG1, __FUNCTION__, "Context"); + + return tr->translator_description (); } SCM @@ -177,7 +174,7 @@ Translator::print_smob (SCM s, SCM port, scm_print_state *) Translator *sc = (Translator *) ly_cdr (s); scm_puts ("#simple_trans_list_, port); /* don't try to print properties, that is too much hassle. diff --git a/scm/backend-documentation-lib.scm b/scm/backend-documentation-lib.scm index 645c56c92b..3ed112e9d6 100644 --- a/scm/backend-documentation-lib.scm +++ b/scm/backend-documentation-lib.scm @@ -95,7 +95,7 @@ (let* ((grob name) (engravers (filter-list (lambda (x) (engraver-makes-grob? name x)) all-engravers-list)) - (engraver-names (map Translator::name engravers)) + (engraver-names (map ly-translator-name engravers)) ) (string-append @@ -108,7 +108,7 @@ (define (engraver-makes-grob? name-symbol grav) - (memq name-symbol (assoc 'grobs-created (Translator::description grav))) + (memq name-symbol (assoc 'grobs-created (ly-translator-description grav))) ) (define (document-all-grobs name) @@ -209,10 +209,7 @@ (texi (description-list->texi descs)) ) - (string-append - (node name) - (texi-section 1 name #f) - texi) + texi ) ) diff --git a/scm/engraver-documentation-lib.scm b/scm/engraver-documentation-lib.scm index f1e67ab88d..8e554f4efb 100644 --- a/scm/engraver-documentation-lib.scm +++ b/scm/engraver-documentation-lib.scm @@ -22,11 +22,11 @@ (let* ( (level (if (eq? where 'context) 3 2)) - (propsr (cdr (assoc 'properties-read (Translator::description engraver)))) - (propsw (cdr (assoc 'properties-written (Translator::description engraver)))) - (name (Translator::name engraver)) + (propsr (cdr (assoc 'properties-read (ly-translator-description engraver)))) + (propsw (cdr (assoc 'properties-written (ly-translator-description engraver)))) + (name (ly-translator-name engraver)) (name-sym (string->symbol name)) - (desc (cdr (assoc 'description (Translator::description engraver)))) + (desc (cdr (assoc 'description (ly-translator-description engraver)))) (grobs (engraver-grobs engraver)) ) @@ -78,7 +78,7 @@ ;; First level Engraver description (define (document-separate-engraver top grav) - (let ((name (Translator::name grav))) + (let ((name (ly-translator-name grav))) (processing name) (string-append (node (engraver-name name)) @@ -88,7 +88,7 @@ (define (find-engraver-by-name name list) (if (null? list) #f - (if (equal? name (Translator::name (car list))) + (if (equal? name (ly-translator-name (car list))) (car list) (find-engraver-by-name name (cdr list))))) @@ -150,7 +150,7 @@ (if (eq? eg #f) '() - (map symbol->string (cdr (assoc 'grobs-created (Translator::description eg)))) + (map symbol->string (cdr (assoc 'grobs-created (ly-translator-description eg)))) ) )) @@ -199,7 +199,7 @@ (define all-engravers-list (ly-get-all-translators)) (define (document-all-engravers name) (let* ((gravs all-engravers-list) - (names (map Translator::name gravs)) + (names (map ly-translator-name gravs)) (doc (apply string-append (map (lambda (x) (document-separate-engraver name x)) gravs)))) diff --git a/scm/generate-documentation.scm b/scm/generate-documentation.scm index 18afa60d6e..baa021cbff 100644 --- a/scm/generate-documentation.scm +++ b/scm/generate-documentation.scm @@ -17,9 +17,11 @@ ;;;;;;;;;;;;;;;; (define load-files '("documentation-lib.scm" + "function-documentation.scm" "engraver-documentation-lib.scm" "music-documentation-lib.scm" - "backend-documentation-lib.scm")) + "backend-documentation-lib.scm" + )) (map load-from-path load-files) @@ -34,13 +36,23 @@ (let* ((doc (string-append - (document-music "LilyPond music properties") - (document-paper "LilyPond interpretation contexts") - (document-all-engravers "LilyPond engravers") - (document-all-engraver-properties "LilyPond context properties") - (document-all-grobs "LilyPond backend") - (document-all-interfaces "LilyPond interfaces") - (document-all-backend-properties "LilyPond backend properties") + (document-music "music properties") + (document-paper "interpretation contexts") + (document-all-engravers "engravers") + (document-all-engraver-properties "context properties") + (document-all-grobs "backend") + (document-all-interfaces "interfaces") + + (node "backend properties") + (texi-section 1 "backend properties" #f) + + (document-all-backend-properties "backend properties") + + (node "function documentation") + (texi-section 1 "function documentation" #f) + + (document-all-scheme-functions) + ) ) (name "lilypond-internals") @@ -55,13 +67,14 @@ ;; we can't use (dir) and top if we're included by lilypond.tely "LilyPond internals" name "(lilypond.info)" '( - ("LilyPond music properties" . "properties for Music representation") - ("LilyPond interpretation contexts" . "Hierarchy and grouping of Engravers") - ("LilyPond engravers" . "Engravers create Grobs") - ("LilyPond context properties" . "context properties") - ("LilyPond backend" . "Detailed description of all Grobs") - ("LilyPond interfaces" . "Grob Interfaces") - ("LilyPond backend properties" . "Grob properties") + ("music properties" . "properties for Music representation") + ("interpretation contexts" . "Hierarchy and grouping of Engravers") + ("engravers" . "Engravers create Grobs") + ("context properties" . "context properties") + ("backend" . "Detailed description of all Grobs") + ("interfaces" . "Grob Interfaces") + ("backend properties" . "Grob properties") + ("function documentation" . "Grob properties") ("Index" . "index") )) diff --git a/scm/molecule.scm b/scm/molecule.scm index e13bbc4893..f0ee68c902 100644 --- a/scm/molecule.scm +++ b/scm/molecule.scm @@ -29,8 +29,8 @@ (let* ( (ext (ly-get-molecule-extent mol axis)) - (lb (ly-bracket axis ext -1 thick protusion)) - (rb (ly-bracket axis ext 1 thick protusion)) + (lb (ly-bracket axis ext thick (- protusion))) + (rb (ly-bracket axis ext thick protusion)) ) (set! mol (ly-combine-molecule-at-edge mol (other-axis axis) 1 lb padding)) (set! mol (ly-combine-molecule-at-edge mol (other-axis axis) -1 rb padding)) diff --git a/scripts/convert-ly.py b/scripts/convert-ly.py index 4ea8a92838..073e0ecd97 100644 --- a/scripts/convert-ly.py +++ b/scripts/convert-ly.py @@ -848,6 +848,15 @@ if 1: conversions.append (((1,5,49), conv, 'noAutoBeaming -> autoBeaming')) + +if 1: + def conv (str): + str = re.sub ('Pitch::transpose', 'ly-transpose-pitch', str) + + return str + + conversions.append (((1,5,56), conv, 'Pitch::transpose->ly-transpose-pitch')) + ################################ # END OF CONVERSIONS ################################ -- 2.39.2