]> git.donarmstrong.com Git - lilypond.git/blob - TODO
patch::: 1.1.37.script1
[lilypond.git] / TODO
1 -*-outline-layout:(2 (-1 -1 0 :) 0);outline-stylish-prefixes:nil -*-
2
3 * GNU LilyPond TODO
4 Features you cannot find in the doco as working, should be
5 mentioned here.  This is an assorted collection of stuff that will be
6 done, might be done, or is an idea that I want to think about
7
8 Most of the items are marked in the code as well
9 Grep for TODO and ugh/ugr/urg.  
10
11 .* BUGS
12 . * header for PS enteredby = "bla <bla@bar.com>"
13 . * Hash_table::remove ().
14 . * 1.  With "lilypond -f ps": The black notes with ledger lines seem to
15 > have extra "blobs" over and to the left of them and all the ledger
16 > lines from the staff to the note will have a blob too.  For example,
17 > with the note "a4" there will be a black note at the ledger line where
18 > "c" would be too.  However, only the "a4" will have the extra blob.
19 . * ps/lily.ps
20 . * AFM for BlueSky AFM files.
21 . * devise standard for functioning of Vertical_align_element.
22 . * fix interstaff slurs & beams.
23 . * staff size for post/prebreaks
24 . * .ly files
25 .  * input/star-spangled-banner
26 .  * input/scripts.ly
27 .  * mutopia/J.S.Bach/wtk1-fugue2.ly
28 .  * input/test/grace
29 .  * fix: text on rests: ridiculous dims
30 . * \score { \notes { c8 c8 c8 c c c }
31 \paper { \translator { \VoiceContext \remove "Auto_beam_engraver";}}
32 }
33 . * m=\notes\relative c'''{
34   \time 2/4;
35
36   R2*4 | c2 | c2 | c2 | c2 | c2 | c2 | c2 | c2 | c2 | \break
37   <{R2*10}{s2 \mark "A"; }> | % Too narrow space for the first rest in
38 1.1.29
39   r4 r8 [g16 \p ( a ] |
40 [ ) g8-. fis16 ( g ][ ) fis8-. f16 ( g ] |
41 [ ) f8-. e16 ( f ][ ) e8-. es16 ( f ] |
42 [ ) es8 \f c16 ( d][es8 d16 c ] |
43 ) d4 r8 [g16 \p ( a ] |
44 [ ) g8-. fis16 ( g ][ ) fis8-. f16 ( g ] | \break
45 ) c2 | c2 | c2 | c2 | c2 | c2 | c2 | c2 | c2 |
46 }
47
48 \score{
49   \m
50   \paper{
51     \translator{
52       \ScoreContext
53       SkipBars = 1;
54     }
55     \translator {
56       \OrchestralPartStaffContext
57     }
58   }
59 }
60 . * midi key.
61 . * P.P.S. It can be cool in mudela-book to distinguish in pre,postMudelaExample,
62 whether MudelaExample is epsed or not: ( if this fragment is floating eps, than 1,
63 otherwise 2). say preMudelaExample[eps]{}, and change it in document body sometimes.
64 . * fix singleStaffBracket
65 . * declare performers in \midi
66 . * fix MIDI
67 . * \shape 1st dim skipped? 
68 . * turn slope-damping on/off
69 . * tremolo stuff
70 . * fix height of / collisions with lyrics (chords), 
71     see input/test/vertical-text.ly; input/test/repeat.ly
72 . * We need feta-din*.mf files for more sizes than 10.
73 . * latex bla.tex broken (titles / \lilyfooter stuff?
74 . * fix dynamics decently, ie. use kerning & ligatures.  
75 . * support_l_arr_ empty in staff-margin's G_staff_side_item
76 . * minVerticalAlign for StaffGroups.
77 . * fix OrchestralScore and Hara-kiri (i.e., fix Coriolan)
78 . * Phrasing:  Indicating the textual underlay of a piece, or
79 otherwise dividing a piece into phrases.
80
81 There are distinct ways of specifying the first two (although at
82 present, they're not properly distinguished) but no distinct way to
83 specify the third.  Should there be?
84
85 .* TODO before 1.2
86 . * \selectmusic to cut pieces from music. 
87 . * TODO: merge atom & molecule; make  tree from molecule.
88 . * break priority setting from SCM.
89 . * Gade score
90 .  * remove [] in favour of auto-beamer
91 .  * The minimum distance between different staffs works only within 
92   StaffGroups, not between StaffGroups. The Gade Score looks quite
93   strange on the pages where the Timpani and/or Brass sections don't
94   play. I've set the minimum distance with:
95     \translator {
96        \OrchestralScoreContext
97         minVerticalAlign = 2.5*\staffheight;
98     }
99 . * hangOnClef with non-breakable clefs.
100 . * Aha, the problem is the new TeX code generation for changing fonts.
101 > (The explanation below is mostly intended for Han-Wen and Jan)
102 > Before, the font was changed with macros declared separately for 
103 > pure TeX and LaTeX, but now all the fonts are declared directly in
104 > the generated code using the low-level TeX commands. This circumvents
105 > the fontencoding mechanism of LaTeX and is a potential source of
106 > problems also for us users of the Latin-1 character set. 
107 > I think it still works since the inputencoding latin1 is 
108 > declared by ly2dvi, but it still means that e.g. an o with
109 > umlaut is typeset as a combination of the two symbols 'o' and
110 > 'umlaut' instead of as a single character, as would be the case
111 > if fontencoding OT1 had been used. This shouldn't give any 
112 > difference in layout, though. One of the main argument for using
113 > fontencoding OT1 is for the hyphenation mechanism to work, an 
114 > argument that's clearly irrelevant in our application. Yet we
115 > see the problem for August.
116 . * Check gcc 2.8.1 compatibility
117 . * Abstraction for engravers:
118 .  * make "in-between" engraver (Tie, Extender)
119 .  * make wide_spanner_engraver (line_group_spanne,r staff_symbol)
120 . * remove Interval dim_ from Dimension_cache and rename the struct.
121 . * do scaled fonts generally 
122 . * The Lilypond accidental symbols are available through the TeX macros, 
123 \textflat, \textsharp and \textnatural defined in the init file
124 lilyponddefs.tex. All the symbols are defined in the files fetaXX.tex
125 where XX corresponds to the size. I don't know where (or even if) they
126 are installed but they are generated in the mf/out/ directory during the
127 compilation.
128 . * make dependencies () a virtual function.
129 . * fix Repeated_music design
130 . * one big ly2dvi input that includes *all* tests.
131 . * store req -> element, element -> element causes for warnings
132 . * use G_text_item in stead.
133 . * junk Script_def
134 . * include examples in RPM.
135 . * fix partial measures in meaningful way.
136 . * add scripts to bars eg.  |^"bla" 
137 . * relative mode for mi2mu
138 . * uniformise recent feta contributions.
139 .  * use SCM and Molecules for {accordeon stuff, }
140 .  * bigger and fatter 4/4 C
141 . * sort out directory stuff.
142 .  * --prefix option?
143 .  * -I option per filetype?
144 .  * kpathsea?
145
146 . * ly2dvi/lilypond logfile.
147 . * How can I specify a chord whose duration is longer than a whole note?
148  \type ChordNames { \chord{ A1*2-min } }
149
150 gives me a parse error.  And \times doesn't work either.  I can't use
151 a spacer note.  So it seems to be impossible to have long chords of
152 general length.  Of course, in the example above I can use \breve.
153 But what if I want a chord that lasts for 3 whole notes?  Or what
154 about 2.5 whole notes?  Is there a mechanism for getting this kind of
155 length?  
156
157 . * fractional chord durs.
158 . * hang Item on Spanner
159 . * do --safe for PS output?
160 . * convert-mudela --output
161 . * Staff_margin (with a partial measure.)
162 . * fix pletvisibility properties:
163 .  * bracket on/off/no-bracket-when-beam
164 .  * num on/off/no-num-when-beam
165 . * fix: standchen.
166 . * junk text{sharp,flat,etc}
167 . * fix convert-mudela manpage
168 . * decimal point in \paper {}
169 . * {  \voiceone <a'4.*2/3  d''4.*2/3 fis''4.*2/3>  [g''8 fis'' e''] d''4 |}
170          and
171          { \voicetwo  d'4 d'2.*2/3 } spacing
172 . * tied notes for MIDI
173 . * sharp / flat on trills (in MIDI ??)
174 . * scm-ify \property values.
175 . * move class Lookup {} into scm
176 . * msgfmt -o check?
177 . * \breathmark TeX macro 
178 . * add new glyphs to font.ly
179 . * formatting of input stuff. 
180 . * \notes{ a \< b \cr } vs \notes{ a \< b \! }
181 . * space after bars?
182 . * 'hinterfleisch' before bar (e.g. wtk1-fugue2)?
183 . * Summary of minor spelling irregularities:
184 .  *  capitalization/use of underscores in property names
185 .  * fix SkipBars  -> skipBars
186 . * broken scripts:
187         lbheel = \script { "bheel" 0 0 -1  0 0 }
188         rbheel = \script { "bheel" 0 0 1 0 0 }
189         lbtoe = \script { "btoe" 0 0 -1 0 0 }
190         rbtoe = \script { "btoe" 0 0 1 0 0 }
191         lfheel = \script { "fheel" 0 0 -1  0 0 }
192         rfheel = \script { "fheel" 0 0 1 0 0 }
193         lftoe = \script { "ftoe" 0 0 -1 0 0 }
194         rftoe = \script { "ftoe" 0 0 1 0 0 }
195         and also
196         portato= \script { "portato" 0 -1 0 1 0 }
197 . * ly2dvi
198 .  * bottomnote for ly2dvi
199 .  * deps for ly2dvi
200 .* STUFF
201 . * compulsory hshift
202 . * arrows on slurs.
203 . * Align_element::padding  ?
204 . * uniformise property names...
205 .  * ydirection <-> yDirection
206 .  * rather allow '_' in identifiers first (i.e. junk ^ and _),
207             and do y_direction?
208 .  * typo checks on property names?
209 . * use streambufs and iostream
210         to provide IO handling for TeX stream, mudela stream, data-file.
211 . * seriously buffer TeX output (do profile of writing .5 mb TeX file.)
212 . * strip EXEs before installing
213 . * zip target for binary windows dist (JBR)
214 . * junking \skip req in lyrics
215 . * mi2mu empty staffs.
216 . * horizontal centering of dynamics 
217 . * $DEPENDENCIES_OUTPUT support
218 . * Xdvi zooming ?! Try to understand GS garbage collection.
219 gs: Error: /undefined in draw_beam
220 gs: Operand stack:
221 . * fix vertical alignment and stafflines
222 . * declaring Performers
223 . * GrandStaff needs more work -- I want a single word
224         `harpsichord' to the left of the grandstaff, not one on each
225         stave.  (Organ staff -- with separate pedal -- but common
226         properties may be something to think about.  Of course for
227         organ you want to be able to give stop indications on the way
228         through, so the \property Voice.Instrument would be a stop,
229         and \property GrandStaff.instrument would be PipeOrgan...)
230 . * *.yo: fix pod manpage layout legacy
231 . * text-items clash with stems/beams
232 . * --include, -I option for ly2dvi (pass on to lily)
233 . * fix placement of beam-less abbrev
234 . * \meter 3/4;
235         <{\voiceone cis4. cis8 cis4 | cis4 cis cis | r1 }
236          {\voicetwo cis,4 r r | r2. | r1 }> |
237         }
238 . * Musical_pitch (analogous to Duration and Rhythmic_req)
239           think about, analogous to pitch: 
240            * { a4 a16 } c <-- duration of c?
241            * < a4 b8 > c <-- duration of c?
242 . * \tempo 4. = 90;
243 . * fix audio-items (don't use (input) requests, but copy data)
244 . * make sure all ex's have a mudela-version
245 . * do rest-collisions for Multi_measure_rests as well.
246 . * split error/warning in error/warning/non_fatal_error
247 . * add a Duration_convert member to Duration_iter to set parameters.
248         Junk global duration settings. 
249 . * en-,discouraged linebreaking: 
250 .  * handle DISALLOW < penalty > FORCE
251 .  * discourage breaking of slurs
252 . * fix variable define/lookup parser global<->paper
253 . * fix title/instrument placements; see input/test/title.ly
254 . * <\voiceone c4. \voicetwo c4>
255 . * add full cello suites to web site (kom op, Maarten!)
256 . * Rethink Time_description
257 \cadenza , \meter, \grouping should all be \properties
258 . * rename
259 .  * measure -> bar
260 .  * abbrev -> tremolo
261 .  * abbreviation-beam -> (measured/unmeasured) tremolo
262 .  * partial -> anacrouse
263 . * shared lib
264 . * robustify Beam (in case of no stems, 32nd notes)
265 . * decentralised spring factory
266 . * move paper vars into engraver properties
267 . * check for groff / troff/ nroff et
268 . * more intelligent file searching
269 . * disable spaces in TeX stuff
270 . * handle ^C for tmp/file creation.
271 . * make LilyPond RPM fully relocatable
272 . * dots & rest collisions.
273 . * documentation
274 .  * remove links to non-free SW.
275 .  * internal documentation
276 .  * a general paper. 
277 .  * \properties
278 .   * left/rightbeamcount
279 .   * various other new properties.
280 .  * introduction?
281 .  * info?
282 .  * LaTeX?
283 .  * more manpages?
284 . * the warning about the negative slur/tie length appears twice
285 which is irritating.
286 . * better hshift (dots, distance, head dependent)
287 . * clefs (AG): The "8" should appear closer to the actual clef,
288 touching it.
289 . * put errorlevel in Input class
290 . * junk nesting slurs
291 . * integrate midi-elts from mi2mu and lily?
292
293 .* FONT
294 . * the bracket is ugly (wings are too parabolic, should be more circular)
295 . * versioning for Feta
296 . * The `3' in the meter key is a one or two pixels too thin (at 600dpi)
297         in the middle:
298 . * design macro for penstroke with rounded endings
299 . * timesig C: fat yet less curved.  Check out relations. 
300 . * design decent macro for bulbed endings
301 . * printer dependencies.
302 . * y-refpoint for rests should be the 4th staffline (gclef: b')
303 . * clean-up eight+ rests
304 . * versioning  
305 . * lo-res fixes.
306 . * work out sizes of character fonts.
307 . * more symbols
308 .  * piano pedals: Ped/*
309 .  * maxima notehead
310 .  * coda signs: Segno, O+
311 .  * glissando, arpeggio
312 .  * lengthened trill
313 . * 128th flags
314 . * include important spacing dims in fetalog 
315 .* 3RD PARTY BUGS
316 . * GNU diff 2.7: diff -rN does not see a new directory with empty file
317 . * check out GCC signatures?
318 . * glibc 2.0:
319           f = fopen ("/dev/null", "r")
320           assert (feof (f))
321
322 . * tetex: mfplain.mem
323 .* 3RD PARTY PROJECTS:
324 . * make GCC warn about ctor that leaves member vars  uninitialised.
325 . * GNU patch 
326 .  * 'double-fix' mode: ignore identical fix, rather than suggest 
327             to revert patch direction when (more or less? exactly) the same 
328             thing is fixed
329 .* PROJECTS
330 . * Scripts:
331 .  * fix position of bar number
332 .  * stack scripts in chords:
333           % fingering:        footing:
334             < a-4 c-2 g-1 >   < c-\ltoe e-\lheel >
335 .  * script-spacing
336 .  * slur parts as a script
337 .  * stack parameterised scripts for fingering and footing:
338
339 . * convert-mudela:
340 .  * automatically add  a \version if not present.
341 .  * better parsing
342 .  * make smarter
343 .  * convert-mudela -e empty.ly
344
345 . * emacs mudela-mode
346 .  *  should handle block comments too.
347 .  *  handle lexer modes (\header, \melodic, \lyric) etc.
348 .  *  indentation
349 .  *  notenames?
350 .  *  fontlock: \melodic \melodic
351
352 . * use properties for:
353 .  * default tempo.
354 .  * cadenza mode? 
355
356 . * page handling:
357 .  * PS output
358 .  * optimal pagebreaking.
359
360 . * Unicode support? -> man 7 unicode
361 .  * 16 bit Strings
362 .  * -u switch
363 .  * detect of 16/8 bit files
364 .  * examples to go with it.
365
366 . * Spring_spacer:
367 .  * write a faster Spring_spacer (without matrices if possible)
368 .  * relate energybound to linelen unitspace fontsize etc.
369 .  * used fixed point fp?
370
371 . * \header
372 .  * output header info to MIDI too.
373
374 . * a musical dictionary. See Documentation/vocabulary-*, other
375         languages:
376 .  * explanations
377 .  * italian
378 .  * german
379 .  * dutch
380 .  * swedish
381          .. ?
382
383 . * chords
384 .  * guitar chords (fret diagrams)
385 .  * other chord name styles (american(?) style)
386 .  * basso continuo
387 .  * MIDI output?
388
389 . * Debug logs:
390 .  * derive lily_stream, Dstream, texstream from ostream?
391 .  * indentable stream as baseclass for TeX stream, lily stream, Dstream.
392 .  * use dstream feature in mi2mu
393 .  * integrate IO checking into stream class
394
395 . * input converters
396 .  * NIFF?
397 .  * ABC? 
398 .  * SMDL?
399
400 . * add to MIDI output:
401 .  * tempo change
402 .  * ornaments (and trills?)
403 .  * repeat/volta
404 .  * slurs
405 .  * accents
406 .  * dynamics
407
408 > Would it be hard to add support for proper dynamics in MIDI output?  I
409 > would really like to have this feature...
410
411 To answer this, I have to give a little background.  Please say so if
412 I am being obtuse.
413
414 Both audio and notation elements are created decentrally, when
415 LilyPond says "Interpreting music ... [8][16] etc."  After all
416 elements are created, they are processed again to calculate all
417 parameters.  After that is done, they are dumped onto the output (the
418 MIDI stream or the TeX file).
419
420 The audio and notation elements are created by objects called
421 performer and engraver respectively.  They work by taking a chunk of
422 input (a so-called request), and using the request to create an audio
423 or notation element.
424
425 After some processing, the engraver sends the created elements to
426 its enclosing notation/performance context.
427
428 In the case of notation, engravers can also modify existing elements
429 created by sibling engravers.  Eg. the beam-engraver will modify stems
430 when it creates a beam over a couple of stems.  This is done in
431 Engraver::do_acknowledge_element () and
432 Engraver::do_process_acknowledged ().
433
434 In the case of audio, there are no mechanisms to modify existing audio
435 elements. After the audio elements are created, they are sent directly
436 to the enclosing context (an instance of Performer_group_performer),
437 through the method Performer::play ()
438
439 Concretely spoken, for dynamics you have to write a performer
440 (Dynamics_performer), that will take the input requests. If I
441 understand correctly, every MIDI note played must have its dynamic
442 strength set separately.  That means the the Dynamics_performer must
443 set the strength of every Audio_note it finds.  This means that one
444 has to modify existing Audio items.  The best way of doing this is
445 with a broadcast/acknowledge process.
446
447 So the best way of handling this, is
448
449   1 supporting dynamic settings in Audio_note
450
451   2 mimicking the broadcast/acknowledge mechanism of the Engravers in
452   the Performers
453
454   3 using that mechanism to write a Dynamics_performer that will modify
455   any notes it finds to set appropriate strengths.
456
457 You could also kludge this by deriving from Performer_group_performer
458 a performer that also sets dynamics within notes, but that is not the
459 elegant way to do it.
460
461 I'd say that the work involved is not hard, but you have to be fluent
462 with C++ and need some insight into the working of Notation Contexts
463 and friends.  I guess I could do it in a day or so, but if you are not
464 so fluent with the inner workings of LilyPond, it could take you some
465 more time (A few more days?).
466
467 Please note, that I am *not* going to code this myself: my days are
468 valuable, and I think I have more interesting things to do than fixing
469 the MIDI output (I don't even have a soundcard).  But I *do* want to help
470 you or other people with implementing this, so if you need help, don't
471 hesitate to ask.
472
473 .  * account for rhythmic position in measure
474 .  * etc.
475
476 . * grace notes
477 .  * make separate class for Grace_*_engravers 
478         (which is at Voice_gravs level)
479 .  * make encapsulated spacing problems.
480
481 . * accidentals per Voice_group
482
483 . * Output class, handles : (smallish)
484 .  * help text /(c) notice?
485 .  * version line
486 .  * warning /errors/progress
487 .  * abort on error/warning; exit status
488 .  * quiet/ignore-version options
489 .  * logfile output
490
491 . * PS 
492 .  * speed up PS code.
493 .  * PS lines to .eps files
494 .  * write custom prolog
495
496 .  * NIFF ?
497 .  * Common Music Notation
498 .  * PostScript output (esp. Beams, Slurs, etc)
499 .  * Move all Score_elems, into libmutype.a
500 .  * SGML
501
502 . * Documentation
503 .  * Doc (C) stuff of sheet music
504 .  * a better format?  SGML?  TeX?  Info?
505 .  * a better tutorial
506
507 . * more spanners (smallish)
508 .  * Glissando
509 .  * trill
510
511 . * Rewrite Stem, Beam and Rhythmic_grouping (hairy)
512 .  * [c8. c32 c32]
513 .  * doc on Rhythmic_grouping
514 .  * general shaving on Beam and Stem
515 .  * use plet grouping
516 .  * separate visual from rhythmic info even more
517 .  * beams over bars
518
519 . * lines:
520 .  * Ledger lines, should be separate item: Ledger_lines
521 .  * set different line sizes / thicknesses
522 .  * beam stem showthrough, inter beam sizes (french vs german style)
523
524 . * Collisions
525 .  * left/right note balls should be handled by Collision:
526         < \multi 2; { \stem 1; <b c> } { <f as b> } >
527
528 . * Keys:
529 .  * merge key{item} & localkey{item}?
530 .  * spacing, national styles?
531
532 . * Support for TAB
533 .  * redo Notehead to allow digits as heads
534 .  * add a \tablature {} lexer mode for easy entering
535
536 . * should adjust stemlength for flag number.
537
538 . * breaking:
539 .  * caching breakpoints
540 .  * saving them
541 .  * specify number of lines
542
543 .* INPUTLANGUAGE
544 . * \rhythms 4 16 16 16 16; c c c c c -> c4 c16 etc. 
545 . * Language:
546 .  * \type -> \context ?
547 .  * \translator -> ?
548 .  * fix \partial 
549 .  * \bla {} vs \bla ; 
550 .  * mix engraver hacking with music ?
551 .  * \once\property  KEY = VAL
552 .  * \addtranslator, \removetranslator
553 .  * junk ^ and _ for scripts
554 .  * junk _ for lyrics.
555 .  * abstract grammar.
556 . * Figure out semicolons.
557 . * c4 4 4 4 for c4 c4 c4 c4?
558 . * <c f a>4 ?
559 . * Viola mode?
560
561                 @c c g e g 
562         for
563                 c g es g, 
564
565                 @A c g e g
566         for
567                 cis gis e gis
568 . * configure pitch_byte
569 . * rest name configurable
570
571
572 .* SMALLISH PROJECTS
573
574 . * fix confusing naming in Engraver vs Engraver_group_engraver (context)
575
576 . * progress when creating MIDI elts.
577
578 . * A range for context errors (eg. mark both { and }. )
579
580 . * lyric in staff  (sharpsharp in staff, text below)
581
582 . * half sharps/flats
583
584 . * write Dynamic_line (to group dynamics horizontally)
585
586 . * use Real for all y positions.
587
588 . * half-sharps, half-flats
589
590 . * adaptive accidental spacing.
591
592 . * handle EOF graciously in error messages.
593
594 . * midi esp.: use I32 iso int where 32 bits are needed (or assumed...)
595
596 . * stafftypes: voice names/ instrument names.
597
598 . * lily \tempo
599
600 . *   % toe to bheel   four to five
601             %   ^_u            4_5  
602             %     -                           
603             %  --|x--         --|x--
604             %  --|---         --|---
605             %  --|---         --|---
606           (where "to" is a tiny bow)
607
608 . * auxilliary file for caching info.
609
610 . * Text_crescendo
611
612 . * revise calcideal
613
614 .* IDEAS
615 . * Output data structures of Mudela in XML/SGML.
616 . * create libmudela, or liblily_frontend
617 . * move MIDI stuff (including Quantization) to a ANSI C libmidi library.
618 . * Spacing_request for manually adjusting spacing
619 . * caching breakpoints
620 . * used fixedpoint arithmetic for min. energy.
621 . * move towards incremental algorithms.
622 . * versioning stuff (cvt mudela, mudela, etc.)
623 . * dynamic loading of engravers? 
624 .* SMOBS
625 Han-Wen Nienhuys <hanwen@cs.uu.nl> writes:
626
627 >       class Foo_class {
628 >               Foo_smob *smob_ptr_;
629 >       }
630
631 >       struct Foo_smob {
632 >               Foo_class *class_ptr_
633 >       }
634
635 Usually you can get away without having this interlinked structure.
636 One piece of information you need when exporting objects to scheme is
637 the smob tag for your class.  You might store this value (a long) into
638 a class static variable, or a file static variable.  I'll use a class
639 static variable in this example.
640
641 I typically use code that works like this (untested code ahead):
642
643 class Foo_class {
644     static long *Foo_smob_tag;
645     SCM obj; // representation as a scheme object, description comes later
646 }
647
648 // call this once on startup
649 void init_Foo_class {
650     static scm_smobfuns type_rec;
651
652     type_rec.mark = foo_mark;
653     type_rec.free = foo_free;
654     type_rec.print = foo_display;
655     type_rec.equalp = 0;
656     Foo_class::Foo_smob_tag = new int(scm_new_smob(type_rec));
657 }
658
659 When you want to export an object to scheme, you put a pointer to the
660 object itself in the cdr of the cell, and the tag in the car of the
661 cell.  The code looks like this:
662
663 // Is this a Foo?
664 static int
665 foo_p(SCM obj)
666 {
667     return(SCM_NIMP(obj) && SCM_CAR(obj) == Foo_class::Foo_smob_tag);
668 }
669
670 // given a Scheme representation, return, a C++ representation
671 static Foo_class *
672 foo_unbox(SCM obj)
673 {
674     return((Foo_class*)SCM_CDR(obj));
675 }
676
677 // the SCM representation of the object is stored inside itself
678 // this will become useful when destructor gets called
679 static SCM
680 foo_box(Foo_class *foo)
681 {
682     SCM_DEFER_INTS;
683     SCM_NEWCELL(foo->obj);
684     SCM_SETCAR(foo->obj, Foo_class::Foo_smob_tag);
685     SCM_SETCDR(foo->obj, (SCM)foo);
686     SCM_ALLOW_INTS;
687     return foo->obj;
688 }
689
690 > C++ determines life time, so what is the strategy?
691
692 What happens now when the destructor gets called?  Lets set the cdr to
693 NULL, and then check for that in all of the primitive functions that
694 use your smob.  We'll call this notion 'live'; a scheme object is
695 'live' if the C++ representation still exists, it's dead if the C++
696 object is gone.  You can still have references to dead objects in
697 scheme code; it's just an error to use them.  This idea is stolen from
698 Emacs's handling of buffers ('buffer-live-p' and friends).
699
700 Add another function, foo_live_p:
701
702 static int
703 foo_live_p(SCM obj)
704 {
705     return(foo_p(obj) && SCM_CDR(obj) != NULL);
706 }
707
708 In you destructor, you need to do:
709
710 ~Foo_class()
711 {
712     SCM_CDR(this->obj, NULL);
713 }
714
715 When writing new primitives, now just check foo_live_p().
716
717 I hope the above helps,
718
719 -russ
720
721
722 --
723 "Even if you are on the right track, you'll get run over 
724 if you just sit there."  
725              --Will Rogers (1879-1935)
726
727 * OUTLINE SETUP
728 .* .EMACS
729 ;;; from outline.el
730 (defvar outline-font-lock-keywords
731   '(;; Highlight headings according to the level.
732     ;; must change this to allout node layout
733     ;;("^\\(\\*+\\)[ \t]*\\(.+\\)?[ \t]*$"
734     ("^\\([.]*[ ]*[*]\\)[ \t]*\\(.*\\)$"
735      (1 font-lock-string-face)
736      (2 (let ((len (- (match-end 1) (match-beginning 1))))
737           (or (cdr (assq len '((1 . font-lock-function-name-face)
738                                (2 . font-lock-keyword-face)
739                                (3 . font-lock-comment-face))))
740               font-lock-variable-name-face))
741         nil t))
742     ;; Highlight citations of the form [1] and [Mar94].
743     ("\\[\\([A-Z][A-Za-z]+\\)*[0-9]+\\]" . font-lock-type-face))
744   "Additional expressions to highlight in Outline mode.")
745
746 (add-hook 'outline-mode-hook
747           '(lambda ()
748             (setq font-lock-maximum-decoration t)
749             (setq font-lock-maximum-decoration t)
750             (make-local-variable 'font-lock-defaults)
751             (setq font-lock-defaults '(outline-font-lock-keywords t))
752             (font-lock-mode global-font-lock-mode)
753         ))
754  
755 (require 'allout)
756 (outline-init 't)