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