]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/undead.cc
Issue 5167/6: Changes: show \markup xxx = ... \etc assignments
[lilypond.git] / lily / undead.cc
index 9ba0878e3cf55f3a459e3f69f216f096a7fdb11c..4aed7a60237f12b21d35e7f0eb5fb4aa122dc939 100644 (file)
 */
 
 #include "smobs.hh"
-#include "ly-smobs.icc"
 
-class Undead {
-  DECLARE_SIMPLE_SMOBS (Undead);
+class Undead : public Simple_smob<Undead>
+{
+public:
+  int print_smob (SCM, scm_print_state *) const;
+  SCM mark_smob () const;
+  static const char * const type_p_name_;
+private:
   SCM object_;
 public:
-  SCM object () { return object_; }
-  Undead (SCM object = SCM_UNDEFINED) : object_(object) { };
+  SCM object () const { return object_; }
+  Undead (SCM object = SCM_UNDEFINED) : object_ (object) { };
 };
 
 SCM
-Undead::mark_smob (SCM s)
+Undead::mark_smob () const
 {
   bool saved = parsed_objects_should_be_dead;
   parsed_objects_should_be_dead = false;
-  scm_gc_mark (Undead::unsmob (s)->object ());
+  scm_gc_mark (object ());
   parsed_objects_should_be_dead = saved;
   return SCM_UNDEFINED;
 }
 
 int
-Undead::print_smob (SCM undead,
-                   SCM port,
-                   scm_print_state *)
+Undead::print_smob (SCM port, scm_print_state *) const
 {
   scm_puts ("#<Undead ", port);
-  scm_display (Undead::unsmob (undead)->object (), port);
+  scm_display (object (), port);
   scm_puts (" >", port);
   return 1;
 }
 
-IMPLEMENT_SIMPLE_SMOBS (Undead);
-IMPLEMENT_DEFAULT_EQUAL_P (Undead);
-IMPLEMENT_TYPE_P (Undead, "ly:undead?")
+const char * const Undead::type_p_name_ = "ly:undead?";
 
 LY_DEFINE (ly_make_undead, "ly:make-undead",
-          1, 0, 0, (SCM object),
-          "This packages @var{object} in a manner that keeps it from"
-          " triggering \"Parsed object should be dead\" messages.")
+           1, 0, 0, (SCM object),
+           "This packages @var{object} in a manner that keeps it from"
+           " triggering \"Parsed object should be dead\" messages.")
 {
   Undead undead (object);
   return undead.smobbed_copy ();
 }
 
 LY_DEFINE (ly_get_undead, "ly:get-undead",
-          1, 0, 0, (SCM undead),
-          "Get back object from @var{undead}.")
+           1, 0, 0, (SCM undead),
+           "Get back object from @var{undead}.")
 {
   LY_ASSERT_SMOB (Undead, undead, 1);
-  return Undead::unsmob (undead)->object ();
+  return unsmob<Undead> (undead)->object ();
+}
+
+// '
+// These are not protected since the means of protecting them would be
+// problematic to trigger during the mark pass where the array element
+// references get set.  However, they get set only when in the mark
+// pass when checking for parsed elements that should be dead, and we
+// query and clear them immediately afterwards.  So there should be no
+// way in which the references would have become unprotected in the
+// mean time.
+
+vector<parsed_dead *> parsed_dead::elements;
+
+SCM
+parsed_dead::readout ()
+{
+  SCM result = SCM_EOL;
+  for (vsize i = 0; i < elements.size (); i++)
+    {
+      SCM elt = elements[i]->readout_one ();
+      if (!SCM_UNBNDP (elt))
+        result = scm_cons (elt, result);
+    }
+  return result;
+}
+
+LY_DEFINE (ly_parsed_undead_list_x, "ly:parsed-undead-list!",
+           0, 0, 0, (),
+           "Return the list of objects that have been found live"
+           " that should have been dead, and clear that list.")
+{
+  return parsed_dead::readout ();
 }