2 object-key-undumper.cc -- implement Object_key_undumper
4 source file of the GNU LilyPond music typesetter
6 (c) 2004--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
9 #include "object-key-undumper.hh"
11 #include "ly-smobs.icc"
13 IMPLEMENT_SMOBS (Object_key_undumper);
14 IMPLEMENT_DEFAULT_EQUAL_P (Object_key_undumper);
17 Object_key_undumper::mark_smob (SCM smob)
19 Object_key_undumper *undumper = (Object_key_undumper *) SCM_CELL_WORD_1 (smob);
20 for (Int_to_key_map::const_iterator i (undumper->keys_.begin ());
21 i != undumper->keys_.end (); i++)
22 scm_gc_mark ((*i).second->self_scm ());
28 Object_key_undumper::print_smob (SCM s, SCM port, scm_print_state*)
31 scm_puts ("#<Object_key_undumper>", port);
35 Object_key_undumper::Object_key_undumper ()
41 Object_key_undumper::parse_contents (SCM contents)
43 for (SCM s = contents; scm_is_pair (s); s = scm_cdr (s))
45 SCM entry = scm_car (s);
46 if (scm_car (entry) != ly_symbol2scm ("define-key"))
49 int number = scm_to_int (scm_cadr (entry));
50 SCM skey = scm_caddr (entry);
52 SCM new_key = SCM_EOL;
54 for (SCM t = skey; scm_is_pair (t); t = scm_cdr (t))
56 SCM item = scm_car (t);
57 if (scm_is_pair (item)
58 && scm_car (item) == ly_symbol2scm ("key"))
60 int index = scm_to_int (scm_cadr (item));
61 Object_key const *key = get_key (index);
62 *tail = scm_cons (key->self_scm (), SCM_EOL);
65 *tail = scm_cons (item, SCM_EOL);
66 tail = SCM_CDRLOC (*tail);
69 Object_key *k = Object_key::undump (new_key);
76 Object_key_undumper::get_key (int idx)
78 Int_to_key_map::const_iterator i (keys_.find (idx));
79 assert (i != keys_.end ());
84 Object_key_undumper::~Object_key_undumper ()