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"
15 #include "input-score.hh"
16 #include "symtable.hh"
17 #include "input-staff.hh"
18 #include "input-music.hh"
20 #include "script-def.hh"
24 Identifier::error(String expect)
26 String e("Wrong identifier type: ");
27 e += String(classname()) + "(expected " + expect + ")";
32 Identifier::print()const
34 mtor << "identifier \'" << name << "\'=";
39 #define DEFAULT_PRINT(Class, Content_type, accessor) \
41 Class::do_print() const { \
42 ((Class*)this)->accessor(false)->print(); \
46 DEFAULT_PRINT(Script_id, Script_def, script);
47 DEFAULT_PRINT(Lookup_id, Lookup, lookup);
48 DEFAULT_PRINT(Symtables_id, Symtables, symtables);
49 DEFAULT_PRINT(Staff_id, Input_staff, staff);
50 DEFAULT_PRINT(M_chord_id, Music_general_chord, mchord);
51 DEFAULT_PRINT(M_voice_id, Music_voice, mvoice);
52 DEFAULT_PRINT(Request_id, Request, request);
53 DEFAULT_PRINT(Score_id, Input_score, score);
55 Real_id::do_print() const
58 mtor << *((Real_id*)this)->real(false)<< "\n";
61 #define implement_id_class(Idclass, Class, accessor) \
62 char const * Idclass::classname() const\
67 Idclass::accessor(bool copy) {\
69 return new Class(* (Class*) data);\
71 return (Class*) data;\
73 Idclass::~Idclass() { delete accessor(false); }\
74 Idclass::Idclass(String s, Class*st, int code):Identifier(s,code) { data = st; }\
77 implement_id_class(Real_id, Real, real)
78 implement_id_class(Script_id, Script_def, script)
79 implement_id_class(Lookup_id, Lookup, lookup)
80 implement_id_class(Symtables_id, Symtables, symtables)
81 implement_id_class(Staff_id, Input_staff, staff)
82 implement_id_class(M_chord_id, Music_general_chord, mchord)
83 implement_id_class(M_voice_id, Music_voice, mvoice)
84 implement_id_class(Score_id, Input_score, score)
85 implement_id_class(Request_id, Request, request)