]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/atom.cc
release: 1.1.44
[lilypond.git] / lily / atom.cc
index 00660aac555a6751a9918ae6299a23c231794a73..61a1b3e32f1015c2194a34754f84b8a1bea3eb84 100644 (file)
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+  (c)  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
-#include "symbol.hh"
-#include "tex.hh"
+
+#include "atom.hh"
 #include "interval.hh"
-#include "dimen.hh"
 #include "string.hh"
-#include "varray.hh"
+#include "array.hh"
 #include "debug.hh"
+#include "dimensions.hh"
+#include "lookup.hh"
+#include "main.hh"
+#include "global-ctor.hh"
+
+Atom::Atom(SCM s)
+{
+  func_ = s;
+}
+
+
+#ifdef ATOM_SMOB
+int
+Atom::smob_display (SCM smob, SCM port, scm_print_state*)
+{
+  Atom* a =(Atom*) SCM_CDR(smob);
+  String i (a->off_.str ());
+  
+  scm_puts ("#<Atom ", port);
+  scm_puts (i.ch_C(), port);
+  gh_display (a->func_);
+  scm_puts (">", port);
+
+  /* non-zero means success */
+  return 1;
+}
+
+
+scm_sizet
+Atom::smob_free (SCM smob)
+{
+  Atom * a= (Atom*) SCM_CDR(smob);
+  delete a;
+  return sizeof (Atom);
+}
+
+SCM
+Atom::smob_mark (SCM smob) 
+{
+  Atom * a= (Atom*) SCM_CDR(smob);
+  scm_gc_mark (a->func_);
+  return a->font_;
+}
+
+long Atom::smob_tag_;
 
 void
-Atom::print() const
+Atom::init_smob ()
 {
-#ifndef NPRINT
-  DOUT << "texstring: " <<sym_.tex<<"\n";    
-#endif
+  static scm_smobfuns type_rec;
+
+  type_rec.mark = smob_mark;
+  type_rec.free = smob_free;
+  type_rec.print = smob_display;
+  type_rec.equalp = 0;
+
+  smob_tag_ = scm_newsmob (&type_rec);
 }
 
-Box
-Atom::extent() const
+
+SCM
+Atom::make_smob () const
 {
-  Box b (sym_.dim);
-  b.translate (off_);
-  return b;
+  SCM smob;
+  SCM_NEWCELL (smob);
+  SCM_SETCAR (smob, smob_tag_);
+  SCM_SETCDR (smob, this);
+  return smob;
 }
 
-Atom::Atom (Symbol s)
+SCM
+Atom::make_atom (SCM outputfunc)
 {
-  sym_=s;
+  Atom * a= new Atom(outputfunc);
+  return a->make_smob ();
 }
 
+SCM
+Atom::copy_self () const
+{
+  return (new Atom (*this))->make_smob ();
+}
 
-String
-Atom::TeX_string() const
+bool
+Atom::Atom_b (SCM obj)
 {
-  String tex_str = sym_.tex;
-  Offset off = off_;
+  return(SCM_NIMP(obj) && SCM_CAR(obj) == smob_tag_);
+}
 
-  /* infinity checks. */
-  for (int a =X_AXIS; a < NO_AXES; a++)
-    {
-      Axis ax = (Axis)a;
-      if (abs (off[ax]) >= 100 CM)
-       {
-         warning ("ridiculous dimension " + axis_name_str (ax)  + ", " 
-                  +print_dimen(off[ax]));
-         off[ax] = 0.0;
-         tex_str += "\errormark"; 
-       }
-    }
-  // whugh.. Hard coded...
-  String s ("\\placebox{");
-  s += print_dimen (off[Y_AXIS])+"}{";
-  s += print_dimen (off[X_AXIS]) + "}{";
-  s += tex_str + "}";
-  return s;
+Atom* 
+Atom::atom_l (SCM a)
+{
+  assert (Atom_b (a));
+  return (Atom*) SCM_CDR(a);
 }
+
+
+ADD_GLOBAL_CTOR_WITHNAME(atomsmob, Atom::init_smob);
+#endif
+
+