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>
15 #include "music-output-def.hh"
17 #include "identifier.hh"
18 #include "my-lily-lexer.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
)
34 Identifier::Identifier (Identifier
const&s
)
38 token_code_i_
= s
.token_code_i_
;
39 accessed_b_
= s
.accessed_b_
;
42 Identifier::~Identifier()
47 Identifier::error (String expect
) const
49 ::error (_f ("wrong identifier type, expected: `%s'", expect
));
53 Identifier::str () const
59 Identifier::do_str () const
66 #define DUMMY_STR(Class) \
68 Class ## _identifier::do_str () const { \
69 return String (#Class); \
73 DUMMY_STR(Music_output_def
);
76 #define DEFAULT_STR(Class) \
78 Class ## _identifier::do_str () const\
80 return to_str (*data_p_);\
89 #define DEFAULT_ACCESSOR(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)\
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) \
110 Class ## _identifier::Class ## _identifier (Class ## _identifier const &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
*)
130 Identifier::mark_smob (SCM s
)