lilypond-1.3.154
[lilypond.git] / lily / identifier.cc
blob28e450ac496c99cd4a8c2a41d15ec4736ce94552
1 /*
2 identifier.cc -- implement identifier and derived classes
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
11 JUNKTHIS!
13 #include <assert.h>
15 #include "music-output-def.hh"
16 #include "score.hh"
17 #include "identifier.hh"
18 #include "my-lily-lexer.hh"
19 #include "debug.hh"
20 #include "ly-smobs.icc"
23 IMPLEMENT_UNSMOB(Identifier, identifier);
24 IMPLEMENT_SMOBS(Identifier);
25 IMPLEMENT_DEFAULT_EQUAL_P(Identifier);
27 Identifier::Identifier (int code)
29 token_code_i_ = code;
30 accessed_b_ = 0;
31 smobify_self ();
34 Identifier::Identifier (Identifier const&s)
35 : Input (s)
37 smobify_self ();
38 token_code_i_ = s.token_code_i_;
39 accessed_b_ = s.accessed_b_;
42 Identifier::~Identifier()
46 void
47 Identifier::error (String expect) const
49 ::error (_f ("wrong identifier type, expected: `%s'", expect));
52 String
53 Identifier::str () const
55 return do_str ();
58 String
59 Identifier::do_str () const
61 return "";
65 /* ugh. */
66 #define DUMMY_STR(Class) \
67 String \
68 Class ## _identifier::do_str () const { \
69 return String (#Class); \
72 DUMMY_STR(Score);
73 DUMMY_STR(Music_output_def);
76 #define DEFAULT_STR(Class) \
77 String \
78 Class ## _identifier::do_str () const\
80 return to_str (*data_p_);\
86 fucking C++ blows me.
89 #define DEFAULT_ACCESSOR(Class)\
90 Class*\
91 Class ## _identifier::access_content_ ## Class (bool copy_b) const {\
92 ((Class ## _identifier*)this)->accessed_b_ = true;\
93 return copy_b ? new Class (*data_p_) : data_p_;\
96 #define VIRTUAL_ACCESSOR(Class)\
97 Class*\
98 Class ## _identifier::access_content_ ## Class (bool copy_b) const{\
99 ((Class ## _identifier*)this)->accessed_b_ = true;\
100 return copy_b ? dynamic_cast<Class*> (data_p_->clone()) : data_p_;\
103 #define IMPLEMENT_ID_CLASS(Class) \
104 Class ## _identifier::~Class ## _identifier() { delete data_p_; }\
105 Class ## _identifier::Class ## _identifier (Class*st, int code) \
106 :Identifier (code)\
108 data_p_ = st;\
110 Class ## _identifier::Class ## _identifier (Class ## _identifier const &s) \
111 : Identifier (s)\
113 data_p_ = s.access_content_ ## Class (true);\
117 IMPLEMENT_ID_CLASS(Score);
118 IMPLEMENT_ID_CLASS(Music_output_def);
119 VIRTUAL_ACCESSOR(Music_output_def);
120 DEFAULT_ACCESSOR(Score);
124 Identifier::print_smob (SCM s, SCM p, scm_print_state*)
126 return 1;
130 Identifier::mark_smob (SCM s)
132 return SCM_EOL;