2 identifier.cc -- implement identifier and derived classes
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1998 Han-Wen Nienhuys <hanwen@stack.nl>
10 #include "midi-def.hh"
11 #include "paper-def.hh"
13 #include "identifier.hh"
14 #include "my-lily-lexer.hh"
16 #include "symtable.hh"
18 #include "script-def.hh"
20 #include "translator.hh"
23 IMPLEMENT_IS_TYPE_B(Identifier);
25 Identifier::~Identifier()
30 Identifier::error (String expect)
32 String e (_("Wrong identifier type: "));
33 e += String (name()) + _("(expected ") + expect + ")";
37 Identifier::Identifier (int code)
45 Identifier::print() const
47 DOUT << "identifier ";
52 #define DEFAULT_PRINT(Class, Content_type, accessor) \
54 Class::do_print() const { \
55 ((Class*)this)->accessor()->print(); \
60 DEFAULT_PRINT(Script_id, General_script_def, script);
61 DEFAULT_PRINT(Lookup_id, Lookup, lookup);
62 DEFAULT_PRINT(Translator_id, Translator, translator);
63 DEFAULT_PRINT(Symtables_id, Symtables, symtables);
64 DEFAULT_PRINT(Music_id,Music , music);
65 DEFAULT_PRINT(Request_id, Request, request);
66 DEFAULT_PRINT(Score_id, Score, score);
67 DEFAULT_PRINT(Midi_def_id,Midi_def, mididef);
68 DEFAULT_PRINT(Paper_def_id,Paper_def, paperdef);
72 Duration_id::do_print() const
76 Real_id::do_print() const
78 DOUT << *data_p_<< "\n";
82 Int_id::do_print() const
84 DOUT << *data_p_<< "\n";
88 #define DEFAULT_ACCESSOR(Idclass, Class, accessor)\
90 Idclass::accessor () {\
92 return new Class (*data_p_);\
95 #define VIRTUAL_ACCESSOR(Idclass, Class, accessor)\
97 Idclass::accessor () {\
99 return (Class*)data_p_->clone();\
102 #define IMPLEMENT_ID_CLASS(Idclass, Class, accessor) \
103 IMPLEMENT_IS_TYPE_B1(Idclass,Identifier)\
104 Idclass::~Idclass() { delete data_p_; }\
105 Idclass::Idclass (Class*st, int code):Identifier (code) { data_p_ = st; }\
107 IMPLEMENT_ID_CLASS(Duration_id, Duration, duration);
108 IMPLEMENT_ID_CLASS(Translator_id, Translator, translator);
109 IMPLEMENT_ID_CLASS(Int_id, int, intid);
110 IMPLEMENT_ID_CLASS(Real_id, Real, real);
111 IMPLEMENT_ID_CLASS(Script_id, General_script_def, script);
112 IMPLEMENT_ID_CLASS(Lookup_id, Lookup, lookup);
113 IMPLEMENT_ID_CLASS(Symtables_id, Symtables, symtables);
114 IMPLEMENT_ID_CLASS(Music_id, Music, music);
115 IMPLEMENT_ID_CLASS(Score_id, Score, score);
116 IMPLEMENT_ID_CLASS(Request_id, Request, request);
117 IMPLEMENT_ID_CLASS(Midi_def_id, Midi_def, mididef);
118 IMPLEMENT_ID_CLASS(Paper_def_id, Paper_def, paperdef);
120 Identifier::Identifier (Identifier const&s)
126 DEFAULT_ACCESSOR(Duration_id, Duration, duration);
127 VIRTUAL_ACCESSOR(Translator_id,Translator, translator);
128 DEFAULT_ACCESSOR(Int_id, int, intid);
129 DEFAULT_ACCESSOR(Real_id, Real, real);
130 VIRTUAL_ACCESSOR(Script_id, General_script_def, script);
131 DEFAULT_ACCESSOR(Lookup_id, Lookup, lookup);
132 DEFAULT_ACCESSOR(Symtables_id, Symtables, symtables);
133 VIRTUAL_ACCESSOR(Music_id, Music, music);
134 DEFAULT_ACCESSOR(Score_id, Score, score);
135 VIRTUAL_ACCESSOR(Request_id, Request, request);
136 DEFAULT_ACCESSOR(Midi_def_id, Midi_def, mididef);
137 DEFAULT_ACCESSOR(Paper_def_id, Paper_def, paperdef);