2 identifier.cc -- implement identifier and derived classes
4 source file of the LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
11 #include "identifier.hh"
12 #include "my-lily-lexer.hh"
14 #include "input-register.hh"
15 #include "input-score.hh"
16 #include "symtable.hh"
17 #include "input-staff.hh"
18 #include "input-music.hh"
20 #include "script-def.hh"
22 #include "input-register.hh"
25 Identifier::error(String expect)
27 String e("Wrong identifier type: ");
28 e += String(classname()) + "(expected " + expect + ")";
32 Identifier::Identifier(String n, int code)
42 Identifier::print()const
44 mtor << "identifier \'" << name << "\'=";
49 #define DEFAULT_PRINT(Class, Content_type, accessor) \
51 Class::do_print() const { \
52 ((Class*)this)->accessor(false)->print(); \
56 DEFAULT_PRINT(Script_id, Script_def, script);
57 DEFAULT_PRINT(Lookup_id, Lookup, lookup);
58 DEFAULT_PRINT(Symtables_id, Symtables, symtables);
59 DEFAULT_PRINT(Staff_id, Input_staff, staff);
60 DEFAULT_PRINT(M_chord_id, Music_general_chord, mchord);
61 DEFAULT_PRINT(M_voice_id, Music_voice, mvoice);
62 DEFAULT_PRINT(Request_id, Request, request);
63 DEFAULT_PRINT(Score_id, Input_score, score);
64 DEFAULT_PRINT(Input_regs_id, Input_register, iregs);
67 Real_id::do_print() const
70 mtor << *((Real_id*)this)->real(false)<< "\n";
73 #define implement_id_class(Idclass, Class, accessor) \
74 char const * Idclass::classname() const\
79 Idclass::accessor(bool copy) {\
82 return new Class(* (Class*) data);\
84 return (Class*) data;\
86 Idclass::~Idclass() { delete accessor(false); }\
87 Idclass::Idclass(String s, Class*st, int code):Identifier(s,code) { data = st; }\
90 implement_id_class(Real_id, Real, real);
91 implement_id_class(Script_id, Script_def, script);
92 implement_id_class(Lookup_id, Lookup, lookup);
93 implement_id_class(Symtables_id, Symtables, symtables);
94 implement_id_class(Staff_id, Input_staff, staff);
95 implement_id_class(M_chord_id, Music_general_chord, mchord);
96 implement_id_class(M_voice_id, Music_voice, mvoice);
97 implement_id_class(Score_id, Input_score, score);
98 implement_id_class(Request_id, Request, request);
99 implement_id_class(Input_regs_id, Input_register, iregs);
101 Identifier::Identifier(Identifier const&)