2 identifier.cc -- implement identifier and derived classes
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 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()
27 if (!accessed_b_
&& !init_b_
)
28 warning (_("Variable not used"));
31 Identifier::error (String expect
)
33 String
e (_("Wrong identifier type: "));
34 e
+= String (name()) + _("(expected ") + expect
+ ")";
38 Identifier::Identifier (int code
)
46 Identifier::print() const
48 DOUT
<< "identifier ";
53 #define DEFAULT_PRINT(Class, Content_type, accessor) \
55 Class::do_print() const { \
56 ((Class*)this)->accessor()->print(); \
61 DEFAULT_PRINT(Script_id
, General_script_def
, script
);
62 DEFAULT_PRINT(Lookup_id
, Lookup
, lookup
);
63 DEFAULT_PRINT(Translator_id
, Translator
, translator
);
64 DEFAULT_PRINT(Symtables_id
, Symtables
, symtables
);
65 DEFAULT_PRINT(Music_id
,Music
, music
);
66 DEFAULT_PRINT(Request_id
, Request
, request
);
67 DEFAULT_PRINT(Score_id
, Score
, score
);
68 DEFAULT_PRINT(Midi_def_id
,Midi_def
, mididef
);
69 DEFAULT_PRINT(Paper_def_id
,Paper_def
, paperdef
);
73 Duration_id::do_print() const
77 Real_id::do_print() const
79 DOUT
<< *data_p_
<< "\n";
83 Int_id::do_print() const
85 DOUT
<< *data_p_
<< "\n";
89 #define DEFAULT_ACCESSOR(Idclass, Class, accessor)\
91 Idclass::accessor () {\
93 return new Class (*data_p_);\
96 #define VIRTUAL_ACCESSOR(Idclass, Class, accessor)\
98 Idclass::accessor () {\
100 return (Class*)data_p_->clone();\
103 #define IMPLEMENT_ID_CLASS(Idclass, Class, accessor) \
104 IMPLEMENT_IS_TYPE_B1(Idclass,Identifier)\
105 Idclass::~Idclass() { delete data_p_; }\
106 Idclass::Idclass (Class*st, int code):Identifier (code) { data_p_ = st; }\
108 IMPLEMENT_ID_CLASS(Duration_id, Duration, duration);
109 IMPLEMENT_ID_CLASS(Translator_id
, Translator
, translator
);
110 IMPLEMENT_ID_CLASS(Int_id
, int, intid
);
111 IMPLEMENT_ID_CLASS(Real_id
, Real
, real
);
112 IMPLEMENT_ID_CLASS(Script_id
, General_script_def
, script
);
113 IMPLEMENT_ID_CLASS(Lookup_id
, Lookup
, lookup
);
114 IMPLEMENT_ID_CLASS(Symtables_id
, Symtables
, symtables
);
115 IMPLEMENT_ID_CLASS(Music_id
, Music
, music
);
116 IMPLEMENT_ID_CLASS(Score_id
, Score
, score
);
117 IMPLEMENT_ID_CLASS(Request_id
, Request
, request
);
118 IMPLEMENT_ID_CLASS(Midi_def_id
, Midi_def
, mididef
);
119 IMPLEMENT_ID_CLASS(Paper_def_id
, Paper_def
, paperdef
);
121 Identifier::Identifier (Identifier
const&)
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
);