2 atom.cc -- implement Atom
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "interval.hh"
14 #include "dimensions.hh"
17 #include "global-ctor.hh"
27 Atom::smob_display (SCM smob, SCM port, scm_print_state*)
29 Atom* a =(Atom*) SCM_CDR(smob);
30 String i (a->off_.str ());
32 scm_puts ("#<Atom ", port);
33 scm_puts (i.ch_C(), port);
34 gh_display (a->func_);
37 /* non-zero means success */
43 Atom::smob_free (SCM smob)
45 Atom * a= (Atom*) SCM_CDR(smob);
51 Atom::smob_mark (SCM smob)
53 Atom * a= (Atom*) SCM_CDR(smob);
54 scm_gc_mark (a->func_);
63 static scm_smobfuns type_rec;
65 type_rec.mark = smob_mark;
66 type_rec.free = smob_free;
67 type_rec.print = smob_display;
70 smob_tag_ = scm_newsmob (&type_rec);
75 Atom::make_smob () const
79 SCM_SETCAR (smob, smob_tag_);
80 SCM_SETCDR (smob, this);
85 Atom::make_atom (SCM outputfunc)
87 Atom * a= new Atom(outputfunc);
88 return a->make_smob ();
92 Atom::copy_self () const
94 return (new Atom (*this))->make_smob ();
98 Atom::Atom_b (SCM obj)
100 return(SCM_NIMP(obj) && SCM_CAR(obj) == smob_tag_);
107 return (Atom*) SCM_CDR(a);
111 ADD_GLOBAL_CTOR_WITHNAME(atomsmob, Atom::init_smob);