2 scm-hash.cc -- implement Scheme_hash_table
4 source file of the GNU LilyPond music typesetter
6 (c) 1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "scm-hash.hh"
11 #include "hash-table-iter.hh"
13 Scheme_hash_table::Scheme_hash_table ()
15 hash_func_
= ly_scm_hash
;
21 Scheme_hash_table::operator =(Scheme_hash_table
const & src
)
23 Hash_table
<SCM
,SCM
>::operator = (src
);
25 // we do not copy the self_scm_ field!
29 Scheme_hash_table::do_smobify_self ()
33 #include "ly-smobs.icc"
34 IMPLEMENT_SMOBS(Scheme_hash_table
);
37 Scheme_hash_table::mark_smob (SCM s
)
40 can't typecheck naively, since GC bit lives in CAR of S
42 //assert (SMOB_IS_TYPE_B (Scheme_hash_table, s));
44 Scheme_hash_table
*me
= SMOB_TO_TYPE(Scheme_hash_table
,s
);
45 for (Hash_table_iter
<SCM
,SCM
> i (*me
); i
.ok(); i
++)
47 scm_gc_mark (i
.key());
48 scm_gc_mark (i
.val ());
54 Scheme_hash_table::Scheme_hash_table (Scheme_hash_table
const &src
)
55 : Hash_table
<SCM
,SCM
> (src
)
57 hash_func_
= src
.hash_func_
;
63 Scheme_hash_table::print_smob (SCM s
, SCM p
, scm_print_state
*)
65 assert (SMOB_IS_TYPE_B (Scheme_hash_table
, s
));
66 Scheme_hash_table
*me
= SMOB_TO_TYPE(Scheme_hash_table
,s
);
67 for (Hash_table_iter
<SCM
,SCM
> i (*me
); i
.ok(); i
++)
69 scm_display (i
.key(), p
);
71 scm_display (i
.val (), p
);
80 Scheme_hash_table::~Scheme_hash_table( )
86 Scheme_hash_table::to_alist () const
89 for (Hash_table_iter
<SCM
,SCM
> i (*this); i
.ok(); i
++)
90 l
= gh_cons (gh_cons (i
.key (), i
.val()), l
);