From 31e311c0fb0ede49394d058b6c22f2a130421b9e Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Mon, 3 Mar 1997 13:09:34 +0100 Subject: [PATCH] release: 0.0.38 --- .dstreamrc | 9 +- Documentation/CodingStyle.pod | 9 +- Documentation/README.pod | 18 +- Documentation/faq.pod | 50 +++- Documentation/language.pod | 27 +- NEWS | 25 +- Sources.make | 108 +++---- TODO | 12 +- Variables.make | 7 +- flower/assoc-iter.hh | 39 +++ flower/data-file.cc | 95 ++++++ flower/data-file.hh | 59 ++++ flower/libc-extension.cc | 98 ++++++ flower/libc-extension.hh | 25 ++ flower/string-data.hh | 95 ++++++ flower/string-data.inl | 209 +++++++++++++ flower/string-handle.hh | 70 +++++ flower/string-handle.inl | 156 ++++++++++ flower/text-db.cc | 48 +++ flower/text-db.hh | 55 ++++ flower/text-stream.cc | 31 ++ flower/text-stream.hh | 74 +++++ genheader | 2 +- hdr/Makefile | 2 +- hdr/{barreg.hh => bar-reg.hh} | 11 +- hdr/bar.hh | 2 +- hdr/beam.hh | 4 +- hdr/class-name.hh | 19 ++ hdr/{clefitem.hh => clef-item.hh} | 4 +- hdr/{clefreg.hh => clef-reg.hh} | 11 +- hdr/{complexstaff.hh => complex-staff.hh} | 4 +- hdr/complex-walker.hh | 47 +++ hdr/complexwalker.hh | 95 ------ ...ionalspanner.hh => directional-spanner.hh} | 2 +- hdr/grouping.hh | 6 +- hdr/headreg.hh | 12 +- hdr/identifier.hh | 7 +- hdr/identparent.hh | 5 + hdr/{inputfile.hh => input-file.hh} | 2 +- hdr/{inputmusic.hh => input-music.hh} | 2 +- hdr/{inputscore.hh => input-score.hh} | 6 +- hdr/{inputstaff.hh => input-staff.hh} | 2 +- hdr/item.hh | 5 +- hdr/{keyitem.hh => key-item.hh} | 4 +- hdr/{keyreg.hh => key-reg.hh} | 11 +- hdr/lexer.hh | 1 + hdr/{localkeyitem.hh => local-key-item.hh} | 4 +- hdr/{localkeyreg.hh => local-key-reg.hh} | 9 +- hdr/lookup.hh | 2 +- hdr/lyricwalker.hh | 2 +- hdr/{meterreg.hh => meter-reg.hh} | 11 +- hdr/meter.hh | 2 +- hdr/{midioutput.hh => midi-output.hh} | 2 +- hdr/notehead.hh | 4 +- hdr/{paperdef.hh => paper-def.hh} | 16 +- hdr/proto.hh | 5 +- hdr/pscore.hh | 4 +- hdr/register.hh | 112 +++---- hdr/registergroup.hh | 44 ++- hdr/request.hh | 9 +- hdr/rest.hh | 2 +- hdr/{scorecolumn.hh => score-column.hh} | 0 hdr/{scorewalker.hh => score-walker.hh} | 2 +- hdr/score.hh | 4 +- hdr/{scriptdef.hh => script-def.hh} | 2 +- hdr/script-reg.hh | 29 ++ hdr/script.hh | 12 +- hdr/scriptreg.hh | 26 -- hdr/{slurreg.hh => slur-reg.hh} | 15 +- hdr/slur.hh | 4 +- hdr/spanner.hh | 7 +- hdr/{staffcolumn.hh => staff-column.hh} | 3 +- hdr/staff-elem-info.hh | 43 +++ hdr/{staffelem.hh => staff-elem.hh} | 16 +- hdr/{staffwalker.hh => staff-walker.hh} | 4 +- hdr/staff.hh | 2 +- hdr/staffeleminfo.hh | 28 -- hdr/staffsym.hh | 2 +- hdr/{stembeamreg.hh => stem-beam-reg.hh} | 13 +- hdr/stem.hh | 3 +- hdr/symbol.hh | 1 + hdr/symtable.hh | 3 +- hdr/{tstream.hh => tex-stream.hh} | 0 hdr/{textdef.hh => text-def.hh} | 4 +- hdr/{textreg.hh => text-reg.hh} | 13 +- hdr/textitem.hh | 4 +- hdr/textspanner.hh | 12 +- ...timedescription.hh => time-description.hh} | 0 hdr/voice-element.hh | 37 +++ hdr/voice-group-regs.hh | 29 ++ hdr/{voiceregs.hh => voice-regs.hh} | 16 +- hdr/voice.hh | 26 +- hdr/voicegroupregs.hh | 27 -- hdr/walkregs.hh | 34 ++- init/symbol.ini | 4 +- input/midi.ly | 3 +- input/scales.ly | 14 +- src/Makefile | 2 +- src/{barreg.cc => bar-reg.cc} | 31 +- src/bar.cc | 4 +- src/beam.cc | 6 +- src/binary-source-file.cc | 14 +- src/break.cc | 2 +- src/calcideal.cc | 4 +- src/{clefitem.cc => clef-item.cc} | 10 +- src/{clefreg.cc => clef-reg.cc} | 52 ++-- src/{complexstaff.cc => complex-staff.cc} | 11 +- src/complex-walker.cc | 108 +++++++ src/complexwalker.cc | 279 ------------------ ...ionalspanner.cc => directional-spanner.cc} | 2 +- src/duration.cc | 2 +- src/grouping.cc | 4 +- src/headreg.cc | 48 +-- src/identifier.cc | 45 ++- src/{inputmusic.cc => input-music.cc} | 3 +- src/{inputscore.cc => input-score.cc} | 18 +- src/{inputstaff.cc => input-staff.cc} | 8 +- src/item.cc | 2 +- src/{keyitem.cc => key-item.cc} | 10 +- src/{keyreg.cc => key-reg.cc} | 43 +-- src/lexer.l | 3 +- src/lexerinit.cc | 2 +- src/lily-stream.cc | 2 +- src/{localkeyitem.cc => local-key-item.cc} | 8 +- src/{localkeyreg.cc => local-key-reg.cc} | 34 ++- src/lookup.cc | 17 +- src/{lyricitem.cc => lyric-item.cc} | 11 +- src/lyricstaff.cc | 2 +- src/lyricwalker.cc | 4 +- src/main.cc | 6 +- src/{meterreg.cc => meter-reg.cc} | 21 +- src/meter.cc | 4 +- src/midi-event.cc | 2 +- src/midi-main.cc | 2 +- src/midi-score.cc | 2 +- src/midi-template.cc | 2 +- src/midi-track.cc | 2 +- src/my-midi-lexer.cc | 4 +- src/my-midi-parser.cc | 2 +- src/mylexer.cc | 18 +- src/note.cc | 5 +- src/notehead.cc | 8 +- src/{paperdef.cc => paper-def.cc} | 25 +- src/parser.y | 23 +- src/pscore.cc | 8 +- src/register.cc | 70 +++-- src/registergroup.cc | 69 +++-- src/request.cc | 14 +- src/rest.cc | 6 +- src/{scorecolumn.cc => score-column.cc} | 4 +- src/{scorewalker.cc => score-walker.cc} | 8 +- src/score.cc | 18 +- src/scoreline.cc | 2 +- src/scores.cc | 4 +- src/{scriptdef.cc => script-def.cc} | 6 +- src/script-reg.cc | 76 +++++ src/script.cc | 8 +- src/scriptreg.cc | 69 ----- src/{slurreg.cc => slur-reg.cc} | 36 ++- src/slur.cc | 6 +- src/{sourcefile.cc => source-file.cc} | 4 +- src/source.cc | 2 +- src/spanner.cc | 2 +- src/{staffcolumn.cc => staff-column.cc} | 13 +- src/staff-elem-info.cc | 38 +++ src/{staffelem.cc => staff-elem.cc} | 8 +- src/{staffwalker.cc => staff-walker.cc} | 12 +- src/staff.cc | 14 +- src/staffeleminfo.cc | 32 -- src/staffline.cc | 2 +- src/staffsym.cc | 4 +- src/{stembeamreg.cc => stem-beam-reg.cc} | 41 +-- src/stem.cc | 24 +- src/symbol.cc | 5 + src/symtable.cc | 19 +- src/template2.cc | 5 +- src/template3.cc | 10 +- src/template6.cc | 4 +- src/{tstream.cc => tex-stream.cc} | 20 +- src/tex.cc | 8 +- src/{textdef.cc => text-def.cc} | 6 +- src/text-reg.cc | 59 ++++ src/textitem.cc | 15 +- src/textreg.cc | 54 ---- src/textspanner.cc | 8 +- ...timedescription.cc => time-description.cc} | 4 +- src/voice-group-regs.cc | 85 ++++++ src/voice-regs.cc | 65 ++++ src/voice.cc | 11 +- src/voiceelt.cc | 8 +- src/voicegroupregs.cc | 70 ----- src/voiceregs.cc | 34 --- src/walkregs.cc | 171 ++++++++++- src/warn.cc | 4 +- 194 files changed, 2970 insertions(+), 1467 deletions(-) create mode 100644 flower/assoc-iter.hh create mode 100644 flower/data-file.cc create mode 100644 flower/data-file.hh create mode 100644 flower/libc-extension.cc create mode 100644 flower/libc-extension.hh create mode 100644 flower/string-data.hh create mode 100644 flower/string-data.inl create mode 100644 flower/string-handle.hh create mode 100644 flower/string-handle.inl create mode 100644 flower/text-db.cc create mode 100644 flower/text-db.hh create mode 100644 flower/text-stream.cc create mode 100644 flower/text-stream.hh rename hdr/{barreg.hh => bar-reg.hh} (68%) create mode 100644 hdr/class-name.hh rename hdr/{clefitem.hh => clef-item.hh} (85%) rename hdr/{clefreg.hh => clef-reg.hh} (69%) rename hdr/{complexstaff.hh => complex-staff.hh} (81%) create mode 100644 hdr/complex-walker.hh delete mode 100644 hdr/complexwalker.hh rename hdr/{directionalspanner.hh => directional-spanner.hh} (91%) rename hdr/{inputfile.hh => input-file.hh} (92%) rename hdr/{inputmusic.hh => input-music.hh} (99%) rename hdr/{inputscore.hh => input-score.hh} (91%) rename hdr/{inputstaff.hh => input-staff.hh} (93%) rename hdr/{keyitem.hh => key-item.hh} (88%) rename hdr/{keyreg.hh => key-reg.hh} (72%) rename hdr/{localkeyitem.hh => local-key-item.hh} (89%) rename hdr/{localkeyreg.hh => local-key-reg.hh} (66%) rename hdr/{meterreg.hh => meter-reg.hh} (64%) rename hdr/{midioutput.hh => midi-output.hh} (90%) rename hdr/{paperdef.hh => paper-def.hh} (83%) rename hdr/{scorecolumn.hh => score-column.hh} (100%) rename hdr/{scorewalker.hh => score-walker.hh} (94%) rename hdr/{scriptdef.hh => script-def.hh} (90%) create mode 100644 hdr/script-reg.hh delete mode 100644 hdr/scriptreg.hh rename hdr/{slurreg.hh => slur-reg.hh} (59%) rename hdr/{staffcolumn.hh => staff-column.hh} (92%) create mode 100644 hdr/staff-elem-info.hh rename hdr/{staffelem.hh => staff-elem.hh} (89%) rename hdr/{staffwalker.hh => staff-walker.hh} (92%) delete mode 100644 hdr/staffeleminfo.hh rename hdr/{stembeamreg.hh => stem-beam-reg.hh} (67%) rename hdr/{tstream.hh => tex-stream.hh} (100%) rename hdr/{textdef.hh => text-def.hh} (83%) rename hdr/{textreg.hh => text-reg.hh} (51%) rename hdr/{timedescription.hh => time-description.hh} (100%) create mode 100644 hdr/voice-element.hh create mode 100644 hdr/voice-group-regs.hh rename hdr/{voiceregs.hh => voice-regs.hh} (51%) delete mode 100644 hdr/voicegroupregs.hh rename src/{barreg.cc => bar-reg.cc} (61%) rename src/{clefitem.cc => clef-item.cc} (85%) rename src/{clefreg.cc => clef-reg.cc} (59%) rename src/{complexstaff.cc => complex-staff.cc} (79%) create mode 100644 src/complex-walker.cc delete mode 100644 src/complexwalker.cc rename src/{directionalspanner.cc => directional-spanner.cc} (65%) rename src/{inputmusic.cc => input-music.cc} (98%) rename src/{inputscore.cc => input-score.cc} (83%) rename src/{inputstaff.cc => input-staff.cc} (92%) rename src/{keyitem.cc => key-item.cc} (92%) rename src/{keyreg.cc => key-reg.cc} (61%) rename src/{localkeyitem.cc => local-key-item.cc} (94%) rename src/{localkeyreg.cc => local-key-reg.cc} (59%) rename src/{lyricitem.cc => lyric-item.cc} (71%) rename src/{meterreg.cc => meter-reg.cc} (65%) rename src/{paperdef.cc => paper-def.cc} (73%) rename src/{scorecolumn.cc => score-column.cc} (94%) rename src/{scorewalker.cc => score-walker.cc} (94%) rename src/{scriptdef.cc => script-def.cc} (72%) create mode 100644 src/script-reg.cc delete mode 100644 src/scriptreg.cc rename src/{slurreg.cc => slur-reg.cc} (70%) rename src/{sourcefile.cc => source-file.cc} (98%) rename src/{staffcolumn.cc => staff-column.cc} (92%) create mode 100644 src/staff-elem-info.cc rename src/{staffelem.cc => staff-elem.cc} (96%) rename src/{staffwalker.cc => staff-walker.cc} (92%) delete mode 100644 src/staffeleminfo.cc rename src/{stembeamreg.cc => stem-beam-reg.cc} (74%) rename src/{tstream.cc => tex-stream.cc} (80%) rename src/{textdef.cc => text-def.cc} (85%) create mode 100644 src/text-reg.cc delete mode 100644 src/textreg.cc rename src/{timedescription.cc => time-description.cc} (96%) create mode 100644 src/voice-group-regs.cc create mode 100644 src/voice-regs.cc delete mode 100644 src/voicegroupregs.cc delete mode 100644 src/voiceregs.cc diff --git a/.dstreamrc b/.dstreamrc index 0ae4806aca..13642e8b39 100644 --- a/.dstreamrc +++ b/.dstreamrc @@ -14,6 +14,7 @@ Idealspacing 1 # yydebug InitParser 1 Parser 1 +InitDeclarations 1 # FlexLexer debug InitLexer 1 @@ -32,8 +33,8 @@ Staff_commands 1 Stem 1 Staff 0 Score 1 -Voice 1 -Voice_element 1 +Voice 0 +Voice_element 0 Input_cursor 1 Commands_at 1 Input_command 1 @@ -41,7 +42,7 @@ Time_description 1 Melodic_req 0 Midi_walker 0 Stem_req 1 -Group_change_req 1 +Group_change_req 0 Script_req 1 Colinfo 1 Word_wrap 1 @@ -49,3 +50,5 @@ Text_req 1 Script_def 1 Text_def 1 Paperdef 1 +Symtable 1 +Symtables 1 \ No newline at end of file diff --git a/Documentation/CodingStyle.pod b/Documentation/CodingStyle.pod index 521bf1e126..2ccc103080 100644 --- a/Documentation/CodingStyle.pod +++ b/Documentation/CodingStyle.pod @@ -16,13 +16,14 @@ in emacs: (add-hook 'c-mode-hook '(lambda ()(setq c-basic-offset 4))) - - (add-hook 'c++-mode-hook '(lambda() (c-set-style "Stroustrup") ) ) +=head2 FILES +The class C is declared in F and +implemented in F. =head2 CLASSES and TYPES: @@ -34,7 +35,7 @@ in emacs: Class::member() Type Class::member_type_ -the C is a Hungarian notation postfix for $C$. See below +the C is a Hungarian notation postfix for C. See below =head2 COMMENTS @@ -88,7 +89,7 @@ symbols. Staff is the "brains" for PStaff NB: in PCursor (which is part of the library) P stands for PointerCursor -=head2 MEMBERS(2) +=head2 MEMBERS (2) Standard methods: diff --git a/Documentation/README.pod b/Documentation/README.pod index 96c5ea4dd5..a4dc31770b 100644 --- a/Documentation/README.pod +++ b/Documentation/README.pod @@ -123,7 +123,7 @@ add F to the search path for input files. =item B<-M,--midi> -do midi output only +Do midi output only. =item B<-d,--debug>, @@ -201,7 +201,7 @@ LilyPond does use a lot of resources. For operation you need the following: =over 5 =item * -a fast computer (a full page of music typically takes 1 minute +A fast computer (a full page of music typically takes 1 minute on my 486/66, using the DEBUG compile. It's lot slower than most MusiXTeX preprocessors) @@ -226,7 +226,7 @@ Do: You probably want to edit Variables.make to tailor the compilation flags. If you're not into debugging C++, then you should go for no -debugging and C<-O2> +debugging and C<-O2>. =head1 AUTHORS @@ -236,11 +236,11 @@ debugging and C<-O2> Han-Wen Nienhuys , Main author =item * -Jan Nieuwenhuizen , Context errors, Lyrics, -bits of FlowerLib, general comments. +Jan C. Nieuwenhuizen , Context errors, Lyrics, Midi +output, m2m, bits of FlowerLib, general comments. =item * -Mats Bengtsson , bugfixes, testing, general comments. +Mats Bengtsson , bugfixes, testing, criticism, general comments. =back @@ -326,8 +326,10 @@ includes files from the directory F. =head1 SEE ALSO -There are some documentation files in the subdirectory F, -among others: lilygut, lilyinput, error, faq, +There are some documentation files in the subdirectory +F, among others: lilygut, lilyinput, error, faq. There +is a rudimentary webpage at the following URL: +http://www.stack.nl/~hanwen/lilypond/index.html =head1 REMARKS diff --git a/Documentation/faq.pod b/Documentation/faq.pod index 79e511498e..8cb445e23c 100644 --- a/Documentation/faq.pod +++ b/Documentation/faq.pod @@ -6,6 +6,20 @@ FAQ - LilyPond FAQs Some questions that have been answered before. +Q: Gee, I really like MPP, why would I want to switch to LilyPond? + +A: The design of MPP is broken beyond repair: it is very difficult to +enhance MPP, and any working version is (probably) bug-ridden. + +Every once in a while, I have a major attack of hybris, and I go in to +enhance MPP. I usually end up thoroughly frustated within an hour or +so. I concur, it does work but extending MPP is a major pain. + +We will not sacrifice development time on something else than the most +trivial bugfixes. If you insist on using MusiXTeX, then LilyPond is +not for you, and you might try PMX which does also nice output. + + Q: Why are [] around the notes, and () inbetween? A: [] designate beams, a note can only be in one beam at the same @@ -20,13 +34,13 @@ Q: I want a DOS/NT/W95 port. A0: Reconsider. Try Linux. It's fun! A1: Currently (patchlevel 27), LilyPond (and flowerLib) compiles, links -and runs on windhoos-nt, using the cygnus gnu port (release b17.1). +and runs on Windhoos-NT, using the CYGNUS GNU port (release b17.1). I (JCN) only had to make a minor workaround for missing library calls. Have a look at http://www.cygnus.com/gnu-win32. To make LilyPond type -make $OS. (I am not promising to maintain this platform, it is just that +C. (I am not promising to maintain this platform, it is just that when having to use doze, i-m sometimes too lazy to reboot.) -A2: I haven't had time to find a GCC crosscompiler (*with* g++, mind you) to +A2: I haven't had time to find a GCC crosscompiler (I g++, mind you) to DOS/win (in rpm, please :). @@ -34,6 +48,7 @@ Q: Why GPL? A: Yes. + Q: Why shouldn't I put all commands (\clef, \meter) inside the music? A: You should do what you like, but at some time we will enable @@ -53,8 +68,10 @@ simple front end to the complicated internals. Q: Why do I need g++ >= 2.7? A: By using g++ LilyPond is portable to all platforms which support -g++ (there are quite a few). Not having to support other compilers -saves us a *lot* of trouble. LilyPond & FlowerLib uses: +g++ (there are quite a few, more than platforms which have AT&T CC or +Micro$oft C++). Not having to support other compilers saves us a I +of trouble. You need a version better than 2.7 because LilyPond & +FlowerLib uses: =over 6 @@ -81,3 +98,26 @@ named return values =back +Q: Why do I have to tell LilyPond explictly that the lowest-line-note +is "es" if I am using the key of "bes"? + +A: The goal of lilypond (and MPP) was to design a language which +conveys the I message of a piece. That is the reason that it +does not ask you to enter the line on which the note is is. (Or the +"natural" note-name without any "es" or "is" postfix) + +We do realise it is a bit shortsighted of us to assume that any user could +readily read the music he/she is entering. We might extend LilyPond to +allow "programmable" intervals, keys and clefs (and thus give him a +means to build his own scales, custom etc.). + +For now, you can program LilyPond to use custom notenames and do + + notenames { ces_key_notenames } + music { $ % music in the key of ces + ... + $} + notenames { dutch_notenames } % restore default + +as an ad-hoc solution. + diff --git a/Documentation/language.pod b/Documentation/language.pod index e316fdc14e..c7e9a81bc9 100644 --- a/Documentation/language.pod +++ b/Documentation/language.pod @@ -22,6 +22,12 @@ A musical notation that is relatively easy to comprehend to both programmers and non programmers. The final aim is to be able to express what can be expressed in sheet music. +This document is intended to summarise the plans for mudela 2 (mudela +0 being mpp-input, and mudela-1 LilyPond input upto version 0.0.38). +Ideas for any further extensions (mudela 3, read total vapourware) +should be marked as such. + + =over 5 =item * @@ -129,6 +135,11 @@ voices on one staff? We might be able to do without the staff{} construct, but I doubt if it will make things easier. +=head1 DECISIONS + +[none, yet] + + =head1 THOUGHTS =head2 Typing @@ -197,7 +208,11 @@ As simple fix, we might do key declarations: \key{\keybes} +[LOOSE] +We could be even more rabid, and use '\rab' as \bar terminator. + +Just kidding of course... [LOOSE THOUGHT] @@ -298,7 +313,7 @@ Mats is an arduous fan of having the commands inside music. I am not. I see the Mudela music as something which can be plugged into different staffs, transposed, translated in time, copied, quoted, etc. Encouraging "inline" commands would be bad since they hinder this -reuse of typed music. +reuse of mudela-isated music. The way I figure it, the bad part is essentially counting bars/wholes. Maybe we can get rid of it, by reinstalling the "mark" @@ -313,6 +328,7 @@ There is another complication: some symbols (bars) sometimes are linked across staffs. I should first think of a way to do this in LilyPond, before even considering a syntax. +[see also: filtering] =head2 Volta @@ -322,11 +338,14 @@ uhh? The syntax of /, * and : has to be settled, we have - - notes (1, 2, 4, 8 etc) + - notes (1, 2, 4, 8 etc), which also can take 1*2/3 to do plets. - meter 2*4 - plet 2/3 - multiple notes: 3*4 - abbreviations (not implemented) c4/4 or c4*4 + - measure grouping, {2*4 3*4} + - skip + =head2 Filtering @@ -384,7 +403,6 @@ I don't see the big win of this. sc1.staff{<\b1 \b2>} sc1.paper=mypaperdef; - We're not doing a programming language. In this syntax the parser has to lookup what sc1 means, decide if it should copied shallow/deep, decide if has a staff block, switch the mode after it finds that staff @@ -396,6 +414,9 @@ listening, Philip Glass?), but I think that would be something for Mudela version 3. And I think using m4 (or something alike) would be just as convenient. +It might clear things up, if JCN told us what is so special about this +syntax (without the C++ looks). + =head2 Transposition Has to be done. How about: diff --git a/NEWS b/NEWS index 6592108aec..130c3b9656 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,13 @@ +pl 38 + +Internal + - great filename renaming operation with - convention. + - printing methods for paper_def/lookup/symtab(s) + - untied all registers from complexwalker. Now registers are +intrinsically hierarchical. All walker communication is done via a +"top level" register. + +****** pl 37 @@ -5,23 +15,22 @@ Documentation - language.pod as starting point for mudela devel. - Jan's patches: -(jan's pl 36-3) - +Features + - m2m patchy --no-triplet option; + lilypond accepts m2m's real midi output (hand-add red tape) + - m2m output only valid durations, resync option wip - m2m produces .ly output Internal - simpler and better naming for Duration* - the great String renaming / index to base=0 change - Track_column, Lily_stream -Features - - m2m patchy --no-triplet option; - lilypond accepts m2m's real midi output (hand-add red tape) - - m2m output only valid durations, resync option wip + - Duration, Plet, Duration_convert taking load off duration calc. Bugfix - m2m duration calc -Internal - - Duration, Plet, Duration_convert taking load off duration calc. + +****** pl 36 - Jan's patches: - do MIDI rests cleanly. diff --git a/Sources.make b/Sources.make index a4e776d8f4..df8d33f407 100644 --- a/Sources.make +++ b/Sources.make @@ -1,76 +1,76 @@ # Sources.make # sourcefiles to be shipped. Also used for dependencies -hdr=bar.hh barreg.hh beam.hh\ +hdr=bar.hh bar-reg.hh beam.hh\ binary-source-file.hh\ - boxes.hh break.hh clefreg.hh clefitem.hh\ + boxes.hh break.hh class-name.hh clef-reg.hh clef-item.hh\ colhpos.hh commandrequest.hh \ - complexwalker.hh complexstaff.hh\ - const.hh debug.hh dimen.hh directionalspanner.hh\ + complex-walker.hh complex-staff.hh\ + const.hh debug.hh dimen.hh directional-spanner.hh\ glob.hh grouping.hh headreg.hh idealspacing.hh\ identifier.hh identparent.hh \ - inputmusic.hh inputscore.hh inputstaff.hh\ - inputfile.hh\ - item.hh key.hh keyitem.hh\ - keyreg.hh\ + input-music.hh input-score.hh input-staff.hh\ + input-file.hh\ + item.hh key.hh key-item.hh\ + key-reg.hh\ keyword.hh leastsquares.hh lexer.hh linespace.hh \ - localkeyitem.hh localkeyreg.hh lookup.hh \ - lyricitem.hh lyricstaff.hh lyricwalker.hh\ - main.hh meter.hh meterreg.hh\ - mididef.hh midiitem.hh midioutput.hh midistream.hh\ - midiwalker.hh\ + local-key-item.hh local-key-reg.hh lookup.hh \ + lyric-item.hh lyricstaff.hh lyricwalker.hh\ + main.hh meter.hh meter-reg.hh\ + midi-def.hh midi-item.hh midi-output.hh midi-stream.hh\ + midi-walker.hh\ misc.hh\ molecule.hh moment.hh musicalrequest.hh\ - notehead.hh notename.hh offset.hh paperdef.hh\ + notehead.hh notename.hh offset.hh paper-def.hh\ parseconstruct.hh pcol.hh proto.hh\ pscore.hh pstaff.hh qlp.hh\ qlpsolve.hh register.hh registergroup.hh reqtodo.hh \ - request.hh rest.hh scorecolumn.hh score.hh\ - scoreline.hh scorewalker.hh script.hh scriptdef.hh scriptreg.hh \ - slur.hh slurreg.hh source.hh sourcefile.hh\ + request.hh rest.hh score-column.hh score.hh\ + scoreline.hh score-walker.hh script.hh script-def.hh script-reg.hh \ + slur.hh slur-reg.hh source.hh source-file.hh\ spanner.hh staff.hh\ - staffelem.hh staffeleminfo.hh staffline.hh staffsym.hh stembeamreg.hh\ - staffcolumn.hh stem.hh staffwalker.hh symbol.hh symtable.hh\ - tex.hh textdef.hh \ - textitem.hh textreg.hh textspanner.hh timedescription.hh \ - tstream.hh voice.hh\ - voiceregs.hh voicegroupregs.hh walkregs.hh + staff-elem.hh staff-elem-info.hh staffline.hh staffsym.hh stem-beam-reg.hh\ + staff-column.hh stem.hh staff-walker.hh symbol.hh symtable.hh\ + tex.hh text-def.hh \ + textitem.hh text-reg.hh textspanner.hh time-description.hh \ + tex-stream.hh voice.hh\ + voice-element.hh voice-regs.hh voice-group-regs.hh walkregs.hh -mycc=bar.cc barreg.cc beam.cc \ +mycc=bar.cc bar-reg.cc beam.cc \ binary-source-file.cc\ - boxes.cc break.cc calcideal.cc clefreg.cc\ - clefitem.cc colhpos.cc commandrequest.cc\ - complexstaff.cc complexwalker.cc \ + boxes.cc break.cc calcideal.cc clef-reg.cc\ + clef-item.cc colhpos.cc commandrequest.cc\ + complex-staff.cc complex-walker.cc \ debug.cc dimen.cc\ - directionalspanner.cc\ + directional-spanner.cc\ grouping.cc groupregs.cc headreg.cc\ idealspacing.cc identifier.cc\ - inputmusic.cc inputscore.cc\ - inputstaff.cc\ - inputfile.cc\ - item.cc key.cc keyitem.cc \ - keyreg.cc keyword.cc\ + input-music.cc input-score.cc\ + input-staff.cc\ + input-file.cc\ + item.cc key.cc key-item.cc \ + key-reg.cc keyword.cc\ leastsquares.cc lexerinit.cc linespace.cc \ - localkeyitem.cc localkeyreg.cc lookup.cc\ - lyricitem.cc lyricstaff.cc lyricwalker.cc\ - main.cc meter.cc meterreg.cc\ - mididef.cc midiitem.cc midioutput.cc midistream.cc\ - midiwalker.cc misc.cc molecule.cc mylexer.cc note.cc\ + local-key-item.cc local-key-reg.cc lookup.cc\ + lyric-item.cc lyricstaff.cc lyricwalker.cc\ + main.cc meter.cc meter-reg.cc\ + midi-def.cc midi-item.cc midi-output.cc midi-stream.cc\ + midi-walker.cc misc.cc molecule.cc mylexer.cc note.cc\ notehead.cc notename.cc\ - paperdef.cc pcol.cc pscore.cc pstaff.cc qlp.cc qlpsolve.cc\ + paper-def.cc pcol.cc pscore.cc pstaff.cc qlp.cc qlpsolve.cc\ register.cc registergroup.cc request.cc rest.cc\ - scorecolumn.cc score.cc\ - scoreline.cc scores.cc scorewalker.cc script.cc\ - scriptdef.cc scriptreg.cc slur.cc\ - slurreg.cc source.cc sourcefile.cc\ + score-column.cc score.cc\ + scoreline.cc scores.cc score-walker.cc script.cc\ + script-def.cc script-reg.cc slur.cc\ + slur-reg.cc source.cc source-file.cc\ spanner.cc staff.cc\ - staffelem.cc staffline.cc staffsym.cc\ - stembeamreg.cc staffcolumn.cc stem.cc\ - staffeleminfo.cc staffwalker.cc symbol.cc\ + staff-elem.cc staffline.cc staffsym.cc\ + stem-beam-reg.cc staff-column.cc stem.cc\ + staff-elem-info.cc staff-walker.cc symbol.cc\ symtable.cc tex.cc texbeam.cc\ - texslur.cc textdef.cc textitem.cc textreg.cc textspanner.cc\ - timedescription.cc tstream.cc voice.cc voiceelt.cc \ - voiceregs.cc voicegroupregs.cc\ + texslur.cc text-def.cc textitem.cc text-reg.cc textspanner.cc\ + time-description.cc tex-stream.cc voice.cc voiceelt.cc \ + voice-regs.cc voice-group-regs.cc\ walkregs.cc warn.cc windhoos-suck-suck-suck-thank-you-cygnus.cc wordwrap.cc\ template1.cc template2.cc template3.cc template4.cc\ template5.cc template6.cc version.cc @@ -78,10 +78,10 @@ mycc=bar.cc barreg.cc beam.cc \ # a bit of a hack to keep exec size under control. stablecc=request.cc bar.cc boxes.cc break.cc \ item.cc keyword.cc leastsquares.cc \ - lookup.cc molecule.cc meter.cc\ - paperdef.cc parser.cc lexer.cc pstaff.cc qlp.cc qlpsolve.cc\ + molecule.cc meter.cc\ + paper-def.cc parser.cc lexer.cc pstaff.cc qlp.cc qlpsolve.cc\ template1.cc template2.cc template3.cc template4.cc\ - template5.cc template6.cc version.cc tstream.cc tex.cc\ + template5.cc template6.cc version.cc tex-stream.cc tex.cc\ voice.cc wordwrap.cc spanner.cc @@ -127,8 +127,8 @@ mym2mcc=\ # mym2msharedcc=\ binary-source-file.cc\ - inputfile.cc\ - sourcefile.cc\ + input-file.cc\ + source-file.cc\ source.cc\ # diff --git a/TODO b/TODO index a00bad0be1..e9824ff756 100644 --- a/TODO +++ b/TODO @@ -2,23 +2,25 @@ before 0.1 * remove spurious/outdated comments in .ly - * more control in Register_groups - * pushgroup, popgroup. * basic dynamics - * basic syntax + * basic syntax & parser/lexer cleanup. * decent TeX page layout * clean split for m2m of sources. + * caching of Register_group_register hierarchies. + This is an assorted collection of stuff that will be done, might be done, or is an idea that I want to think about BUGS + * plet bugs: scales.ly + * key at clef change. * key undo @@ -57,6 +59,8 @@ SMALLISH PROJECTS * parshape + * a pure parser. + * bar numbers/repetition marks * read from mmap directly: study yy_scan_buffer @@ -135,6 +139,8 @@ IDEAS * create libmudela, or liblily_frontend + * Horizontal_align_item, Vertical_align_item. + * move MIDI io to a ANSI C libmidi library. * fold indentifiers and notenames? diff --git a/Variables.make b/Variables.make index 6a9b2cf738..1d8348bb86 100644 --- a/Variables.make +++ b/Variables.make @@ -3,7 +3,7 @@ # version info MAJVER=0 MINVER=0 -PATCHLEVEL=37 +PATCHLEVEL=38 @@ -19,7 +19,7 @@ DEBUGFLAG=-g # CXX=g++ # turn off -pipe if linker doesn't support it -EXTRACXXFLAGS=-pipe -Wall -W -Wmissing-prototypes -DSTRING_UTILS_INLINED -O +EXTRACXXFLAGS=-pipe -Wall -W -Wmissing-prototypes -DSTRING_UTILS_INLINED # # -lefence = ElectricFence. @@ -72,8 +72,10 @@ m2mcc=$(mym2mcc) $(mym2mgencc) $(mym2msharedcc) MY_CCSOURCE=$(addprefix $(CCDIR)/, $(mycc)) CCSOURCE=$(addprefix $(CCDIR)/, $(cc)) + obs=$(addprefix $(OBJECTDIR)/,$(cc:.cc=.o)) m2mobs=$(addprefix $(OBJECTDIR)/,$(m2mcc:.cc=.o)) + allcc=$(mycc) $(mym2mcc) allobs=$(obs) $(m2mobs) allexe=$(exe) $(m2m) @@ -124,4 +126,5 @@ STRIPDEBUG=true #replace to do stripping of certain objects LINKER=$(CXX) include Site.make +TAGSACTION=etags -l c++ --no-defines diff --git a/flower/assoc-iter.hh b/flower/assoc-iter.hh new file mode 100644 index 0000000000..34b88df22d --- /dev/null +++ b/flower/assoc-iter.hh @@ -0,0 +1,39 @@ +/* + associter.hh -- part of flowerlib + + (c) 1996 Han-Wen Nienhuys +*/ + +#ifndef ASSOCITER_HH +#define ASSOCITER_HH + +#include "assoc.hh" + +/// an iterator for the #Assoc# class +template +struct Assoc_iter { + int i; + Assoc &assoc_; + /// we don't want to be bothered by const correctness + Assoc_iter(const Assoc &a) : + assoc_((Assoc &)a) + { + i= next(0); + } + int next(int j) { + while (j < assoc_.arr.size() && assoc_.arr[j].free) + j++; + return j; + } + bool ok() const { + return i < assoc_.arr.size(); + } + void OK()const { + assert(!ok() || !assoc_.arr[i].free); + } + void operator++(int) { i++; i = next(i); } + K key() { return assoc_.arr[i].key; } + V &val() { return assoc_.arr[i].val; } +}; + +#endif diff --git a/flower/data-file.cc b/flower/data-file.cc new file mode 100644 index 0000000000..0dad79c91f --- /dev/null +++ b/flower/data-file.cc @@ -0,0 +1,95 @@ +#include +#include + +#include "data-file.hh" + +void +Data_file::gobble_white() +{ + char c; + + while ((c=data_get()) == ' ' ||c == '\t') + if (eof()) + break; + + data_unget(c); +} + +String +Data_file::get_word() +{// should handle escape seq's + String s; + + while (1) + { + char c = data_get(); + + if (isspace(c) || eof()) + { + data_unget(c); + break; + } + + + if (c == '\"') + { + rawmode= true; + + while ((c = data_get()) != '\"') + if (eof()) + error("EOF in a string"); + else + s += c; + + + rawmode= false; + } + else + s += c; + } + + return s; +} + +/** get a char + Only class member who uses text_file::get + */ +char +Data_file::data_get() { + char c = get(); + if (!rawmode && c == '#') // gobble comment + { + while ((c = get()) != '\n' && !eof()) + ; + return '\n'; + } + + return c; +} + +/// read line, gobble '\n' +String Data_file::get_line() +{ + char c; + String s; + + while ((c = data_get()) != '\n' && !eof()) + s += c; + return s; +} + +/// gobble stuff before first entry on a line. +void +Data_file::gobble_leading_white() +{ + // eat blank lines. + while (!eof()) { + char c = data_get(); + if (!isspace(c)) { + data_unget(c); + break; + } + } +} + + diff --git a/flower/data-file.hh b/flower/data-file.hh new file mode 100644 index 0000000000..dae9e56347 --- /dev/null +++ b/flower/data-file.hh @@ -0,0 +1,59 @@ +/* + data-file.hh -- declare Data_file + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + + +#ifndef DATAFILE_HH +#define DATAFILE_HH + +#include "text-stream.hh" + +/// read a data file +class Data_file : private Text_stream +{ + + public: + bool rawmode; + + Text_stream::line; + Text_stream::eof; + Text_stream::get_name; + + char data_get(); + void data_unget(char c) { + unget(c); + } + + /// read line, eat #\n# + String get_line(); + + /// read a word till next space, leave space. Also does quotes + String get_word(); + + /// gobble horizontal white stuff. + void gobble_white(); + + /// gobble empty stuff before first field. + void gobble_leading_white(); + Data_file(String s) : Text_stream(s) { + //*mlog << "(" << s << flush; + rawmode= false; + } + + ~Data_file() { + // *mlog << ")"< +*/ + +#include +#include +#include "libc-extension.hh" + +/* + compensate for lacking libc functions. + */ + char* +strnlwr( char* start_l ,int n) +{ + char * p = start_l + n; + while ( --p >= start_l) { + *p = tolower( *p ); /* a macro on some compilers */ + } + return start_l; +} + + char* +strnupr( char* start_l, int n) +{ + char * p = start_l + n; + while ( --p >= start_l) { + *p = toupper( *p ); /* a macro on some compilers */ + } + return start_l; +} + +/** locate a substring. #memmem# finds the first occurrence of + #needle# in #haystack# + */ + + char * +memmem(const Byte * haystack, const Byte *needle, + int haystack_len, int needle_len) +{ + const Byte * end_haystack = haystack + haystack_len - needle_len; + const Byte * end_needle = needle + needle_len ; + + /* Ahhh ... Some minimal lowlevel stuff. This *is* nice; Varation + is the spice of life */ + while (haystack < end_haystack) { + const Byte *subneedle_l = needle; + const Byte *subhaystack_l = haystack; + while (subneedle_l < end_needle) { + if (*subneedle_l++ != *subhaystack_l++) + goto next; // yeah. I should be prosecuted. + } + + // completed the needle. Gotcha. + return (char*) haystack; + next: + haystack++; + } + return 0; +} + +Byte * +memrchr(const Byte * p, int n, char c) +{ + const Byte * q = p+n; + while (q > p) { + if (*--q == c) + return (Byte*)q; + } + return 0; +} + + +template +inline void +my_swap(T &t1, T &t2, T &tmp) +{ + tmp = t1; + t1 = t2; + t2 = tmp; +} + +Byte* +strrev( Byte* byte_l, int length_i ) +{ + Byte tmp_byte; + + Byte* left_l = byte_l; + Byte* right_l = byte_l + length_i; + + while ( right_l > left_l ) { + my_swap(*right_l-- , *left_l++ , tmp_byte); + } + return byte_l; +} diff --git a/flower/libc-extension.hh b/flower/libc-extension.hh new file mode 100644 index 0000000000..e06feb5af4 --- /dev/null +++ b/flower/libc-extension.hh @@ -0,0 +1,25 @@ +/* + libc-extension.hh -- declare some string.h extensions + + source file of the flowerlib + + (c) 1997 Han-Wen Nienhuys +*/ + + +#ifndef LIBC_EXTENSION_HH +#define LIBC_EXTENSION_HH +#include "fproto.hh" + +char* strnlwr( char* start_l ,int n); +char* strnupr( char* start_l, int n); +/* + should use void* like in libc + */ +char *memmem(const Byte * haystack, const Byte *needle, + int haystack_len, int needle_len); +Byte *memrchr(const Byte * p, int n, char c); +Byte*strrev( Byte* byte_l, int length_i ); + + +#endif // LIBC_EXTENSION_HH diff --git a/flower/string-data.hh b/flower/string-data.hh new file mode 100644 index 0000000000..d4f4b6b5b9 --- /dev/null +++ b/flower/string-data.hh @@ -0,0 +1,95 @@ +/* + string-data.hh -- declare String_data + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + + +#ifndef STRINGDATA_HH +#define STRINGDATA_HH + + +/**Internal String struct. + the data itself. Handles simple tasks (resizing, resetting) + */ +class String_data { + // GNU malloc: storage overhead is 8 bytes anyway. + +friend class String_handle; + int maxlen; // maxlen is arraysize-1 + + int length_i_; + Byte* data_byte_p_; + int references; + + /// init to "" + String_data(); + + /// init from src. Conservative allocation. + String_data(String_data const &src); + + ~String_data(); + + /** POST: maxlen >= j. + @param j, maximum stringlength_i_. + contents thrown away. + */ + void setmax(int j); + + /** POST: maxlen >= j. + @param j, maximum stringlength_i_. + contents are kept if it grows. + */ + void remax(int j); + + /// check if writeable. + void OKW(); + + /// check state. + void OK(); + + /// reduce memory usage. + void tighten(); + + // assignment. + void set( Byte const* byte_c_l, int length_i ); + + void set( char const* ch_c_l ); + + /// concatenation. + void append( Byte const* byte_c_l, int length_i ); + + void operator += ( char const* ch_c_l ); + + char const* ch_c_l() const; + + char* ch_l(); + + Byte const* byte_c_l() const; + + // idem, non const + Byte* byte_l(); + + void trunc(int j); + + /** access element. not really safe. Can alter length_i_ without + #String_data# knowing it. */ + Byte &operator [](int j); + Byte operator [](int j) const; + bool null_terminated_b()const; +}; + + + +#ifdef STRING_UTILS_INLINED +#ifndef INLINE +#define INLINE inline +#endif +#include "string-data.inl" + +#endif + + +#endif // STRING_DATA_HH diff --git a/flower/string-data.inl b/flower/string-data.inl new file mode 100644 index 0000000000..f5bdc86c38 --- /dev/null +++ b/flower/string-data.inl @@ -0,0 +1,209 @@ +/* -*-C++-*- + String_data.inl -- implement String_data + + source file of Flower lib + + (c) 1997 Han-Wen Nienhuys +*/ + +#ifndef STRINGDATA_INL +#define STRINGDATA_INL + +#include +#include + +#include "string-data.hh" +const int INITIALMAX=8; + +#include + +INLINE void +String_data::OKW() +{ + assert (references == 1); +} + +INLINE void +String_data::OK() +{ + assert(maxlen >= length_i_); + assert(bool(data_byte_p_)); + assert(references >= 1); +} + + +INLINE +String_data::String_data() +{ + references=0; + maxlen = INITIALMAX; + data_byte_p_ = new Byte[maxlen + 1]; + data_byte_p_[0] = 0; + length_i_ = 0; +} + +INLINE +String_data::String_data(String_data const &src) +{ + references=0; + maxlen = length_i_ = src.length_i_; + data_byte_p_ = new Byte[maxlen+1]; // should calc GNU 8byte overhead. + memcpy( data_byte_p_, src.data_byte_p_, length_i_ + 1 ); +} + +INLINE +String_data::~String_data() +{ + assert(references == 0); + delete[] data_byte_p_; +} + +INLINE void +String_data::setmax(int j) +{ + OKW(); + if (j > maxlen) { + delete data_byte_p_; + maxlen = j; + data_byte_p_ = new Byte[maxlen + 1]; + + data_byte_p_[0] = 0; + length_i_ = 0; + } +} + +/* this is all quite hairy: + update of length_i_ + update of maxlen + alloc of buffer + copying of buffer + needs blondification: + split tasks + define change authority +*/ +INLINE void +String_data::remax(int j) +{ + OKW(); + if (j > maxlen) { + Byte *p = new Byte[j + 1]; + memcpy( p, data_byte_p_, ( maxlen = 0 && j <= length_i_); + data_byte_p_[j] = 0; + length_i_ = j; +} + +INLINE bool +String_data::null_terminated_b()const +{ + return !memchr(data_byte_p_, length_i_, 0); +} + +INLINE Byte& +String_data::operator [](int j) +{ + assert(j >= 0 && j <= length_i_); + return data_byte_p_[j] ; +} + +INLINE Byte +String_data::operator [](int j) const +{ + assert(j >= 0 && j <= length_i_); + return data_byte_p_[j]; +} + + + + +#endif // __STRING_UTIL_CC // diff --git a/flower/string-handle.hh b/flower/string-handle.hh new file mode 100644 index 0000000000..fe109d8842 --- /dev/null +++ b/flower/string-handle.hh @@ -0,0 +1,70 @@ +/* + string-handle.hh -- declare String_handle + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + + +#ifndef STRINGHANDLE_HH +#define STRINGHANDLE_HH +#include "fproto.hh" + + +/** + Reference counting for strings. + + handles ref. counting, and provides a very thin interface using + Byte * + + */ +class String_handle { + String_data* data; + + /// decrease ref count. Named kind of like a Tanenbaum semafore + void down(); + + /// increase ref count + void up(String_data *d); + + /** make sure data has only one reference. + POST: data->references == 1 + */ + void copy(); + +public: + String_handle(); + ~String_handle(); + String_handle(String_handle const & src); + + Byte const* byte_c_l() const; + char const* ch_c_l() const; + Byte* byte_l(); + char* ch_l(); + bool null_terminated_b()const; + void operator =(String_handle const &src); + void operator += (char const *s); + Byte operator[](int j) const; + + /** Access elements. WARNING: NOT SAFE + don't use this for loops. Use byte_c_l() + */ + Byte &operator[](int j); + void append( Byte const* byte_c_l, int length_i ); + void set( Byte const* byte_c_l, int length_i ); + void operator = (char const *p); + void trunc(int j); + int length_i() const; +}; + +#ifdef STRING_UTILS_INLINED +#ifndef INLINE +#define INLINE inline +#endif +#include "string-handle.inl" +/* we should be resetting INLINE. oh well. */ +#endif + + +#endif // STRINGHANDLE_HH diff --git a/flower/string-handle.inl b/flower/string-handle.inl new file mode 100644 index 0000000000..7286fd6d20 --- /dev/null +++ b/flower/string-handle.inl @@ -0,0 +1,156 @@ +/* -*-c++-*- + + stringhandle.inl -- implement String_handle + + source file of Flower lib + + (c) 1997 Han-Wen Nienhuys +*/ + +#ifndef STRINGHANDLE_INL +#define STRINGHANDLE_INL + +#include +#include + +#include "string-data.hh" +#include "string-handle.hh" + +INLINE void +String_handle::down() +{ + if (!(--data->references)) delete data; data = 0; +} + +/// increase ref count +INLINE void +String_handle::up(String_data *d) +{ + data=d; data->references ++; +} + +INLINE void +String_handle::copy() +{ + if (data->references !=1){ + String_data *newdata = new String_data(*data); + down(); + up(newdata); + } +} + +INLINE +String_handle::String_handle() +{ + up(new String_data); +} + +INLINE +String_handle::~String_handle() +{ + down(); +} + +INLINE +String_handle::String_handle(String_handle const & src) +{ + up(src.data); +} + +INLINE Byte* +String_handle::byte_l() +{ + copy(); + return data->byte_l(); +} + +INLINE char* +String_handle::ch_l() +{ + copy(); + return (char*)data->byte_l(); +} + +INLINE Byte +const* String_handle::byte_c_l() const +{ + return data->byte_c_l(); +} + +INLINE char const* +String_handle::ch_c_l() const +{ + return (char const*)data->byte_c_l(); +} + +INLINE void +String_handle::operator =(String_handle const &src) +{ + if (this == &src) + return; + down(); + up(src.data); +} + +INLINE void +String_handle::operator += (char const *s) +{ + copy(); + *data += s; +} + + +INLINE Byte +String_handle::operator[](int j) const +{ + return (*data)[j]; +} + +// !NOT SAFE! +// don't use this for loops. Use byte_c_l() +INLINE Byte & +String_handle::operator[](int j) +{ + copy(); // hmm. Not efficient + return data->byte_l()[j]; +} + +INLINE void +String_handle::append( Byte const* byte_c_l, int length_i ) +{ + copy(); + data->append( byte_c_l, length_i ); +} + +INLINE void +String_handle::set( Byte const* byte_c_l, int length_i ) +{ + copy(); + data->set( byte_c_l, length_i ); +} + +INLINE void +String_handle::operator = (char const *p) +{ + copy(); + data->set( p ); +} + +INLINE void +String_handle::trunc(int j) +{ + copy(); data->trunc(j); +} + +INLINE int +String_handle::length_i() const +{ + return data->length_i_; +} + +INLINE bool +String_handle::null_terminated_b() const { + return data->null_terminated_b(); +} + +#endif diff --git a/flower/text-db.cc b/flower/text-db.cc new file mode 100644 index 0000000000..ebfc992ff2 --- /dev/null +++ b/flower/text-db.cc @@ -0,0 +1,48 @@ +#include "text-db.hh" +bool +Text_db::eof() +{ + Data_file::gobble_leading_white(); + return Data_file::eof(); +} + +void +Text_db::gobble_leading_white() +{ + while (1) { + Data_file::gobble_leading_white(); + if (eof()) + return ; + char c; + if ((c = data_get()) !='\n'){ + data_unget (c); + return ; + } + } +} + + +Text_record +Text_db::get_record() +{ + while (1) { + String s; + Array fields; + assert(!eof()); + + while ((s = get_word()) != "") + { + fields.push(s); + gobble_white(); + } + + + if (get_line() != "") + assert(false); + + assert (fields.size()); + return Text_record(fields, get_name(), line()); + } +} + + diff --git a/flower/text-db.hh b/flower/text-db.hh new file mode 100644 index 0000000000..3535a84f8f --- /dev/null +++ b/flower/text-db.hh @@ -0,0 +1,55 @@ +#ifndef TEXTDB_HH +#define TEXTDB_HH + +#include "data-file.hh" + +/**a "const" Array. Contents can't be changed. do "#" comments, read quote enclosed fields */ + +class Text_record : Array +{ + int line_no; + String filename; + +public: + Text_record() { } // needed because of other ctor + + /// report an error in this line. + message(String s) { + cerr << '\n'<< filename << ": "<< line_no << s << "\n"; + } + String operator[](int j) { + return Array::operator[](j); + } + + Text_record(Array s, String fn, int j) : Array(s) { + filename = fn; line_no = j; + } + Array::size; +}; + +/** abstraction for a datafile. + add a subrec/fieldsep/record separator + */ + +class Text_db : private Data_file +{ + void gobble_leading_white(); +public: + /// get a line with records + Text_record get_record(); + + Text_db(String fn):Data_file(fn) { } + Data_file::error; + bool eof(); + + /// get next line. + Text_record operator++(int) { + return get_record(); + } + /// are we done yet? + operator bool() { + return !eof(); + } +}; + +#endif diff --git a/flower/text-stream.cc b/flower/text-stream.cc new file mode 100644 index 0000000000..a2d3e4b119 --- /dev/null +++ b/flower/text-stream.cc @@ -0,0 +1,31 @@ +#include "text-stream.hh" + +Text_stream::Text_stream(String fn) +{ + ios::sync_with_stdio(); + if (fn == "") + { + name = ""; + f = stdin; + } + + else + { + name = fn; + f = fopen(fn, "r"); + } + + if (!f) { + cerr <<__FUNCTION__<< ": can't open `" << fn << "'\n"; + exit(1); + } + + line_no = 1; + } + +void +Text_stream::message(String s) +{ + cerr << "\n"< +#include +#include "string.hh" +#include "varray.hh" + +/** + line counting input stream. + a stream for textfiles. linecounting. Thin interface getchar and + ungetchar. (ungetc is unlimited) + + should protect get and unget against improper use +*/ + + +class Text_stream +{ + int line_no; + + // could just have used streams. + FILE *f; + Array pushback; + String name; + + public: + Text_stream(String fn); + String get_name() { return name; } + bool eof() { + return feof(f); + } + bool eol() { + return (peek() == '\n'); + } + char peek() { + char c = get(); + unget(c); + return c; + } + int line(){ + return line_no; + } + + char get() { + char c; + + if (pushback.empty()) + c = getc(f); + else + c = pushback.pop(); + + if (c =='\n') + line_no++; + return c; + } + void unget(char c) { + if (c =='\n') + line_no--; + pushback.push(c); + } + ~Text_stream (){ + if (!eof()) + cerr <<__FUNCTION__<< ": closing unended file"; + + fclose(f); + } + + /// GNU format message. + void message(String s); +}; + +#endif diff --git a/genheader b/genheader index de9e7bf1e3..7c36afe0ae 100755 --- a/genheader +++ b/genheader @@ -17,7 +17,7 @@ my $headstr ="/* */\n"; my $startdef= $fn; -$startdef =~ s/\./_/; +$startdef =~ s/[\.-]/_/g; $startdef =~ tr/a-z/A-Z/; my $terminatestr="\n"; if ($hh_q) { diff --git a/hdr/Makefile b/hdr/Makefile index 384c9bc39e..aab2511d4f 100644 --- a/hdr/Makefile +++ b/hdr/Makefile @@ -6,7 +6,7 @@ dist: TAGS: $(hdr) - etags -CT $(hdr) + $(TAGSACTION) $^ clean: rm -f parser.hh diff --git a/hdr/barreg.hh b/hdr/bar-reg.hh similarity index 68% rename from hdr/barreg.hh rename to hdr/bar-reg.hh index 0b99ec0a52..c73e5d1f4f 100644 --- a/hdr/barreg.hh +++ b/hdr/bar-reg.hh @@ -1,5 +1,5 @@ /* - barreg.hh -- declare Bar_register + bar-reg.hh -- declare Bar_register source file of the LilyPond music typesetter @@ -21,10 +21,11 @@ public: Bar * bar_p_; virtual bool try_request(Request *req_l); - virtual void process_request(); - virtual void do_pre_move_process(); - virtual void do_post_move_process(); - Bar_register(Complex_walker*); + virtual void process_requests(); + virtual void pre_move_processing(); + virtual void post_move_processing(); + Bar_register(); + NAME_MEMBERS(Bar_register); }; #endif // BARREG_HH diff --git a/hdr/bar.hh b/hdr/bar.hh index e83a7681c6..3727358d96 100644 --- a/hdr/bar.hh +++ b/hdr/bar.hh @@ -12,7 +12,7 @@ struct Bar: Item { String type; Bar(String type); - const char * name() const; +NAME_MEMBERS(Bar); void do_print() const; Molecule*brew_molecule_p()const; }; diff --git a/hdr/beam.hh b/hdr/beam.hh index eb8020c53a..8eb2f148b5 100644 --- a/hdr/beam.hh +++ b/hdr/beam.hh @@ -7,7 +7,7 @@ #ifndef BEAM_HH #define BEAM_HH #include "proto.hh" -#include "directionalspanner.hh" +#include "directional-spanner.hh" #include "plist.hh" /** a beam connects multiple stems Beam adjusts the stems its owns to @@ -23,7 +23,7 @@ struct Beam: public Directional_spanner { /* *************** */ - const char * name() const; +NAME_MEMBERS(Beam); virtual Interval width()const; Offset center() const; diff --git a/hdr/class-name.hh b/hdr/class-name.hh new file mode 100644 index 0000000000..26da52dc0e --- /dev/null +++ b/hdr/class-name.hh @@ -0,0 +1,19 @@ +/* + class-name.hh -- declare + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + + +#ifndef CLASS_NAME_HH +#define CLASS_NAME_HH + +/// a macro to declare the classes name as a static and virtual function. +#define NAME_MEMBERS(c) \ +static const char *static_name(){ return #c; }\ +virtual const char *name() const{ return c::static_name(); } \ +int a_stupid_nonexistent_function_to_allow_the_semicolon_come_out() + +#endif // CLASS-NAME_HH diff --git a/hdr/clefitem.hh b/hdr/clef-item.hh similarity index 85% rename from hdr/clefitem.hh rename to hdr/clef-item.hh index 2e67a7d094..341204f8ea 100644 --- a/hdr/clefitem.hh +++ b/hdr/clef-item.hh @@ -1,6 +1,6 @@ /* - clefitem.hh -- declare Clef_item + clef-item.hh -- declare Clef_item (c) 1996,97 Han-Wen Nienhuys */ @@ -19,7 +19,7 @@ struct Clef_item : Item { /* *************** */ - const char * name() const; +NAME_MEMBERS(Clef_item); Clef_item(); void read(Clef_register const&); void read(String); diff --git a/hdr/clefreg.hh b/hdr/clef-reg.hh similarity index 69% rename from hdr/clefreg.hh rename to hdr/clef-reg.hh index 8f9e25042c..cc3a8a90e9 100644 --- a/hdr/clefreg.hh +++ b/hdr/clef-reg.hh @@ -6,6 +6,7 @@ #ifndef CLEF_HH #define CLEF_HH + #include "scalar.hh" #include "varray.hh" #include "register.hh" @@ -13,15 +14,19 @@ /// where is c-0 in the staff? class Clef_register : public Request_register { Clef_item *clef_p_; + Clef_change_req * clef_req_l_; + public: int c0_position_i_; String clef_type_str_; /* ************** */ - virtual void process_request(); - virtual void do_pre_move_process(); + virtual void process_requests(); + virtual void pre_move_processing(); + virtual void post_move_processing(); virtual bool try_request(Request*); - Clef_register(Complex_walker*); + Clef_register(); + NAME_MEMBERS(Clef_register); void read_req(Clef_change_req*); bool set_type(String); }; diff --git a/hdr/complexstaff.hh b/hdr/complex-staff.hh similarity index 81% rename from hdr/complexstaff.hh rename to hdr/complex-staff.hh index 74ecef4732..0a37e3a5f7 100644 --- a/hdr/complexstaff.hh +++ b/hdr/complex-staff.hh @@ -1,5 +1,5 @@ /* - complexstaff.hh -- declare Complex_staff + complex-staff.hh -- declare Complex_staff (c) 1996,1997 Han-Wen Nienhuys */ @@ -10,7 +10,7 @@ #include "key.hh" #include "staff.hh" -#include "staffwalker.hh" +#include "staff-walker.hh" /// struct Complex_staff : Staff { diff --git a/hdr/complex-walker.hh b/hdr/complex-walker.hh new file mode 100644 index 0000000000..861cee77f8 --- /dev/null +++ b/hdr/complex-walker.hh @@ -0,0 +1,47 @@ +/* + complex-walker.hh -- declare Complex_walker + + (c) 1996,97 Han-Wen Nienhuys +*/ + +#ifndef COMPLEXWALKER_HH +#define COMPLEXWALKER_HH + +#include "proto.hh" +#include "staff-walker.hh" +#include "staff-elem-info.hh" + +/** + A staff walker which uses registers to decide what to print + */ +class Complex_walker: public Staff_walker { + bool try_command_request(Command_req *req_l); + void do_announces(); + void try_request(Request*req); + + + +public: + int c0_position_i_; + Walker_registers *walk_regs_p_; + + /* *************** */ + + void regs_process_requests(); + void typeset_element(Staff_elem *elem_p); + void announce_element(Staff_elem_info); + virtual void process_requests(); + virtual void do_post_move(); + virtual void do_pre_move(); + + Complex_walker(Complex_staff*); + ~Complex_walker(); + + Complex_staff *staff(); +private: +}; + + +#endif // COMPLEXWALKER_HH + + diff --git a/hdr/complexwalker.hh b/hdr/complexwalker.hh deleted file mode 100644 index a67d5b881a..0000000000 --- a/hdr/complexwalker.hh +++ /dev/null @@ -1,95 +0,0 @@ -/* - complexwalker.hh -- declare Complex_walker - - (c) 1996,97 Han-Wen Nienhuys -*/ - -#ifndef COMPLEXWALKER_HH -#define COMPLEXWALKER_HH - -#include "proto.hh" -#include "assoc.hh" -#include "staffwalker.hh" -#include "staffeleminfo.hh" -#include "plist.hh" - -/** - A staff walker which uses registers to decide what to print - */ -class Complex_walker: public Staff_walker { - bool try_command_request(Command_req *req_l); - void do_change_group( Voice * v, String group_id_str); - void do_announces(); - void try_request(Request*req); - int c0_position_i_; - - Array prebreak_item_p_arr_; - Array nobreak_item_p_arr_; - Array postbreak_item_p_arr_; - -public: - - IPointerList voice_reg_list_; - IPointerList group_reg_list_; - Assoc voice_group_map_; - - Array announce_info_arr_; - Walker_registers *walk_regs_p_; - - /* *************** */ - - Voice_registers *find_voice_reg(Voice*v_l)const; - Voice_registers *get_voice_reg(Voice*v_l); - - /** search for voice_group containing #v_l# - - @return - pointer if found, 0 if not found. - */ - Voice_group_registers *find_voice_group(Voice* v_l)const; - - /// search. Create if necessary - Voice_group_registers *get_voice_group(Voice* v_l); - /** search for voice_group named #id# - - @return - pointer if found, 0 if not found. - */ - Voice_group_registers *find_voice_group(const char* id)const; - - /** - search for voice_group named #id#, create if necessary - */ - Voice_group_registers *get_voice_group(const char*); - - Array get_voice_regs(Voice_group_registers *) const; - - void regs_process_requests(); - void typeset_breakable_item(Item * pre_p , - Item * nobreak_p, Item * post_p); - void typeset_element(Staff_elem *elem_p); - void announce_element(Staff_elem_info); - virtual void process_requests(); - virtual void do_post_move(); - virtual void do_pre_move(); - /** - @return the position of central c. - */ - int c0_position_i() const; - - /** - set the position of central c. - @param the new position - */ - void set_c0_position(int j); - Complex_walker(Complex_staff*); - ~Complex_walker(); - - Complex_staff *staff(); -private: -}; - - -#endif // COMPLEXWALKER_HH - - diff --git a/hdr/directionalspanner.hh b/hdr/directional-spanner.hh similarity index 91% rename from hdr/directionalspanner.hh rename to hdr/directional-spanner.hh index 1578edf574..9399b71c4d 100644 --- a/hdr/directionalspanner.hh +++ b/hdr/directional-spanner.hh @@ -1,5 +1,5 @@ /* - directionalspanner.hh -- part of LilyPond + directional-spanner.hh -- part of LilyPond (c) 1996,97 Han-Wen Nienhuys */ diff --git a/hdr/grouping.hh b/hdr/grouping.hh index 72d2960f82..06b4421b0a 100644 --- a/hdr/grouping.hh +++ b/hdr/grouping.hh @@ -44,8 +44,10 @@ struct Rhythmic_grouping { Array generate_beams(Array, int&); - /// multiply self to span #i# - void extend(MInterval i); + /** multiply self to span #i#. + In implementation, this isn't really const, but conceptually it is. + */ + void extend(MInterval i) const; void translate(Moment); private: void init(); diff --git a/hdr/headreg.hh b/hdr/headreg.hh index d5eb6fa5cd..eaa2d6f9d7 100644 --- a/hdr/headreg.hh +++ b/hdr/headreg.hh @@ -11,13 +11,17 @@ struct Notehead_register : Request_register { Item* note_p_; + Rhythmic_req * note_req_l_; int dir_i_; + /* *************** */ - Notehead_register(Complex_walker*); + Notehead_register(); virtual bool try_request(Request *req_l) ; - virtual void process_request(); - virtual void do_pre_move_process(); - void set_dir(int); + virtual void process_requests(); + virtual void pre_move_processing(); + virtual void post_move_processing(); + void set_feature(Features); + NAME_MEMBERS(Notehead_register); }; diff --git a/hdr/identifier.hh b/hdr/identifier.hh index 0c9b252afa..1aa7f7d0c4 100644 --- a/hdr/identifier.hh +++ b/hdr/identifier.hh @@ -9,11 +9,11 @@ #define IDENTIFIER_HH #include "identparent.hh" #include "symtable.hh" -#include "inputstaff.hh" -#include "inputmusic.hh" +#include "input-staff.hh" +#include "input-music.hh" #include "notename.hh" #include "lookup.hh" -#include "scriptdef.hh" +#include "script-def.hh" #define make_id_class(Idclass, Class, accessor) \ struct Idclass : Identifier {\ @@ -26,6 +26,7 @@ struct Idclass : Identifier {\ return (Class*) data;\ }\ ~Idclass() { delete accessor(false); }\ + virtual void do_print()const; \ }\ make_id_class(Real_id, Real, real); diff --git a/hdr/identparent.hh b/hdr/identparent.hh index da7ab7012c..3e6d566ee7 100644 --- a/hdr/identparent.hh +++ b/hdr/identparent.hh @@ -20,6 +20,8 @@ struct Identifier { Identifier(String n) : name(n) { } virtual ~Identifier() {} + + void print()const; virtual const char*classname() { return "new Identifier"; } void error(String); IDACCESSOR(Input_staff, staff) @@ -31,8 +33,11 @@ struct Identifier { IDACCESSOR(Lookup,lookup) IDACCESSOR(Real,real) IDACCESSOR(Notename_tab, notename_tab) +protected: + virtual void do_print()const=0; private: Identifier(Identifier const&){} + }; #endif // IDENTPARENT_HH diff --git a/hdr/inputfile.hh b/hdr/input-file.hh similarity index 92% rename from hdr/inputfile.hh rename to hdr/input-file.hh index 5e55050299..a01ea75076 100644 --- a/hdr/inputfile.hh +++ b/hdr/input-file.hh @@ -1,5 +1,5 @@ /* - inputfile.hh -- declare Input_file + input-file.hh -- declare Input_file source file of the LilyPond music typesetter diff --git a/hdr/inputmusic.hh b/hdr/input-music.hh similarity index 99% rename from hdr/inputmusic.hh rename to hdr/input-music.hh index da3030f11b..1d7a8caa66 100644 --- a/hdr/inputmusic.hh +++ b/hdr/input-music.hh @@ -1,5 +1,5 @@ /* - inputmusic.hh -- part of LilyPond + input-music.hh -- part of LilyPond (c) 1996,97 Han-Wen Nienhuys */ diff --git a/hdr/inputscore.hh b/hdr/input-score.hh similarity index 91% rename from hdr/inputscore.hh rename to hdr/input-score.hh index 88cc1894a8..4286f4b60b 100644 --- a/hdr/inputscore.hh +++ b/hdr/input-score.hh @@ -1,5 +1,5 @@ /* - inputscore.hh -- declare + input-score.hh -- declare source file of the LilyPond music typesetter @@ -23,7 +23,7 @@ struct Input_score { int errorlevel_i_; /// paper_, staffs_ and commands_ form the problem definition. - Paperdef *paper_p_; + Paper_def *paper_p_; Midi_def* midi_p_; IPointerList staffs_; @@ -36,7 +36,7 @@ struct Input_score { void add(Input_staff*); ~Input_score(); /// construction - void set(Paperdef*); + void set(Paper_def*); void set(Midi_def* midi_p); void print() const; Score*parse(); diff --git a/hdr/inputstaff.hh b/hdr/input-staff.hh similarity index 93% rename from hdr/inputstaff.hh rename to hdr/input-staff.hh index f72cac8ba1..3b874a1b39 100644 --- a/hdr/inputstaff.hh +++ b/hdr/input-staff.hh @@ -1,5 +1,5 @@ /* - inputstaff.hh -- declare Input_staff + input-staff.hh -- declare Input_staff (c) 1996,97 Han-Wen Nienhuys */ diff --git a/hdr/item.hh b/hdr/item.hh index a5a9442dc9..d1fc8c8bfa 100644 --- a/hdr/item.hh +++ b/hdr/item.hh @@ -4,7 +4,7 @@ #include "glob.hh" #include "boxes.hh" #include "string.hh" -#include "staffelem.hh" +#include "staff-elem.hh" /** a horizontally fixed size element of the score @@ -24,7 +24,8 @@ struct Item : Staff_elem { virtual Item *item() { return this; } Item(); void do_print()const; - const char*name()const; + + NAME_MEMBERS(Item); }; diff --git a/hdr/keyitem.hh b/hdr/key-item.hh similarity index 88% rename from hdr/keyitem.hh rename to hdr/key-item.hh index 86dae4d9fc..e56af8e682 100644 --- a/hdr/keyitem.hh +++ b/hdr/key-item.hh @@ -1,5 +1,5 @@ /* - keyitem.hh -- part of LilyPond + key-item.hh -- part of LilyPond (c) 1996,97 Han-Wen Nienhuys */ @@ -19,7 +19,7 @@ struct Key_item : Item { /* *************** */ - const char * name() const; +NAME_MEMBERS(Key_item); Key_item(int cposition); void add(int pitch, int acc); void read(const Key_register&); diff --git a/hdr/keyreg.hh b/hdr/key-reg.hh similarity index 72% rename from hdr/keyreg.hh rename to hdr/key-reg.hh index 6cf6a37242..d8a96d066e 100644 --- a/hdr/keyreg.hh +++ b/hdr/key-reg.hh @@ -1,5 +1,5 @@ /* - keyreg.hh -- declare Key_register + key-reg.hh -- declare Key_register source file of the LilyPond music typesetter @@ -21,11 +21,12 @@ struct Key_register : Request_register { bool default_key_b_; virtual bool try_request(Request *req_l); - virtual void process_request(); - virtual void do_pre_move_process(); - virtual void do_post_move_process(); + virtual void process_requests(); + virtual void pre_move_processing(); + virtual void post_move_processing(); virtual void acknowledge_element(Staff_elem_info); - Key_register(Complex_walker*); + Key_register(); + NAME_MEMBERS(Key_register); private: void read_req(Key_change_req * r); diff --git a/hdr/lexer.hh b/hdr/lexer.hh index 7f06158c3a..6a9d21a98e 100644 --- a/hdr/lexer.hh +++ b/hdr/lexer.hh @@ -43,6 +43,7 @@ struct My_flex_lexer : yyFlexLexer { void new_input(String s); bool close_input(); int yylex(); + void print_declarations() const; }; extern My_flex_lexer *lexer; diff --git a/hdr/localkeyitem.hh b/hdr/local-key-item.hh similarity index 89% rename from hdr/localkeyitem.hh rename to hdr/local-key-item.hh index e9640023d4..96bad9999e 100644 --- a/hdr/localkeyitem.hh +++ b/hdr/local-key-item.hh @@ -1,5 +1,5 @@ /* - localkeyitem.hh -- part of LilyPond + local-key-item.hh -- part of LilyPond (c) 1996,97 Han-Wen Nienhuys */ @@ -15,7 +15,7 @@ struct Local_acc { }; struct Local_key_item : Item { - const char * name() const; +NAME_MEMBERS(Local_key_item); Array accs; Array support_items_; int c0_position; diff --git a/hdr/localkeyreg.hh b/hdr/local-key-reg.hh similarity index 66% rename from hdr/localkeyreg.hh rename to hdr/local-key-reg.hh index 07c016678c..d0a2867a87 100644 --- a/hdr/localkeyreg.hh +++ b/hdr/local-key-reg.hh @@ -1,5 +1,5 @@ /* - localkeyreg.hh -- declare Local_key_register + local-key-reg.hh -- declare Local_key_register (c) 1997 Han-Wen Nienhuys */ @@ -15,10 +15,11 @@ struct Local_key_register : Request_register { Local_key_item* key_item_p_; const Key *key_c_l_; /* *************** */ - virtual void process_request(); + virtual void process_requests(); virtual void acknowledge_element(Staff_elem_info); - virtual void do_pre_move_process(); - Local_key_register(Complex_walker*); + virtual void pre_move_processing(); + Local_key_register(); + NAME_MEMBERS(Local_key_register); }; #endif // LOCALKEYREG_HH diff --git a/hdr/lookup.hh b/hdr/lookup.hh index 28bd8677ea..524cdf1958 100644 --- a/hdr/lookup.hh +++ b/hdr/lookup.hh @@ -14,7 +14,7 @@ struct Lookup { String texsetting; /* *************** */ void add(String, Symtable*); - + void print()const; Real internote(); Symbol linestaff(int n, Real w); diff --git a/hdr/lyricwalker.hh b/hdr/lyricwalker.hh index 40ef06d972..1a80523883 100644 --- a/hdr/lyricwalker.hh +++ b/hdr/lyricwalker.hh @@ -9,7 +9,7 @@ #include "proto.hh" #include "grouping.hh" -#include "staffwalker.hh" +#include "staff-walker.hh" /// a simple walker which collects words, and then print them, first on top struct Lyric_walker: Staff_walker { diff --git a/hdr/meterreg.hh b/hdr/meter-reg.hh similarity index 64% rename from hdr/meterreg.hh rename to hdr/meter-reg.hh index f14e2ecb9e..6ebe18c282 100644 --- a/hdr/meterreg.hh +++ b/hdr/meter-reg.hh @@ -1,5 +1,5 @@ /* - meterreg.hh -- declare Meter_register + meter-reg.hh -- declare Meter_register source file of the LilyPond music typesetter @@ -20,9 +20,10 @@ public: Meter * meter_p_; virtual bool try_request(Request *req_l); - virtual void process_request(); - virtual void do_pre_move_process(); - virtual void do_post_move_process(); - Meter_register(Complex_walker*); + virtual void process_requests(); + virtual void pre_move_processing(); + virtual void post_move_processing(); + Meter_register(); + NAME_MEMBERS(Meter_register); }; #endif // METERREG_HH diff --git a/hdr/meter.hh b/hdr/meter.hh index 7de58e7c64..928434b28a 100644 --- a/hdr/meter.hh +++ b/hdr/meter.hh @@ -13,7 +13,7 @@ struct Meter: Item { Array args; /* *************** */ - const char * name() const; +NAME_MEMBERS(Meter); Meter(Array args) ; Molecule*brew_molecule_p() const; diff --git a/hdr/midioutput.hh b/hdr/midi-output.hh similarity index 90% rename from hdr/midioutput.hh rename to hdr/midi-output.hh index 34d7f7b039..a590f5a790 100644 --- a/hdr/midioutput.hh +++ b/hdr/midi-output.hh @@ -1,5 +1,5 @@ /* - midioutput.hh -- declare Midi_output + midi-output.hh -- declare Midi_output source file of the LilyPond music typesetter diff --git a/hdr/notehead.hh b/hdr/notehead.hh index febbe4d955..d7a68e7798 100644 --- a/hdr/notehead.hh +++ b/hdr/notehead.hh @@ -18,7 +18,7 @@ takes care of: */ struct Notehead : Item { - const char * name() const; + NAME_MEMBERS(Notehead); int position; /// -1 = lowest, 0 = inside, 1 = top @@ -38,7 +38,7 @@ struct Notehead : Item { */ Notehead(int staff_size); void do_print()const; - static int compare(Notehead*&a, Notehead*&b) ; + static int compare(Notehead * const &a, Notehead *const &b) ; Molecule* brew_molecule_p()const; }; #endif // NOTEHEAD_HH diff --git a/hdr/paperdef.hh b/hdr/paper-def.hh similarity index 83% rename from hdr/paperdef.hh rename to hdr/paper-def.hh index 03abf6abdc..ae557258b0 100644 --- a/hdr/paperdef.hh +++ b/hdr/paper-def.hh @@ -1,5 +1,5 @@ /* - paperdef.hh -- declare + paper-def.hh -- declare source file of the LilyPond music typesetter @@ -7,8 +7,8 @@ */ -#ifndef PAPERDEF_HH -#define PAPERDEF_HH +#ifndef Paper_def_HH +#define Paper_def_HH #include "proto.hh" #include "real.hh" #include "string.hh" @@ -23,7 +23,7 @@ see TODO */ -struct Paperdef { +struct Paper_def { Lookup *lookup_p_; String outfile; @@ -37,10 +37,10 @@ struct Paperdef { /* *************** */ void reinit(); - Paperdef(Lookup*); + Paper_def(Lookup*); void set(Lookup*); - ~Paperdef(); - Paperdef(Paperdef const&); + ~Paper_def(); + Paper_def(Paper_def const&); Real interline()const; Real internote()const; Real rule_thickness()const; @@ -50,5 +50,5 @@ struct Paperdef { Real duration_to_dist(Moment); }; -#endif // PAPERDEF_HH +#endif // Paper_def_HH diff --git a/hdr/proto.hh b/hdr/proto.hh index 0ca6d726dd..5a47fc459a 100644 --- a/hdr/proto.hh +++ b/hdr/proto.hh @@ -35,6 +35,7 @@ struct Complex_music; struct Complex_staff; struct Complex_walker; struct Cresc_req; +struct Directional_spanner; struct Decresc_req; struct Duration; struct Duration_iterator; @@ -107,10 +108,10 @@ struct Plet_req; struct Plet; struct PScore; struct PStaff; -struct Paperdef; +struct Paper_def; struct Partial_measure_req; struct Rational; -struct Register_group; +struct Register_group_register; struct Request; struct Request_register; struct Rest; diff --git a/hdr/pscore.hh b/hdr/pscore.hh index f1f8dbbc96..b7ad49c0e1 100644 --- a/hdr/pscore.hh +++ b/hdr/pscore.hh @@ -15,7 +15,7 @@ */ struct PScore { - Paperdef *paper_l_; + Paper_def *paper_l_; /// the columns, ordered left to right IPointerList cols; @@ -41,7 +41,7 @@ struct PScore { /* *************** */ /* CONSTRUCTION */ - PScore(Paperdef*); + PScore(Paper_def*); /// add a line to the broken stuff. Positions given in #config# void set_breaking(Array); diff --git a/hdr/register.hh b/hdr/register.hh index 95dfe1e67b..da80db38fe 100644 --- a/hdr/register.hh +++ b/hdr/register.hh @@ -10,33 +10,22 @@ #include "proto.hh" #include "varray.hh" #include "request.hh" -#include "staffeleminfo.hh" - +#include "staff-elem-info.hh" /** a struct which processes requests, and creates the #Staff_elem#s. - Hungarian postfix: reg + It may use derived classes. Hungarian postfix: register */ class Request_register { + friend class Register_group_register; /** - Warning: you can't copy a #Request_register# - */ - Request_register(Request_register const &); -public: - Complex_walker * walk_l_; - Array accepted_req_arr_; - - Request_register(Complex_walker*); - Request_register(); - virtual ~Request_register(){} - - /** - take note of item/spanner - put item in spanner. Adjust local key; etc. + You cannot copy a Request_register + */ + Request_register(const Request_register&){} +protected: - Default: ignore the info - */ - virtual void acknowledge_element(Staff_elem_info){} + /// utility + virtual Paper_def * paper() const; /** try to fit the request in this register @@ -46,48 +35,71 @@ public: true: request swallowed. Don't try to put the request elsewhere. - (may be we could use C++ exceptions.. :-) - #Request_register::try_request# always returns false + Default: always return false */ virtual bool try_request(Request *req_l); /// make items/spanners with the requests you got - virtual void process_request(){} - - /// typeset any spanners. Empty #accepted_req_arr_# - void pre_move_processing(); - /// reset any appropriate data. - void post_move_processing(); - virtual bool acceptable_request_b(Request*) const; - virtual void set_dir(int){} -protected: - /// utility - Paperdef * paper() const; - - - /** - invoke walker method to typeset element - */ - void typeset_element(Staff_elem*elem_p); - + virtual void process_requests(){} + + /** typeset any items/spanners. Default: do nothing + */ + virtual void pre_move_processing(){} + /** reset any appropriate data. Default: do nothing + */ + virtual void post_move_processing(){} + + /** + Is this request eligible to be processed? Default: return false. + */ + virtual bool acceptable_request_b(Request*) const; /** - typeset a "command" item. + typeset a "command" item. Default: pass on to daddy. If the column is not breakable, #pre_p# and #post_p# are junked */ - void typeset_breakable_item(Item * pre_p , Item * nobreak_p, Item * post_p); - /** virtual, called by #pre_move_processing()# - #Request_register::do_pre_move_process()# defaults to NOP + virtual void typeset_breakable_item(Item * pre_p , + Item * nobreak_p, Item * post_p); + /** + Invoke walker method to typeset element. Default: pass on to daddy. + */ + virtual void typeset_element(Staff_elem*elem_p); + + /** + take note of item/spanner + put item in spanner. Adjust local key; etc. + + Default: ignore the info */ - virtual void do_pre_move_process(){} - /** virtual, called by #post_move_processing#, - #Request_register::do_post_move_process()# defaults to NOP */ - virtual void do_post_move_process(){} + virtual void acknowledge_element(Staff_elem_info) {} /** - Announce element to walker. Utility + Announce element. Default: pass on to daddy. Utility */ - void announce_element(Staff_elem_info); + virtual void announce_element(Staff_elem_info); + /** + Set features of the register(s). Default: ignore features. + */ + virtual void set_feature(Features){} + /** + Does this equal or contain a certain register? + */ + virtual bool contains_b(Request_register*reg_l); + /** + Get information on the staff. Default: ask daddy. + */ + virtual Staff_info get_staff_info(); + + virtual void do_print()const; +public: + /** Every Request_register (except for the 'top' which is directly + inside the Staff_walker, is a element of a group. */ + Register_group_register * daddy_reg_l_; + + Request_register(); + virtual ~Request_register(){} + NAME_MEMBERS(Request_register); + void print() const; }; diff --git a/hdr/registergroup.hh b/hdr/registergroup.hh index c3a4df4a62..6d6e76a15b 100644 --- a/hdr/registergroup.hh +++ b/hdr/registergroup.hh @@ -12,25 +12,41 @@ #include "plist.hh" -#include "staffeleminfo.hh" +#include "staff-elem-info.hh" +#include "register.hh" + /** Group a number of registers. Usually delegates everything to its contents. + Postfix: group */ -class Register_group { -public: +class Register_group_register : public Request_register { +protected: IPointerList reg_list_; + virtual void do_print()const; +public: + + /** + Junk #reg_l#. + + Pre: + #reg_l# is in #reg_list_# + */ + virtual void terminate_register(Request_register * reg_l); - void set_dir(int i); - bool acceptable_request_b(Request*); - void pre_move_processing(); - void post_move_processing(); - void acknowledge_element(Staff_elem_info info); - bool try_request(Request*); - void process_requests(); - virtual ~Register_group(); - void add(Request_register* reg_p); - bool contains_b(Request_register*); -// bool contains_b(Register_group*); + /** + Remove #reg_l# from the list, and return it. + */ + Request_register * get_register_p(Request_register*reg_l); + virtual void set_feature(Features i); + virtual bool acceptable_request_b(Request*); + virtual void pre_move_processing(); + virtual void post_move_processing(); + virtual void acknowledge_element(Staff_elem_info info); + virtual bool try_request(Request*); + virtual void process_requests(); + virtual ~Register_group_register(); + virtual void add(Request_register* reg_p); + virtual bool contains_b(Request_register*); }; #endif // REGISTERGROUP_HH diff --git a/hdr/request.hh b/hdr/request.hh index 63929a923b..1936d5a2ab 100644 --- a/hdr/request.hh +++ b/hdr/request.hh @@ -13,22 +13,25 @@ #include "glob.hh" #include "string.hh" #include "moment.hh" +#include "class-name.hh" /** a voice element wants something printed. Hungarian postfix: req @see lilygut manpage */ -struct Request { +class Request { +public: Voice_element*elt_l_; char const* defined_ch_c_l_; /* *************** */ + Voice * voice_l(); Request(); Request(Request const&); virtual ~Request(){} - virtual const char * name() const { return "Request";} + NAME_MEMBERS(Request); virtual Request* clone() const { return new Request(*this); } void print()const ; @@ -63,7 +66,7 @@ protected: #define REQUESTMETHODS(T,accessor) \ virtual T * accessor() { return this;}\ -virtual const char* name() const { return #T; }\ +NAME_MEMBERS(T);\ virtual Request *clone() const { return new T(*this); } \ virtual void do_print() const diff --git a/hdr/rest.hh b/hdr/rest.hh index d03bd0c96f..85c7266677 100644 --- a/hdr/rest.hh +++ b/hdr/rest.hh @@ -18,7 +18,7 @@ struct Rest : Item { Rest(int dur,int dots); void do_print()const; - const char * name() const; +NAME_MEMBERS(Rest); Molecule* brew_molecule_p()const; }; #endif diff --git a/hdr/scorecolumn.hh b/hdr/score-column.hh similarity index 100% rename from hdr/scorecolumn.hh rename to hdr/score-column.hh diff --git a/hdr/scorewalker.hh b/hdr/score-walker.hh similarity index 94% rename from hdr/scorewalker.hh rename to hdr/score-walker.hh index fdbad24fae..b3d304256e 100644 --- a/hdr/scorewalker.hh +++ b/hdr/score-walker.hh @@ -1,5 +1,5 @@ /* - scorewalker.hh -- declare Score_walker + score-walker.hh -- declare Score_walker source file of the LilyPond music typesetter diff --git a/hdr/score.hh b/hdr/score.hh index bab7020ccc..a865ed02f3 100644 --- a/hdr/score.hh +++ b/hdr/score.hh @@ -20,7 +20,7 @@ /// the total music def of one movement struct Score { /// paper_, staffs_ and commands_ form the problem definition. - Paperdef *paper_p_; + Paper_def *paper_p_; Midi_def *midi_p_; IPointerList staffs_; @@ -48,7 +48,7 @@ struct Score { /// void set(Midi_def* midi_p); /// - void set(Paperdef* midi_p); + void set(Paper_def* midi_p); // standard void OK() const; diff --git a/hdr/scriptdef.hh b/hdr/script-def.hh similarity index 90% rename from hdr/scriptdef.hh rename to hdr/script-def.hh index 3c22681d23..8b5be32561 100644 --- a/hdr/scriptdef.hh +++ b/hdr/script-def.hh @@ -1,5 +1,5 @@ /* - scriptdef.hh -- part of LilyPond + script-def.hh -- part of LilyPond (c) 1996,97 Han-Wen Nienhuys */ diff --git a/hdr/script-reg.hh b/hdr/script-reg.hh new file mode 100644 index 0000000000..33592cae03 --- /dev/null +++ b/hdr/script-reg.hh @@ -0,0 +1,29 @@ +/* + script-reg.hh -- part of LilyPond + + (c) 1997 Han-Wen Nienhuys +*/ + + +#ifndef SCRIPTREG_HH +#define SCRIPTREG_HH + +#include "register.hh" + + +struct Script_register : Request_register { + Script * script_p_; + Script_req * script_req_l_; + int dir_i_; + /* *************** */ + void set_feature(Features dir_i_); + Script_register(); + virtual bool try_request(Request*); + virtual void process_requests(); + virtual void acknowledge_element(Staff_elem_info); + virtual void pre_move_processing(); + virtual void post_move_processing(); + NAME_MEMBERS(Script_register); +}; + +#endif // SCRIPTREG_HH diff --git a/hdr/script.hh b/hdr/script.hh index 7c089e3a54..df408f0435 100644 --- a/hdr/script.hh +++ b/hdr/script.hh @@ -7,7 +7,7 @@ #ifndef SCRIPT_HH #define SCRIPT_HH -#include "scriptdef.hh" +#include "script-def.hh" #include "item.hh" struct Script : Item { @@ -20,8 +20,8 @@ struct Script : Item { Array support; /* *************** */ - const char * name() const; - Molecule* brew_molecule_p()const; + NAME_MEMBERS(Script); + Molecule *brew_molecule_p()const; virtual void do_post_processing(); virtual void do_pre_processing(); Script(Script_req*, int staffsize); @@ -30,9 +30,9 @@ struct Script : Item { Interval support_height()const; virtual Interval width() const; private: - void set_symdir(); - void set_default_dir(); - void set_default_index(); + void set_symdir(); + void set_default_dir(); + void set_default_index(); Symbol symbol()const; }; diff --git a/hdr/scriptreg.hh b/hdr/scriptreg.hh deleted file mode 100644 index 72953427d5..0000000000 --- a/hdr/scriptreg.hh +++ /dev/null @@ -1,26 +0,0 @@ -/* - scriptreg.hh -- part of LilyPond - - (c) 1997 Han-Wen Nienhuys -*/ - - -#ifndef SCRIPTREG_HH -#define SCRIPTREG_HH - -#include "register.hh" - - -struct Script_register : Request_register { - Script * script_p_; - int dir_i_; - /* *************** */ - void set_dir(int dir_i_); - Script_register(Complex_walker*); - virtual bool try_request(Request*); - virtual void process_request(); - virtual void acknowledge_element(Staff_elem_info); - virtual void do_pre_move_process(); -}; - -#endif // SCRIPTREG_HH diff --git a/hdr/slurreg.hh b/hdr/slur-reg.hh similarity index 59% rename from hdr/slurreg.hh rename to hdr/slur-reg.hh index 701b60a279..e357c8795e 100644 --- a/hdr/slurreg.hh +++ b/hdr/slur-reg.hh @@ -1,5 +1,5 @@ /* - slurreg.hh -- declare Slur_register + slur-reg.hh -- declare Slur_register (c) 1997 Han-Wen Nienhuys */ @@ -12,17 +12,22 @@ struct Slur_register : Request_register { Array requests_arr_; + Array new_slur_req_l_arr_; Array slur_l_stack_; Array end_slur_l_arr_; + int dir_i_; + /* *************** */ ~Slur_register(); - Slur_register(Complex_walker*); + Slur_register(); virtual bool try_request(Request*); - virtual void process_request(); + virtual void process_requests(); virtual void acknowledge_element(Staff_elem_info); - virtual void do_pre_move_process(); - virtual void set_dir(int); + virtual void pre_move_processing(); + virtual void post_move_processing(); + virtual void set_feature(Features); + NAME_MEMBERS(Slur_register); }; #endif // SLURREG_HH diff --git a/hdr/slur.hh b/hdr/slur.hh index c3e6a93c76..87f1fe855e 100644 --- a/hdr/slur.hh +++ b/hdr/slur.hh @@ -7,7 +7,7 @@ #ifndef SLUR_HH #define SLUR_HH -#include "directionalspanner.hh" +#include "directional-spanner.hh" #include "fproto.hh" #include "varray.hh" @@ -29,7 +29,7 @@ struct Slur : Directional_spanner { void process(); private: Molecule*brew_molecule_p()const; - const char * name() const; + NAME_MEMBERS(Slur); }; #endif // SLUR_HH diff --git a/hdr/spanner.hh b/hdr/spanner.hh index 878d48d6e0..43a3567fa5 100644 --- a/hdr/spanner.hh +++ b/hdr/spanner.hh @@ -8,7 +8,7 @@ #define SPANNER_HH #include "proto.hh" -#include "staffelem.hh" +#include "staff-elem.hh" /** a symbol which is attached between two columns. A spanner is a symbol which spans across several columns, so its @@ -38,7 +38,7 @@ struct Spanner:Staff_elem { Spanner(); virtual Interval width()const; void do_print()const; - const char* name()const; + Spanner *broken_at(PCol *c1, PCol *c2) const; virtual Spanner* spanner() { return this; } protected: @@ -48,6 +48,7 @@ protected: PRE c1 >= start, c2 <= stop */ - virtual Spanner *do_break_at( PCol *c1, PCol *c2) const=0; + virtual Spanner *do_break_at( PCol *c1, PCol *c2) const=0; + NAME_MEMBERS(Spanner); }; #endif diff --git a/hdr/staffcolumn.hh b/hdr/staff-column.hh similarity index 92% rename from hdr/staffcolumn.hh rename to hdr/staff-column.hh index d80b6fa7b3..dd6303ea8c 100644 --- a/hdr/staffcolumn.hh +++ b/hdr/staff-column.hh @@ -1,5 +1,5 @@ /* - staffcolumn.hh -- declare Staff_column + staff-column.hh -- declare Staff_column (c) 1996,97 Han-Wen Nienhuys */ @@ -16,6 +16,7 @@ class Staff_column { Staff_column(Staff_column const&); public: + Array creationreq_l_arr_; Array musicalreq_l_arr_; Array commandreq_l_arr_; Staff * staff_l_; diff --git a/hdr/staff-elem-info.hh b/hdr/staff-elem-info.hh new file mode 100644 index 0000000000..9c6264a86b --- /dev/null +++ b/hdr/staff-elem-info.hh @@ -0,0 +1,43 @@ +/* + staff-elem-info.hh -- declare Staff_elem_info + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + + +#ifndef STAFFELEMINFO_HH +#define STAFFELEMINFO_HH + +#include "proto.hh" +#include "varray.hh" +/// data container. +struct Staff_elem_info { + Staff_elem * elem_p_; + Request*req_l_; + const Voice * voice_l_; + Array origin_reg_l_arr_; + + + /* *** */ + Staff_elem_info(Staff_elem*, Request*); + Staff_elem_info(); +}; + +struct Staff_info { + int *c0_position_i_; + Staff_walker *walk_l_; + const Time_description *time_c_l_; + const Rhythmic_grouping *rhythmic_c_l_; +}; + + +struct Features { + bool initialiser_b_; + int direction_i_; + + Features(); + static Features dir(int); +}; +#endif // STAFFELEMINFO_HH diff --git a/hdr/staffelem.hh b/hdr/staff-elem.hh similarity index 89% rename from hdr/staffelem.hh rename to hdr/staff-elem.hh index 3928c994e9..e2fce84582 100644 --- a/hdr/staffelem.hh +++ b/hdr/staff-elem.hh @@ -1,5 +1,5 @@ /* - staffelem.hh -- part of LilyPond + staff-elem.hh -- part of LilyPond (c) 1996,97 Han-Wen Nienhuys */ @@ -10,6 +10,8 @@ #include "proto.hh" #include "offset.hh" #include "molecule.hh" +#include "class-name.hh" + /** Both Spanner and Item are Staff_elem's. Most Staff_elem's depend on other Staff_elem's, eg, Beam needs to know and set direction of @@ -37,20 +39,21 @@ struct Staff_elem { virtual void print() const; virtual Interval width() const; virtual Interval height() const; - Paperdef *paper() const; + Paper_def *paper() const; virtual ~Staff_elem(); Staff_elem(); - + NAME_MEMBERS(Staff_elem); void translate(Offset); void add_processing(); void pre_processing(); void post_processing(); void molecule_processing(); - virtual const char *name() const; // to find out derived classes. + virtual Spanner* spanner() { return 0; } virtual Item * item() { return 0; } - void add_depedency(Staff_elem* ); + void add_dependency(Staff_elem* ); void substitute_dependency(Staff_elem* old, Staff_elem * newdep); + protected: /// do printing of derived info. @@ -79,6 +82,7 @@ private: Offset offset_; Array dependencies; }; -#define NAME_METHOD(c) const char *c::name()const{ return #c; } struct c + + #endif // STAFFELEM_HH diff --git a/hdr/staffwalker.hh b/hdr/staff-walker.hh similarity index 92% rename from hdr/staffwalker.hh rename to hdr/staff-walker.hh index aed371ef32..fb0d098e07 100644 --- a/hdr/staffwalker.hh +++ b/hdr/staff-walker.hh @@ -1,5 +1,5 @@ /* - staffwalker.hh -- declare Staff_walker + staff-walker.hh -- declare Staff_walker (c) 1996,97 Han-Wen Nienhuys */ @@ -8,7 +8,7 @@ #define STAFFWALKER_HH #include "proto.hh" -#include "timedescription.hh" +#include "time-description.hh" #include "pcursor.hh" /** diff --git a/hdr/staff.hh b/hdr/staff.hh index e45398e789..959859b6e4 100644 --- a/hdr/staff.hh +++ b/hdr/staff.hh @@ -35,7 +35,7 @@ public: void add(const PointerList &s); void add_voice(Voice *v); - Paperdef*paper()const; + Paper_def*paper()const; void setup_staffcols(); diff --git a/hdr/staffeleminfo.hh b/hdr/staffeleminfo.hh deleted file mode 100644 index b8af8aeb22..0000000000 --- a/hdr/staffeleminfo.hh +++ /dev/null @@ -1,28 +0,0 @@ -/* - staffeleminfo.hh -- declare Staff_elem_info - - source file of the LilyPond music typesetter - - (c) 1997 Han-Wen Nienhuys -*/ - - -#ifndef STAFFELEMINFO_HH -#define STAFFELEMINFO_HH - -#include "proto.hh" - -/// data container. -struct Staff_elem_info { - Staff_elem * elem_p_; - Request*req_l_; - const Voice * voice_l_; - Voice_group_registers * group_regs_l_; - Request_register * origin_reg_l_; - - /* *** */ - Staff_elem_info(Staff_elem*, Request*, Request_register*); - Staff_elem_info(); -}; - -#endif // STAFFELEMINFO_HH diff --git a/hdr/staffsym.hh b/hdr/staffsym.hh index 294a0218a0..bcec2bfaff 100644 --- a/hdr/staffsym.hh +++ b/hdr/staffsym.hh @@ -20,7 +20,7 @@ public: /// this many lines. int no_lines_i_; - const char *name()const; + NAME_MEMBERS(Staff_symbol); Staff_symbol(int lines); virtual Molecule* brew_molecule_p() const; void set_extent(PCol* p1, PCol* p2); diff --git a/hdr/stembeamreg.hh b/hdr/stem-beam-reg.hh similarity index 67% rename from hdr/stembeamreg.hh rename to hdr/stem-beam-reg.hh index 3d9d6026df..dddba269a4 100644 --- a/hdr/stembeamreg.hh +++ b/hdr/stem-beam-reg.hh @@ -1,5 +1,5 @@ /* - stembeamreg.hh -- part of LilyPond + stem-beam-reg.hh -- part of LilyPond (c) 1997 Han-Wen Nienhuys */ @@ -20,13 +20,14 @@ struct Stem_beam_register : Request_register { int default_dir_i_; /* *************** */ - Stem_beam_register(Complex_walker*); + Stem_beam_register(); ~Stem_beam_register(); - void set_dir(int dir_i_); + virtual void set_feature(Features dir_i_); virtual bool try_request(Request*); - virtual void process_request(); + virtual void process_requests(); virtual void acknowledge_element(Staff_elem_info); - virtual void do_pre_move_process(); - virtual void do_post_move_process(); + virtual void pre_move_processing(); + virtual void post_move_processing(); + NAME_MEMBERS(Stem_beam_register); }; #endif // STEMBEAMREG_HH diff --git a/hdr/stem.hh b/hdr/stem.hh index 2aafd66074..34776ea49c 100644 --- a/hdr/stem.hh +++ b/hdr/stem.hh @@ -61,7 +61,8 @@ struct Stem : Item { /// ensure that this Stem also encompasses the Notehead #n# void add(Notehead*n); - const char * name() const; + + NAME_MEMBERS(Stem); Real hindex()const; void do_print() const; diff --git a/hdr/symbol.hh b/hdr/symbol.hh index 62de3be496..c166fa5bcf 100644 --- a/hdr/symbol.hh +++ b/hdr/symbol.hh @@ -11,6 +11,7 @@ struct Symbol { Symbol (String, Box); Symbol(); + String str()const; // for printing. }; #endif diff --git a/hdr/symtable.hh b/hdr/symtable.hh index 61dc38b42e..f96d02c1ec 100644 --- a/hdr/symtable.hh +++ b/hdr/symtable.hh @@ -9,7 +9,7 @@ struct Symtable : public Assoc { Symbol lookup(String)const; - + void print()const; }; @@ -20,6 +20,7 @@ struct Symtables : private Assoc { Symtables(); Symtables(Symtables const&); Assoc::add; + void print()const; }; diff --git a/hdr/tstream.hh b/hdr/tex-stream.hh similarity index 100% rename from hdr/tstream.hh rename to hdr/tex-stream.hh diff --git a/hdr/textdef.hh b/hdr/text-def.hh similarity index 83% rename from hdr/textdef.hh rename to hdr/text-def.hh index da0055281d..cc9c3c95b3 100644 --- a/hdr/textdef.hh +++ b/hdr/text-def.hh @@ -1,5 +1,5 @@ /* - textdef.hh -- part of LilyPond + text-def.hh -- part of LilyPond (c) 1996,97 Han-Wen Nienhuys */ @@ -22,7 +22,7 @@ struct Text_def { bool compare(const Text_def&); Text_def(); virtual void print() const; - virtual Atom create_atom(Paperdef*) const; + virtual Atom create_atom(Paper_def*) const; }; #endif // TEXTDEF_HH diff --git a/hdr/textreg.hh b/hdr/text-reg.hh similarity index 51% rename from hdr/textreg.hh rename to hdr/text-reg.hh index 3dd2172335..59317e5bcd 100644 --- a/hdr/textreg.hh +++ b/hdr/text-reg.hh @@ -1,5 +1,5 @@ /* - textreg.hh -- part of LilyPond + text-reg.hh -- part of LilyPond (c) 1997 Han-Wen Nienhuys */ @@ -11,13 +11,16 @@ struct Text_register : Request_register{ Text_item * text_p_; + Text_req * text_req_l_; int dir_i_; /* *************** */ - void set_dir(int dir_i); - Text_register(Complex_walker*); + virtual void set_feature(Features ); + Text_register(); virtual bool try_request(Request*); - virtual void process_request(); - virtual void do_pre_move_process(); + virtual void process_requests(); + virtual void pre_move_processing(); + virtual void post_move_processing(); + NAME_MEMBERS(Text_register); }; #endif // TEXTREG_HH diff --git a/hdr/textitem.hh b/hdr/textitem.hh index 4e0e454941..ae0b556308 100644 --- a/hdr/textitem.hh +++ b/hdr/textitem.hh @@ -7,7 +7,7 @@ #ifndef TEXT_ITEM_HH #define TEXT_ITEM_HH -#include "textdef.hh" +#include "text-def.hh" #include "item.hh" struct Text_item : Item { @@ -17,7 +17,7 @@ struct Text_item : Item { Text_def* tdef_l_; /* ***************/ - const char * name() const; + NAME_MEMBERS(Text_item); virtual void set_default_index(); Molecule* brew_molecule_p() const; void do_pre_processing(); diff --git a/hdr/textspanner.hh b/hdr/textspanner.hh index 586d25a5d8..dbdea979ad 100644 --- a/hdr/textspanner.hh +++ b/hdr/textspanner.hh @@ -8,8 +8,8 @@ #define TEXTSPANNER_HH #include "string.hh" -#include "directionalspanner.hh" -#include "textdef.hh" +#include "directional-spanner.hh" +#include "text-def.hh" /** a spanner which puts texts on top of other spanners. Use for triplets, eentweetjes, ottava, etc. */ @@ -20,10 +20,10 @@ struct Text_spanner : Spanner { /* *************** */ - const char * name() const; - virtual void do_pre_processing(); - virtual void do_post_processing(); - virtual Interval height() const ; + NAME_MEMBERS(Text_spanner); + virtual void do_pre_processing(); + virtual void do_post_processing(); + virtual Interval height() const ; virtual Molecule* brew_molecule_p()const; virtual void do_print() const; virtual Spanner* do_break_at(PCol*,PCol*)const; diff --git a/hdr/timedescription.hh b/hdr/time-description.hh similarity index 100% rename from hdr/timedescription.hh rename to hdr/time-description.hh diff --git a/hdr/voice-element.hh b/hdr/voice-element.hh new file mode 100644 index 0000000000..0c5b6b1328 --- /dev/null +++ b/hdr/voice-element.hh @@ -0,0 +1,37 @@ +/* + voice-element.hh -- declare Voice_element + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + + +#ifndef VOICE_ELEMENT_HH +#define VOICE_ELEMENT_HH + +#include "proto.hh" +#include "plist.hh" +#include "moment.hh" + +/** one horizontal bit. Voice_element is nothing but a container for + *the requests, */ +struct Voice_element { + Moment duration; + char const* defined_ch_c_l_; + const Voice *voice_l_; + IPointerList reqs; + + /* *************** */ + + Voice_element(); + Voice_element(Voice_element const & src ); + + void add(Request*); + bool find_plet_start_bo(char c, Moment& moment_r); + void print ()const; + void set_default_group(String id); + void set_plet_backwards(Moment& now_moment_r, Moment until_moment, int num_i, int den_i); +}; + +#endif // VOICE-ELEMENT_HH diff --git a/hdr/voice-group-regs.hh b/hdr/voice-group-regs.hh new file mode 100644 index 0000000000..7c1b4ed78a --- /dev/null +++ b/hdr/voice-group-regs.hh @@ -0,0 +1,29 @@ +/* + voice-group-regs.hh -- declare Voice_group_registers + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + + +#ifndef VOICEGROUPREGS_HH +#define VOICEGROUPREGS_HH + +#include "registergroup.hh" + +struct Voice_group_registers : Register_group_register { + String group_id_str_; + Array voice_regs_l_; + + /* *************** */ + + NAME_MEMBERS(Voice_group_registers); + static bool static_acceptable_request_b(Request*); + virtual void terminate_register(Request_register*); + virtual void do_print() const; + virtual void add(Request_register*); + Voice_group_registers(String id); + virtual bool try_request(Request*); +}; +#endif // VOICEGROUPREGS_HH diff --git a/hdr/voiceregs.hh b/hdr/voice-regs.hh similarity index 51% rename from hdr/voiceregs.hh rename to hdr/voice-regs.hh index c9e809b618..82070a704e 100644 --- a/hdr/voiceregs.hh +++ b/hdr/voice-regs.hh @@ -1,5 +1,5 @@ /* - voiceregs.hh -- declare Voice_registers + voice-regs.hh -- declare Voice_registers source file of the LilyPond music typesetter @@ -12,15 +12,19 @@ #include "registergroup.hh" -struct Voice_registers : Register_group { - Voice *voice_l_; +class Voice_registers : public Register_group_register { + +public: + Voice *voice_l_; /* *************** */ - static bool acceptable_request_b(Request*); + NAME_MEMBERS(Voice_registers); + virtual bool acceptable_request_b(Request*); virtual void acknowledge_element(Staff_elem_info info); - - Voice_registers(Complex_walker*,Voice*); + virtual bool try_request(Request*); + Voice_registers(Voice*); + virtual void do_print() const; }; diff --git a/hdr/voice.hh b/hdr/voice.hh index 4b8e258c1f..06e6e1da27 100644 --- a/hdr/voice.hh +++ b/hdr/voice.hh @@ -7,8 +7,10 @@ /** class for horizontal stuff. - Voice is a ordered row of Voice_elements. It is strictly horizontal: - you cannot have two rhythmic elements running parallel in a Voice + Voice is a ordered row of Voice_elements. It is strictly + horizontal: you cannot have two rhythmic elements running parallel + in a Voice. For proper processing, each Voice should have + Group_change_req as a first element. */ @@ -30,24 +32,4 @@ struct Voice { void set_plet_backwards(Moment& now_moment_r, Moment until_moment, int num_i, int den_i); }; -/** one horizontal bit. Apart from being a container for the requests, Voice_element is nothing - */ -struct Voice_element { - Moment duration; - char const* defined_ch_c_l_; - const Voice *voice_l_; - IPointerList reqs; - - /* *************** */ - - Voice_element(); - Voice_element(Voice_element const & src ); - - void add(Request*); - bool find_plet_start_bo(char c, Moment& moment_r); - void print ()const; - void set_default_group(String id); - void set_plet_backwards(Moment& now_moment_r, Moment until_moment, int num_i, int den_i); - /// return true when done -}; #endif diff --git a/hdr/voicegroupregs.hh b/hdr/voicegroupregs.hh deleted file mode 100644 index 649be8e600..0000000000 --- a/hdr/voicegroupregs.hh +++ /dev/null @@ -1,27 +0,0 @@ -/* - voicegroupregs.hh -- declare - - source file of the LilyPond music typesetter - - (c) 1997 Han-Wen Nienhuys -*/ - - -#ifndef VOICEGROUPREGS_HH -#define VOICEGROUPREGS_HH - -#include "registergroup.hh" - -struct Voice_group_registers : Register_group { - String group_id_str_; - Complex_walker * walk_l_; - - /* *************** */ - void set_dir(int i); - static bool acceptable_request_b(Request*); - - void acknowledge_element(Staff_elem_info info); - Voice_group_registers(Complex_walker*, String id = ""); - bool try_request(Request*); -}; -#endif // VOICEGROUPREGS_HH diff --git a/hdr/walkregs.hh b/hdr/walkregs.hh index 93801d0717..643ce57605 100644 --- a/hdr/walkregs.hh +++ b/hdr/walkregs.hh @@ -13,8 +13,38 @@ #include "registergroup.hh" -struct Walker_registers : Register_group { - Walker_registers(Complex_walker *w); +/** + Top level registers: the interface to Complex_walker. + + [sigh. Sometimes I wish C++ could do better late binding.] + */ +struct Walker_registers : Register_group_register { + Array prebreak_item_p_arr_; + Array nobreak_item_p_arr_; + Array postbreak_item_p_arr_; + Array announce_info_arr_; + Array group_l_arr_; + Complex_walker * walk_l_; + + /* *************** */ + void change_group(Group_change_req * greq_l, + Voice_registers *voice_regs_l, + Voice_group_registers * old_group); + Voice_group_registers * get_group(String id); + void typeset_musical_item(Staff_elem * elem_p); + Walker_registers(Complex_walker*); + void do_announces(); + void terminate_register(Request_register * reg); + virtual bool try_request(Request * r); + virtual Staff_info get_staff_info(); + + virtual void announce_element(Staff_elem_info); + virtual void acknowledge_element(Staff_elem_info); + virtual void typeset_breakable_item(Item * pre_p , Item * nobreak_p, Item * post_p); + virtual void typeset_element(Staff_elem*elem_p); + virtual void pre_move_processing(); + virtual void post_move_processing(); + virtual Paper_def * paper() const; }; #endif // WALKREGS_HH diff --git a/init/symbol.ini b/init/symbol.ini index 7de1e0f521..82029a9e1b 100644 --- a/init/symbol.ini +++ b/init/symbol.ini @@ -1,7 +1,7 @@ include "dutch.ini" # do not include init/ path -include "script.ini" -include "table_sixteen.ini" +include "script.ini" +include "table_sixteen.ini" # not needed if doing MIDI diff --git a/input/midi.ly b/input/midi.ly index 38e5073778..9e45033808 100644 --- a/input/midi.ly +++ b/input/midi.ly @@ -4,7 +4,7 @@ melodie = music { $\clef\violin c c | g g | a a | g2 - f f | e e | d d8.( e16 | )c2 | % :| + f f | e e | d d8. e16 | c2 | % :| $ } @@ -33,6 +33,7 @@ score { commands { meter { 2 * 4} } + paper{} midi { tempo 4:120 } diff --git a/input/scales.ly b/input/scales.ly index d98c1bba43..11568c9ea6 100644 --- a/input/scales.ly +++ b/input/scales.ly @@ -4,15 +4,15 @@ staff {melodic music{ $ \duration { 8 } \octave{ } - |[ a a a a a a a a a ] + |[ a a a a a a a a a ]8/9 \octave{ ' } - |[ a a a a a a a a a ] + |[ a a a a a a a a a ]8/9 \octave { ` } - [ `c `g d a 'e 'b ''f '''c '''g ] - [ '''g '''c ''f 'b 'e a d `g `c ] + [ `c `g d a 'e 'b ''f '''c '''g ] 8/9 + [ '''g '''c ''f 'b 'e a d `g `c ] 8/9 \octave{ ' } - [ `c `g d a 'e 'b ''f '''c '''g ] - [ '''g '''c ''f 'b 'e a d `g `c ] + [ `c `g d a 'e 'b ''f '''c '''g ] 8/9 + [ '''g '''c ''f 'b 'e a d `g `c ] 8/9 \octave { } [ c g 'd ]2/3 [ 'd g c ]2/3 @@ -54,7 +54,7 @@ score { } commands { meter {6*8} - skip 36*8 + skip {36*8} meter {4*4} } } diff --git a/src/Makefile b/src/Makefile index e78d5785f7..f49e05d64d 100644 --- a/src/Makefile +++ b/src/Makefile @@ -9,7 +9,7 @@ dist: ln $(DISTFILES) $(DDIR)/$(SUBDIR) TAGS: $(allcc) - etags -CT $(allcc) + $(TAGSACTION) $^ clean: rm -f $(gencc) diff --git a/src/barreg.cc b/src/bar-reg.cc similarity index 61% rename from src/barreg.cc rename to src/bar-reg.cc index f0b32fd3df..b72eca8755 100644 --- a/src/barreg.cc +++ b/src/bar-reg.cc @@ -1,49 +1,46 @@ /* - barreg.cc -- implement Bar_register + bar-reg.cc -- implement Bar_register source file of the LilyPond music typesetter (c) 1997 Han-Wen Nienhuys */ -#include "barreg.hh" +#include "bar-reg.hh" #include "bar.hh" #include "commandrequest.hh" -#include "complexwalker.hh" -#include "scorecolumn.hh" +#include "score-column.hh" +#include "time-description.hh" - -Bar_register::Bar_register(Complex_walker*w) - : Request_register(w) +Bar_register::Bar_register() { - do_post_move_process(); + post_move_processing(); } bool Bar_register::try_request(Request*r_l) { - if (!r_l->command()->bar()) + Command_req* c_l = r_l->command(); + if (!c_l|| !c_l->bar()) return false; assert(!bar_req_l_); - bar_req_l_ = r_l->command()->bar(); + bar_req_l_ = c_l->bar(); return true; } void -Bar_register::process_request() +Bar_register::process_requests() { - if (bar_req_l_ ) { bar_p_ = new Bar(bar_req_l_->type_str_); - } else if (!walk_l_->time_.whole_in_measure_) { + } else if (!get_staff_info().time_c_l_->whole_in_measure_) { bar_p_ = new Bar("|"); } if (bar_p_){ - walk_l_->allow_break(); - announce_element(Staff_elem_info(bar_p_, bar_req_l_, this) ); + announce_element(Staff_elem_info(bar_p_, bar_req_l_) ); } } @@ -62,7 +59,7 @@ Bar_register::split_bar(Bar *& pre, Bar * no, Bar * &post) } void -Bar_register::do_pre_move_process() +Bar_register::pre_move_processing() { if (bar_p_) { Bar * post_p =0; @@ -75,7 +72,7 @@ Bar_register::do_pre_move_process() } void -Bar_register::do_post_move_process() +Bar_register::post_move_processing() { bar_req_l_ = 0; bar_p_ =0; diff --git a/src/bar.cc b/src/bar.cc index ad64e016a6..32a7cd5fe6 100644 --- a/src/bar.cc +++ b/src/bar.cc @@ -1,11 +1,11 @@ #include "bar.hh" #include "string.hh" #include "molecule.hh" -#include "paperdef.hh" +#include "paper-def.hh" #include "lookup.hh" #include "debug.hh" -NAME_METHOD(Bar); + Bar::Bar( String t) { diff --git a/src/beam.cc b/src/beam.cc index f554d424bc..64f3e3cf77 100644 --- a/src/beam.cc +++ b/src/beam.cc @@ -9,11 +9,11 @@ #include "leastsquares.hh" #include "pcol.hh" #include "stem.hh" -#include "paperdef.hh" +#include "paper-def.hh" #include "lookup.hh" #include "grouping.hh" -NAME_METHOD(Beam); + struct Stem_info { Real x; @@ -58,7 +58,7 @@ void Beam::add(Stem*s) { stems.bottom().add(s); - s->add_depedency(this); + s->add_dependency(this); s->print_flag = false; } diff --git a/src/binary-source-file.cc b/src/binary-source-file.cc index 8545f221e9..39eec37254 100644 --- a/src/binary-source-file.cc +++ b/src/binary-source-file.cc @@ -1,6 +1,11 @@ -// -// binary-source-file.cc -// +/* + binary-source-file.cc -- implement Binary_source_file + + source file of the LilyPond music typesetter + + (c) 1997 Jan Nieuwenhuizen +*/ + #include // INT_MAX #include @@ -9,8 +14,9 @@ #include "plist.hh" #include "string.hh" #include "debug.hh" -#include "sourcefile.hh" +#include "source-file.hh" #include "binary-source-file.hh" +#include "string-convert.hh" Binary_source_file::Binary_source_file( String& filename_str ) : Source_file( filename_str ) diff --git a/src/break.cc b/src/break.cc index 6128fdd097..7d21918637 100644 --- a/src/break.cc +++ b/src/break.cc @@ -2,7 +2,7 @@ do calculations for breaking problem */ #include "break.hh" -#include "paperdef.hh" +#include "paper-def.hh" #include "linespace.hh" #include "debug.hh" #include "scoreline.hh" diff --git a/src/calcideal.cc b/src/calcideal.cc index 1a96243426..5ead08dd39 100644 --- a/src/calcideal.cc +++ b/src/calcideal.cc @@ -1,8 +1,8 @@ #include "idealspacing.hh" #include "score.hh" #include "pscore.hh" -#include "paperdef.hh" -#include "scorecolumn.hh" +#include "paper-def.hh" +#include "score-column.hh" #include "dimen.hh" diff --git a/src/clefitem.cc b/src/clef-item.cc similarity index 85% rename from src/clefitem.cc rename to src/clef-item.cc index 037aab69b8..528623eed6 100644 --- a/src/clefitem.cc +++ b/src/clef-item.cc @@ -1,19 +1,19 @@ /* - clefitem.cc -- implement Clef_item + clef-item.cc -- implement Clef_item source file of the LilyPond music typesetter (c) 1997 Han-Wen Nienhuys */ -#include "clefitem.hh" +#include "clef-item.hh" #include "string.hh" #include "molecule.hh" -#include "paperdef.hh" +#include "paper-def.hh" #include "lookup.hh" -#include "clefreg.hh" +#include "clef-reg.hh" + -NAME_METHOD(Clef_item); Clef_item::Clef_item() { diff --git a/src/clefreg.cc b/src/clef-reg.cc similarity index 59% rename from src/clefreg.cc rename to src/clef-reg.cc index ed6f78073b..2d9dcc112b 100644 --- a/src/clefreg.cc +++ b/src/clef-reg.cc @@ -7,21 +7,21 @@ Mats Bengtsson */ -#include "clefreg.hh" -#include "clefitem.hh" +#include "clef-reg.hh" +#include "clef-item.hh" #include "debug.hh" #include "commandrequest.hh" -#include "timedescription.hh" -#include "complexwalker.hh" -#include "staffcolumn.hh" +#include "time-description.hh" +#include "staff-column.hh" -Clef_register::Clef_register(Complex_walker*w) - : Request_register(w) +Clef_register::Clef_register() { clef_p_ = 0; - set_type("violin"); + /* ugly hack to prevent segfault (daddy_reg_l_ == 0 at construction) */ + clef_type_str_ = ""; } + bool Clef_register::set_type(String s) { @@ -36,7 +36,8 @@ Clef_register::set_type(String s) c0_position_i_= 10; }else return false; - walk_l_->set_c0_position(c0_position_i_); + *get_staff_info().c0_position_i_ = c0_position_i_; + return true; } @@ -50,48 +51,57 @@ Clef_register::read_req(Clef_change_req*c_l) bool Clef_register::try_request(Request * r_l) { - Command_req* creq_l= r_l->command(); if (!creq_l || !creq_l->clefchange()) return false; - accepted_req_arr_.push(creq_l); + clef_req_l_ = creq_l->clefchange(); + // do it now! Others have to read c0_pos. read_req(creq_l->clefchange()); return true; } void -Clef_register::process_request() +Clef_register::process_requests() { - const Time_description *time_l = &walk_l_->time_; - if (!accepted_req_arr_.size() && - (!time_l->whole_in_measure_|| !time_l->when_)) { - + const Time_description *time_l = get_staff_info().time_c_l_; + if (!clef_req_l_ && (!time_l->whole_in_measure_|| !time_l->when_)) { clef_p_ = new Clef_item; clef_p_->change = false; - } else if (accepted_req_arr_.size()) { + } else if (clef_req_l_) { clef_p_ = new Clef_item; clef_p_->change = true; } if (clef_p_) { clef_p_->read(*this); -// announce_element(Staff_elem_info(clef_p_, -// accepted_req_arr_[0], this)); + announce_element(Staff_elem_info(clef_p_, + clef_req_l_)); } } void -Clef_register::do_pre_move_process() +Clef_register::pre_move_processing() { if (!clef_p_) return; if (clef_p_->change) { + Clef_item* post_p = new Clef_item(*clef_p_); + post_p->change = false; typeset_breakable_item(new Clef_item(*clef_p_), - clef_p_, new Clef_item(*clef_p_) ); + clef_p_, post_p); } else { typeset_breakable_item(0, 0, clef_p_); } clef_p_ = 0; } +void +Clef_register::post_move_processing() +{ + clef_req_l_ = 0; + /* not in ctor, since the reg might not be linked in.*/ + if (clef_type_str_ == "") { + set_type("violin"); + } +} diff --git a/src/complexstaff.cc b/src/complex-staff.cc similarity index 79% rename from src/complexstaff.cc rename to src/complex-staff.cc index 627b5745e2..bb13274449 100644 --- a/src/complexstaff.cc +++ b/src/complex-staff.cc @@ -1,14 +1,9 @@ -#include "debug.hh" -#include "complexstaff.hh" -#include "complexwalker.hh" +#include "complex-staff.hh" +#include "complex-walker.hh" #include "score.hh" #include "pscore.hh" #include "staffsym.hh" -#include "pscore.hh" -#include "bar.hh" -#include "meter.hh" -#include "scorecolumn.hh" -#include "commandrequest.hh" +#include "score-column.hh" const NO_LINES = 5; diff --git a/src/complex-walker.cc b/src/complex-walker.cc new file mode 100644 index 0000000000..9fbd0525e6 --- /dev/null +++ b/src/complex-walker.cc @@ -0,0 +1,108 @@ +/* + complex-walker.cc -- implement Complex_walker + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + +#include "musicalrequest.hh" +#include "staff-column.hh" +#include "voice.hh" +#include "pscore.hh" +#include "complex-staff.hh" +#include "debug.hh" +#include "voice-group-regs.hh" +#include "voice-regs.hh" +#include "complex-walker.hh" +//#include "misc.hh" +#include "commandrequest.hh" +#include "walkregs.hh" + +void +Complex_walker::do_post_move() +{ + walk_regs_p_->post_move_processing(); +} + +void +Complex_walker::do_pre_move() +{ + walk_regs_p_->pre_move_processing(); +} + +void +Complex_walker::do_announces() +{ + walk_regs_p_->do_announces(); +} + +bool +Complex_walker::try_command_request(Command_req *req_l) +{ + return walk_regs_p_->try_request(req_l); +} + +void +Complex_walker::try_request(Request*req) +{ + walk_regs_p_->try_request(req); +} + +void +Complex_walker::process_requests() +{ + Staff_column*c =ptr(); + + for (int i=0; i < c->creationreq_l_arr_.size(); i++) { + try_request(c->creationreq_l_arr_[i]); + } + for (int i=0; i < c->commandreq_l_arr_.size(); i++) { + try_request(c->commandreq_l_arr_[i]); + } + + for (int i=0; i < c->musicalreq_l_arr_.size(); i++) { + try_request(c->musicalreq_l_arr_[i]); + } + + regs_process_requests(); + do_announces(); +} + +void +Complex_walker::regs_process_requests() +{ + walk_regs_p_->process_requests(); +} + +void +Complex_walker::typeset_element(Staff_elem *elem_p) +{ + if (!elem_p) + return; + if (elem_p->spanner()) + pscore_l_->typeset_spanner(elem_p->spanner(), staff()->pstaff_l_); + else + ptr()->typeset_musical_item(elem_p->item()); +} + +Complex_walker::Complex_walker(Complex_staff*s) + : Staff_walker(s, s->pstaff_l_->pscore_l_) +{ + walk_regs_p_ = new Walker_registers(this); + do_post_move(); +} + + +Complex_walker::~Complex_walker() +{ +} + +Complex_staff* +Complex_walker::staff() +{ + return (Complex_staff*) staff_l_; +} + + + diff --git a/src/complexwalker.cc b/src/complexwalker.cc deleted file mode 100644 index e3bcade138..0000000000 --- a/src/complexwalker.cc +++ /dev/null @@ -1,279 +0,0 @@ -/* - complexwalker.cc -- implement Complex_walker - - source file of the LilyPond music typesetter - - (c) 1997 Han-Wen Nienhuys -*/ - -#include "associter.hh" -#include "script.hh" -#include "musicalrequest.hh" -#include "staffcolumn.hh" -#include "voice.hh" -#include "pscore.hh" -#include "complexstaff.hh" -#include "debug.hh" -#include "voicegroupregs.hh" -#include "voiceregs.hh" -#include "complexwalker.hh" -#include "misc.hh" -#include "commandrequest.hh" -#include "walkregs.hh" - - -void -Complex_walker::announce_element(Staff_elem_info info) -{ - info.group_regs_l_ = find_voice_group((Voice*)info.voice_l_); - announce_info_arr_.push(info); -} - -void -Complex_walker::do_announces() -{ - Request dummy_req; - for (int i = 0; i < announce_info_arr_.size(); i++){ - Staff_elem_info info = announce_info_arr_[i]; - - if (!info.req_l_) - info.req_l_ = &dummy_req; - - walk_regs_p_->acknowledge_element(info); - for (iter_top(voice_reg_list_,j); j.ok(); j++) { - j->acknowledge_element(info); - } - for (iter_top ( group_reg_list_, j); j.ok(); j++) { - j->acknowledge_element(info); - } - } -} - -Voice_registers * -Complex_walker::find_voice_reg(Voice*v_l)const -{ - for (iter_top(voice_reg_list_, i); i.ok(); i++) { - if (i->voice_l_ == v_l) - return i; - } - return 0; -} - -Voice_registers* -Complex_walker::get_voice_reg(Voice*v_l) -{ - Voice_registers *regs_p=find_voice_reg(v_l); - if (regs_p) - return regs_p; - - regs_p = new Voice_registers(this,v_l); - voice_reg_list_.bottom().add (regs_p); - return regs_p; -} - -Voice_group_registers * -Complex_walker::find_voice_group(Voice* v_l)const -{ - if (!voice_group_map_.elt_query(v_l)) - return 0; - else return voice_group_map_[v_l]; -} - -Voice_group_registers * -Complex_walker::find_voice_group(const char *id)const -{ - for (iter_top(group_reg_list_, i); i.ok(); i++) - if (i->group_id_str_ == id) - return i; - return 0; -} - - -Voice_group_registers * -Complex_walker::get_voice_group(Voice *v_l) -{ - Voice_group_registers *group_p = find_voice_group(v_l); - if (group_p) - return group_p; - - group_p = new Voice_group_registers(this); - group_reg_list_.bottom().add(group_p); - voice_group_map_[v_l] = group_p; - return group_p; -} - - -Voice_group_registers * -Complex_walker::get_voice_group(const char* id) -{ - Voice_group_registers *group_p = find_voice_group(id); - if (group_p) - return group_p; - group_p = new Voice_group_registers(this,id); - group_reg_list_.bottom().add(group_p); - return group_p; -} - -void -Complex_walker::do_change_group(Voice * v, String group_id_str) -{ - voice_group_map_[v] = get_voice_group(group_id_str); -} - -bool -Complex_walker::try_command_request(Command_req *req_l) -{ - bool b=false; - Voice *voice_l = (Voice*)req_l->elt_l_->voice_l_; // ugh - if (req_l->groupchange()){ - do_change_group(voice_l, req_l->groupchange()->newgroup_str_); - b|= true; - } else if(req_l->groupfeature()) { - Voice_group_registers* reg_l = get_voice_group(voice_l); - b |= reg_l->try_request(req_l); - } else { - b |= walk_regs_p_->try_request(req_l); - } - return b; -} - -void -Complex_walker::try_request(Request*req) -{ - bool b=false; - Voice *voice_l = (Voice*)req->elt_l_->voice_l_; // ahh. This sux - - if (req->command()) { - b = try_command_request(req->command()); - } else if (Voice_registers::acceptable_request_b(req)) { - Voice_registers *vregs_l = get_voice_reg(voice_l); - b = vregs_l->try_request(req); - } else if (Voice_group_registers::acceptable_request_b(req)){ - Voice_group_registers* reg_l = get_voice_group(voice_l); - b = reg_l->try_request(req); - } - - if (!b) - warning("junking request: " + String(req->name()), - req->defined_ch_c_l_); -} - -void -Complex_walker::process_requests() -{ - Staff_column*c =ptr(); - - for (int i=0; i < c->commandreq_l_arr_.size(); i++) { - try_request(c->commandreq_l_arr_[i]); - } - - for (int i=0; i < c->musicalreq_l_arr_.size(); i++) { - try_request(c->musicalreq_l_arr_[i]); - } - - regs_process_requests(); - do_announces(); -} - -void -Complex_walker::regs_process_requests() -{ - walk_regs_p_->process_requests(); - for (iter_top(voice_reg_list_, j); j.ok(); j++) { - j->process_requests(); - } - for (iter_top(group_reg_list_, j); j.ok(); j++) - j->process_requests(); -} - -void -Complex_walker::typeset_element(Staff_elem *elem_p) -{ - if (!elem_p) - return; - if (elem_p->spanner()) - pscore_l_->typeset_spanner(elem_p->spanner(), staff()->pstaff_l_); - else - ptr()->typeset_musical_item(elem_p->item()); -} - -Complex_walker::Complex_walker(Complex_staff*s) - : Staff_walker(s, s->pstaff_l_->pscore_l_) -{ - walk_regs_p_ = new Walker_registers(this); - do_post_move(); -} - - -Complex_walker::~Complex_walker() -{ -} - -int -Complex_walker::c0_position_i()const -{ - return c0_position_i_; -} - -void -Complex_walker::set_c0_position(int p) -{ - c0_position_i_ =p; -} - -Complex_staff* -Complex_walker::staff() -{ - return (Complex_staff*) staff_l_; -} - - -void -Complex_walker::do_pre_move() -{ - walk_regs_p_->pre_move_processing(); - for (iter_top(voice_reg_list_,i); i.ok(); i++) { - i->pre_move_processing(); - } - for (iter_top (group_reg_list_, j); j.ok(); j++) - j->pre_move_processing(); - - ptr()->typeset_breakable_items(prebreak_item_p_arr_, - nobreak_item_p_arr_, - postbreak_item_p_arr_); -} - -void -Complex_walker::do_post_move() -{ - walk_regs_p_->post_move_processing(); - for (iter_top(voice_reg_list_,i); i.ok(); i++) { - i->post_move_processing(); - } - announce_info_arr_.set_size(0); - for (iter_top (group_reg_list_, j); j.ok(); j++) - j->post_move_processing(); -} - -Array -Complex_walker::get_voice_regs(Voice_group_registers* group_regs_l) const - return l_arr; -{ - for (Assoc_iter i(voice_group_map_); - i.ok(); i++) { - if (i.val() == group_regs_l) - l_arr.push(find_voice_reg(i.key())); - } -} - -void -Complex_walker::typeset_breakable_item(Item * pre_p , Item * nobreak_p, - Item * post_p) -{ - if (pre_p) - prebreak_item_p_arr_.push(pre_p); - if (nobreak_p) - nobreak_item_p_arr_.push(nobreak_p); - if (post_p) - postbreak_item_p_arr_.push(post_p); -} diff --git a/src/directionalspanner.cc b/src/directional-spanner.cc similarity index 65% rename from src/directionalspanner.cc rename to src/directional-spanner.cc index e7ce9c7ddc..7e2bb7c878 100644 --- a/src/directionalspanner.cc +++ b/src/directional-spanner.cc @@ -1,4 +1,4 @@ -#include "directionalspanner.hh" +#include "directional-spanner.hh" Directional_spanner::Directional_spanner() { diff --git a/src/duration.cc b/src/duration.cc index 6a251235ea..a7a1c5dfcf 100644 --- a/src/duration.cc +++ b/src/duration.cc @@ -8,7 +8,7 @@ #include "proto.hh" // ugh, these all for midi-main.hh #include "plist.hh" #include "string.hh" -#include "sourcefile.hh" +#include "source-file.hh" #include "source.hh" #include "midi-main.hh" // *tors diff --git a/src/grouping.cc b/src/grouping.cc index 6c2e6760c8..bc665a19c0 100644 --- a/src/grouping.cc +++ b/src/grouping.cc @@ -316,7 +316,7 @@ Rhythmic_grouping::translate(Moment m) } void -Rhythmic_grouping::extend(MInterval m) +Rhythmic_grouping::extend(MInterval m)const { assert(m.left >= interval().left); while (m.right >interval().right ) { @@ -325,7 +325,7 @@ Rhythmic_grouping::extend(MInterval m) a[i] =new Rhythmic_grouping(*children[i]); a[i]->translate(children.top()->interval().right); } - children.concat(a); + ((Rhythmic_grouping*)this)->children.concat(a); } assert(m.right <= interval().right); OK(); diff --git a/src/headreg.cc b/src/headreg.cc index c41037c513..dc5d72d572 100644 --- a/src/headreg.cc +++ b/src/headreg.cc @@ -6,65 +6,71 @@ #include "rest.hh" #include "notehead.hh" #include "headreg.hh" -#include "paperdef.hh" -#include "complexwalker.hh" +#include "paper-def.hh" +#include "complex-walker.hh" #include "musicalrequest.hh" -Notehead_register::Notehead_register(Complex_walker*w_l) - :Request_register(w_l) +Notehead_register::Notehead_register() { note_p_ = 0; - set_dir(0); + set_feature(Features::dir(0)); + post_move_processing(); } bool Notehead_register::try_request(Request *req_l) { if (req_l->note() || req_l->rest()) - accepted_req_arr_.push(req_l); + note_req_l_=req_l->rhythmic(); else return false; return true; } void -Notehead_register::set_dir(int d) +Notehead_register::set_feature(Features d) { - dir_i_ = d; + if(d.direction_i_ || d.initialiser_b_) + dir_i_ = d.direction_i_; } void -Notehead_register::process_request() +Notehead_register::process_requests() { - if (!accepted_req_arr_.size()) + if (!note_req_l_) return; - Request* req_l = accepted_req_arr_.top(); - if (req_l->note()) { + + if (note_req_l_->note()) { Notehead*n_p = new Notehead(8); // ugh note_p_ = n_p; - n_p->set_rhythmic(req_l->rhythmic()); - n_p->position = req_l->note()->height() + - walk_l_->c0_position_i(); + n_p->set_rhythmic(note_req_l_->rhythmic()); + n_p->position = note_req_l_->note()->height() + + *get_staff_info().c0_position_i_; } else { - note_p_ = new Rest ( req_l->rhythmic()->balltype, - req_l->rhythmic()->dots); - if (req_l->rhythmic()->balltype <= 2) + note_p_ = new Rest ( note_req_l_->rhythmic()->balltype, + note_req_l_->rhythmic()->dots); + if (note_req_l_->rhythmic()->balltype <= 2) note_p_->translate( Offset(0, 6 * paper()->internote())); } - Staff_elem_info itinf(note_p_,req_l,this); + Staff_elem_info itinf(note_p_,note_req_l_); announce_element(itinf); } void -Notehead_register::do_pre_move_process() +Notehead_register::pre_move_processing() { if (note_p_) { - if (dir_i_ && note_p_->name() == String("Rest")) + if (dir_i_ && note_p_->name() == Rest::static_name()) note_p_->translate(Offset(0, 4*dir_i_ * paper()->internote())); typeset_element(note_p_); note_p_ = 0; } } +void +Notehead_register::post_move_processing() +{ + note_req_l_ = 0; +} diff --git a/src/identifier.cc b/src/identifier.cc index d55c3fc4e4..59f1ff5d83 100644 --- a/src/identifier.cc +++ b/src/identifier.cc @@ -1,6 +1,14 @@ +/* + identifier.cc -- implement identifier and derived classes + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + #include -#include "identparent.hh" +#include "identifier.hh" #include "lexer.hh" #include "debug.hh" @@ -11,3 +19,38 @@ Identifier::error(String expect) e += String(classname()) + "(expected " + expect + ")"; ::error(e); } + +void +Identifier::print()const +{ + mtor << "identifier \'" << name << "\'="; + do_print(); +} + +/* ugh. */ +#define DEFAULT_PRINT(Class, Content_type, accessor) \ +void \ +Class::do_print() const { \ + ((Class*)this)->accessor(false)->print(); \ +} \ +class Class + +DEFAULT_PRINT(Script_id, Script_def, script); +DEFAULT_PRINT(Lookup_id, Lookup, lookup); +DEFAULT_PRINT(Symtables_id, Symtables, symtables); +DEFAULT_PRINT(Staff_id, Input_staff, staff); +DEFAULT_PRINT(M_chord_id, Music_general_chord, mchord); +DEFAULT_PRINT(M_voice_id, Music_voice, mvoice); + +void +Real_id::do_print() const +{ + Identifier::print(); + mtor << *((Real_id*)this)->real(false)<< "\n"; +} + +void +Notetab_id::do_print() const +{ + mtor << "unknown" << "\n"; +} diff --git a/src/inputmusic.cc b/src/input-music.cc similarity index 98% rename from src/inputmusic.cc rename to src/input-music.cc index b7ad70b0ab..f1047e8bf9 100644 --- a/src/inputmusic.cc +++ b/src/input-music.cc @@ -1,7 +1,8 @@ #include "debug.hh" -#include "inputmusic.hh" +#include "input-music.hh" #include "voice.hh" #include "musicalrequest.hh" +#include "voice-element.hh" void Input_music::check_plet(Voice_element* velt_l) diff --git a/src/inputscore.cc b/src/input-score.cc similarity index 83% rename from src/inputscore.cc rename to src/input-score.cc index 6fca9dc8eb..f39d47a4b1 100644 --- a/src/inputscore.cc +++ b/src/input-score.cc @@ -1,5 +1,5 @@ /* - inputscore.cc -- implement Input_score + input-score.cc -- implement Input_score source file of the LilyPond music typesetter @@ -7,12 +7,12 @@ */ #include "debug.hh" -#include "inputscore.hh" -#include "inputstaff.hh" -#include "inputmusic.hh" +#include "input-score.hh" +#include "input-staff.hh" +#include "input-music.hh" #include "score.hh" -#include "paperdef.hh" -#include "mididef.hh" +#include "paper-def.hh" +#include "midi-def.hh" #include "staff.hh" @@ -23,7 +23,7 @@ Input_score::add(Input_staff*s) } void -Input_score::set(Paperdef*p) +Input_score::set(Paper_def*p) { delete paper_p_; paper_p_ = p; @@ -38,7 +38,7 @@ Input_score::set(Midi_def* midi_p) Input_score::Input_score(Input_score const&s) { - paper_p_ = (s.paper_p_)? new Paperdef(*s.paper_p_) :0; + paper_p_ = (s.paper_p_)? new Paper_def(*s.paper_p_) :0; midi_p_ = (s.midi_p_)? new Midi_def(*s.midi_p_) : 0; defined_ch_c_l_ = s.defined_ch_c_l_; errorlevel_i_ = s.errorlevel_i_; @@ -55,7 +55,7 @@ Input_score::parse() if (midi_p_) s_p->set(new Midi_def(*midi_p_)); if (paper_p_) - s_p->set( new Paperdef(*paper_p_)); + s_p->set( new Paper_def(*paper_p_)); for (iter_top(staffs_,i); i.ok(); i++) { Staff* staf_p=i->parse(s_p, score_wide_music_p_); diff --git a/src/inputstaff.cc b/src/input-staff.cc similarity index 92% rename from src/inputstaff.cc rename to src/input-staff.cc index 952af6bd71..9e3958e97e 100644 --- a/src/inputstaff.cc +++ b/src/input-staff.cc @@ -1,5 +1,5 @@ /* - inputstaff.cc -- implement Input_staff + input-staff.cc -- implement Input_staff source file of the LilyPond music typesetter @@ -8,10 +8,10 @@ #include "debug.hh" #include "score.hh" -#include "inputmusic.hh" -#include "inputstaff.hh" +#include "input-music.hh" +#include "input-staff.hh" #include "staff.hh" -#include "complexstaff.hh" +#include "complex-staff.hh" #include "lyricstaff.hh" #include "lexer.hh" diff --git a/src/item.cc b/src/item.cc index 3ea6c0445e..e653c46ac6 100644 --- a/src/item.cc +++ b/src/item.cc @@ -1,7 +1,7 @@ #include "debug.hh" #include "item.hh" -NAME_METHOD(Item); + Item::Item() { diff --git a/src/keyitem.cc b/src/key-item.cc similarity index 92% rename from src/keyitem.cc rename to src/key-item.cc index 6b465572dd..963b1bc578 100644 --- a/src/keyitem.cc +++ b/src/key-item.cc @@ -1,16 +1,16 @@ -#include "keyitem.hh" +#include "key-item.hh" #include "key.hh" #include "debug.hh" #include "molecule.hh" -#include "paperdef.hh" +#include "paper-def.hh" #include "lookup.hh" -//#include "clefreg.hh" -#include "keyreg.hh" +//#include "clef-reg.hh" +#include "key-reg.hh" const int FLAT_TOP_PITCH=2; /* fes,ges,as and bes typeset in lower octave */ const int SHARP_TOP_PITCH=4; /* ais and bis typeset in lower octave */ -NAME_METHOD(Key_item); + Key_item::Key_item(int c) { diff --git a/src/keyreg.cc b/src/key-reg.cc similarity index 61% rename from src/keyreg.cc rename to src/key-reg.cc index 197a8f6b31..84b0e268c6 100644 --- a/src/keyreg.cc +++ b/src/key-reg.cc @@ -1,5 +1,5 @@ /* - keyreg.cc -- implement Key_register + key-reg.cc -- implement Key_register source file of the LilyPond music typesetter @@ -8,29 +8,28 @@ todo: key undo */ - -#include "keyreg.hh" -#include "keyitem.hh" -#include "complexwalker.hh" +#include "time-description.hh" +#include "key-reg.hh" +#include "key-item.hh" #include "commandrequest.hh" -#include "staffcolumn.hh" -#include "localkeyreg.hh" +#include "staff-column.hh" +#include "local-key-reg.hh" #include "musicalrequest.hh" -Key_register::Key_register(Complex_walker*w) - : Request_register(w) +Key_register::Key_register() { - do_post_move_process(); + post_move_processing(); } - bool Key_register::try_request(Request * req_l) { - if (!req_l->command()->keychange()) + Command_req* creq_l= req_l->command(); + if (!creq_l|| !creq_l->keychange()) return false; + assert(!keyreq_l_); // todo - keyreq_l_ = req_l->command()->keychange(); + keyreq_l_ = creq_l->keychange(); read_req(keyreq_l_); return true; } @@ -40,16 +39,17 @@ Key_register::acknowledge_element(Staff_elem_info info) { Command_req * r_l = info.req_l_->command() ; if (r_l && r_l->clefchange() && !kit_p_) { - kit_p_ = new Key_item(walk_l_->c0_position_i()); + int c0_i= *get_staff_info().c0_position_i_; + kit_p_ = new Key_item(c0_i); kit_p_->read(*this); - announce_element(Staff_elem_info(kit_p_, keyreq_l_, this)); + announce_element(Staff_elem_info(kit_p_, keyreq_l_)); } } void -Key_register::process_request() +Key_register::process_requests() { - Time_description *time_l = &walk_l_->time_; + const Time_description *time_l = get_staff_info().time_c_l_; if (!keyreq_l_ && (!time_l->whole_in_measure_|| !time_l->when_)) { @@ -57,14 +57,15 @@ Key_register::process_request() } if ( default_key_b_ || keyreq_l_) { - kit_p_ = new Key_item(walk_l_->c0_position_i()); + int c0_i= *get_staff_info().c0_position_i_; + kit_p_ = new Key_item(c0_i); kit_p_->read(*this); - announce_element(Staff_elem_info(kit_p_, keyreq_l_, this)); + announce_element(Staff_elem_info(kit_p_, keyreq_l_)); } } void -Key_register::do_pre_move_process() +Key_register::pre_move_processing() { if (kit_p_) { if (default_key_b_) @@ -90,7 +91,7 @@ Key_register::read_req(Key_change_req * r) } void -Key_register::do_post_move_process() +Key_register::post_move_processing() { keyreq_l_ = 0; default_key_b_ = false; diff --git a/src/lexer.l b/src/lexer.l index 6f72f7f2cc..3f86adcd54 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -8,9 +8,10 @@ #include "varray.hh" #include "parser.hh" #include "debug.hh" -#include "inputscore.hh" +#include "input-score.hh" #include "parseconstruct.hh" #include "main.hh" +#include "string-convert.hh" %} diff --git a/src/lexerinit.cc b/src/lexerinit.cc index 02dd000e63..2eb9ed4e50 100644 --- a/src/lexerinit.cc +++ b/src/lexerinit.cc @@ -13,7 +13,7 @@ #include "lexer.hh" #include "debug.hh" #include "main.hh" -#include "sourcefile.hh" +#include "source-file.hh" #include "source.hh" My_flex_lexer *lexer=0; diff --git a/src/lily-stream.cc b/src/lily-stream.cc index 2a4d4a4417..4b79481424 100644 --- a/src/lily-stream.cc +++ b/src/lily-stream.cc @@ -15,7 +15,7 @@ #include "string.hh" #include "moment.hh" -#include "sourcefile.hh" +#include "source-file.hh" #include "source.hh" #include "midi-main.hh" // *tors diff --git a/src/localkeyitem.cc b/src/local-key-item.cc similarity index 94% rename from src/localkeyitem.cc rename to src/local-key-item.cc index 77bad62b2e..425982120c 100644 --- a/src/localkeyitem.cc +++ b/src/local-key-item.cc @@ -1,13 +1,13 @@ -#include "localkeyitem.hh" +#include "local-key-item.hh" #include "molecule.hh" #include "scalar.hh" #include "lookup.hh" -#include "paperdef.hh" +#include "paper-def.hh" #include "musicalrequest.hh" #include "notehead.hh" #include "misc.hh" -NAME_METHOD(Local_key_item); + Local_key_item::Local_key_item(int i) { @@ -18,7 +18,7 @@ void Local_key_item::add(Item*head_l) { support_items_.push(head_l); - add_depedency(head_l); + add_dependency(head_l); } void diff --git a/src/localkeyreg.cc b/src/local-key-reg.cc similarity index 59% rename from src/localkeyreg.cc rename to src/local-key-reg.cc index 3817a36ba2..b71f14e920 100644 --- a/src/localkeyreg.cc +++ b/src/local-key-reg.cc @@ -1,28 +1,29 @@ /* - localkeyreg.cc -- implement Local_key_register + local-key-reg.cc -- implement Local_key_register (c) 1997 Han-Wen Nienhuys */ + #include "musicalrequest.hh" #include "commandrequest.hh" -#include "localkeyreg.hh" -#include "localkeyitem.hh" -#include "complexwalker.hh" -#include "keyreg.hh" +#include "local-key-reg.hh" +#include "local-key-item.hh" +#include "complex-walker.hh" +#include "key-reg.hh" #include "debug.hh" +#include "key-item.hh" -Local_key_register::Local_key_register(Complex_walker*w) - : Request_register(w) +Local_key_register::Local_key_register() { key_item_p_ = 0; key_c_l_ = 0; } void -Local_key_register::do_pre_move_process() +Local_key_register::pre_move_processing() { if (key_item_p_) { - walk_l_->typeset_element(key_item_p_); + typeset_element(key_item_p_); key_item_p_ = 0; } } @@ -39,7 +40,7 @@ Local_key_register::acknowledge_element(Staff_elem_info info) if (!key_item_p_) { - key_item_p_ = new Local_key_item(walk_l_->c0_position_i()); + key_item_p_ = new Local_key_item(*get_staff_info().c0_position_i_); } key_item_p_->add(melodic_l_); @@ -47,21 +48,22 @@ Local_key_register::acknowledge_element(Staff_elem_info info) local_key_.oct(melodic_l_->octave_i_) .set(melodic_l_->notename_i_, melodic_l_->accidental_i_); } - } else if (info.req_l_->command() && - info.req_l_->command()->keychange()) { - Key_register * key_reg_l = (Key_register*)info.origin_reg_l_; + } else if (info.elem_p_->name()==Key_item::static_name()) { + Key_register * key_reg_l = + (Key_register*)info.origin_reg_l_arr_[0]; key_c_l_ = &key_reg_l->key_; local_key_.reset(*key_c_l_); } } void -Local_key_register::process_request() +Local_key_register::process_requests() { - if (!walk_l_->time_.whole_in_measure_) { + const Time_description * time_c_l_ = get_staff_info().time_c_l_; + if (! time_c_l_->whole_in_measure_){ if (key_c_l_) local_key_.reset(*key_c_l_); - else if( walk_l_->when() >0) + else if( time_c_l_->when_ >0) warning ("Help me! can't figure current key", 0); } } diff --git a/src/lookup.cc b/src/lookup.cc index a87454e2d1..ffd668e75d 100644 --- a/src/lookup.cc +++ b/src/lookup.cc @@ -1,3 +1,11 @@ +/* + lookup.cc -- implement simple Lookup methods. + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + #include "lookup.hh" #include "debug.hh" #include "symtable.hh" @@ -27,6 +35,14 @@ Lookup::add(String s, Symtable*p) symtables_->add(s, p); } +void +Lookup::print()const +{ + mtor << "Lookup: " << texsetting << " {\n"; + symtables_->print(); + mtor << "}\n"; +} + Symbol Lookup::text(String style, String text, int dir) { @@ -42,7 +58,6 @@ Lookup::text(String style, String text, int dir) return s; } -/* *************** */ Real Lookup::internote() diff --git a/src/lyricitem.cc b/src/lyric-item.cc similarity index 71% rename from src/lyricitem.cc rename to src/lyric-item.cc index b35c866761..c0adac7b63 100644 --- a/src/lyricitem.cc +++ b/src/lyric-item.cc @@ -1,11 +1,11 @@ #include "musicalrequest.hh" -#include "paperdef.hh" -#include "lyricitem.hh" +#include "paper-def.hh" +#include "lyric-item.hh" #include "stem.hh" #include "molecule.hh" #include "lookup.hh" -#include "textdef.hh" -#include "sourcefile.hh" +#include "text-def.hh" +#include "source-file.hh" #include "source.hh" #include "debug.hh" #include "main.hh" @@ -20,9 +20,8 @@ Lyric_item::Lyric_item(Lyric_req* lreq_l, int voice_count_i) void Lyric_item::do_pre_processing() { - // override Text_item // test context-error - if ( tdef_l_->text_str_.index_i( "Gates" ) )// :-) + if ( tdef_l_->text_str_.index_i( "Gates" ) >=0)// :-) warning( "foul word", tdef_l_->defined_ch_c_l_ ); } diff --git a/src/lyricstaff.cc b/src/lyricstaff.cc index 8ee1793328..abefcd2048 100644 --- a/src/lyricstaff.cc +++ b/src/lyricstaff.cc @@ -1,6 +1,6 @@ #include "musicalrequest.hh" #include "voice.hh" -#include "staffwalker.hh" +#include "staff-walker.hh" #include "debug.hh" #include "staff.hh" #include "lyricstaff.hh" diff --git a/src/lyricwalker.cc b/src/lyricwalker.cc index c77b716ec2..6abc2192a9 100644 --- a/src/lyricwalker.cc +++ b/src/lyricwalker.cc @@ -12,8 +12,8 @@ #include "lyricstaff.hh" #include "lyricwalker.hh" #include "debug.hh" -#include "lyricitem.hh" -#include "staffcolumn.hh" +#include "lyric-item.hh" +#include "staff-column.hh" void Lyric_walker::process_requests() diff --git a/src/main.cc b/src/main.cc index 450545ab25..058db492d9 100644 --- a/src/main.cc +++ b/src/main.cc @@ -8,7 +8,7 @@ #include "main.hh" #include "path.hh" #include "config.hh" -#include "sourcefile.hh" +#include "source-file.hh" #include "source.hh" Source source; @@ -19,7 +19,7 @@ extern void parse_file(String,String); void destill_inname( String &name_str_r); -long_option_init theopts[] = { +Long_option_init theopts[] = { 1, "output", 'o', 0, "warranty", 'w', 0, "help", 'h', @@ -91,7 +91,7 @@ main (int argc, char **argv) cout << get_version(); String init_str("symbol.ini"); - while (long_option_init * opt = oparser()) { + while (Long_option_init * opt = oparser()) { switch ( opt->shortname){ case 'o': set_default_output(oparser.optarg); diff --git a/src/meterreg.cc b/src/meter-reg.cc similarity index 65% rename from src/meterreg.cc rename to src/meter-reg.cc index 3aab0fb291..a27737c076 100644 --- a/src/meterreg.cc +++ b/src/meter-reg.cc @@ -1,25 +1,26 @@ /* - meterreg.cc -- implement Meter_register + meter-reg.cc -- implement Meter_register source file of the LilyPond music typesetter (c) 1997 Han-Wen Nienhuys */ -#include "meterreg.hh" +#include "meter-reg.hh" #include "meter.hh" #include "commandrequest.hh" -Meter_register::Meter_register(Complex_walker*w) - : Request_register(w) +Meter_register::Meter_register() + { - do_post_move_process(); + post_move_processing(); } bool Meter_register::try_request(Request*r_l) { - if (!r_l->command()->meterchange()) + Command_req* creq_l= r_l->command(); + if (!creq_l || !creq_l->meterchange()) return false; assert(!meter_req_l_); @@ -29,7 +30,7 @@ Meter_register::try_request(Request*r_l) } void -Meter_register::process_request() +Meter_register::process_requests() { if (meter_req_l_ ) { Array args; @@ -40,11 +41,11 @@ Meter_register::process_request() } if (meter_p_) - announce_element(Staff_elem_info(meter_p_, meter_req_l_, this) ); + announce_element(Staff_elem_info(meter_p_, meter_req_l_) ); } void -Meter_register::do_pre_move_process() +Meter_register::pre_move_processing() { if (meter_p_) { Meter * post_p =new Meter(*meter_p_); @@ -56,7 +57,7 @@ Meter_register::do_pre_move_process() } void -Meter_register::do_post_move_process() +Meter_register::post_move_processing() { meter_req_l_ = 0; meter_p_ =0; diff --git a/src/meter.cc b/src/meter.cc index 4f06b6469e..94f6b6c5e9 100644 --- a/src/meter.cc +++ b/src/meter.cc @@ -1,9 +1,9 @@ #include "scalar.hh" #include "molecule.hh" #include "meter.hh" -#include "paperdef.hh" +#include "paper-def.hh" #include "lookup.hh" -NAME_METHOD(Meter); + Meter::Meter(Arraya) :args(a) { diff --git a/src/midi-event.cc b/src/midi-event.cc index e62a888a83..36d6694779 100644 --- a/src/midi-event.cc +++ b/src/midi-event.cc @@ -9,7 +9,7 @@ #include "plist.hh" // all for midi-main.hh #include "string.hh" #include "source.hh" -#include "sourcefile.hh" +#include "source-file.hh" #include "midi-main.hh" // *tors #include "moment.hh" #include "duration.hh" diff --git a/src/midi-main.cc b/src/midi-main.cc index 5dfdf64662..90aad5299e 100644 --- a/src/midi-main.cc +++ b/src/midi-main.cc @@ -13,7 +13,7 @@ #include "string.hh" #include "lgetopt.hh" #include "source.hh" -#include "sourcefile.hh" +#include "source-file.hh" #include "midi-main.hh" #include "moment.hh" #include "duration.hh" diff --git a/src/midi-score.cc b/src/midi-score.cc index f24f9093d1..02905b8718 100644 --- a/src/midi-score.cc +++ b/src/midi-score.cc @@ -8,7 +8,7 @@ #include "string.hh" #include "moment.hh" #include "duration.hh" -#include "sourcefile.hh" +#include "source-file.hh" #include "source.hh" #include "midi-main.hh" // *tors #include "midi-event.hh" diff --git a/src/midi-template.cc b/src/midi-template.cc index c4caa838b4..c2bfd01eaa 100644 --- a/src/midi-template.cc +++ b/src/midi-template.cc @@ -14,7 +14,7 @@ class ostream; #include "plist.tcc" #include "pcursor.tcc" #include "string.hh" -#include "sourcefile.hh" +#include "source-file.hh" #include "moment.hh" #include "duration.hh" diff --git a/src/midi-track.cc b/src/midi-track.cc index 99bd9dee8c..6fccd518ec 100644 --- a/src/midi-track.cc +++ b/src/midi-track.cc @@ -6,7 +6,7 @@ #include "proto.hh" #include "plist.hh" #include "string.hh" -#include "sourcefile.hh" +#include "source-file.hh" #include "source.hh" #include "midi-main.hh" // *tors diff --git a/src/my-midi-lexer.cc b/src/my-midi-lexer.cc index c261e5c503..4aa37d3146 100644 --- a/src/my-midi-lexer.cc +++ b/src/my-midi-lexer.cc @@ -4,8 +4,8 @@ // copyright 1997 Jan Nieuwenhuizen #include "debug.hh" -#include "inputfile.hh" -#include "sourcefile.hh" +#include "input-file.hh" +#include "source-file.hh" #include "my-midi-lexer.hh" int diff --git a/src/my-midi-parser.cc b/src/my-midi-parser.cc index 62f4d499c8..31555f79af 100644 --- a/src/my-midi-parser.cc +++ b/src/my-midi-parser.cc @@ -7,7 +7,7 @@ #include "plist.hh" // ugh #include "string.hh" -#include "sourcefile.hh" +#include "source-file.hh" #include "source.hh" #include "midi-main.hh" // *tors diff --git a/src/mylexer.cc b/src/mylexer.cc index 10c395759c..7da6dddec8 100644 --- a/src/mylexer.cc +++ b/src/mylexer.cc @@ -1,16 +1,17 @@ #include + #include "interval.hh" #include "identparent.hh" -#include "associter.hh" +#include "assoc-iter.hh" #include "lexer.hh" -#include "inputfile.hh" +#include "input-file.hh" #include "parser.hh" #include "keyword.hh" #include "assoc.hh" #include "lexer.hh" #include "debug.hh" #include "notename.hh" -#include "sourcefile.hh" +#include "source-file.hh" #include "parseconstruct.hh" static Keyword_ent the_key_tab[]={ @@ -25,7 +26,6 @@ static Keyword_ent the_key_tab[]={ "goto", GOTO, "in", IN_T, "key", KEY, - "meter", METER, "midi", MIDI, "mm", MM_T, @@ -64,7 +64,8 @@ My_flex_lexer::ret_notename(int *p, String text, int octave_mod) char const* ch_c_l = here_ch_c_l(); if ( ch_c_l ) { ch_c_l--; - while ( ( *ch_c_l == ' ' ) || ( *ch_c_l == '\t' ) || ( *ch_c_l == '\n' ) ) + while ( ( *ch_c_l == ' ' ) + || ( *ch_c_l == '\t' ) || ( *ch_c_l == '\n' ) ) ch_c_l--; ch_c_l++; } @@ -127,6 +128,13 @@ My_flex_lexer::~My_flex_lexer() } delete the_id_tab; } +void +My_flex_lexer::print_declarations()const +{ + for (Assoc_iter ai(*the_id_tab); ai.ok(); ai++) { + ai.val()->print(); + } +} String My_flex_lexer::spot()const diff --git a/src/note.cc b/src/note.cc index 0f7eb8e85f..496d892e5b 100644 --- a/src/note.cc +++ b/src/note.cc @@ -12,9 +12,10 @@ #include "notename.hh" #include "identparent.hh" #include "varray.hh" -#include "textdef.hh" +#include "text-def.hh" #include "parseconstruct.hh" -#include "inputmusic.hh" +#include "input-music.hh" +#include "voice-element.hh" int default_duration = 4, default_dots=0, default_octave=0; int default_plet_type = 1, default_plet_dur = 1; diff --git a/src/notehead.cc b/src/notehead.cc index a0c031c106..722b231e68 100644 --- a/src/notehead.cc +++ b/src/notehead.cc @@ -2,12 +2,12 @@ #include "notehead.hh" #include "dimen.hh" #include "debug.hh" -#include "paperdef.hh" +#include "paper-def.hh" #include "lookup.hh" #include "molecule.hh" #include "musicalrequest.hh" -NAME_METHOD(Notehead); + Notehead::Notehead(int ss) { @@ -37,7 +37,7 @@ Notehead::do_print()const int -Notehead::compare(Notehead*&a, Notehead*&b) +Notehead::compare(Notehead *const &a, Notehead * const &b) { return a->position - b->position; } @@ -45,7 +45,7 @@ Notehead::compare(Notehead*&a, Notehead*&b) Molecule* Notehead::brew_molecule_p() const return out; { - Paperdef *p = paper(); + Paper_def *p = paper(); Real dy = p->internote(); Symbol s = p->lookup_p_->ball(balltype); diff --git a/src/paperdef.cc b/src/paper-def.cc similarity index 73% rename from src/paperdef.cc rename to src/paper-def.cc index f5c3bcdfae..b49a53fc8e 100644 --- a/src/paperdef.cc +++ b/src/paper-def.cc @@ -1,6 +1,6 @@ #include #include "misc.hh" -#include "paperdef.hh" +#include "paper-def.hh" #include "debug.hh" #include "lookup.hh" #include "dimen.hh" @@ -12,7 +12,7 @@ const Real PHI = (1+sqrt(5))/2; // see Roelofs, p. 57 Real -Paperdef::duration_to_dist(Moment d) +Paper_def::duration_to_dist(Moment d) { if (!d) return 0; @@ -21,12 +21,12 @@ Paperdef::duration_to_dist(Moment d) } Real -Paperdef::rule_thickness()const +Paper_def::rule_thickness()const { return 0.4 PT; } -Paperdef::Paperdef(Lookup *l) +Paper_def::Paper_def(Lookup *l) { lookup_p_ = l; linewidth = 15 *CM_TO_PT; // in cm for now @@ -35,11 +35,11 @@ Paperdef::Paperdef(Lookup *l) outfile = "lelie.out"; } -Paperdef::~Paperdef() +Paper_def::~Paper_def() { delete lookup_p_; } -Paperdef::Paperdef(Paperdef const&s) +Paper_def::Paper_def(Paper_def const&s) { lookup_p_ = new Lookup(*s.lookup_p_); geometric_ = s.geometric_; @@ -49,7 +49,7 @@ Paperdef::Paperdef(Paperdef const&s) } void -Paperdef::set(Lookup*l) +Paper_def::set(Lookup*l) { assert(l != lookup_p_); delete lookup_p_; @@ -57,34 +57,35 @@ Paperdef::set(Lookup*l) } Real -Paperdef::interline() const +Paper_def::interline() const { return lookup_p_->ball(4).dim.y.length(); } Real -Paperdef::internote() const +Paper_def::internote() const { return lookup_p_->internote(); } Real -Paperdef::note_width()const +Paper_def::note_width()const { return lookup_p_->ball(4).dim.x.length( ); } Real -Paperdef::standard_height() const +Paper_def::standard_height() const { return 20 PT; } void -Paperdef::print() const +Paper_def::print() const { #ifndef NPRINT mtor << "Paper {width: " << print_dimen(linewidth); mtor << "whole: " << print_dimen(whole_width); mtor << "out: " <print(); mtor << "}\n"; #endif } diff --git a/src/parser.y b/src/parser.y index b8b175ef1a..08ea828119 100644 --- a/src/parser.y +++ b/src/parser.y @@ -4,9 +4,9 @@ #include "lookup.hh" #include "misc.hh" #include "lexer.hh" -#include "paperdef.hh" -#include "mididef.hh" -#include "inputscore.hh" +#include "paper-def.hh" +#include "midi-def.hh" +#include "input-score.hh" #include "main.hh" #include "keyword.hh" #include "debug.hh" @@ -15,6 +15,7 @@ #include "identifier.hh" #include "commandrequest.hh" #include "musicalrequest.hh" +#include "voice-element.hh" #ifndef NDEBUG #define YYDEBUG 1 @@ -22,7 +23,7 @@ Array pre_reqs, post_reqs; Array define_spots; -Paperdef*default_paper(); +Paper_def*default_paper(); char const* defined_ch_c_l; char const* req_defined_ch_c_l; int fatal_error_i = 0; @@ -38,7 +39,7 @@ int fatal_error_i = 0; Voice_element *el; String *string; const char *consstr; - Paperdef *paper; + Paper_def *paper; Midi_def* midi; Input_music *music; Music_general_chord *chord; @@ -795,15 +796,19 @@ parse_file(String init, String s) *mlog << "Parsing ... "; lexer = new My_flex_lexer; -#ifdef YYDEBUG +#ifndef NDEBUG yydebug = !monitor->silence("InitParser") && check_debug; lexer->set_debug( !monitor->silence("InitLexer") && check_debug); #endif lexer->new_input(init); + yyparse(); -#ifdef YYDEBUG +#ifndef NDEBUG + if (check_debug && !monitor->silence("InitDeclarations")) + lexer->print_declarations(); + yydebug = !monitor->silence("Parser") && check_debug; lexer->set_debug( !monitor->silence("Lexer") && check_debug); #endif @@ -817,10 +822,10 @@ parse_file(String init, String s) warning("Braces don't match.",0); } -Paperdef* +Paper_def* default_paper() { - return new Paperdef( + return new Paper_def( lexer->lookup_identifier("default_table")->lookup(true)); } diff --git a/src/pscore.cc b/src/pscore.cc index cebeb86f4c..73e57ce6f2 100644 --- a/src/pscore.cc +++ b/src/pscore.cc @@ -2,12 +2,12 @@ #include "debug.hh" #include "lookup.hh" #include "spanner.hh" -#include "paperdef.hh" +#include "paper-def.hh" #include "molecule.hh" #include "dimen.hh" #include "scoreline.hh" #include "pscore.hh" -#include "tstream.hh" +#include "tex-stream.hh" #include "item.hh" #include "break.hh" @@ -28,7 +28,7 @@ PScore::clean_cols() { for (iter_top(cols,c); c.ok(); ) if (!c->used_b()) { - delete c.get(); + delete c.get_p(); } else c++; } @@ -110,7 +110,7 @@ PScore::add(PCol *p) cols.bottom().add(p); } -PScore::PScore( Paperdef*p) +PScore::PScore( Paper_def*p) { paper_l_ = p; } diff --git a/src/register.cc b/src/register.cc index a1b45a96a5..126507cc6b 100644 --- a/src/register.cc +++ b/src/register.cc @@ -10,9 +10,11 @@ #include "musicalrequest.hh" #include "register.hh" #include "notehead.hh" -#include "complexwalker.hh" -#include "localkeyitem.hh" -#include "complexstaff.hh" +#include "complex-walker.hh" +#include "local-key-item.hh" +#include "complex-staff.hh" +#include "registergroup.hh" +#include "debug.hh" bool @@ -23,54 +25,33 @@ Request_register::try_request(Request*) Request_register::Request_register() { - walk_l_=0; -} - -Request_register::Request_register(Complex_walker*w_l) -{ - walk_l_=w_l; -} - -void -Request_register::pre_move_processing() -{ - do_pre_move_process(); - accepted_req_arr_.set_size(0); -} -void -Request_register::post_move_processing() -{ - do_post_move_process(); -} - -Request_register::Request_register(Request_register const&) -{ - assert(false); + daddy_reg_l_ = 0; } void Request_register::announce_element(Staff_elem_info i) { - walk_l_->announce_element(i); + i.origin_reg_l_arr_.push(this); + daddy_reg_l_->announce_element(i); } void Request_register::typeset_element(Staff_elem*p) { - walk_l_->typeset_element(p); + daddy_reg_l_->typeset_element(p); } -Paperdef* +Paper_def* Request_register::paper()const { - return walk_l_->staff()->paper(); + return daddy_reg_l_->paper(); } void Request_register::typeset_breakable_item(Item * pre_p , Item * nobreak_p, Item * post_p) { - walk_l_->typeset_breakable_item(pre_p, nobreak_p,post_p); + daddy_reg_l_->typeset_breakable_item(pre_p, nobreak_p, post_p); } bool @@ -78,3 +59,30 @@ Request_register::acceptable_request_b(Request*)const { return false; } + +bool +Request_register::contains_b(Request_register *reg_l) +{ + return this == reg_l; +} + +Staff_info +Request_register::get_staff_info() return inf; +{ + inf = daddy_reg_l_->get_staff_info(); +} + +void +Request_register::print() const +{ +#ifndef NPRINT + mtor << name() << " {"; + do_print(); + mtor << "}\n"; +#endif +} + +void +Request_register::do_print()const +{ +} diff --git a/src/registergroup.cc b/src/registergroup.cc index c1bb809be8..87652e5e54 100644 --- a/src/registergroup.cc +++ b/src/registergroup.cc @@ -1,5 +1,5 @@ /* - registergroup.cc -- implement Register_group + registergroup.cc -- implement Register_group_register source file of the LilyPond music typesetter @@ -10,7 +10,7 @@ #include "register.hh" bool -Register_group::acceptable_request_b(Request* r) +Register_group_register::acceptable_request_b(Request* r) { for (iter_top(reg_list_, i); i.ok(); i++) { if (i->acceptable_request_b(r)) @@ -20,54 +20,61 @@ Register_group::acceptable_request_b(Request* r) } void -Register_group::set_dir(int d) +Register_group_register::set_feature(Features d) { for (iter_top(reg_list_, i); i.ok(); i++) { - i->set_dir(d); + i->set_feature(d); } } void -Register_group::pre_move_processing() +Register_group_register::pre_move_processing() { for (iter_top(reg_list_, i); i.ok(); i++) i->pre_move_processing(); } void -Register_group::process_requests() +Register_group_register::process_requests() { for (iter_top(reg_list_, i); i.ok(); i++) - i->process_request(); + i->process_requests(); } void -Register_group::post_move_processing() +Register_group_register::post_move_processing() { for (iter_top(reg_list_, i); i.ok(); i++) i->post_move_processing(); } void -Register_group::acknowledge_element(Staff_elem_info info) +Register_group_register::acknowledge_element(Staff_elem_info info) { + if (!contains_b(info.origin_reg_l_arr_[0])) + return; + for (iter_top(reg_list_, i); i.ok(); i++) i->acknowledge_element(info); } - bool -Register_group::contains_b(Request_register* reg_l) +Register_group_register::contains_b(Request_register* reg_l) { - for (iter_top(reg_list_, i); i.ok(); i++) - if (i.ptr() == reg_l) + bool parent_b = Request_register::contains_b(reg_l); + + if (parent_b) + return true; + for (iter_top(reg_list_, j); j.ok(); j++) + if (j->contains_b(reg_l)) return true; - return false; + return false; } + bool -Register_group::try_request(Request*req_l) +Register_group_register::try_request(Request*req_l) { for (iter_top(reg_list_, i); i.ok(); i++) if (i->try_request(req_l)) @@ -75,14 +82,38 @@ Register_group::try_request(Request*req_l) return false; } - - void -Register_group::add(Request_register *reg_p) +Register_group_register::add(Request_register *reg_p) { reg_list_.bottom().add(reg_p); + reg_p->daddy_reg_l_ = this; +} + + +Register_group_register::~Register_group_register() +{ + +} + +Request_register * +Register_group_register::get_register_p(Request_register*reg_l) +{ + iterator(reg_list_) reg_cur= reg_list_.find(reg_l); + assert(reg_cur.ok()); + return reg_cur.get_p(); +} + +void +Register_group_register::terminate_register(Request_register*r_l) +{ + delete get_register_p(r_l); } -Register_group::~Register_group() +void +Register_group_register::do_print()const { +#ifndef NPRINT + for (iter_top(reg_list_, i); i.ok(); i++) + i->print(); +#endif } diff --git a/src/request.cc b/src/request.cc index 991be88550..ecfe68c881 100644 --- a/src/request.cc +++ b/src/request.cc @@ -9,8 +9,10 @@ #include "musicalrequest.hh" #include "misc.hh" #include "debug.hh" -#include "scriptdef.hh" -#include "textdef.hh" +#include "script-def.hh" +#include "text-def.hh" +#include "voice.hh" +#include "voice-element.hh" void Stem_req::do_print() const @@ -288,3 +290,11 @@ Skip_req::do_print() const mtor << "duration: " << duration(); } +Voice * +Request::voice_l() +{ + if (!elt_l_) + return 0; + else + return (Voice*)elt_l_->voice_l_; +} diff --git a/src/rest.cc b/src/rest.cc index e334d17bac..0e4394a3c6 100644 --- a/src/rest.cc +++ b/src/rest.cc @@ -1,7 +1,7 @@ #include "rest.hh" #include "dimen.hh" #include "debug.hh" -#include "paperdef.hh" +#include "paper-def.hh" #include "lookup.hh" #include "molecule.hh" @@ -11,7 +11,7 @@ Rest::Rest(int t, int d) balltype = t; dots = d; } -NAME_METHOD(Rest); + void Rest::do_print()const @@ -25,7 +25,7 @@ Rest::do_print()const Molecule* Rest::brew_molecule_p()const { - Paperdef *p =paper(); + Paper_def *p =paper(); Symbol s; s = p->lookup_p_->rest(balltype); diff --git a/src/scorecolumn.cc b/src/score-column.cc similarity index 94% rename from src/scorecolumn.cc rename to src/score-column.cc index 80fc804f0c..4387630e8d 100644 --- a/src/scorecolumn.cc +++ b/src/score-column.cc @@ -1,5 +1,5 @@ /* - scorecolumn.cc -- implement Score_column + score-column.cc -- implement Score_column source file of the LilyPond music typesetter @@ -8,7 +8,7 @@ #include "debug.hh" #include "pcol.hh" -#include "scorecolumn.hh" +#include "score-column.hh" int Score_column::compare(Score_column & c1, Score_column &c2) diff --git a/src/scorewalker.cc b/src/score-walker.cc similarity index 94% rename from src/scorewalker.cc rename to src/score-walker.cc index c79031ab9a..a780b05ff6 100644 --- a/src/scorewalker.cc +++ b/src/score-walker.cc @@ -1,5 +1,5 @@ /* - scorewalker.cc -- implement Score_walker + score-walker.cc -- implement Score_walker source file of the LilyPond music typesetter @@ -7,11 +7,11 @@ */ #include "debug.hh" #include "plist.hh" -#include "scorewalker.hh" +#include "score-walker.hh" #include "score.hh" -#include "staffwalker.hh" +#include "staff-walker.hh" #include "staff.hh" -#include "scorecolumn.hh" +#include "score-column.hh" Score_walker::Score_walker(Score *s) :PCursor (s->cols_) diff --git a/src/score.cc b/src/score.cc index 4d8ac63296..0dd16ecbf7 100644 --- a/src/score.cc +++ b/src/score.cc @@ -5,19 +5,19 @@ (c) 1997 Han-Wen Nienhuys */ -#include "tstream.hh" +#include "tex-stream.hh" #include "score.hh" -#include "scorecolumn.hh" +#include "score-column.hh" #include "pscore.hh" #include "staff.hh" #include "debug.hh" -#include "paperdef.hh" +#include "paper-def.hh" #include "main.hh" #include "source.hh" -#include "sourcefile.hh" -#include "scorewalker.hh" -#include "midioutput.hh" -#include "mididef.hh" +#include "source-file.hh" +#include "score-walker.hh" +#include "midi-output.hh" +#include "midi-def.hh" extern String default_out_fn; @@ -96,7 +96,7 @@ Score::clean_cols() for (iter_top(cols_,c); c.ok(); ) { if (!c->pcol_l_->used_b()) { - delete c.get(); + delete c.get_p(); } else { c->preprocess(); c++; @@ -178,7 +178,7 @@ Score::last() const } void -Score::set(Paperdef *pap_p) +Score::set(Paper_def *pap_p) { delete paper_p_; paper_p_ = pap_p; diff --git a/src/scoreline.cc b/src/scoreline.cc index 505d7e79cf..2f8f0f3a4b 100644 --- a/src/scoreline.cc +++ b/src/scoreline.cc @@ -3,7 +3,7 @@ #include "dimen.hh" #include "spanner.hh" #include "symbol.hh" -#include "paperdef.hh" +#include "paper-def.hh" #include "pcol.hh" #include "pscore.hh" diff --git a/src/scores.cc b/src/scores.cc index b4019fd141..a6df7ead96 100644 --- a/src/scores.cc +++ b/src/scores.cc @@ -1,8 +1,8 @@ #include "main.hh" -#include "inputscore.hh" +#include "input-score.hh" #include "score.hh" #include "string.hh" -#include "paperdef.hh" +#include "paper-def.hh" #include "debug.hh" static Array score_array_global; diff --git a/src/scriptdef.cc b/src/script-def.cc similarity index 72% rename from src/scriptdef.cc rename to src/script-def.cc index 508ae6a24b..53bdd121ef 100644 --- a/src/scriptdef.cc +++ b/src/script-def.cc @@ -1,5 +1,5 @@ #include "debug.hh" -#include "scriptdef.hh" +#include "script-def.hh" Script_def::Script_def(String idx, int stem, int staff ,bool invert) { @@ -11,8 +11,8 @@ Script_def::Script_def(String idx, int stem, int staff ,bool invert) void Script_def::print() const { - mtor << "idx: " << symidx; - mtor << "direction, stem: " << stemdir << " staff : " << staffdir; + mtor << "Script_def{ idx: " << symidx + << " direction, stem: " << stemdir << " staff : " << staffdir << "}\n"; } int Script_def::compare(Script_def const & c) diff --git a/src/script-reg.cc b/src/script-reg.cc new file mode 100644 index 0000000000..6cfba0f397 --- /dev/null +++ b/src/script-reg.cc @@ -0,0 +1,76 @@ +/* + script-reg.cc -- implement Script_register + + (c) 1997 Han-Wen Nienhuys +*/ + +#include "script-reg.hh" +#include "script.hh" +#include "musicalrequest.hh" +#include "complex-walker.hh" +#include "stem.hh" + +Script_register::Script_register() +{ + script_p_ = 0; + post_move_processing(); +} + +bool +Script_register::try_request(Request *r_l) +{ + if (!r_l->script()) + return false ; + + if (script_req_l_ + && Script_req::compare(*script_req_l_, *r_l->script())) + + return false; + + script_req_l_ = r_l->script(); + + return true; +} + +void +Script_register::process_requests() +{ + if (script_req_l_) { + script_p_ = new Script(script_req_l_, 10); + announce_element( + Staff_elem_info(script_p_, script_req_l_)); + } +} + +void +Script_register::acknowledge_element(Staff_elem_info info) +{ + if (!script_p_) + return; + if (info.elem_p_->name() == Stem::static_name()) + script_p_->set_stem((Stem*)info.elem_p_); + else if (info.req_l_->rhythmic()) + script_p_->set_support(info.elem_p_->item()); +} + +void +Script_register::pre_move_processing() +{ + if (script_p_){ + script_p_->dir = dir_i_; + typeset_element(script_p_); + script_p_ = 0; + } +} +void +Script_register::post_move_processing() +{ + script_req_l_ = 0; +} + +void +Script_register::set_feature(Features i) +{ + if (i.direction_i_|| i.initialiser_b_) + dir_i_ = i.direction_i_; +} diff --git a/src/script.cc b/src/script.cc index a98a8a9926..2a31133c33 100644 --- a/src/script.cc +++ b/src/script.cc @@ -1,24 +1,24 @@ #include "musicalrequest.hh" -#include "paperdef.hh" +#include "paper-def.hh" #include "script.hh" #include "stem.hh" #include "molecule.hh" #include "lookup.hh" -NAME_METHOD(Script); + void Script::set_stem(Stem*st_l) { stem_l_ = st_l; - add_depedency(st_l); + add_dependency(st_l); } void Script::set_support(Item*i) { support.push(i); - add_depedency(i); + add_dependency(i); } Script::Script(Script_req* rq, int staflen) diff --git a/src/scriptreg.cc b/src/scriptreg.cc deleted file mode 100644 index bff07f54d2..0000000000 --- a/src/scriptreg.cc +++ /dev/null @@ -1,69 +0,0 @@ -/* - scriptreg.cc -- implement Script_register - - (c) 1997 Han-Wen Nienhuys -*/ - -#include "scriptreg.hh" -#include "script.hh" -#include "musicalrequest.hh" -#include "complexwalker.hh" - -Script_register::Script_register(Complex_walker*w) - : Request_register(w) -{ - script_p_ = 0; -} - -bool -Script_register::try_request(Request *r_l) -{ - if (!r_l->script()) - return false ; - - if (accepted_req_arr_.size() - && Script_req::compare(*accepted_req_arr_[0]->script(), *r_l->script())) - - return false; - - accepted_req_arr_.push(r_l); - - return true; -} - -void -Script_register::process_request() -{ - if (accepted_req_arr_.size() ) { - script_p_ = new Script(accepted_req_arr_[0]->script(), 10); - announce_element( - Staff_elem_info(script_p_, accepted_req_arr_[0], this)); - } -} - -void -Script_register::acknowledge_element(Staff_elem_info info) -{ - if (!script_p_) - return; - if (info.elem_p_->name() == String("Stem")) - script_p_->set_stem((Stem*)info.elem_p_); - else if (info.req_l_->rhythmic()) - script_p_->set_support(info.elem_p_->item()); -} - -void -Script_register::do_pre_move_process() -{ - if (script_p_){ - script_p_->dir = dir_i_; - typeset_element(script_p_); - script_p_ = 0; - } -} - -void -Script_register::set_dir(int i) -{ - dir_i_ = i; -} diff --git a/src/slurreg.cc b/src/slur-reg.cc similarity index 70% rename from src/slurreg.cc rename to src/slur-reg.cc index d1eb312d85..15a9af8eaa 100644 --- a/src/slurreg.cc +++ b/src/slur-reg.cc @@ -1,27 +1,26 @@ /* - slurreg.cc -- implement Slur_register + slur-reg.cc -- implement Slur_register (c) 1997 Han-Wen Nienhuys */ #include "plist.hh" #include "musicalrequest.hh" -#include "complexwalker.hh" -#include "slurreg.hh" +#include "complex-walker.hh" +#include "slur-reg.hh" #include "slur.hh" #include "debug.hh" - +#include "notehead.hh" void -Slur_register::set_dir(int i) +Slur_register::set_feature(Features i) { - dir_i_ = i; + dir_i_ = i.direction_i_; } -Slur_register::Slur_register(Complex_walker* w) - : Request_register(w) +Slur_register::Slur_register() { - set_dir(0); + set_feature(Features::dir(0)); } bool @@ -30,14 +29,14 @@ Slur_register::try_request(Request *req_l) if(!req_l->slur()) return false; - accepted_req_arr_.push(req_l); + new_slur_req_l_arr_.push(req_l->slur()); return true; } void Slur_register::acknowledge_element(Staff_elem_info info) { - if (info.elem_p_->name() == String("Notehead")) { + if (info.elem_p_->name() == Notehead::static_name()) { Notehead *head_p =(Notehead*) info.elem_p_ ;// ugh for (int i = 0; i < slur_l_stack_.size(); i++) slur_l_stack_[i]->add(head_p ); @@ -49,11 +48,11 @@ Slur_register::acknowledge_element(Staff_elem_info info) abracadabra */ void -Slur_register::process_request() +Slur_register::process_requests() { Array start_slur_l_arr_; - for (int i=0; i< accepted_req_arr_.size(); i++) { - Slur_req* slur_req_l = accepted_req_arr_[i]->slur(); + for (int i=0; i< new_slur_req_l_arr_.size(); i++) { + Slur_req* slur_req_l = new_slur_req_l_arr_[i]; // end slur: move the slur to other array if (slur_req_l->spantype == Span_req::STOP) { if (slur_l_stack_.empty()) @@ -69,7 +68,7 @@ Slur_register::process_request() Slur * s_p =new Slur; requests_arr_.push(slur_req_l); start_slur_l_arr_.push(s_p); - announce_element(Staff_elem_info(s_p, slur_req_l, this)); + announce_element(Staff_elem_info(s_p, slur_req_l)); } } for (int i=0; i < start_slur_l_arr_.size(); i++) @@ -77,7 +76,7 @@ Slur_register::process_request() } void -Slur_register::do_pre_move_process() +Slur_register::pre_move_processing() { for (int i = 0; i < end_slur_l_arr_.size(); i++) { if (dir_i_) @@ -87,6 +86,11 @@ Slur_register::do_pre_move_process() end_slur_l_arr_.set_size(0); } +void +Slur_register::post_move_processing() +{ + new_slur_req_l_arr_.set_size(0); +} Slur_register::~Slur_register() { for (int i=0; i < requests_arr_.size(); i++) { diff --git a/src/slur.cc b/src/slur.cc index 386b178a20..ba77a6948e 100644 --- a/src/slur.cc +++ b/src/slur.cc @@ -6,14 +6,14 @@ #include "slur.hh" #include "scalar.hh" #include "lookup.hh" -#include "paperdef.hh" +#include "paper-def.hh" #include "notehead.hh" #include "pcol.hh" #include "molecule.hh" #include "debug.hh" #include "boxes.hh" -NAME_METHOD(Slur); + Slur::Slur() { @@ -37,7 +37,7 @@ void Slur::add(Notehead*n) { encompass.push(n); - add_depedency(n); + add_dependency(n); } void diff --git a/src/sourcefile.cc b/src/source-file.cc similarity index 98% rename from src/sourcefile.cc rename to src/source-file.cc index 5caa8545fa..f0d21bf91a 100644 --- a/src/sourcefile.cc +++ b/src/source-file.cc @@ -1,5 +1,5 @@ // -// sourcefile.cc +// source-file.cc // #include // open, mmap @@ -22,7 +22,7 @@ #include "parseconstruct.hh" #include "main.hh" // find_file -#include "sourcefile.hh" +#include "source-file.hh" Source_file::Source_file( String &filename_str ) { diff --git a/src/source.cc b/src/source.cc index 519a6fe96a..8a8c528835 100644 --- a/src/source.cc +++ b/src/source.cc @@ -8,7 +8,7 @@ #include "proto.hh" #include "plist.hh" -#include "sourcefile.hh" +#include "source-file.hh" #include "source.hh" Source::Source() diff --git a/src/spanner.cc b/src/spanner.cc index 15efb59071..cc57686393 100644 --- a/src/spanner.cc +++ b/src/spanner.cc @@ -2,7 +2,7 @@ #include "spanner.hh" #include "pcol.hh" -NAME_METHOD(Spanner); + void Spanner::do_print()const diff --git a/src/staffcolumn.cc b/src/staff-column.cc similarity index 92% rename from src/staffcolumn.cc rename to src/staff-column.cc index 229ab69933..546a2a66e1 100644 --- a/src/staffcolumn.cc +++ b/src/staff-column.cc @@ -1,5 +1,5 @@ /* - staffcolumn.cc -- implement Staff_column + staff-column.cc -- implement Staff_column source file of the LilyPond music typesetter @@ -7,15 +7,16 @@ */ #include "staff.hh" #include "voice.hh" -#include "timedescription.hh" -#include "scorecolumn.hh" -#include "staffcolumn.hh" +#include "time-description.hh" +#include "score-column.hh" +#include "staff-column.hh" #include "commandrequest.hh" #include "musicalrequest.hh" #include "interval.hh" #include "pscore.hh" #include "item.hh" #include "pcol.hh" +#include "voice-element.hh" void Staff_column::OK() const @@ -42,7 +43,9 @@ Staff_column::add(Voice_element*ve) if (c_l->timing()) { timing_req_l_arr_.push(j->command()->timing()); } - if (!c_l->barcheck() && !c_l->partial() && + if (c_l->groupchange()) + creationreq_l_arr_.push(c_l); + else if (!c_l->barcheck() && !c_l->partial() && !c_l->measuregrouping()) setup_one_request(j); // no need to bother children } else { diff --git a/src/staff-elem-info.cc b/src/staff-elem-info.cc new file mode 100644 index 0000000000..9a6283e373 --- /dev/null +++ b/src/staff-elem-info.cc @@ -0,0 +1,38 @@ +/* + staff-elem-info.cc -- implement Staff_elem_info + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + +#include "staff-elem-info.hh" +#include "request.hh" + +Staff_elem_info::Staff_elem_info(Staff_elem*s_l, Request*r_l) +{ + elem_p_ = s_l; + voice_l_ = (r_l)?r_l->voice_l():0; + req_l_ = r_l; +} + +Staff_elem_info::Staff_elem_info() +{ + elem_p_ = 0; + voice_l_ = 0; + + req_l_ = 0; +} + +Features::Features() +{ + direction_i_ = 0; + initialiser_b_ = false; +} + +Features +Features::dir(int d) return f; +{ + f.initialiser_b_ = true; + f.direction_i_ = d; +} diff --git a/src/staffelem.cc b/src/staff-elem.cc similarity index 96% rename from src/staffelem.cc rename to src/staff-elem.cc index 1b5e592762..b24172fa63 100644 --- a/src/staffelem.cc +++ b/src/staff-elem.cc @@ -2,7 +2,7 @@ #include "symbol.hh" #include "pstaff.hh" #include "molecule.hh" -#include "staffelem.hh" +#include "staff-elem.hh" #include "debug.hh" String @@ -86,7 +86,7 @@ Staff_elem::print()const #endif } -NAME_METHOD(Staff_elem); + Staff_elem::Staff_elem() { @@ -97,7 +97,7 @@ Staff_elem::Staff_elem() } -Paperdef* +Paper_def* Staff_elem::paper() const { assert(pstaff_l_); @@ -189,7 +189,7 @@ Staff_elem::substitute_dependency(Staff_elem * old, Staff_elem * newdep) } void -Staff_elem::add_depedency(Staff_elem * p) +Staff_elem::add_dependency(Staff_elem * p) { for (int i=0; i < dependencies.size(); i ++) if (dependencies[i] == p) diff --git a/src/staffwalker.cc b/src/staff-walker.cc similarity index 92% rename from src/staffwalker.cc rename to src/staff-walker.cc index c3900d35f2..a383d351b3 100644 --- a/src/staffwalker.cc +++ b/src/staff-walker.cc @@ -1,5 +1,5 @@ /* - staffwalker.cc -- implement Staff_walker + staff-walker.cc -- implement Staff_walker source file of the LilyPond music typesetter @@ -9,14 +9,14 @@ #include "grouping.hh" #include "staff.hh" #include "musicalrequest.hh" -#include "staffwalker.hh" -#include "staffcolumn.hh" -#include "scorecolumn.hh" +#include "staff-walker.hh" +#include "staff-column.hh" +#include "score-column.hh" #include "debug.hh" -#include "timedescription.hh" +#include "time-description.hh" #include "commandrequest.hh" #include "grouping.hh" -#include "scorewalker.hh" +#include "score-walker.hh" Staff_walker::~Staff_walker() { diff --git a/src/staff.cc b/src/staff.cc index d5c08487ab..4f72617f5e 100644 --- a/src/staff.cc +++ b/src/staff.cc @@ -1,14 +1,14 @@ #include "staff.hh" #include "score.hh" #include "voice.hh" -#include "staffwalker.hh" -#include "staffcolumn.hh" -#include "scorecolumn.hh" - +#include "staff-walker.hh" +#include "staff-column.hh" +#include "score-column.hh" +#include "voice-element.hh" #include "debug.hh" #include "musicalrequest.hh" #include "commandrequest.hh" // todo -#include "midistream.hh" +#include "midi-stream.hh" void Staff::add(PointerList const &l) @@ -17,7 +17,7 @@ Staff::add(PointerList const &l) voice_list_.bottom().add(i); } -Paperdef * +Paper_def * Staff::paper() const { return score_l_->paper_p_; @@ -34,7 +34,7 @@ Staff::clean_cols() i->command_column_l_ =0; if (!i->command_column_l_&& !i->musical_column_l_) - delete i.get(); + delete i.get_p(); else i++; } diff --git a/src/staffeleminfo.cc b/src/staffeleminfo.cc deleted file mode 100644 index 611000541d..0000000000 --- a/src/staffeleminfo.cc +++ /dev/null @@ -1,32 +0,0 @@ -/* - staffeleminfo.cc -- implement Staff_elem_info - - source file of the LilyPond music typesetter - - (c) 1997 Han-Wen Nienhuys -*/ - -#include "staffeleminfo.hh" -#include "request.hh" -#include "voice.hh" - -Staff_elem_info::Staff_elem_info(Staff_elem*s_l, Request*r_l, - Request_register *reg_l) -{ - elem_p_ = s_l; - voice_l_ = (r_l)?r_l->elt_l_->voice_l_:0; - req_l_ = r_l; - group_regs_l_ = 0; - origin_reg_l_ = reg_l; -} - -Staff_elem_info::Staff_elem_info() -{ - elem_p_ = 0; - voice_l_ = 0; - - group_regs_l_ = 0; - origin_reg_l_ = 0; - req_l_ = 0; -} - diff --git a/src/staffline.cc b/src/staffline.cc index 7b79f09212..5d18b219e6 100644 --- a/src/staffline.cc +++ b/src/staffline.cc @@ -3,7 +3,7 @@ #include "dimen.hh" #include "spanner.hh" #include "symbol.hh" -#include "paperdef.hh" +#include "paper-def.hh" #include "molecule.hh" #include "pcol.hh" #include "pscore.hh" diff --git a/src/staffsym.cc b/src/staffsym.cc index 49f559f2e8..631a5f3673 100644 --- a/src/staffsym.cc +++ b/src/staffsym.cc @@ -7,10 +7,10 @@ */ #include "staffsym.hh" #include "lookup.hh" -#include "paperdef.hh" +#include "paper-def.hh" #include "debug.hh" -NAME_METHOD(Staff_symbol); + Staff_symbol::Staff_symbol(int l) { diff --git a/src/stembeamreg.cc b/src/stem-beam-reg.cc similarity index 74% rename from src/stembeamreg.cc rename to src/stem-beam-reg.cc index 504ba6854f..f08b02f424 100644 --- a/src/stembeamreg.cc +++ b/src/stem-beam-reg.cc @@ -1,26 +1,27 @@ /* - stembeamreg.cc -- part of LilyPond + stem-beam-reg.cc -- part of LilyPond (c) 1997 Han-Wen Nienhuys */ #include "musicalrequest.hh" -#include "stembeamreg.hh" +#include "stem-beam-reg.hh" #include "beam.hh" #include "stem.hh" #include "grouping.hh" #include "textspanner.hh" -#include "complexwalker.hh" -#include "complexstaff.hh" +#include "complex-walker.hh" +#include "complex-staff.hh" #include "debug.hh" #include "grouping.hh" -Stem_beam_register::Stem_beam_register(Complex_walker*w) - :Request_register(w) +#include "notehead.hh" + +Stem_beam_register::Stem_beam_register() { - do_post_move_process(); + post_move_processing(); current_grouping = 0; beam_p_ = 0; - set_dir(0); + set_feature(Features::dir(0)); start_req_l_ = 0; } @@ -40,7 +41,7 @@ Stem_beam_register::try_request(Request*req_l) if ( req_l->stem() ) { if (current_grouping && !current_grouping->child_fit_query( - walk_l_->time_.whole_in_measure_)) + get_staff_info().time_c_l_->whole_in_measure_)) return false; if (stem_req_l_ && Stem_req::compare(*stem_req_l_, *req_l->stem())) @@ -53,7 +54,7 @@ Stem_beam_register::try_request(Request*req_l) } void -Stem_beam_register::process_request() +Stem_beam_register::process_requests() { if (beam_req_l_) { if (beam_req_l_->spantype == Span_req::STOP) { @@ -80,7 +81,7 @@ Stem_beam_register::process_request() stem_p_ = new Stem(4); if (current_grouping) current_grouping->add_child( - walk_l_->time_.whole_in_measure_, + get_staff_info().time_c_l_->whole_in_measure_, stem_req_l_->duration()); stem_p_->flag = stem_req_l_->balltype; @@ -96,8 +97,7 @@ Stem_beam_register::process_request() stem_p_->print_flag = true; } - announce_element(Staff_elem_info(stem_p_, - stem_req_l_, this)); + announce_element(Staff_elem_info(stem_p_, stem_req_l_)); } } @@ -107,14 +107,14 @@ Stem_beam_register::acknowledge_element(Staff_elem_info info) if (!stem_p_) return; - if (info.elem_p_->name() == String("Notehead") && + if (info.elem_p_->name() == Notehead::static_name() && stem_req_l_->duration() == info.req_l_->rhythmic()->duration()) stem_p_->add((Notehead*)info.elem_p_); } void -Stem_beam_register::do_pre_move_process() +Stem_beam_register::pre_move_processing() { if (stem_p_) { if (default_dir_i_) @@ -124,8 +124,9 @@ Stem_beam_register::do_pre_move_process() stem_p_ = 0; } if (beam_p_ && end_beam_b_) { - walk_l_->default_grouping->extend(current_grouping->interval()); - beam_p_->set_grouping(*walk_l_->default_grouping, *current_grouping); + const Rhythmic_grouping * rg_c_l = get_staff_info().rhythmic_c_l_; + rg_c_l->extend(current_grouping->interval()); + beam_p_->set_grouping(*rg_c_l, *current_grouping); typeset_element(beam_p_); delete current_grouping; current_grouping = 0; @@ -134,7 +135,7 @@ Stem_beam_register::do_pre_move_process() end_beam_b_ = false; } void -Stem_beam_register::do_post_move_process() +Stem_beam_register::post_move_processing() { stem_p_ = 0; beam_req_l_ = 0; @@ -149,7 +150,7 @@ Stem_beam_register::~Stem_beam_register() } void -Stem_beam_register::set_dir(int i) +Stem_beam_register::set_feature(Features i) { - default_dir_i_ = i; + default_dir_i_ = i.direction_i_; } diff --git a/src/stem.cc b/src/stem.cc index e9a4f943bf..74ea4b57fc 100644 --- a/src/stem.cc +++ b/src/stem.cc @@ -1,7 +1,7 @@ #include "stem.hh" #include "dimen.hh" #include "debug.hh" -#include "paperdef.hh" +#include "paper-def.hh" #include "notehead.hh" #include "lookup.hh" #include "molecule.hh" @@ -9,7 +9,7 @@ #include "misc.hh" const int STEMLEN=7; -NAME_METHOD(Stem); + Stem::Stem(int c) //, Moment len) { @@ -40,7 +40,7 @@ Stem::set_stemend(Real se) // todo: margins if (! ((dir > 0 && se >= maxnote) || (se <= minnote && dir <0)) ) - WARN << "Weird stem size; check for narrow beams.\n"; + warning("Weird stem size; check for narrow beams",0); top = (dir < 0) ? maxnote : se; bot = (dir < 0) ? se : minnote; @@ -55,12 +55,12 @@ Stem::add(Notehead *n) if (n->balltype == 1) return; int p = n->position; - if ( p < minnote) + if (p < minnote) minnote = p; - if ( p> maxnote) + if (p > maxnote) maxnote = p; heads.push(n); - n->add_depedency(this); + n->add_dependency(this); } @@ -104,7 +104,11 @@ Stem::set_default_stemlen() void Stem::set_default_extents() { - assert(minnote<=maxnote); + if (minnote > maxnote) { + warning("Empty stem. Ugh!", 0); + minnote = -10; + maxnote = 20; + } if (!stemlen) set_default_stemlen(); @@ -119,6 +123,8 @@ Stem::set_default_extents() void Stem::set_noteheads() { + if(!heads.size()) + return; heads.sort(Notehead::compare); heads[0]->extremal = -1; heads.top()->extremal = 1; @@ -151,7 +157,7 @@ Stem::width()const { if (!print_flag || abs(flag) <= 4) return Interval(0,0); // TODO! - Paperdef*p= paper(); + Paper_def*p= paper(); Interval r(p->lookup_p_->flag(flag).dim.x); r+= stem_xoffset; return r; @@ -163,7 +169,7 @@ Stem::brew_molecule_p()const return out; assert(bot!=top); - Paperdef *p =paper(); + Paper_def *p =paper(); Real dy = p->internote(); Symbol ss =p->lookup_p_->stem(bot*dy,top*dy); diff --git a/src/symbol.cc b/src/symbol.cc index 01b235679b..becdf1e29f 100644 --- a/src/symbol.cc +++ b/src/symbol.cc @@ -14,3 +14,8 @@ Symbol::Symbol(String s, Box b) } +String +Symbol::str()const return s; +{ + s = "symbol(\'"+tex+"\', (" + dim.x.str() + ", " + dim.y.str() + "))"; +} diff --git a/src/symtable.cc b/src/symtable.cc index 87ed983da3..d55e9ac59b 100644 --- a/src/symtable.cc +++ b/src/symtable.cc @@ -4,7 +4,7 @@ #include "real.hh" #include "symbol.hh" #include "assoc.hh" -#include "associter.hh" +#include "assoc-iter.hh" #include "symtable.hh" Symtables::Symtables() @@ -42,3 +42,20 @@ Symtables::operator()(String s) { return Assoc::operator[](s); } +void +Symtables::print() const +{ + for (Assoc_iter i(*this); i.ok(); i++) { + mtor << "table \'" << i.key() << "\' {\n"; + i.val()->print(); + mtor << "}\n"; + } +} +void +Symtable::print() const +{ + for (Assoc_iter i(*this); i.ok(); i++) { + mtor << "\'" << i.key() << "\'->" << i.val().str() << "\n"; + } +} + diff --git a/src/template2.cc b/src/template2.cc index b3b8624ef0..0f581474c3 100644 --- a/src/template2.cc +++ b/src/template2.cc @@ -8,10 +8,11 @@ #include "symbol.hh" #include "voice.hh" +#include "voice-element.hh" #include "musicalrequest.hh" #include "staff.hh" -#include "scorecolumn.hh" -#include "staffcolumn.hh" +#include "score-column.hh" +#include "staff-column.hh" #include "spanner.hh" #include "plist.tcc" #include "pcursor.tcc" diff --git a/src/template3.cc b/src/template3.cc index 185c185076..7df0ef372b 100644 --- a/src/template3.cc +++ b/src/template3.cc @@ -1,10 +1,10 @@ #include "request.hh" -#include "inputscore.hh" -#include "inputstaff.hh" -#include "inputmusic.hh" +#include "input-score.hh" +#include "input-staff.hh" +#include "input-music.hh" #include "molecule.hh" -#include "sourcefile.hh" - +#include "source-file.hh" +#include "voice-element.hh" #include "plist.tcc" #include "pcursor.tcc" diff --git a/src/template6.cc b/src/template6.cc index e85062003e..0401c8cd93 100644 --- a/src/template6.cc +++ b/src/template6.cc @@ -1,8 +1,8 @@ #include "proto.hh" #include "plist.tcc" #include "register.hh" -#include "voicegroupregs.hh" -#include "voiceregs.hh" +#include "voice-group-regs.hh" +#include "voice-regs.hh" IPL_instantiate(Voice_registers); diff --git a/src/tstream.cc b/src/tex-stream.cc similarity index 80% rename from src/tstream.cc rename to src/tex-stream.cc index d56c58a3c4..5722599b31 100644 --- a/src/tstream.cc +++ b/src/tex-stream.cc @@ -1,8 +1,17 @@ +/* + tex-stream.cc -- implement Tex_stream + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + #include #include + #include "tex.hh" #include "main.hh" -#include "tstream.hh" +#include "tex-stream.hh" #include "debug.hh" Tex_stream::Tex_stream(String filename) @@ -21,7 +30,6 @@ Tex_stream::header() *os << "% Automatically generated, at "; time_t t(time(0)); *os << ctime(&t); -//*os << "% from input file ..\n"; } Tex_stream::~Tex_stream() { @@ -56,8 +64,12 @@ Tex_stream::operator<<(String s) case '}': nest_level--; *os << *cp; - assert (nest_level >= 0); - /* FALTHROUGH */ + + if (nest_level < 0) { + delete os; // we want to see the remains. + assert(nest_level>=0); + } + /* FALLTHROUGH */ case '\n': *os << "%\n"; diff --git a/src/tex.cc b/src/tex.cc index d7f1162d29..e8349e63cc 100644 --- a/src/tex.cc +++ b/src/tex.cc @@ -15,8 +15,9 @@ static void substitute_arg(String& r, String arg) { int p = r.index_i('%'); - if (!p ) return ; - else p--; + if (p < 0) + return ; + r = r.left_str(p) + arg + r.right_str(r.length_i() - p -1); } @@ -27,10 +28,11 @@ substitute_args(String source, Array args) String retval (source); for (int i = 0 ; i < args.size(); i++) substitute_arg(retval, args[i]); - while (retval.index_i('%')) + while (retval.index_i('%') >= 0) substitute_arg(retval, ""); return retval; } + String substitute_args(String source, Array args) { diff --git a/src/textdef.cc b/src/text-def.cc similarity index 85% rename from src/textdef.cc rename to src/text-def.cc index d4e9824d1b..d67622e141 100644 --- a/src/textdef.cc +++ b/src/text-def.cc @@ -1,8 +1,8 @@ #include "debug.hh" #include "lookup.hh" -#include "paperdef.hh" +#include "paper-def.hh" #include "molecule.hh" -#include "textdef.hh" +#include "text-def.hh" Text_def::Text_def() { @@ -18,7 +18,7 @@ Text_def::compare(const Text_def&def) } Atom -Text_def::create_atom(Paperdef*p) const +Text_def::create_atom(Paper_def*p) const { return p->lookup_p_->text(style_str_, text_str_, -align_i_); } diff --git a/src/text-reg.cc b/src/text-reg.cc new file mode 100644 index 0000000000..5232549a14 --- /dev/null +++ b/src/text-reg.cc @@ -0,0 +1,59 @@ +/* + text-reg.cc -- implement Text_register + + (c) 1997 Han-Wen Nienhuys +*/ + +#include "musicalrequest.hh" +#include "text-reg.hh" +#include "textitem.hh" + +Text_register::Text_register() +{ + text_p_ = 0; + set_feature(Features::dir(0)); + post_move_processing(); +} + +bool +Text_register::try_request(Request*req_l) +{ + if (!req_l->text()) + return false; + if (text_req_l_ && + Text_req::compare(*req_l->text(), *text_req_l_)) + + return false; + + text_req_l_ = req_l->text(); + return true; +} + +void +Text_register::process_requests() +{ + + if (text_req_l_) { + text_p_ = new Text_item(text_req_l_, 10); // UGH + announce_element(Staff_elem_info(text_p_, text_req_l_)); + } +} +void +Text_register::pre_move_processing() +{ + if (text_p_) { + text_p_->dir_i_ = dir_i_; + typeset_element(text_p_); + text_p_ = 0; + } +} +void +Text_register::set_feature(Features i) +{ + dir_i_ = i.direction_i_; +} +void +Text_register::post_move_processing() +{ + text_req_l_ = 0; +} diff --git a/src/textitem.cc b/src/textitem.cc index 56fb8e054b..ed943f52a2 100644 --- a/src/textitem.cc +++ b/src/textitem.cc @@ -1,11 +1,20 @@ -#include "musicalrequest.hh" -#include "paperdef.hh" +/* + textitem.cc -- implement Text_item + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + + + #include "musicalrequest.hh" +#include "paper-def.hh" #include "textitem.hh" #include "stem.hh" #include "molecule.hh" #include "lookup.hh" -NAME_METHOD(Text_item); + Text_item::Text_item(Text_req* treq_l, int staffsize_i) { diff --git a/src/textreg.cc b/src/textreg.cc deleted file mode 100644 index 7e6d59e2cb..0000000000 --- a/src/textreg.cc +++ /dev/null @@ -1,54 +0,0 @@ -/* - textreg.cc -- implement Text_register - - (c) 1997 Han-Wen Nienhuys -*/ - -#include "musicalrequest.hh" -#include "textreg.hh" -#include "textitem.hh" - -Text_register::Text_register(Complex_walker*w) - : Request_register(w) -{ - text_p_ = 0; - set_dir(0); -} - -bool -Text_register::try_request(Request*req_l) -{ - if (!req_l->text()) - return false; - if (accepted_req_arr_.size() && - Text_req::compare(*req_l->text(), *accepted_req_arr_[0]->text())) - - return false; - - accepted_req_arr_.push(req_l); - return true; -} - -void -Text_register::process_request() -{ - - if (accepted_req_arr_.size()) { - text_p_ = new Text_item(accepted_req_arr_[0]->text(), 10); - announce_element(Staff_elem_info(text_p_, accepted_req_arr_[0], this)); - } -} -void -Text_register::do_pre_move_process() -{ - if (text_p_) { - text_p_->dir_i_ = dir_i_; - typeset_element(text_p_); - text_p_ = 0; - } -} -void -Text_register::set_dir(int i) -{ - dir_i_ = i; -} diff --git a/src/textspanner.cc b/src/textspanner.cc index 8cd1b8ac3f..8a648232f6 100644 --- a/src/textspanner.cc +++ b/src/textspanner.cc @@ -1,17 +1,17 @@ #include "molecule.hh" #include "boxes.hh" #include "textspanner.hh" -#include "textdef.hh" +#include "text-def.hh" #include "debug.hh" -#include "paperdef.hh" +#include "paper-def.hh" + -NAME_METHOD(Text_spanner); void Text_spanner::set_support(Directional_spanner*d) { support = d; - add_depedency(d); + add_dependency(d); } Text_spanner::Text_spanner() diff --git a/src/timedescription.cc b/src/time-description.cc similarity index 96% rename from src/timedescription.cc rename to src/time-description.cc index 59d1189b11..a7b04bafae 100644 --- a/src/timedescription.cc +++ b/src/time-description.cc @@ -1,12 +1,12 @@ /* - timedescription.cc -- implement Time_description + time-description.cc -- implement Time_description source file of the LilyPond music typesetter (c) 1997 Han-Wen Nienhuys */ -#include "timedescription.hh" +#include "time-description.hh" #include "debug.hh" String diff --git a/src/voice-group-regs.cc b/src/voice-group-regs.cc new file mode 100644 index 0000000000..a5a5c3735b --- /dev/null +++ b/src/voice-group-regs.cc @@ -0,0 +1,85 @@ +/* + voicegroup.cc -- implement Voice_group_registers + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + +#include "plist.hh" +#include "musicalrequest.hh" +#include "voice-regs.hh" +#include "voice-group-regs.hh" +#include "register.hh" +#include "text-reg.hh" +#include "stem-beam-reg.hh" +#include "script-reg.hh" +#include "complex-walker.hh" +#include "commandrequest.hh" +#include "debug.hh" + +static int temp_id_count; + +Voice_group_registers::Voice_group_registers(String id) +{ + add(new Text_register); + add(new Stem_beam_register); + add(new Script_register); + + if (id=="") // UGH + id = __FUNCTION__ + String(temp_id_count++); + group_id_str_ = id; +} + +bool +Voice_group_registers::try_request(Request*r_l) +{ + for (int i=0; i < voice_regs_l_.size(); i++) { + if (voice_regs_l_[i]->voice_l_ == r_l->voice_l()) + goto gotcha; + } + return false; +gotcha: + if (r_l->groupfeature()) { + set_feature(Features::dir(r_l->groupfeature()->stemdir_i_)); + return true; + } + return Register_group_register::try_request(r_l); +} + + +bool +Voice_group_registers::static_acceptable_request_b(Request*r) +{ + return (r->stem() || r->beam() || r->text() || r->script() || + r->groupfeature()); +} + +void +Voice_group_registers::terminate_register(Request_register*r_l) +{ + if (r_l->name() == Voice_registers::static_name()) { + for (int i=0; i name() == Voice_registers::static_name()) + voice_regs_l_.push( (Voice_registers*)r_l ); +} diff --git a/src/voice-regs.cc b/src/voice-regs.cc new file mode 100644 index 0000000000..1f61617007 --- /dev/null +++ b/src/voice-regs.cc @@ -0,0 +1,65 @@ +/* + voice-regs.cc -- implement Voice_registers + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ +#include "commandrequest.hh" +#include "musicalrequest.hh" +#include "voice-regs.hh" +#include "register.hh" +#include "slur-reg.hh" +#include "headreg.hh" +#include "walkregs.hh" +#include "debug.hh" + +Voice_registers::Voice_registers(Voice *v_p) +{ + voice_l_ = v_p; + add(new Notehead_register); + add(new Slur_register); +} + +void +Voice_registers::acknowledge_element(Staff_elem_info i) +{ + if (i.voice_l_ != voice_l_) + return; + Register_group_register::acknowledge_element(i); +} + +bool +Voice_registers::try_request(Request*r_l) +{ + if (r_l->voice_l() !=voice_l_) + return false; + + Command_req *c=r_l->command(); + if (c&&c->terminate()) { + daddy_reg_l_->terminate_register(this); + return true; // scary. We're deleted now.. + } else if (c&&c->groupchange()) { + + ((Walker_registers*)daddy_reg_l_->daddy_reg_l_)-> // scary. + change_group(c->groupchange(), this, + (Voice_group_registers*)daddy_reg_l_); // UGR! + return true; + } + + return Register_group_register::try_request(r_l); +} + +bool +Voice_registers::acceptable_request_b(Request*r) +{ +// return (r->rest() || r->note() || r->slur() || r->groupchange()); + return r->groupchange() + || Register_group_register::acceptable_request_b(r); +} +void +Voice_registers::do_print() const +{ + mtor << "Voice= " << voice_l_<<'\n'; + Register_group_register::do_print(); +} diff --git a/src/voice.cc b/src/voice.cc index ad07cf2040..6301f29945 100644 --- a/src/voice.cc +++ b/src/voice.cc @@ -10,8 +10,9 @@ #include "voice.hh" #include "musicalrequest.hh" #include "commandrequest.hh" -#include "midiitem.hh" -#include "midistream.hh" +#include "midi-item.hh" +#include "midi-stream.hh" +#include "voice-element.hh" void Voice::set_default_group(String s) @@ -29,7 +30,8 @@ Voice::find_plet_start_bo(char c, Moment& moment_r) } void -Voice::set_plet_backwards(Moment& now_moment_r, Moment until_moment, int num_i, int den_i) +Voice::set_plet_backwards(Moment& now_moment_r, Moment until_moment, + int num_i, int den_i) { for (iter_bot(elts, i); i.ok(); i--) if ( now_moment_r <= until_moment ) @@ -62,9 +64,10 @@ void Voice::print() const { #ifndef NPRINT - mtor << "start: "<< start<print(); + mtor << "}\n"; #endif } diff --git a/src/voiceelt.cc b/src/voiceelt.cc index 670dcdfaaa..501ffbc89b 100644 --- a/src/voiceelt.cc +++ b/src/voiceelt.cc @@ -8,6 +8,7 @@ #include "debug.hh" #include "voice.hh" +#include "voice-element.hh" #include "musicalrequest.hh" #include "commandrequest.hh" @@ -59,8 +60,6 @@ Voice_element::find_plet_start_bo(char c, Moment& moment_r) assert( c == ']' ); moment_r += duration; for ( PCursor req_l_pcur( reqs.top() ); req_l_pcur.ok(); req_l_pcur++ ) { - if (req_l_pcur->melodic()) - mtor << (char)('c' + req_l_pcur->melodic()->height()) << "\n"; if (req_l_pcur->beam() && req_l_pcur->beam()->spantype == Span_req::START ) return true; } @@ -79,7 +78,8 @@ Voice_element::set_default_group(String s) } void -Voice_element::set_plet_backwards(Moment& now_moment_r, Moment until_moment, int num_i, int den_i) +Voice_element::set_plet_backwards(Moment& now_moment_r, + Moment until_moment, int num_i, int den_i) { now_moment_r += duration; if ( now_moment_r > until_moment ) @@ -91,7 +91,5 @@ Voice_element::set_plet_backwards(Moment& now_moment_r, Moment until_moment, int req_l_pcur->rhythmic()->plet_factor = Moment(num_i, den_i); if (req_l_pcur->stem()) req_l_pcur->stem()->plet_factor = Moment(num_i, den_i); - if (req_l_pcur->melodic()) - mtor << (char)('c' + req_l_pcur->melodic()->height()) << "\n"; } } diff --git a/src/voicegroupregs.cc b/src/voicegroupregs.cc deleted file mode 100644 index d23b58ac70..0000000000 --- a/src/voicegroupregs.cc +++ /dev/null @@ -1,70 +0,0 @@ -/* - voicegroup.cc -- implement Voice_group_registers - - source file of the LilyPond music typesetter - - (c) 1997 Han-Wen Nienhuys -*/ - -#include "plist.hh" -#include "musicalrequest.hh" -#include "voiceregs.hh" -#include "voicegroupregs.hh" -#include "register.hh" -#include "textreg.hh" -#include "stembeamreg.hh" -#include "scriptreg.hh" -#include "complexwalker.hh" -#include "commandrequest.hh" - -static int temp_id_count; - -Voice_group_registers::Voice_group_registers(Complex_walker*w_l, String id) -{ - walk_l_ = w_l; - add(new Text_register(w_l)); - add(new Stem_beam_register(w_l)); - add(new Script_register(w_l)); - - if (id=="") // UGH - id = __FUNCTION__ + String(temp_id_count++); - group_id_str_ = id; -} - -bool -Voice_group_registers::try_request(Request*r_l) -{ - if (r_l->groupfeature()) { - set_dir(r_l->groupfeature()->stemdir_i_); - return true; - } - return Register_group::try_request(r_l); -} - -void -Voice_group_registers::acknowledge_element(Staff_elem_info i) -{ - if (i.group_regs_l_!= this) - return; - Register_group::acknowledge_element(i); -} -#if 1 -void -Voice_group_registers::set_dir(int i) -{ - Register_group::set_dir(i); - - // ughh - Array vr_arr (walk_l_->get_voice_regs(this)); - for (int j=0; jset_dir(i); - } -} -#endif -bool -Voice_group_registers::acceptable_request_b(Request*r) -{ - return (r->stem() || r->beam() || r->text() || r->script() || - r->groupfeature()); -} diff --git a/src/voiceregs.cc b/src/voiceregs.cc deleted file mode 100644 index ea56a5da46..0000000000 --- a/src/voiceregs.cc +++ /dev/null @@ -1,34 +0,0 @@ -/* - voiceregs.cc -- implement Voice_registers - - source file of the LilyPond music typesetter - - (c) 1997 Han-Wen Nienhuys -*/ - -#include "musicalrequest.hh" -#include "voiceregs.hh" -#include "register.hh" -#include "slurreg.hh" -#include "headreg.hh" - -Voice_registers::Voice_registers(Complex_walker*c_l, Voice *v_p) -{ - voice_l_ = v_p; - add(new Notehead_register(c_l)); - add(new Slur_register(c_l)); -} - -void -Voice_registers::acknowledge_element(Staff_elem_info i) -{ - if (i.voice_l_ != voice_l_) - return; - Register_group::acknowledge_element(i); -} - -bool -Voice_registers::acceptable_request_b(Request*r) -{ - return (r->rest() || r->note() || r->slur()); -} diff --git a/src/walkregs.cc b/src/walkregs.cc index dc24ecd96a..cf88c06c73 100644 --- a/src/walkregs.cc +++ b/src/walkregs.cc @@ -6,18 +6,169 @@ (c) 1997 Han-Wen Nienhuys */ -#include "clefreg.hh" -#include "localkeyreg.hh" -#include "keyreg.hh" -#include "meterreg.hh" -#include "barreg.hh" +#include "debug.hh" +#include "clef-reg.hh" +#include "local-key-reg.hh" +#include "key-reg.hh" +#include "meter-reg.hh" +#include "bar-reg.hh" +#include "bar.hh" #include "walkregs.hh" +#include "staff-elem.hh" +#include "staff.hh" +#include "complex-walker.hh" +#include "staff-column.hh" +#include "voice-group-regs.hh" +#include "voice-regs.hh" +#include "commandrequest.hh" + Walker_registers::Walker_registers(Complex_walker *w) { - add( new Bar_register(w)); - add( new Clef_register(w)); - add( new Key_register(w)); - add( new Meter_register(w)); - add( new Local_key_register(w)); + walk_l_ = w; + add( new Bar_register); + add( new Clef_register); + add( new Key_register); + add( new Meter_register); + add( new Local_key_register); +} + +void +Walker_registers::announce_element(Staff_elem_info info) +{ + if (info.elem_p_->name() == Bar::static_name()) { + walk_l_->allow_break(); + } + announce_info_arr_.push(info); +} + +void +Walker_registers::acknowledge_element(Staff_elem_info ) +{ + assert(false); +} + +void +Walker_registers::do_announces() +{ + Request dummy_req; + for (int i = 0; i < announce_info_arr_.size(); i++){ + Staff_elem_info info = announce_info_arr_[i]; + + if (!info.req_l_) + info.req_l_ = &dummy_req; + Register_group_register::acknowledge_element(info); + } + announce_info_arr_.set_size(0); +} + +void +Walker_registers::typeset_element(Staff_elem *elem_p) +{ + typeset_musical_item(elem_p); +} + +void +Walker_registers::typeset_musical_item(Staff_elem * elem_p) +{ + walk_l_->typeset_element(elem_p); +} + +void +Walker_registers::typeset_breakable_item(Item * pre_p , Item * nobreak_p, + Item * post_p) +{ + if (pre_p) + prebreak_item_p_arr_.push(pre_p); + if (nobreak_p) + nobreak_item_p_arr_.push(nobreak_p); + if (post_p) + postbreak_item_p_arr_.push(post_p); +} + +void +Walker_registers::pre_move_processing() +{ + // this generates all items. + Register_group_register::pre_move_processing(); + walk_l_->ptr()->typeset_breakable_items(prebreak_item_p_arr_, + nobreak_item_p_arr_, + postbreak_item_p_arr_); +} +void +Walker_registers::post_move_processing() +{ + Register_group_register::post_move_processing(); +} + +void +Walker_registers::change_group(Group_change_req * greq_l, + Voice_registers *voice_regs_l, + Voice_group_registers * old_group) +{ + Voice_registers *regs_p = (old_group) + ? (Voice_registers*) old_group->get_register_p(voice_regs_l) + : new Voice_registers(greq_l->voice_l()); + Voice_group_registers * new_group_l = get_group(greq_l->newgroup_str_); + new_group_l->add(regs_p); + + mtor << "processed change request"; + print(); +} + +Voice_group_registers * +Walker_registers::get_group(String id) +{ + for (int i=0; i < group_l_arr_.size(); i++) { + if (group_l_arr_[i]->group_id_str_ == id) + return group_l_arr_[i]; + } + Voice_group_registers *group_p = new Voice_group_registers(id); + group_l_arr_.push(group_p); + add(group_p); + return group_p; +} + +void +Walker_registers::terminate_register(Request_register * reg) +{ + for (int i=0; i < group_l_arr_.size(); i++) { + if (group_l_arr_[i] == reg) { + group_l_arr_.del(i); + Register_group_register::terminate_register(reg); + return; + } + } + assert(false); +} + +bool +Walker_registers::try_request(Request * r) +{ + bool b = Register_group_register::try_request(r); + if (!b) { + Command_req * cr_l = r->command() ; + + if (cr_l && cr_l->groupchange()) { + change_group(cr_l->groupchange(), 0, 0); + } else + warning("junking request: " + String(r->name()), + r->defined_ch_c_l_); + } + return b; +} + + +Staff_info +Walker_registers::get_staff_info() return inf; +{ + inf.c0_position_i_ = &walk_l_->c0_position_i_; + inf.walk_l_ = walk_l_; + inf.time_c_l_ = &walk_l_->time_; + inf.rhythmic_c_l_ = walk_l_->default_grouping; +} +Paper_def* +Walker_registers::paper()const +{ + return walk_l_->staff_l_->paper(); } diff --git a/src/warn.cc b/src/warn.cc index b57c6d2bdc..b1a0357942 100644 --- a/src/warn.cc +++ b/src/warn.cc @@ -1,10 +1,10 @@ #include "debug.hh" #include "lexer.hh" #include "moment.hh" -#include "timedescription.hh" +#include "time-description.hh" #include "proto.hh" #include "plist.hh" -#include "sourcefile.hh" +#include "source-file.hh" #include "source.hh" #include "main.hh" -- 2.39.5