From 17440eeed8ec9fc6714d5b418387fb162d232003 Mon Sep 17 00:00:00 2001 From: David Kastrup Date: Mon, 7 Mar 2016 12:13:06 +0100 Subject: [PATCH] Issue 4798/2: Prepare override/revert to deal with numeric subkeys Those are fairly cosmetic changes (partly comments) to prepare for the possibility of using override/revert with numeric subkeys while retaining the necessity of using a symbol as the main property in a Context.Grob.property.subproperties... n-tuple since the organization of an "nalist" (an alist stack containing reversible subproperty overrides) relies on a few special key values: currently pairs and booleans are specially interpreted while the current implementation requires an eq?-comparable first index for efficiency reasons. --- lily/context-property.cc | 3 ++- lily/nested-property.cc | 9 +++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lily/context-property.cc b/lily/context-property.cc index 534fced49a..e0acae1455 100644 --- a/lily/context-property.cc +++ b/lily/context-property.cc @@ -39,10 +39,11 @@ general_pushpop_property (Context *context, SCM grob_property_path, SCM new_value) { + // Numbers may appear, but not in first place if (!scm_is_symbol (context_property) || !scm_is_symbol (scm_car (grob_property_path))) { - warning (_ ("need symbol arguments for \\override and \\revert")); + warning (_ ("need symbol argument for \\override and \\revert")); if (do_internal_type_checking_global) assert (false); } diff --git a/lily/nested-property.cc b/lily/nested-property.cc index ba43ae62f1..edb7986a51 100644 --- a/lily/nested-property.cc +++ b/lily/nested-property.cc @@ -171,7 +171,12 @@ set_nested_property (Grob *me, SCM big_to_small, SCM value) // This converts an alist with nested overrides in it to a proper // alist. The number of nested overrides is known in advance, // everything up to the last nested override is copied, the tail is -// shared +// shared. +// +// The first nalist index has to be a symbol since the conversion +// relies on eq? comparisons, uses some special non-symbol values for +// special purposes, and does validity checking indexed by symbols. +// Subindexing can be done with equal?-comparable indexes, however. SCM nalist_to_alist (SCM nalist, int nested) @@ -206,7 +211,7 @@ nalist_to_alist (SCM nalist, int nested) scm_set_cdr_x (pair, scm_cons (elt, scm_cdr (pair))); continue; } - + assert (scm_is_symbol (key)); // plain override: apply any known corresponding partials SCM pair = assq_pop_x (key, &partials); if (scm_is_true (pair)) -- 2.39.2