* 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.
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.
@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 =
{ 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
#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 ()
if (book->paper_)
scm_gc_mark (book->paper_->self_scm ());
scm_gc_mark (book->scores_);
-
+ scm_gc_mark (book->input_location_);
+
return book->header_;
}
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;
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_;
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_;
}
#include <cstring>
#include "main.hh"
-#include "input-smob.hh"
+#include "input.hh"
#include "pointer-group-interface.hh"
#include "misc.hh"
#include "paper-score.hh"
#include <cstring>
#include "align-interface.hh"
-#include "input-smob.hh"
+#include "input.hh"
#include "international.hh"
#include "item.hh"
#include "main.hh"
Object_key const *key)
{
key_ = key;
+
/* FIXME: default should be no callback. */
self_scm_ = SCM_EOL;
layout_ = 0;
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:
};
public:
VIRTUAL_COPY_CONSTRUCTOR (Output_def, Output_def);
Output_def (Output_def const &);
-
Output_def ();
virtual void derived_mark ();
#include "object-key.hh"
#include "std-string.hh"
-class Book : public Input
+class Book
{
DECLARE_SMOBS (Book, foo);
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,
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:
/*
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_; }
DECLARE_LISTENER (revert);
public:
VIRTUAL_COPY_CONSTRUCTOR (Translator_group, Engraver_group);
+
Engraver_group ();
virtual void derived_mark () const;
void do_announces ();
+++ /dev/null
-/*
- 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 */
-
Input ();
};
+
+
+#include "input.hh"
+#include "smobs.hh"
+
+SCM make_input (Input spot);
+Input *unsmob_input (SCM);
+
+extern Input dummy_input_global;
+
#endif // INPUT_HH
public:
VIRTUAL_COPY_CONSTRUCTOR (Output_def, Output_def);
DECLARE_SMOBS (Output_def, );
+
public:
SCM scope_;
Output_def *parent_;
#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_;
Score ();
Score (Score const &);
+ VIRTUAL_COPY_CONSTRUCTOR (Score, Score);
SCM get_music () const;
void add_output_def (Output_def *def);
*/
#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. */
(c) 2000--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
*/
-#include "input-smob.hh"
+#include "input.hh"
#include "source-file.hh"
#include "std-string.hh"
#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"
#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"
#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"
#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"
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 ($$);
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;
// 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);
#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 ()
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_;
}
}
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)
vector<char> cxx_arr;
cxx_arr.resize (filesize);
-
copy (str, str + filesize, cxx_arr.begin ());
- free (str);
+ delete[] str;
return cxx_arr;
}
#include "main.hh"
#include "font-metric.hh"
-#include "input-smob.hh"
+#include "input.hh"
#include "string-convert.hh"
#include "warn.hh"
#include "ly-smobs.icc"
#include "context.hh"
#include "input.hh"
-#include "input-smob.hh"
+#include "input.hh"
/* TODO: Rename Stream_event -> Event */