]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/include/book.hh (class Book): idem.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 1 Sep 2006 10:02:46 +0000 (10:02 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 1 Sep 2006 10:02:46 +0000 (10:02 +0000)
* lily/include/context-def.hh (struct Context_def): idem.

* lily/include/score.hh (class Score): don't derive from Input.

* lily/book.cc (Book): add a copy ctor.

25 files changed:
ChangeLog
Documentation/user/programming-interface.itely
lily/book.cc
lily/context-def.cc
lily/grob-property.cc
lily/grob.cc
lily/include/audio-element.hh
lily/include/book-paper-def.hh
lily/include/book.hh
lily/include/context-def.hh
lily/include/engraver-group.hh
lily/include/input-smob.hh [deleted file]
lily/include/input.hh
lily/include/output-def.hh
lily/include/score.hh
lily/input-scheme.cc
lily/input-smob.cc
lily/lily-parser-scheme.cc
lily/music.cc
lily/paper-outputter.cc
lily/parser.yy
lily/score.cc
lily/source-file.cc
lily/stencil.cc
lily/stream-event.cc

index 2d57d37734a4262fb2e768658f9b474bd6508c0d..9f753356b513c4f6c369dbd36a899c31267e2d61 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2006-09-01  Han-Wen Nienhuys  <hanwen@lilypond.org>
 
+       * lily/include/book.hh (class Book): idem.
+
+       * lily/include/context-def.hh (struct Context_def): idem.
+
+       * lily/include/score.hh (class Score): don't derive from Input.
+
+       * lily/book.cc (Book): add a copy ctor. 
+
        * buildscripts/output-distance.py (FileLink.calc_distance): count
        orphans in distance too.
 
index 4536fff21ac5aa661fae9320a994c3e500ee4f4b..8b40fe3140c0d97a7504e935813989395414da7f 100644 (file)
@@ -197,9 +197,8 @@ AltOff = {
 
 @noindent
 This example may be rewritten to pass in music expressions,
-@c fixme
-@ignore
-i@l ilypond[quote,verbatim,ragged-right]
+
+@lilypond[quote,verbatim,ragged-right]
 withAlt = #(define-music-function (parser location mag music) (number? ly:music?)
   #{ \override Stem #'length = #$(* 7.0 mag)
      \override NoteHead #'font-size =
@@ -210,8 +209,7 @@ withAlt = #(define-music-function (parser location mag music) (number? ly:music?
 
 { c'2 \withAlt #0.5 {c'4 c'}
   \withAlt #1.5 {c' c'} c'2 }
-@end l ilypond
-@end ignore
+@end lilypond
 
 @node Void functions
 @subsection Void functions
index 87df4efe841e33cf9b7d9317b7df960cb112aadb..114ef0cdf2df8cc5c56bedef16beb90f3c68a4a4 100644 (file)
@@ -30,18 +30,47 @@ using namespace std;
 #include "ly-smobs.icc"
 
 Book::Book ()
-  : Input ()
 {
   paper_ = 0;
   header_ = SCM_EOL;
   scores_ = SCM_EOL;
+  input_location_ = SCM_EOL;
   smobify_self ();
+
+  input_location_ = make_input (Input ());
+}
+
+Book::Book (Book const &s)
+{
+  paper_ = 0;
+  header_ = SCM_EOL;
+  scores_ = SCM_EOL;
+  input_location_ = SCM_EOL;
+  smobify_self ();
+
+  if (s.paper_)
+    paper_ = s.paper_->clone ();
+  
+  input_location_ = make_input (*s.origin ());
+  header_ = ly_make_anonymous_module (false);
+  if (ly_is_module (s.header_))
+    ly_module_copy (header_, s.header_);
+
+  SCM *t = &scores_;
+  for (SCM p = s.scores_; scm_is_pair (p); p = scm_cdr (p))
+    {
+      Score *newscore = unsmob_score (scm_car (p))->clone ();
+
+      *t = scm_cons (newscore->self_scm (), SCM_EOL);
+      t = SCM_CDRLOC(*t);
+      newscore->unprotect ();
+    }
 }
 
-Book* 
-Book::clone () const
+Input *
+Book::origin () const
 {
-  return new Book (*this);
+  return unsmob_input (input_location_);
 }
 
 Book::~Book ()
@@ -64,7 +93,8 @@ Book::mark_smob (SCM s)
   if (book->paper_)
     scm_gc_mark (book->paper_->self_scm ());
   scm_gc_mark (book->scores_);
-
+  scm_gc_mark (book->input_location_);
+  
   return book->header_;
 }
 
index b856486dba4900e3fd7bd158ea4fb32943b233e7..0af5fabf4fdef003342bc705ffe19797b642be15 100644 (file)
@@ -27,14 +27,21 @@ Context_def::Context_def ()
   context_name_ = SCM_EOL;
   default_child_ = SCM_EOL;
   description_ = SCM_EOL;
+  input_location_ = SCM_EOL;
 
   smobify_self ();
 
+  input_location_ = make_input (Input ());
   context_name_ = ly_symbol2scm ("");
 }
 
+Input *
+Context_def::origin () const
+{
+  return unsmob_input (input_location_);
+}
+
 Context_def::Context_def (Context_def const &s)
-  : Input (s)
 {
   context_aliases_ = SCM_EOL;
   translator_group_type_ = SCM_EOL;
@@ -44,10 +51,11 @@ Context_def::Context_def (Context_def const &s)
   context_name_ = SCM_EOL;
   description_ = SCM_EOL;
   default_child_ = SCM_EOL;
-
+  input_location_ = SCM_EOL;
   smobify_self ();
-  description_ = s.description_;
 
+  description_ = s.description_;
+  input_location_ = make_input (*s.origin ()); 
   default_child_ = s.default_child_;
   accept_mods_ = s.accept_mods_;
   property_ops_ = s.property_ops_;
@@ -88,6 +96,7 @@ Context_def::mark_smob (SCM smob)
   scm_gc_mark (me->property_ops_);
   scm_gc_mark (me->translator_group_type_);
   scm_gc_mark (me->default_child_);
+  scm_gc_mark (me->input_location_);
 
   return me->context_name_;
 }
index c4dce927b43f86f3265348779ede3ef846f6b1b9..8d7ecc0c19528b49b481e293dd9bfcc640df86c5 100644 (file)
@@ -5,7 +5,7 @@
 #include <cstring>
 
 #include "main.hh"
-#include "input-smob.hh"
+#include "input.hh"
 #include "pointer-group-interface.hh"
 #include "misc.hh"
 #include "paper-score.hh"
index a1963e5fe47e3aed5a5f6cce389171d8a7031aba..4b44231e6195e72fe4357db4d55b018e12bfd337 100644 (file)
@@ -11,7 +11,7 @@
 #include <cstring>
 
 #include "align-interface.hh"
-#include "input-smob.hh"
+#include "input.hh"
 #include "international.hh"
 #include "item.hh"
 #include "main.hh"
@@ -36,6 +36,7 @@ Grob::Grob (SCM basicprops,
            Object_key const *key)
 {
   key_ = key;
+  
   /* FIXME: default should be no callback.  */
   self_scm_ = SCM_EOL;
   layout_ = 0;
index a9d8f7ac47982bc83844932d0b226cfd459ccd4d..2941c7d10530950ebdfe78009d48ff97fdbd4e40 100644 (file)
@@ -16,7 +16,8 @@ class Audio_element
 public:
   Audio_element ();
   virtual ~Audio_element ();
-  VIRTUAL_COPY_CONSTRUCTOR(Audio_element,Audio_element);
+
+  VIRTUAL_COPY_CONSTRUCTOR(Audio_element, Audio_element);
   virtual char const *name () const;
 protected:
 };
index 55e7a01180f0d85c4f8507aa665d4a13a04117f6..ee0c4a15a389b1cb249ab4d0bcba399db8d77a33 100644 (file)
@@ -18,7 +18,6 @@ class Output_def : public Output_def
 public:
   VIRTUAL_COPY_CONSTRUCTOR (Output_def, Output_def);
   Output_def (Output_def const &);
-
   Output_def ();
 
   virtual void derived_mark ();
index 9ef2ca21301db146dba7f373061bbaec98747f08..360276ed088f1fd3b39ba0f75968ba6fc7fb375f 100644 (file)
@@ -15,7 +15,7 @@
 #include "object-key.hh"
 #include "std-string.hh"
 
-class Book : public Input
+class Book
 {
   DECLARE_SMOBS (Book, foo);
 
@@ -24,8 +24,11 @@ public:
   SCM header_;
   Output_def *paper_;
   SCM scores_;
+  SCM input_location_;
 
-  Book *clone () const;
+  Book (Book const &);
+  Input *origin() const;
+  VIRTUAL_COPY_CONSTRUCTOR(Book, Book);
   Book ();
   void add_score (SCM);
   Paper_book *process (Output_def *def_paper,
index a92ad4fee53e352c8c650018e0ffbab884c78caf..dd7045015b60c2d2939f91c3e6a3d677e4106256 100644 (file)
@@ -18,7 +18,7 @@
   The definition of a interpretation context as given in the
   input. The lists are stored in order of definition.
 */
-struct Context_def : public Input
+struct Context_def
 {
 private:
   /*
@@ -32,8 +32,9 @@ private:
   SCM context_aliases_;
   SCM translator_group_type_;
   SCM default_child_;
-
+  SCM input_location_;
 public:
+  Input *origin () const;
   void add_context_mod (SCM);
   SCM get_default_child (SCM user_mods) const;
   SCM get_context_name () const { return context_name_; }
index 938fde04923ed41ed11e9ee70f54433f384cff3f..3fa99e638e9cd703a58bb633f2d70bcad9914b76 100644 (file)
@@ -21,6 +21,7 @@ protected:
   DECLARE_LISTENER (revert);
 public:
   VIRTUAL_COPY_CONSTRUCTOR (Translator_group, Engraver_group);
+
   Engraver_group ();
   virtual void derived_mark () const;
   void do_announces ();
diff --git a/lily/include/input-smob.hh b/lily/include/input-smob.hh
deleted file mode 100644 (file)
index 6b80f26..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
-  input-smob.hh -- declare input smob
-
-  source file of the GNU LilyPond music typesetter
-
-  (c) 2000--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
-*/
-
-#ifndef INPUT_SMOB_HH
-#define INPUT_SMOB_HH
-
-#include "input.hh"
-#include "smobs.hh"
-
-SCM make_input (Input spot);
-Input *unsmob_input (SCM);
-
-extern Input dummy_input_global;
-
-#endif /* INPUT_SMOB_HH */
-
index f7224ec7d342f8fcd000f9be53b875e98fe262d5..625910ea74e3a4e42f4e983b753be5fa5c69f582 100644 (file)
@@ -52,4 +52,14 @@ public:
   Input ();
 };
 
+
+
+#include "input.hh"
+#include "smobs.hh"
+
+SCM make_input (Input spot);
+Input *unsmob_input (SCM);
+
+extern Input dummy_input_global;
+
 #endif // INPUT_HH
index de190a7c86ff07174fe5a75500ee51c28acd9b89..a31dcd48fc02cbeef845647d79be1cb6151a0090 100644 (file)
@@ -42,6 +42,7 @@ class Output_def
 public:
   VIRTUAL_COPY_CONSTRUCTOR (Output_def, Output_def);
   DECLARE_SMOBS (Output_def, );
+
 public:
   SCM scope_;
   Output_def *parent_;
index 004e251dd9c78a5b310f74e4563772156b2c5111..fcc5752e52759f0d81121386195e0ceab0a43f96 100644 (file)
 #include "virtual-methods.hh"
 #include "std-string.hh"
 
-class Score : public Input
+class Score
 {
   DECLARE_SMOBS (Score, foo);
 
   SCM music_;
-
+  SCM input_location_;
 public:
+  Input *origin() const;
   vector<Output_def*> defs_;
   string user_key_;
   SCM header_;
@@ -32,6 +34,7 @@ public:
   Score ();
   Score (Score const &);
 
+  VIRTUAL_COPY_CONSTRUCTOR (Score, Score);
   
   SCM get_music () const;
   void add_output_def (Output_def *def);
index 6e954ef162fbd307be8b7fe2f5e5a60556622bd5..c24d2ed1b0d3e0cddfe8786daa81b6a0bb63c56f 100644 (file)
@@ -7,7 +7,7 @@
 */
 
 #include "std-string.hh"
-#include "input-smob.hh"
+#include "input.hh"
 
 /* We don't use IMPLEMENT_TYPE_P, since the smobification part is
    implemented separately from the class.  */
index 72b293f10c09c3bf968e5433c45815dc656eb501..7f66bcd3d3ec13ba84e79d96d75da05a5b314ac6 100644 (file)
@@ -6,7 +6,7 @@
   (c) 2000--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
 */
 
-#include "input-smob.hh"
+#include "input.hh"
 #include "source-file.hh"
 #include "std-string.hh"
 
index 0e844d2bc0ec51053f3f938cb4ac747fbf883af8..7c6650799751039f84e5d4de681a00619c63899a 100644 (file)
@@ -11,7 +11,7 @@
 #include "file-name-map.hh"
 #include "file-name.hh"
 #include "file-path.hh"
-#include "input-smob.hh"
+#include "input.hh"
 #include "international.hh"
 #include "lily-lexer.hh"
 #include "lily-parser.hh"
index 8a169a217baa4c1031724fe03f2f08bca2eec4aa..4d71d99d98e6bfd8069936ccd88600834d563d3b 100644 (file)
@@ -11,7 +11,7 @@
 #include "context.hh"
 #include "dispatcher.hh"
 #include "duration.hh"
-#include "input-smob.hh"
+#include "input.hh"
 #include "international.hh"
 #include "ly-smobs.icc"
 #include "main.hh"
index c321c6f8df4e4d7701d925bc5ad5284706b20242..f11f40d90577411ff11fb0669a9d00a4299ee968 100644 (file)
@@ -17,7 +17,7 @@ using namespace std;
 #include "dimensions.hh"
 #include "file-name.hh"
 #include "font-metric.hh"
-#include "input-smob.hh"
+#include "input.hh"
 #include "lily-version.hh"
 #include "main.hh"
 #include "output-def.hh"
index 17b0cd25a72a7c3ede72fc293e677818b164291f..dff3ee921df7746974d42a129b52594a1ea464ed 100644 (file)
@@ -74,7 +74,6 @@ using namespace std;
 #include "context-def.hh"
 #include "dimensions.hh"
 #include "file-path.hh"
-#include "input-smob.hh"
 #include "input.hh"
 #include "international.hh"
 #include "lily-guile.hh"
@@ -606,11 +605,11 @@ context_def_spec_block:
 context_def_spec_body:
        /**/ {
                $$ = Context_def::make_scm ();
-               unsmob_context_def ($$)->set_spot (@$);
+               unsmob_context_def ($$)->origin ()->set_spot (@$);
        }
        | CONTEXT_DEF_IDENTIFIER {
                $$ = $1;
-               unsmob_context_def ($$)->set_spot (@$);
+               unsmob_context_def ($$)->origin ()->set_spot (@$);
        }
        | context_def_spec_body GROBDESCRIPTIONS embedded_scm {
                Context_def*td = unsmob_context_def ($$);
@@ -642,14 +641,15 @@ book_block:
 book_body:
        {
                $$ = new Book;
-               $$->set_spot (@$);
+               $$->origin ()->set_spot (@$);
                $$->paper_ = dynamic_cast<Output_def*> (unsmob_output_def (PARSER->lexer_->lookup_identifier ("$defaultpaper"))->clone ());
                $$->paper_->unprotect ();
                $$->header_ = PARSER->lexer_->lookup_identifier ("$defaultheader"); 
        }
        | BOOK_IDENTIFIER {
                $$ = unsmob_book ($1);
-               $$->set_spot (@$);
+               $$->protect ();
+               $$->origin ()->set_spot (@$);
        }
        | book_body paper_block {
                $$->paper_ = $2;
@@ -690,12 +690,12 @@ score_body:
                // pass ownernship to C++ again.
                $$ = unsmob_score (score);
                $$->protect ();
-               $$->set_spot (@$);
+               $$->origin ()->set_spot (@$);
        }
        | SCORE_IDENTIFIER {
                $$ = unsmob_score ($1);
                $$->protect ();
-               $$->set_spot (@$);
+               $$->origin ()->set_spot (@$);
        }
        | score_body object_id_setting {
                $$->user_key_ = ly_scm2string ($2);
index 99ec51880a3672e5741447a5ff66864544cc1f73..3f00330e61336c875aa3c97d618157468e2befd7 100644 (file)
@@ -28,13 +28,21 @@ using namespace std;
 
 #include "ly-smobs.icc"
 
+Input *
+Score::origin () const
+{
+  return unsmob_input (input_location_);
+}
+
+
 Score::Score ()
-  : Input ()
 {
   header_ = SCM_EOL;
   music_ = SCM_EOL;
   error_found_ = false;
+  input_location_ = SCM_EOL;
   smobify_self ();
+  input_location_ = make_input (Input ());
 }
 
 Score::~Score ()
@@ -53,6 +61,8 @@ Score::mark_smob (SCM s)
   scm_gc_mark (sc->header_);
   for (vsize i = sc->defs_.size (); i--;)
     scm_gc_mark (sc->defs_[i]->self_scm ());
+
+  scm_gc_mark (sc->input_location_);
   return sc->music_;
 }
 
@@ -65,12 +75,13 @@ Score::print_smob (SCM, SCM p, scm_print_state*)
 }
 
 Score::Score (Score const &s)
-  : Input (s)
 {
   header_ = SCM_EOL;
   music_ = SCM_EOL;
   error_found_ = s.error_found_;
+  input_location_ = SCM_EOL;
   smobify_self ();
+  input_location_ = make_input (*s.origin ()); 
 
   Music *m = unsmob_music (s.music_);
   if (m)
index 186ea1eaf83ff752ad7ab1032eb0dc58e14a1595..cead386ae9166eddde96d50be24ce949baac4b0e 100644 (file)
@@ -78,10 +78,9 @@ gulp_file (string filename, int desired_size)
   vector<char> cxx_arr;
   cxx_arr.resize (filesize);
 
-
   copy (str, str + filesize, cxx_arr.begin ());
   
-  free (str);
+  delete[] str;
   return cxx_arr;
 }
 
index 294894d5f196a45e5e07e059d33e8bf0957a93e6..329c5cae61d2d85b87a41273ae9564bc6b486749 100644 (file)
@@ -10,7 +10,7 @@
 
 #include "main.hh"
 #include "font-metric.hh"
-#include "input-smob.hh"
+#include "input.hh"
 #include "string-convert.hh"
 #include "warn.hh"
 
index 1019c9e85bf728b06b3178fecb85c4374dfd5d10..7a1118e65af459566227edd71d557ed1fa646ce1 100644 (file)
@@ -11,7 +11,7 @@
 #include "ly-smobs.icc"
 #include "context.hh"
 #include "input.hh"
-#include "input-smob.hh"
+#include "input.hh"
 
 /* TODO: Rename Stream_event -> Event */