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 "paper-def.hh"
12 #include "identifier.hh"
13 #include "my-lily-lexer.hh"
15 #include "input-engraver.hh"
16 #include "symtable.hh"
18 #include "script-def.hh"
20 #include "input-engraver.hh"
22 IMPLEMENT_STATIC_NAME(Identifier);
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(String n, int code)
48 Identifier::print()const
50 mtor << "identifier \'" << name_str_ << "\'=";
55 #define DEFAULT_PRINT(Class, Content_type, accessor) \
57 Class::do_print() const { \
58 ((Class*)this)->accessor(false)->print(); \
63 DEFAULT_PRINT(Script_id, General_script_def, script);
64 DEFAULT_PRINT(Lookup_id, Lookup, lookup);
65 DEFAULT_PRINT(Symtables_id, Symtables, symtables);
66 DEFAULT_PRINT(Music_id,Music , music);
67 DEFAULT_PRINT(Request_id, Request, request);
68 DEFAULT_PRINT(Score_id, Score, score);
69 DEFAULT_PRINT(Input_gravs_id, Input_engraver, igravs);
70 DEFAULT_PRINT(Paper_def_id,Paper_def, paperdef);
73 Real_id::do_print() const
75 mtor << *((Real_id*)this)->real(false)<< "\n";
79 Int_id::do_print() const
81 mtor << *((Int_id*)this)->intid(false)<< "\n";
85 #define default_accessor(Idclass, Class, accessor)\
87 Idclass::accessor(bool copy) {\
90 return new Class(* (Class*) data);\
92 return (Class*) data;\
95 #define virtual_accessor(Idclass, Class, accessor)\
97 Idclass::accessor(bool copy) {\
100 return (Class*) ((Class*) data)->clone();\
102 return (Class*) data;\
106 #define implement_id_class(Idclass, Class, accessor) \
107 IMPLEMENT_STATIC_NAME(Idclass)\
108 IMPLEMENT_IS_TYPE_B1(Idclass,Identifier)\
109 Idclass::~Idclass() { delete accessor(false); }\
110 Idclass::Idclass(String s, Class*st, int code):Identifier(s,code) { data = st; }\
114 implement_id_class(Int_id, int, intid);
115 implement_id_class(Real_id, Real, real);
116 implement_id_class(Script_id, General_script_def, script);
117 implement_id_class(Lookup_id, Lookup, lookup);
118 implement_id_class(Symtables_id, Symtables, symtables);
119 implement_id_class(Music_id, Music, music);
120 implement_id_class(Score_id, Score, score);
121 implement_id_class(Request_id, Request, request);
122 implement_id_class(Input_gravs_id, Input_engraver, igravs);
123 implement_id_class(Paper_def_id, Paper_def, paperdef);
125 Identifier::Identifier(Identifier const&)
130 default_accessor(Int_id, int, intid);
131 default_accessor(Real_id, Real, real);
132 virtual_accessor(Script_id, General_script_def, script);
133 default_accessor(Lookup_id, Lookup, lookup);
134 default_accessor(Symtables_id, Symtables, symtables);
135 virtual_accessor(Music_id, Music, music);
136 default_accessor(Score_id, Score, score);
137 virtual_accessor(Request_id, Request, request);
138 default_accessor(Input_gravs_id, Input_engraver, igravs);
139 default_accessor(Paper_def_id, Paper_def, paperdef);