]> git.donarmstrong.com Git - lilypond.git/commitdiff
Avoid "Parsed object should be dead" warning for saved init data
authorDavid Kastrup <dak@gnu.org>
Tue, 27 Mar 2012 12:27:42 +0000 (14:27 +0200)
committerDavid Kastrup <dak@gnu.org>
Fri, 30 Mar 2012 08:50:05 +0000 (10:50 +0200)
lily/undead.cc [new file with mode: 0644]
ly/init.ly

diff --git a/lily/undead.cc b/lily/undead.cc
new file mode 100644 (file)
index 0000000..9ba0878
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+  This file is part of LilyPond, the GNU music typesetter.
+
+  Copyright (C) 2012 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+  LilyPond is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation, either version 3 of the License, or
+  (at your option) any later version.
+
+  LilyPond is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "smobs.hh"
+#include "ly-smobs.icc"
+
+class Undead {
+  DECLARE_SIMPLE_SMOBS (Undead);
+  SCM object_;
+public:
+  SCM object () { return object_; }
+  Undead (SCM object = SCM_UNDEFINED) : object_(object) { };
+};
+
+SCM
+Undead::mark_smob (SCM s)
+{
+  bool saved = parsed_objects_should_be_dead;
+  parsed_objects_should_be_dead = false;
+  scm_gc_mark (Undead::unsmob (s)->object ());
+  parsed_objects_should_be_dead = saved;
+  return SCM_UNDEFINED;
+}
+
+int
+Undead::print_smob (SCM undead,
+                   SCM port,
+                   scm_print_state *)
+{
+  scm_puts ("#<Undead ", port);
+  scm_display (Undead::unsmob (undead)->object (), port);
+  scm_puts (" >", port);
+  return 1;
+}
+
+IMPLEMENT_SIMPLE_SMOBS (Undead);
+IMPLEMENT_DEFAULT_EQUAL_P (Undead);
+IMPLEMENT_TYPE_P (Undead, "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.")
+{
+  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}.")
+{
+  LY_ASSERT_SMOB (Undead, undead, 1);
+  return Undead::unsmob (undead)->object ();
+}
index 684ea14e454731243e8febedfaf292ca3182e304..91578b7ba3d84124900f4d164a44cdb9dc06958e 100644 (file)
@@ -4,9 +4,9 @@
 #(if (and #t (defined? 'set-debug-cell-accesses!))
   (set-debug-cell-accesses! 5000))
 
-\version "2.15.18"
+\version "2.15.35"
 
-#(if (not (pair? lilypond-declarations))
+#(if (not (ly:undead? lilypond-declarations))
      (ly:parser-include-string parser
                               "\\include \"declarations-init.ly\""))
 
@@ -15,7 +15,7 @@
 %% variables
 
 #(if lilypond-declarations
-     (if (pair? lilypond-declarations)
+     (if (ly:undead? lilypond-declarations)
         (begin
           (for-each
            (lambda (p)
                                   (ly:output-def-clone val)
                                   val))
                (module-add! (current-module) (car p) var)))
-           lilypond-declarations)
+           (ly:get-undead lilypond-declarations))
           (note-names-language parser default-language))
-        (module-for-each
-         (lambda (s v)
-           (let ((val (variable-ref v)))
-             (if (not (ly:lily-parser? val))
-                 (set! lilypond-declarations
-                       (cons
-                        (cons*
-                         s v
-                         (if (ly:output-def? val)
-                             (ly:output-def-clone val)
-                             val))
-                        lilypond-declarations)))))
-         (current-module))))
+        (let ((decl '()))
+          (module-for-each
+           (lambda (s v)
+             (let ((val (variable-ref v)))
+               (if (not (ly:lily-parser? val))
+                   (set! decl
+                         (cons
+                          (cons*
+                           s v
+                           (if (ly:output-def? val)
+                               (ly:output-def-clone val)
+                               val))
+                          decl)))))
+           (current-module))
+          (set! lilypond-declarations (ly:make-undead decl)))))
 
 #(ly:set-option 'old-relative #f)
 #(define toplevel-scores (list))