+2002-05-19 Han-Wen <hanwen@cs.uu.nl>
+
+ * 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 <hanwen@cs.uu.nl>
* lily/stem.cc (calc_stem_info): bugfix for less ugly knees.
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
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
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
\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
@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
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
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);
}
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);
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);
}
{
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)))
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)));
}
}
/* 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);
{
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);
}
/* 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);
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;
}
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
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
{
}
-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");
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");
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)
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
}
-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");
}
-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);
}
-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);
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");
}
-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)
{
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 ();
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?")))
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);
}
-
-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<Spanner*> (unsmob_grob (slur));
SCM_ASSERT_TYPE(sl, slur, SCM_ARG1, __FUNCTION__, "spanner grob");
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");
-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);
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");
}
-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)
{
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",
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:\
} _ ## 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
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);
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)
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_;
#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.
/// return pitch from central c (in halfnotes)
int semitone_pitch () const;
String str () const;
- static SCM transpose (SCM,SCM);
+
SCM smobbed_copy () const;
};
-SCM pitch_transpose (SCM p, SCM delta);
+SCM ly_pitch_transpose (SCM p, SCM delta);
DECLARE_UNSMOB(Pitch,pitch);
#include "compare.hh"
Translator_group * daddy_trans_l_ ;
- DECLARE_SCHEME_CALLBACK(name, (SCM trans));
- DECLARE_SCHEME_CALLBACK(description,(SCM trans));
void announces ();
void removal_processing ();
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);
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
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 ());
}
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))
{
*/
-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));
#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);
}
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);
return gh_cons ( scm_reverse_x (before, SCM_EOL), after);
}
+
}
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);
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);
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);
-
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");
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");
}
-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);
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);
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");
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");
}
-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,
int
-Molecule::print_smob (SCM s, SCM port, scm_print_state *)
+Molecule::print_smob (SCM , SCM port, scm_print_state *)
{
-
scm_puts ("#<Molecule ", port);
#if 0
Molecule *r = (Molecule *) ly_cdr (s);
/*
TODO: add optional factor argument.
*/
-SCM
-make_rational (SCM n, SCM d)
+LY_DEFINE (make_moment,"make-moment", 2,0,0, (SCM n, SCM d),
+ "create the rational number with main timing @var{n}/@var{d}.
+
+
+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.
+")
{
Moment m (Rational (1,1));
return m.smobbed_copy ();
}
-
-void
-init_moments ()
-{
- scm_c_define_gsubr ("make-moment", 2 , 0, 0, (Scheme_function_unknown) make_rational);
-}
-
-ADD_SCM_INIT_FUNC (moms,init_moments);
-
SCM
Moment::equal_p (SCM a, SCM b)
{
}
-SCM
-ly_get_mus_property (SCM mus, SCM sym)
+LY_DEFINE(ly_get_mus_property,
+ "ly-get-mus-property", 2, 0, 0, (SCM mus, SCM sym),
+ "Get the property @var{sym} of music expression @var{mus}.")
{
Music * sc = unsmob_music (mus);
SCM_ASSERT_TYPE(sc, mus, SCM_ARG1, __FUNCTION__, "grob");
}
-
-SCM
-ly_set_mus_property (SCM mus, SCM sym, SCM val)
+LY_DEFINE(ly_set_mus_property,
+ "ly-set-mus-property", 3, 0, 0,
+ (SCM mus, SCM sym, SCM val),
+ "Set property @var{sym} in music expression @var{mus} to @var{val}.")
{
Music * sc = unsmob_music (mus);
SCM_ASSERT_TYPE(sc, mus, SCM_ARG1, __FUNCTION__, "grob");
// to do property args
-SCM
-ly_make_music (SCM type)
+LY_DEFINE(ly_make_music,
+ "ly-make-music", 1, 0, 0, (SCM type),
+ "
+Make a music object/expression of type @var{name}. Warning: this
+interface will likely change in the near future.
+
+
+
+Music is the data type that music expressions are stored in. The data
+type does not yet offer many manipulations.
+")
{
SCM_ASSERT_TYPE(gh_string_p(type), type, SCM_ARG1, __FUNCTION__, "string");
return s;
}
-SCM
-ly_music_name (SCM mus)
+LY_DEFINE(ly_music_name, "ly-music-name", 1, 0, 0,
+ (SCM mus),
+ "Return the name of @var{music}.")
{
Music * m = unsmob_music (mus);
SCM_ASSERT_TYPE(m, mus, SCM_ARG1, __FUNCTION__ ,"music");
return ly_str02scm (nm);
}
-SCM
-ly_music_list_p (SCM l)
+LY_DEFINE(ly_music_list_p,"music-list?", 1, 0, 0,
+ (SCM l),"Type predicate: return true if @var{l} is a list of music objects.")
{
if (scm_list_p (l) != SCM_BOOL_T)
return SCM_BOOL_F;
}
return SCM_BOOL_T;
}
-
-static void
-init_functions ()
-{
- scm_c_define_gsubr ("music-list?", 1, 0, 0, (Scheme_function_unknown)ly_music_list_p);
- scm_c_define_gsubr ("ly-get-mus-property", 2, 0, 0, (Scheme_function_unknown)ly_get_mus_property);
- scm_c_define_gsubr ("ly-set-mus-property", 3, 0, 0, (Scheme_function_unknown)ly_set_mus_property);
- scm_c_define_gsubr ("ly-make-music", 1, 0, 0, (Scheme_function_unknown)ly_make_music);
- scm_c_define_gsubr ("ly-music-name", 1, 0, 0, (Scheme_function_unknown)ly_music_name);
-}
-ADD_SCM_INIT_FUNC (musicscm,init_functions);
ADD_MUSIC(Music);
}
notename_i_ = notename;
}
-
-/*
- can't use macro MAKE_SCHEME_CALLBACK().
- messy stuff since Pitch::transpose is overloaded.
- */
-
-SCM
-pitch_transpose (SCM p, SCM delta)
+
+LY_DEFINE(ly_pitch_transpose,
+ "ly-transpose-pitch", 2, 0, 0,
+ (SCM p, SCM delta),
+ "Transpose @var{p} by the amount @var{delta}, where @var{delta} is the
+pitch that central C is transposed to.
+")
{
Pitch* t = unsmob_pitch (p);
Pitch *d = unsmob_pitch (delta);
return tp.smobbed_copy ();
}
-SCM
-Pitch::transpose (SCM p, SCM d)
-{
- return pitch_transpose (p,d);
-}
-
/****************************************************************/
/*
should add optional args
*/
-static SCM
-make_pitch (SCM o, SCM n, SCM a)
+
+LY_DEFINE(make_pitch, "make-pitch", 3, 0, 0,
+ (SCM o, SCM n, SCM a),
+ "
+@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.
+
+")
{
SCM_ASSERT_TYPE(gh_number_p(o), o, SCM_ARG1, __FUNCTION__, "number");
SCM_ASSERT_TYPE(gh_number_p(n), n, SCM_ARG2, __FUNCTION__, "number");
return p.smobbed_copy ();
}
-static SCM
-pitch_octave (SCM pp)
+
+LY_DEFINE(pitch_octave, "pitch-octave", 1, 0, 0,
+ (SCM pp),
+ "extract the octave from pitch @var{p}.")
{
Pitch *p = unsmob_pitch (pp);
SCM_ASSERT_TYPE(p, pp, SCM_ARG1, __FUNCTION__, "Pitch");
return gh_int2scm (q);
}
-static SCM
-pitch_alteration (SCM pp)
+LY_DEFINE(pitch_alteration, "pitch-alteration", 1, 0, 0,
+ (SCM pp),
+ "extract the alteration from pitch @var{p}.")
{
Pitch *p = unsmob_pitch (pp);
SCM_ASSERT_TYPE(p, pp, SCM_ARG1, __FUNCTION__, "Pitch");
return gh_int2scm (q);
}
-static SCM
-pitch_notename (SCM pp)
+LY_DEFINE(pitch_notename, "pitch-notename", 1, 0, 0,
+ (SCM pp),
+ "extract the note name from pitch @var{pp}.")
{
Pitch *p = unsmob_pitch (pp);
SCM_ASSERT_TYPE(p, pp, SCM_ARG1, __FUNCTION__, "Pitch");
return gh_int2scm (q);
}
-static SCM
-pitch_semitones (SCM pp)
+LY_DEFINE(pitch_semitones, "pitch-semitones", 1, 0, 0,
+ (SCM pp),
+ "calculate the number of semitones of @var{p} from central C.")
{
Pitch *p = unsmob_pitch (pp);
SCM_ASSERT_TYPE(p, pp, SCM_ARG1, __FUNCTION__, "Pitch");
return gh_int2scm (q);
}
-SCM pitch_less_proc;
-static SCM
-pitch_less (SCM p1, SCM p2)
-{
- return Pitch::less_p (ly_car (p1), ly_car (p2));
-}
-
-static void
-add_funcs ()
+LY_DEFINE(pitch_less, "pitch<?", 2,0,0, (SCM p1, SCM p2),
+ "Is @var{p1} lower than @var{p2}? This uses lexicographic ordening.")
{
- // should take list?: (make-pitch ' (octave name accidental))
- scm_c_define_gsubr ("make-pitch", 3, 0, 0, (Scheme_function_unknown)make_pitch);
- scm_c_define_gsubr ("pitch-octave", 1, 0, 0, (Scheme_function_unknown)pitch_octave);
- scm_c_define_gsubr ("pitch-notename", 1, 0, 0, (Scheme_function_unknown)pitch_notename);
- scm_c_define_gsubr ("pitch-alteration", 1, 0, 0, (Scheme_function_unknown)pitch_alteration);
- scm_c_define_gsubr ("pitch-semitones", 1, 0, 0, (Scheme_function_unknown)pitch_semitones);
- scm_c_define_gsubr ("Pitch::transpose", 2, 0, 0, (Scheme_function_unknown) pitch_transpose);
- pitch_less_proc = gh_new_procedure2_0 ("pitch-less", &pitch_less);
+ return Pitch::less_p (ly_car (p1), ly_car (p2));
}
-ADD_SCM_INIT_FUNC (pitch, add_funcs);
-
SCM
Pitch::smobbed_copy ()const
{
*/
-SCM
-set_lily_option (SCM var, SCM val)
+LY_DEFINE(set_lily_option,"set-lily-option", 2, 0, 0, (SCM var, SCM val),
+ "Set a global option for the program. Supported options include
+
+
+@table @code
+@item help
+List all options.
+@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)\"}.
+")
{
/*
Scheme option usage:
}
-static void
-init_functions ()
-{
- scm_c_define_gsubr ("set-lily-option", 2, 0, 0, (Scheme_function_unknown)set_lily_option);
-}
-
-
-ADD_SCM_INIT_FUNC (init_functions_sopt, init_functions);
}
-#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)
{
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,
*/
Dictionary<Translator*> *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<String,Translator*>::const_iterator (ci (global_translator_dict_p->begin()));
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)
{
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<Translator_group*> (t);
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<Translator_group*> (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);
-
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
Translator *sc = (Translator *) ly_cdr (s);
scm_puts ("#<Translator ", port);
- scm_display (name (s), port);
+ scm_display (ly_translator_name (s), port);
scm_display (sc->simple_trans_list_, port);
/*
don't try to print properties, that is too much hassle.
(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
(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)
(texi (description-list->texi descs))
)
- (string-append
- (node name)
- (texi-section 1 name #f)
- texi)
+ texi
)
)
(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))
)
;; 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))
(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)))))
(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))))
)
))
(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))))
;;;;;;;;;;;;;;;;
(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)
(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")
;; 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")
))
(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))
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
################################