From: David Kastrup Date: Tue, 27 Mar 2012 12:27:42 +0000 (+0200) Subject: Avoid "Parsed object should be dead" warning for saved init data X-Git-Tag: release/2.15.36-1~15 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=9db3ae18972000e81b3c73680e9dd791d8596a64;p=lilypond.git Avoid "Parsed object should be dead" warning for saved init data --- diff --git a/lily/undead.cc b/lily/undead.cc new file mode 100644 index 0000000000..9ba0878e3c --- /dev/null +++ b/lily/undead.cc @@ -0,0 +1,71 @@ +/* + This file is part of LilyPond, the GNU music typesetter. + + Copyright (C) 2012 Han-Wen Nienhuys + + 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 . +*/ + +#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 ("#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 (); +} diff --git a/ly/init.ly b/ly/init.ly index 684ea14e45..91578b7ba3 100644 --- a/ly/init.ly +++ b/ly/init.ly @@ -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) @@ -26,21 +26,23 @@ (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))