supernova: allocators - fix construct method
[supercollider.git] / editors / scel / sc / storeLispOn.sc
blobf3168136c797e1defcc361523404d2dbec09fca7
1 // copyright 2003 stefan kersten <steve@k-hornz.de>
2 //
3 // This program is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU General Public License as
5 // published by the Free Software Foundation; either version 2 of the
6 // License, or (at your option) any later version.
7 //
8 // This program is distributed in the hope that it will be useful, but
9 // WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // General Public License for more details.
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
16 // USA
18 + Object {
19         asLispString {
20                 var stream;
21                 stream = CollStream.new;
22                 this.storeLispOn(stream);
23                 ^stream.collection
24         }
25         asLispExpression {
26                 ^this.asLispString
27         }
28         storeLispOn { arg stream;
29                 stream << "#<" << this << ">"
30         }
33 + Symbol {
34         storeLispOn { arg stream;
35                 stream.putAll(this.asString)
36         }
39 + String {
40         asLispExpression {
41                 ^this
42         }
43         storeLispOn { arg stream;
44                 // note, extra space after \\ is for emacs paren matching
45                 // not syntactically significant
46                 stream.put($").putAll(this.escapeChar($\\ ).escapeChar($")).put($")
47         }
50 + Char {
51         storeLispOn { arg stream;
52                 stream.putAll("?"++this)
53         }
56 + Color {
57         storeLispOn { arg stream;
58                 ("#"++(red*255).asInteger.asHexString(2)
59                         ++(green*255).asInteger.asHexString(2)
60                         ++(blue*255).asInteger.asHexString(2)).storeLispOn(stream)
61         }
64 + Number {
65         storeLispOn { arg stream;
66                 stream << this
67         }
70 + Nil {
71         storeLispOn { arg stream;
72                 stream << "nil"
73         }
76 + True {
77         storeLispOn { arg stream;
78                 stream.put($t)
79         }
82 + False {
83         storeLispOn { arg stream;
84                 nil.storeLispOn(stream)
85         }
88 + Association {
89         storeLispOn { arg stream;
90                 stream.put($();
91                 this.key.storeLispOn(stream);
92                 stream.space.put($.).space;
93                 this.value.storeLispOn(stream);
94                 stream.put($));
95         }
98 + Collection {
99         lispDo { arg function;
100                 this.do(function);
101         }
103         storeLispOn { arg stream;
104                 stream.put($();
105                 this.lispDo { arg x, i;
106                         if (i != 0) { stream.space };
107                         x.storeLispOn(stream);
108                 };
109                 stream.put($));
110         }
113 + Dictionary {
114         lispDo { arg function;
115                 this.associationsDo(function)
116         }
119 // EOF