X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fgrob-scheme.cc;h=572a49ac84afcf788be814ce2a00c2e6c0fde05f;hb=3af0951f9a11677240efa6228683dd4fcea13eaf;hp=e3f72d999b609d08b85345e7ab116d9345c4f61f;hpb=85d8b50f9d36b3f2d38aa11de3755cf563ac49e3;p=lilypond.git diff --git a/lily/grob-scheme.cc b/lily/grob-scheme.cc index e3f72d999b..572a49ac84 100644 --- a/lily/grob-scheme.cc +++ b/lily/grob-scheme.cc @@ -1,185 +1,348 @@ /* - grob-scheme.cc -- Scheme entry points for the grob datatype + This file is part of LilyPond, the GNU music typesetter. - source file of the GNU LilyPond music typesetter + Copyright (C) 1998--2015 Jan Nieuwenhuizen + Han-Wen Nienhuys - (c) 1998--2005 Jan Nieuwenhuizen - Han-Wen Nienhuys -*/ + LilyPond is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + LilyPond is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -#include "grob.hh" + You should have received a copy of the GNU General Public License + along with LilyPond. If not, see . +*/ -#include "warn.hh" +#include "font-interface.hh" +#include "grob-array.hh" #include "item.hh" #include "output-def.hh" +#include "paper-score.hh" #include "system.hh" -#include "font-interface.hh" - +#include "unpure-pure-container.hh" +#include "warn.hh" // error () -LY_DEFINE (ly_grob_set_callback_x, "ly:grob-set-callback!", - 3, 0, 0, (SCM grob, SCM sym, SCM proc), - "Set @var{sym} in grob @var{grob} to value @var{proc}") +LY_DEFINE (ly_grob_property_data, "ly:grob-property-data", + 2, 0, 0, (SCM grob, SCM sym), + "Return the value for property @var{sym} of @var{grob}," + " but do not process callbacks.") { - Grob *sc = unsmob_grob (grob); - SCM_ASSERT_TYPE (sc, grob, SCM_ARG1, __FUNCTION__, "grob"); - SCM_ASSERT_TYPE (scm_is_symbol (sym), sym, SCM_ARG2, __FUNCTION__, "symbol"); - SCM_ASSERT_TYPE (ly_is_procedure (proc), proc, SCM_ARG3, __FUNCTION__, "procedure"); + Grob *sc = unsmob (grob); - sc->set_callback (sym, proc); - return SCM_UNSPECIFIED; + LY_ASSERT_SMOB (Grob, grob, 1); + LY_ASSERT_TYPE (ly_is_symbol, sym, 2); + + return sc->get_property_data (sym); } LY_DEFINE (ly_grob_set_property_x, "ly:grob-set-property!", - 3, 0, 0, (SCM grob, SCM sym, SCM val), - "Set @var{sym} in grob @var{grob} to value @var{val}") + 3, 0, 0, (SCM grob, SCM sym, SCM val), + "Set @var{sym} in grob @var{grob} to value @var{val}.") { - Grob *sc = unsmob_grob (grob); - SCM_ASSERT_TYPE (sc, grob, SCM_ARG1, __FUNCTION__, "grob"); - SCM_ASSERT_TYPE (scm_is_symbol (sym), sym, SCM_ARG2, __FUNCTION__, "symbol"); + Grob *sc = unsmob (grob); + + LY_ASSERT_SMOB (Grob, grob, 1); + LY_ASSERT_TYPE (ly_is_symbol, sym, 2); - if (!type_check_assignment (sym, val, ly_symbol2scm ("backend-type?"))) + if (!ly_is_procedure (val) + && !type_check_assignment (sym, val, ly_symbol2scm ("backend-type?"))) error ("typecheck failed"); - sc->internal_set_property (sym, val); + sc->set_property (sym, val); return SCM_UNSPECIFIED; } -LY_DEFINE (ly_grob_property, "ly:grob-property", - 2, 0, 0, (SCM grob, SCM sym), - "Return the value of a value in grob @var{g} of property @var{sym}. " - "It will return @code{' ()} (end-of-list) " - "if @var{sym} is undefined in @var{g}." - "\n\n") +LY_DEFINE (ly_grob_set_nested_property_x, "ly:grob-set-nested-property!", + 3, 0, 0, (SCM grob, SCM symlist, SCM val), + "Set nested property @var{symlist} in grob @var{grob} to value @var{val}.") +{ + Grob *sc = unsmob (grob); + + LY_ASSERT_SMOB (Grob, grob, 1); + + bool type_ok = scm_is_pair (symlist); + + if (type_ok) + for (SCM s = symlist; scm_is_pair (s) && type_ok; s = scm_cdr (s)) + type_ok &= ly_is_symbol (scm_car (s)); + + SCM_ASSERT_TYPE (type_ok, symlist, SCM_ARG2, __FUNCTION__, "list of symbols"); + + if (scm_is_pair (scm_cdr (symlist))) + set_nested_property (sc, symlist, val); + else + ly_grob_set_property_x (grob, scm_car (symlist), val); + return SCM_UNSPECIFIED; +} + +LY_DEFINE (ly_grob_pure_property, "ly:grob-pure-property", + 4, 1, 0, (SCM grob, SCM sym, SCM beg, SCM end, SCM val), + "Return the pure value for property @var{sym} of @var{grob}." + " If no value is found, return @var{val} or @code{'()}" + " if @var{val} is not specified.") +{ + Grob *sc = unsmob (grob); + + LY_ASSERT_SMOB (Grob, grob, 1); + LY_ASSERT_TYPE (ly_is_symbol, sym, 2); + LY_ASSERT_TYPE (scm_is_integer, beg, 3); + LY_ASSERT_TYPE (scm_is_integer, end, 4); + if (SCM_UNBNDP (val)) + val = SCM_EOL; + + SCM retval = sc->internal_get_pure_property (sym, scm_to_int (beg), scm_to_int (end)); + if (scm_is_null (retval)) + retval = val; + + return retval; +} + +LY_DEFINE (ly_grob_pure_height, "ly:grob-pure-height", + 4, 1, 0, (SCM grob, SCM refp, SCM beg, SCM end, SCM val), + "Return the pure height of @var{grob} given refpoint @var{refp}." + " If no value is found, return @var{val} or @code{'()}" + " if @var{val} is not specified.") { - Grob *sc = unsmob_grob (grob); - SCM_ASSERT_TYPE (sc, grob, SCM_ARG1, __FUNCTION__, "grob"); - SCM_ASSERT_TYPE (scm_is_symbol (sym), sym, SCM_ARG2, __FUNCTION__, "symbol"); + Grob *sc = unsmob (grob); + Grob *ref = unsmob (refp); - return sc->internal_get_property (sym); + LY_ASSERT_SMOB (Grob, grob, 1); + LY_ASSERT_SMOB (Grob, refp, 2); + LY_ASSERT_TYPE (scm_is_integer, beg, 3); + LY_ASSERT_TYPE (scm_is_integer, end, 4); + if (SCM_UNBNDP (val)) + val = SCM_EOL; + + Interval retval = sc->pure_y_extent (ref, scm_to_int (beg), scm_to_int (end)); + + return ly_interval2scm (retval); } +LY_DEFINE (ly_grob_property, "ly:grob-property", + 2, 1, 0, (SCM grob, SCM sym, SCM val), + "Return the value for property @var{sym} of @var{grob}." + " If no value is found, return @var{val} or @code{'()}" + " if @var{val} is not specified.") +{ + Grob *sc = unsmob (grob); + + LY_ASSERT_SMOB (Grob, grob, 1); + LY_ASSERT_TYPE (ly_is_symbol, sym, 2); + if (SCM_UNBNDP (val)) + val = SCM_EOL; + + SCM retval = sc->get_property (sym); + if (scm_is_null (retval)) + retval = val; + + return retval; +} LY_DEFINE (ly_grob_interfaces, "ly:grob-interfaces", - 1, 0, 0, (SCM grob), - "Return the interfaces list of grob @var{grob}.") + 1, 0, 0, (SCM grob), + "Return the interfaces list of grob @var{grob}.") { - Grob *sc = unsmob_grob (grob); - SCM_ASSERT_TYPE (sc, grob, SCM_ARG1, __FUNCTION__, "grob"); + Grob *sc = unsmob (grob); + + LY_ASSERT_SMOB (Grob, grob, 1); - return sc->get_interfaces (); + return sc->interfaces (); } LY_DEFINE (ly_grob_object, "ly:grob-object", - 2, 0, 0, (SCM grob, SCM sym), - "Return the value of a pointer in grob @var{g} of property @var{sym}. " - "It will return @code{' ()} (end-of-list) " - "if @var{sym} is undefined in @var{g}." - "\n\n") + 2, 0, 0, (SCM grob, SCM sym), + "Return the value of a pointer in grob @var{grob} of property" + " @var{sym}. It returns @code{'()} (end-of-list) if @var{sym}" + " is undefined in @var{grob}.") { - Grob *sc = unsmob_grob (grob); - SCM_ASSERT_TYPE (sc, grob, SCM_ARG1, __FUNCTION__, "grob"); - SCM_ASSERT_TYPE (scm_is_symbol (sym), sym, SCM_ARG2, __FUNCTION__, "symbol"); + Grob *sc = unsmob (grob); + + LY_ASSERT_SMOB (Grob, grob, 1); + LY_ASSERT_TYPE (ly_is_symbol, sym, 2); return sc->internal_get_object (sym); } -LY_DEFINE (ly_spanner_get_bound, "ly:spanner-get-bound", - 2, 0, 0, (SCM slur, SCM dir), - "Get one of the bounds of @var{spanner}. @var{dir} is @code{-1} " - "for left, and @code{1} for right.") +LY_DEFINE (ly_grob_set_object_x, "ly:grob-set-object!", + 3, 0, 0, (SCM grob, SCM sym, SCM val), + "Set @var{sym} in grob @var{grob} to value @var{val}.") { - Spanner *sl = dynamic_cast (unsmob_grob (slur)); - SCM_ASSERT_TYPE (sl, slur, SCM_ARG1, __FUNCTION__, "spanner grob"); - SCM_ASSERT_TYPE (is_direction (dir), slur, SCM_ARG2, __FUNCTION__, "dir"); - return sl->get_bound (to_dir (dir))->self_scm (); + Grob *sc = unsmob (grob); + + LY_ASSERT_SMOB (Grob, grob, 1); + LY_ASSERT_TYPE (ly_is_symbol, sym, 2); + + sc->set_object (sym, val); + return SCM_UNSPECIFIED; } /* TODO: make difference between scaled and unscalead variable in calling (i.e different funcs.) */ LY_DEFINE (ly_grob_layout, "ly:grob-layout", - 1, 0, 0, (SCM g), - "Get @code{\\layout} definition from grob @var{g}.") + 1, 0, 0, (SCM grob), + "Get @code{\\layout} definition from grob @var{grob}.") { - Grob *sc = unsmob_grob (g); - SCM_ASSERT_TYPE (sc, g, SCM_ARG1, __FUNCTION__, "grob"); + Grob *sc = unsmob (grob); + + LY_ASSERT_SMOB (Grob, grob, 1); - return sc->get_layout ()->self_scm (); + return sc->layout ()->self_scm (); } LY_DEFINE (ly_grob_alist_chain, "ly:grob-alist-chain", - 1, 1, 0, (SCM grob, SCM global), - "Get an alist chain for grob @var{grob}, with @var{global} as the " - "global default. If unspecified, @code{font-defaults} " - "from the layout block is taken. ") + 1, 1, 0, (SCM grob, SCM global), + "Get an alist chain for grob @var{grob}, with @var{global} as" + " the global default. If unspecified, @code{font-defaults}" + " from the layout block is taken.") { - Grob *sc = unsmob_grob (grob); - SCM_ASSERT_TYPE (sc, grob, SCM_ARG1, __FUNCTION__, "grob"); + Grob *sc = unsmob (grob); - if (global == SCM_UNDEFINED) + LY_ASSERT_SMOB (Grob, grob, 1); + + if (SCM_UNBNDP (global)) { - global = sc->get_layout ()->lookup_variable (ly_symbol2scm ("font-defaults")); - if (global == SCM_UNDEFINED) - global = SCM_EOL; + global = sc->layout ()->lookup_variable (ly_symbol2scm ("font-defaults")); + if (SCM_UNBNDP (global)) + global = SCM_EOL; } return sc->get_property_alist_chain (global); } -LY_DEFINE (ly_get_extent, "ly:grob-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}") +LY_DEFINE (ly_grob_extent, "ly:grob-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 *ref = unsmob (refp); + + LY_ASSERT_SMOB (Grob, grob, 1); + LY_ASSERT_SMOB (Grob, refp, 2); + LY_ASSERT_TYPE (is_axis, axis, 3); + + Axis a = Axis (scm_to_int (axis)); + + if (ref->common_refpoint (sc, a) != ref) + { + // ugh. should use other error message + SCM_ASSERT_TYPE (false, refp, SCM_ARG2, __FUNCTION__, "common refpoint"); + } + return ly_interval2scm (sc->extent (ref, a)); +} + +LY_DEFINE (ly_grob_robust_relative_extent, "ly:grob-robust-relative-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}, or @code{(0,0)} if empty.") +{ + Grob *sc = unsmob (grob); + Grob *ref = unsmob (refp); + + LY_ASSERT_SMOB (Grob, grob, 1); + LY_ASSERT_SMOB (Grob, refp, 2); + LY_ASSERT_TYPE (is_axis, axis, 3); + + Axis a = Axis (scm_to_int (axis)); + + if (ref->common_refpoint (sc, a) != ref) + { + // ugh. should use other error message + SCM_ASSERT_TYPE (false, refp, SCM_ARG2, __FUNCTION__, "common refpoint"); + } + + return ly_interval2scm (robust_relative_extent (sc, ref, a)); +} + +LY_DEFINE (ly_grob_relative_coordinate, "ly:grob-relative-coordinate", + 3, 0, 0, (SCM grob, SCM refp, SCM axis), + "Get the coordinate in @var{axis} direction of @var{grob} relative" + " to the grob @var{refp}.") { - Grob *sc = unsmob_grob (grob); - Grob *ref = unsmob_grob (refp); - SCM_ASSERT_TYPE (sc, grob, SCM_ARG1, __FUNCTION__, "grob"); - SCM_ASSERT_TYPE (ref, refp, SCM_ARG2, __FUNCTION__, "grob"); - SCM_ASSERT_TYPE (is_axis (axis), axis, SCM_ARG3, __FUNCTION__, "axis"); + Grob *sc = unsmob (grob); + Grob *ref = unsmob (refp); + + LY_ASSERT_SMOB (Grob, grob, 1); + LY_ASSERT_SMOB (Grob, refp, 2); + LY_ASSERT_TYPE (is_axis, axis, 3); - return ly_interval2scm (sc->extent (ref, Axis (scm_to_int (axis)))); + Axis a = Axis (scm_to_int (axis)); + + if (ref->common_refpoint (sc, a) != ref) + { + // ugh. should use other error message + SCM_ASSERT_TYPE (false, refp, SCM_ARG2, __FUNCTION__, "common refpoint"); + } + + return scm_from_double (sc->relative_coordinate (ref, a)); } LY_DEFINE (ly_grob_parent, "ly:grob-parent", - 2, 0, 0, (SCM grob, SCM axis), - "Get the parent of @var{grob}. @var{axis} is 0 for the X-axis, " - "1 for the Y-axis.") + 2, 0, 0, (SCM grob, SCM axis), + "Get the parent of @var{grob}. @var{axis} is 0 for the X-axis," + " 1@tie{}for the Y-axis.") { - Grob *sc = unsmob_grob (grob); - SCM_ASSERT_TYPE (sc, grob, SCM_ARG1, __FUNCTION__, "grob"); - SCM_ASSERT_TYPE (is_axis (axis), axis, SCM_ARG2, __FUNCTION__, "axis"); + Grob *sc = unsmob (grob); + + LY_ASSERT_SMOB (Grob, grob, 1); + LY_ASSERT_TYPE (is_axis, axis, 2); Grob *par = sc->get_parent (Axis (scm_to_int (axis))); return par ? par->self_scm () : SCM_EOL; } +LY_DEFINE (ly_grob_set_parent_x, "ly:grob-set-parent!", + 3, 0, 0, (SCM grob, SCM axis, SCM parent_grob), + "Set @var{parent-grob} the parent of grob @var{grob} in axis @var{axis}.") +{ + Grob *gr = unsmob (grob); + Grob *parent = unsmob (parent_grob); + + LY_ASSERT_SMOB (Grob, grob, 1); + LY_ASSERT_TYPE (is_axis, axis, 2); + LY_ASSERT_SMOB (Grob, parent_grob, 3); + + Axis a = Axis (scm_to_int (axis)); + gr->set_parent (parent, a); + return SCM_UNSPECIFIED; +} + LY_DEFINE (ly_grob_properties, "ly:grob-properties", - 1, 0, 0, (SCM grob), - "Get the mutable proprerties of @var{grob}.") + 1, 0, 0, (SCM grob), + "Get the mutable properties of @var{grob}.") { - Grob *g = unsmob_grob (grob); - SCM_ASSERT_TYPE (g, grob, SCM_ARG1, __FUNCTION__, "grob"); + Grob *g = unsmob (grob); + + LY_ASSERT_SMOB (Grob, grob, 1); /* FIXME: uhg? copy/read only? */ return g->mutable_property_alist_; } LY_DEFINE (ly_grob_basic_properties, "ly:grob-basic-properties", - 1, 0, 0, (SCM grob), - "Get the immutable properties of @var{grob}.") + 1, 0, 0, (SCM grob), + "Get the immutable properties of @var{grob}.") { - Grob *g = unsmob_grob (grob); - SCM_ASSERT_TYPE (g, grob, SCM_ARG1, __FUNCTION__, "grob"); + Grob *g = unsmob (grob); + + LY_ASSERT_SMOB (Grob, grob, 1); /* FIXME: uhg? copy/read only? */ return g->immutable_property_alist_; } LY_DEFINE (ly_grob_system, "ly:grob-system", - 1, 0, 0, (SCM g), - "Return the System Grob of @var{g}.") + 1, 0, 0, (SCM grob), + "Return the system grob of @var{grob}.") { - Grob *me = unsmob_grob (g); - SCM_ASSERT_TYPE (me, g, SCM_ARG1, __FUNCTION__, "grob"); + Grob *me = unsmob (grob); + + LY_ASSERT_SMOB (Grob, grob, 1); if (System *g = me->get_system ()) return g->self_scm (); @@ -188,79 +351,147 @@ LY_DEFINE (ly_grob_system, "ly:grob-system", } LY_DEFINE (ly_grob_original, "ly:grob-original", - 1, 0, 0, (SCM grob), - "Return the unbroken original Grob of @var{grob}.") + 1, 0, 0, (SCM grob), + "Return the unbroken original grob of @var{grob}.") { - Grob *me = unsmob_grob (grob); - SCM_ASSERT_TYPE (me, grob, SCM_ARG1, __FUNCTION__, "grob"); - return me->original_ ? me->original_->self_scm () : me->self_scm (); -} + Grob *me = unsmob (grob); -/* TODO: maybe we should return a vector -- random access is more - logical for this list? */ -LY_DEFINE (ly_spanner_broken_into, "ly:spanner-broken-into", - 1, 0, 0, (SCM spanner), - "Return broken-into list for @var{spanner}.") -{ - Spanner *me = dynamic_cast (unsmob_grob (spanner)); - SCM_ASSERT_TYPE (me, spanner, SCM_ARG1, __FUNCTION__, "spanner"); - - SCM s = SCM_EOL; - for (int i = me->broken_intos_.size (); i--;) - s = scm_cons (me->broken_intos_[i]->self_scm (), s); - return s; + LY_ASSERT_SMOB (Grob, grob, 1); + return me->original () ? me->original ()->self_scm () : me->self_scm (); } LY_DEFINE (ly_grob_suicide_x, "ly:grob-suicide!", - 1, 0, 0, (SCM g), - "Kill @var{g}.") + 1, 0, 0, (SCM grob), + "Kill @var{grob}.") { - Grob *me = unsmob_grob (g); - SCM_ASSERT_TYPE (me, g, SCM_ARG1, __FUNCTION__, "grob"); + Grob *me = unsmob (grob); + + LY_ASSERT_SMOB (Grob, grob, 1); me->suicide (); return SCM_UNSPECIFIED; } LY_DEFINE (ly_grob_translate_axis_x, "ly:grob-translate-axis!", - 3, 0, 0, (SCM g, SCM d, SCM a), - "Translate @var{g} on axis @var{a} over distance @var{d}.") + 3, 0, 0, (SCM grob, SCM d, SCM a), + "Translate @var{grob} on axis@tie{}@var{a} over" + " distance@tie{}@var{d}.") { - Grob *me = unsmob_grob (g); - SCM_ASSERT_TYPE (me, g, SCM_ARG1, __FUNCTION__, "grob"); - SCM_ASSERT_TYPE (scm_is_number (d), d, SCM_ARG2, __FUNCTION__, "dimension"); - SCM_ASSERT_TYPE (is_axis (a), a, SCM_ARG3, __FUNCTION__, "axis"); + Grob *me = unsmob (grob); + + LY_ASSERT_SMOB (Grob, grob, 1); + LY_ASSERT_TYPE (scm_is_number, d, 2); + LY_ASSERT_TYPE (is_axis, a, 3); me->translate_axis (scm_to_double (d), Axis (scm_to_int (a))); return SCM_UNSPECIFIED; } -LY_DEFINE (ly_spanner_p, "ly:spanner?", - 1, 0, 0, (SCM g), - "Is @var{g} a spanner object?") +LY_DEFINE (ly_grob_default_font, "ly:grob-default-font", + 1, 0, 0, (SCM grob), + "Return the default font for grob @var{grob}.") +{ + Grob *gr = unsmob (grob); + + LY_ASSERT_SMOB (Grob, grob, 1); + + return Font_interface::get_default_font (gr)->self_scm (); +} + +/* + TODO: consider swapping order, so we can do + + (grob-common-refpoint a b c d e) + */ +LY_DEFINE (ly_grob_common_refpoint, "ly:grob-common-refpoint", + 3, 0, 0, (SCM grob, SCM other, SCM axis), + "Find the common refpoint of @var{grob} and @var{other}" + " for @var{axis}.") +{ + + Grob *gr = unsmob (grob); + + LY_ASSERT_SMOB (Grob, grob, 1); + LY_ASSERT_SMOB (Grob, other, 2); + + Grob *o = unsmob (other); + + LY_ASSERT_TYPE (is_axis, axis, 3); + + Grob *refp = gr->common_refpoint (o, Axis (scm_to_int (axis))); + return refp ? refp->self_scm () : SCM_BOOL_F; +} + +LY_DEFINE (ly_grob_common_refpoint_of_array, "ly:grob-common-refpoint-of-array", + 3, 0, 0, (SCM grob, SCM others, SCM axis), + "Find the common refpoint of @var{grob} and @var{others}" + " (a grob-array) for @var{axis}.") +{ + Grob *gr = unsmob (grob); + + LY_ASSERT_SMOB (Grob, grob, 1); + LY_ASSERT_SMOB (Grob_array, others, 2); + + Grob_array *ga = unsmob (others); + LY_ASSERT_TYPE (is_axis, axis, 3); + + Grob *refp = common_refpoint_of_array (ga->array (), gr, Axis (scm_to_int (axis))); + return refp ? refp->self_scm () : SCM_BOOL_F; +} + +LY_DEFINE (ly_grob_chain_callback, "ly:grob-chain-callback", + 3, 0, 0, (SCM grob, SCM proc, SCM sym), + "Find the callback that is stored as property" + " @var{sym} of grob @var{grob} and chain @var{proc}" + " to the head of this, meaning that it is called" + " using @var{grob} and the previous callback's result.") +{ + Grob *gr = unsmob (grob); + + LY_ASSERT_SMOB (Grob, grob, 1); + SCM_ASSERT_TYPE (ly_is_procedure (proc) || unsmob (proc), proc, SCM_ARG2, __FUNCTION__, "procedure or unpure pure container"); + LY_ASSERT_TYPE (ly_is_symbol, sym, 3); + + chain_callback (gr, proc, sym); + return SCM_UNSPECIFIED; +} + +LY_DEFINE (ly_grob_vertical_less_p, "ly:grob-vertical (me); + LY_ASSERT_SMOB (Grob, a, 1); + LY_ASSERT_SMOB (Grob, b, 2); - return ly_bool2scm (b); + Grob *ga = unsmob (a); + Grob *gb = unsmob (b); + + return ly_bool2scm (Grob::vertical_less (ga, gb)); } -LY_DEFINE (ly_grob_key, "ly:grob-key", - 1, 0, 0, - (SCM grob), - "Return the object-key for @var{grob}.") +LY_DEFINE (ly_grob_get_vertical_axis_group_index, "ly:grob-get-vertical-axis-group-index", + 1, 0, 0, (SCM grob), + "Get the index of the vertical axis group the grob @var{grob} belongs to;" + " return @code{-1} if none is found.") { - Grob *me = unsmob_grob (grob); - SCM_ASSERT_TYPE (me, grob, SCM_ARG1, __FUNCTION__, "Grob"); - return me->get_key ()->self_scm (); + Grob *gr = unsmob (grob); + + LY_ASSERT_SMOB (Grob, grob, 1); + + return scm_from_int (Grob::get_vertical_axis_group_index (gr)); } -LY_DEFINE (ly_grob_default_font, "ly:grob-default-font", - 1, 0, 0, (SCM grob), - "Return the default font for grob @var{gr}.") +LY_DEFINE (ly_grob_spanned_rank_interval, "ly:grob-spanned-rank-interval", + 1, 0, 0, (SCM grob), + "Returns a pair with the @code{rank} of the furthest left" + " column and the @code{rank} of the furthest right column" + " spanned by @code{grob}.") { - Grob *gr = unsmob_grob (grob); - SCM_ASSERT_TYPE (gr, grob, SCM_ARG1, __FUNCTION__, "grob"); + Grob *gr = unsmob (grob); - return Font_interface::get_default_font (gr)->self_scm (); + LY_ASSERT_SMOB (Grob, grob, 1); + + Interval_t iv = gr->spanned_rank_interval (); + + return scm_cons (scm_from_int(iv[LEFT]), scm_from_int(iv[RIGHT])); }