annotate dmd/OutBuffer.d @ 189:a4c9de8e39b3

Now compileable with dmd2.053
author Abscissa
date Wed, 08 Jun 2011 02:21:32 -0400
parents e3afd1303184
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1 module dmd.OutBuffer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2
114
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 93
diff changeset
3 import dmd.common;
189
a4c9de8e39b3 Now compileable with dmd2.053
Abscissa
parents: 178
diff changeset
4 import core.vararg;
34
544b922227c7 update to work with dmd 2.048
korDen
parents: 12
diff changeset
5 import std.exception;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
6
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
7 import core.stdc.stdlib;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
8 import core.stdc.string;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
9
4
d706d958e4e8 Step 2 of restoring GC functionality.
korDen
parents: 2
diff changeset
10 import core.memory;
5
63623152e82a Fixed memory corruption bug which was introduced when attempting to restore GC functionality
dkoroskin <>
parents: 4
diff changeset
11 import core.stdc.stdlib;
2
7427ded8caf7 Removed unreferenced modules
korDen
parents: 0
diff changeset
12
178
e3afd1303184 Many small bugs fixed
korDen
parents: 175
diff changeset
13 import dmd.TObject;
e3afd1303184 Many small bugs fixed
korDen
parents: 175
diff changeset
14
e3afd1303184 Many small bugs fixed
korDen
parents: 175
diff changeset
15 class OutBuffer : TObject
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17 ubyte* data;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18 uint offset;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19 uint size;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21 this()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22 {
178
e3afd1303184 Many small bugs fixed
korDen
parents: 175
diff changeset
23 register();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24 // do nothing
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27 final void* extractData()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29 void* p = cast(void*)data;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
30
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31 data = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32 offset = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33 size = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35 return p;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38 void mark()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43 final void reserve(uint nbytes)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 //printf("OutBuffer::reserve: size = %d, offset = %d, nbytes = %d\n", size, offset, nbytes);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46 if (size - offset < nbytes)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48 size = (offset + nbytes) * 2;
5
63623152e82a Fixed memory corruption bug which was introduced when attempting to restore GC functionality
dkoroskin <>
parents: 4
diff changeset
49 data = cast(ubyte*)realloc(data, size);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
50 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53 final void setsize(uint size)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
58 final void reset()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60 offset = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63 final void write(const(void)* data, uint nbytes)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
64 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
65 reserve(nbytes);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
66 memcpy(this.data + offset, data, nbytes);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
67 offset += nbytes;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
68 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
69
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70 final void writebstring(ubyte* string_)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
73 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
74
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
75 final void writestring(const(char)[] string_)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77 write(string_.ptr , string_.length);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
78 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
79
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80 final void writedstring(const(char)* string_)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
81 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
82 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
83 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
84
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
85 final void writedstring(const(wchar)* string_)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
86 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
87 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
90 final void prependstring(const(char)[] string_)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
91 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
92 uint len = string_.length;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
93 reserve(len);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94 memmove(data + len, data, offset);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
95 memcpy(data, string_.ptr, len);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96 offset += len;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
97 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
98
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99 final void writenl() // write newline
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
100 {
114
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 93
diff changeset
101 version (Windows)
93
df6d0f967680 implemented a whole bunch of methods to make phobos 2.035 compile
Trass3r
parents: 68
diff changeset
102 {
df6d0f967680 implemented a whole bunch of methods to make phobos 2.035 compile
Trass3r
parents: 68
diff changeset
103 version (M_UNICODE)
df6d0f967680 implemented a whole bunch of methods to make phobos 2.035 compile
Trass3r
parents: 68
diff changeset
104 {
68
ee3a9f34dc48 final bits of codegen implementation to compile Phobos
korDen
parents: 34
diff changeset
105 write4(0x000A000D); // newline is CR,LF on Microsoft OS's
93
df6d0f967680 implemented a whole bunch of methods to make phobos 2.035 compile
Trass3r
parents: 68
diff changeset
106 }
df6d0f967680 implemented a whole bunch of methods to make phobos 2.035 compile
Trass3r
parents: 68
diff changeset
107 else
df6d0f967680 implemented a whole bunch of methods to make phobos 2.035 compile
Trass3r
parents: 68
diff changeset
108 {
68
ee3a9f34dc48 final bits of codegen implementation to compile Phobos
korDen
parents: 34
diff changeset
109 writeword(0x0A0D); // newline is CR,LF on Microsoft OS's
ee3a9f34dc48 final bits of codegen implementation to compile Phobos
korDen
parents: 34
diff changeset
110 }
93
df6d0f967680 implemented a whole bunch of methods to make phobos 2.035 compile
Trass3r
parents: 68
diff changeset
111 }
df6d0f967680 implemented a whole bunch of methods to make phobos 2.035 compile
Trass3r
parents: 68
diff changeset
112 else
df6d0f967680 implemented a whole bunch of methods to make phobos 2.035 compile
Trass3r
parents: 68
diff changeset
113 {
df6d0f967680 implemented a whole bunch of methods to make phobos 2.035 compile
Trass3r
parents: 68
diff changeset
114 version (M_UNICODE)
df6d0f967680 implemented a whole bunch of methods to make phobos 2.035 compile
Trass3r
parents: 68
diff changeset
115 {
68
ee3a9f34dc48 final bits of codegen implementation to compile Phobos
korDen
parents: 34
diff changeset
116 writeword('\n');
93
df6d0f967680 implemented a whole bunch of methods to make phobos 2.035 compile
Trass3r
parents: 68
diff changeset
117 }
df6d0f967680 implemented a whole bunch of methods to make phobos 2.035 compile
Trass3r
parents: 68
diff changeset
118 else
df6d0f967680 implemented a whole bunch of methods to make phobos 2.035 compile
Trass3r
parents: 68
diff changeset
119 {
68
ee3a9f34dc48 final bits of codegen implementation to compile Phobos
korDen
parents: 34
diff changeset
120 writeByte('\n');
ee3a9f34dc48 final bits of codegen implementation to compile Phobos
korDen
parents: 34
diff changeset
121 }
ee3a9f34dc48 final bits of codegen implementation to compile Phobos
korDen
parents: 34
diff changeset
122 }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
123 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
124
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
125 final void writeByte(uint b)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
126 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
127 reserve(1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
128 this.data[offset] = cast(ubyte)b;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
129 offset++;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
130 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
131
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
132 final void writebyte(uint b) { writeByte(b); }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
133
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
134 final void writeUTF8(uint b)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
135 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
136 reserve(6);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
137 if (b <= 0x7F)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
138 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
139 this.data[offset] = cast(ubyte)b;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
140 offset++;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
141 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
142 else if (b <= 0x7FF)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
143 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
144 this.data[offset + 0] = cast(ubyte)((b >> 6) | 0xC0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
145 this.data[offset + 1] = cast(ubyte)((b & 0x3F) | 0x80);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
146 offset += 2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
147 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
148 else if (b <= 0xFFFF)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
149 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
150 this.data[offset + 0] = cast(ubyte)((b >> 12) | 0xE0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
151 this.data[offset + 1] = cast(ubyte)(((b >> 6) & 0x3F) | 0x80);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
152 this.data[offset + 2] = cast(ubyte)((b & 0x3F) | 0x80);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
153 offset += 3;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
154 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
155 else if (b <= 0x1FFFFF)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
156 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
157 this.data[offset + 0] = cast(ubyte)((b >> 18) | 0xF0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
158 this.data[offset + 1] = cast(ubyte)(((b >> 12) & 0x3F) | 0x80);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
159 this.data[offset + 2] = cast(ubyte)(((b >> 6) & 0x3F) | 0x80);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
160 this.data[offset + 3] = cast(ubyte)((b & 0x3F) | 0x80);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
161 offset += 4;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
162 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
163 else if (b <= 0x3FFFFFF)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
164 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
165 this.data[offset + 0] = cast(ubyte)((b >> 24) | 0xF8);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
166 this.data[offset + 1] = cast(ubyte)(((b >> 18) & 0x3F) | 0x80);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
167 this.data[offset + 2] = cast(ubyte)(((b >> 12) & 0x3F) | 0x80);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
168 this.data[offset + 3] = cast(ubyte)(((b >> 6) & 0x3F) | 0x80);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
169 this.data[offset + 4] = cast(ubyte)((b & 0x3F) | 0x80);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
170 offset += 5;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
171 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
172 else if (b <= 0x7FFFFFFF)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
173 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
174 this.data[offset + 0] = cast(ubyte)((b >> 30) | 0xFC);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
175 this.data[offset + 1] = cast(ubyte)(((b >> 24) & 0x3F) | 0x80);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
176 this.data[offset + 2] = cast(ubyte)(((b >> 18) & 0x3F) | 0x80);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
177 this.data[offset + 3] = cast(ubyte)(((b >> 12) & 0x3F) | 0x80);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
178 this.data[offset + 4] = cast(ubyte)(((b >> 6) & 0x3F) | 0x80);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
179 this.data[offset + 5] = cast(ubyte)((b & 0x3F) | 0x80);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
180 offset += 6;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
181 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
182 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
183 assert(0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
184 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
185
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
186 final void writedchar(uint b)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
187 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
188 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
189 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
190
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
191 final void prependbyte(uint b)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
192 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
193 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
194 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
195
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
196 final void writeword(uint w)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
197 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
198 reserve(2);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
199 *cast(ushort*)(this.data + offset) = cast(ushort)w;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
200 offset += 2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
201 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
202
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
203 final void writeUTF16(uint w)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
204 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
205 reserve(4);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
206 if (w <= 0xFFFF)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
207 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
208 *cast(ushort*)(this.data + offset) = cast(ushort)w;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
209 offset += 2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
210 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
211 else if (w <= 0x10FFFF)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
212 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
213 *cast(ushort*)(this.data + offset) = cast(ushort)((w >> 10) + 0xD7C0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
214 *cast(ushort*)(this.data + offset + 2) = cast(ushort)((w & 0x3FF) | 0xDC00);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
215 offset += 4;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
216 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
217 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
218 assert(0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
219 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
220
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
221 final void write4(uint w)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
222 {
12
832f71e6f96c *Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents: 5
diff changeset
223 reserve(4);
832f71e6f96c *Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents: 5
diff changeset
224 *cast(uint*)(this.data + offset) = w;
832f71e6f96c *Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents: 5
diff changeset
225 offset += 4;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
226 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
227
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
228 final void write(OutBuffer buf)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
229 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
230 if (buf)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
231 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
232 reserve(buf.offset);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
233 memcpy(data + offset, buf.data, buf.offset);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
234 offset += buf.offset;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
235 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
236 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
237
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
238 final void write(Object obj)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
239 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
240 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
241 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
242
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
243 final void fill0(uint nbytes)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
244 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
245 reserve(nbytes);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
246 memset(data + offset, 0, nbytes);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
247 offset += nbytes;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
248 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
249
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
250 final void align_(uint size)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
251 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
252 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
253 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
254
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
255 void vprintf(const(char)* format, va_list args)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
256 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
257 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
258 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
259
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
260 void printf(T...)(string format, T t)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
261 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
262 string s = std.string.format(format, t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
263 writestring(s);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
264 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
265
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
266 version (M_UNICODE) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
267 /// void vprintf(const uint short *format, va_list args);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
268 /// void printf(const uint short *format, ...);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
269 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
270 final void bracket(char left, char right)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
271 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
272 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
273 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
274
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
275 final uint bracket(uint i, const(char)* left, uint j, const(char)* right)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
276 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
277 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
278 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
279
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
280 final void spread(uint offset, uint nbytes)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
281 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
282 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
283 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
284
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
285 final uint insert(uint offset, const(void)* data, uint nbytes)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
286 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
287 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
288 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
289
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
290 final void remove(uint offset, uint nbytes)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
291 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
292 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
293 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
294
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
295 string toChars()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
296 {
5
63623152e82a Fixed memory corruption bug which was introduced when attempting to restore GC functionality
dkoroskin <>
parents: 4
diff changeset
297 char[] s = getString();
175
94b6033c07f3 get rid of globals
korDen
parents: 114
diff changeset
298 char* copy = cast(char*)GC.malloc(s.length);
5
63623152e82a Fixed memory corruption bug which was introduced when attempting to restore GC functionality
dkoroskin <>
parents: 4
diff changeset
299 memcpy(copy, s.ptr, s.length);
63623152e82a Fixed memory corruption bug which was introduced when attempting to restore GC functionality
dkoroskin <>
parents: 4
diff changeset
300 return assumeUnique(copy[0..s.length]);
63623152e82a Fixed memory corruption bug which was introduced when attempting to restore GC functionality
dkoroskin <>
parents: 4
diff changeset
301
63623152e82a Fixed memory corruption bug which was introduced when attempting to restore GC functionality
dkoroskin <>
parents: 4
diff changeset
302 //return getString().idup;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
303 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
304
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
305 final string extractString()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
306 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
307 char[] s = getString();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
308 data = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
309 offset = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
310 size = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
311
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
312 return assumeUnique(s);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
313 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
314
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
315 final char[] getString()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
316 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
317 char* s = cast(char*)data;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
318 return s[0..offset];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
319 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
320 }