2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2005--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>
6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
21 #include "protected-scm.hh"
23 Protected_scm context_property_lookup_table;
24 Protected_scm grob_property_lookup_table;
25 Protected_scm prob_property_lookup_table;
27 LY_DEFINE (ly_property_lookup_stats, "ly:property-lookup-stats",
29 "Return hash table with a property access corresponding to"
30 " @var{sym}. Choices are @code{prob}, @code{grob}, and"
33 if (context_property_lookup_table.is_bound ()
34 && scm_is_eq (sym, ly_symbol2scm ("context")))
35 return context_property_lookup_table;
36 if (prob_property_lookup_table.is_bound ()
37 && scm_is_eq (sym, ly_symbol2scm ("prob")))
38 return prob_property_lookup_table;
39 if (grob_property_lookup_table.is_bound ()
40 && scm_is_eq (sym, ly_symbol2scm ("grob")))
41 return grob_property_lookup_table;
42 return scm_c_make_hash_table (1);
46 note_property_access (Protected_scm *table, SCM sym)
49 Statistics: which properties are looked up?
51 if (!table->is_bound ())
52 *table = scm_c_make_hash_table (259);
54 SCM hashhandle = scm_hashq_get_handle (*table, sym);
55 if (scm_is_false (hashhandle))
57 scm_hashq_set_x (*table, sym, scm_from_int (0));
58 hashhandle = scm_hashq_get_handle (*table, sym);
61 int count = scm_to_int (scm_cdr (hashhandle)) + 1;
62 scm_set_cdr_x (hashhandle, scm_from_int (count));