OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // This file was generated at 2014-02-07 15:31:16.733174 | 5 // This file was generated at 2014-02-07 15:31:16.733174 |
6 | 6 |
7 #include "src/unicode-inl.h" | 7 #include "src/unicode-inl.h" |
8 #include <stdio.h> | 8 #include <stdio.h> |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 | 10 |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 unsigned stream_length) { | 264 unsigned stream_length) { |
265 // Assume everything will fit in the buffer and stream won't be needed. | 265 // Assume everything will fit in the buffer and stream won't be needed. |
266 last_byte_of_buffer_unused_ = false; | 266 last_byte_of_buffer_unused_ = false; |
267 unbuffered_start_ = NULL; | 267 unbuffered_start_ = NULL; |
268 bool writing_to_buffer = true; | 268 bool writing_to_buffer = true; |
269 // Loop until stream is read, writing to buffer as long as buffer has space. | 269 // Loop until stream is read, writing to buffer as long as buffer has space. |
270 unsigned utf16_length = 0; | 270 unsigned utf16_length = 0; |
271 while (stream_length != 0) { | 271 while (stream_length != 0) { |
272 unsigned cursor = 0; | 272 unsigned cursor = 0; |
273 uint32_t character = Utf8::ValueOf(stream, stream_length, &cursor); | 273 uint32_t character = Utf8::ValueOf(stream, stream_length, &cursor); |
274 ASSERT(cursor > 0 && cursor <= stream_length); | 274 DCHECK(cursor > 0 && cursor <= stream_length); |
275 stream += cursor; | 275 stream += cursor; |
276 stream_length -= cursor; | 276 stream_length -= cursor; |
277 bool is_two_characters = character > Utf16::kMaxNonSurrogateCharCode; | 277 bool is_two_characters = character > Utf16::kMaxNonSurrogateCharCode; |
278 utf16_length += is_two_characters ? 2 : 1; | 278 utf16_length += is_two_characters ? 2 : 1; |
279 // Don't need to write to the buffer, but still need utf16_length. | 279 // Don't need to write to the buffer, but still need utf16_length. |
280 if (!writing_to_buffer) continue; | 280 if (!writing_to_buffer) continue; |
281 // Write out the characters to the buffer. | 281 // Write out the characters to the buffer. |
282 // Must check for equality with buffer_length as we've already updated it. | 282 // Must check for equality with buffer_length as we've already updated it. |
283 if (utf16_length <= buffer_length) { | 283 if (utf16_length <= buffer_length) { |
284 if (is_two_characters) { | 284 if (is_two_characters) { |
285 *buffer++ = Utf16::LeadSurrogate(character); | 285 *buffer++ = Utf16::LeadSurrogate(character); |
286 *buffer++ = Utf16::TrailSurrogate(character); | 286 *buffer++ = Utf16::TrailSurrogate(character); |
287 } else { | 287 } else { |
288 *buffer++ = character; | 288 *buffer++ = character; |
289 } | 289 } |
290 if (utf16_length == buffer_length) { | 290 if (utf16_length == buffer_length) { |
291 // Just wrote last character of buffer | 291 // Just wrote last character of buffer |
292 writing_to_buffer = false; | 292 writing_to_buffer = false; |
293 unbuffered_start_ = stream; | 293 unbuffered_start_ = stream; |
294 } | 294 } |
295 continue; | 295 continue; |
296 } | 296 } |
297 // Have gone over buffer. | 297 // Have gone over buffer. |
298 // Last char of buffer is unused, set cursor back. | 298 // Last char of buffer is unused, set cursor back. |
299 ASSERT(is_two_characters); | 299 DCHECK(is_two_characters); |
300 writing_to_buffer = false; | 300 writing_to_buffer = false; |
301 last_byte_of_buffer_unused_ = true; | 301 last_byte_of_buffer_unused_ = true; |
302 unbuffered_start_ = stream - cursor; | 302 unbuffered_start_ = stream - cursor; |
303 } | 303 } |
304 utf16_length_ = utf16_length; | 304 utf16_length_ = utf16_length; |
305 } | 305 } |
306 | 306 |
307 | 307 |
308 void Utf8DecoderBase::WriteUtf16Slow(const uint8_t* stream, | 308 void Utf8DecoderBase::WriteUtf16Slow(const uint8_t* stream, |
309 uint16_t* data, | 309 uint16_t* data, |
310 unsigned data_length) { | 310 unsigned data_length) { |
311 while (data_length != 0) { | 311 while (data_length != 0) { |
312 unsigned cursor = 0; | 312 unsigned cursor = 0; |
313 uint32_t character = Utf8::ValueOf(stream, Utf8::kMaxEncodedSize, &cursor); | 313 uint32_t character = Utf8::ValueOf(stream, Utf8::kMaxEncodedSize, &cursor); |
314 // There's a total lack of bounds checking for stream | 314 // There's a total lack of bounds checking for stream |
315 // as it was already done in Reset. | 315 // as it was already done in Reset. |
316 stream += cursor; | 316 stream += cursor; |
317 if (character > unibrow::Utf16::kMaxNonSurrogateCharCode) { | 317 if (character > unibrow::Utf16::kMaxNonSurrogateCharCode) { |
318 *data++ = Utf16::LeadSurrogate(character); | 318 *data++ = Utf16::LeadSurrogate(character); |
319 *data++ = Utf16::TrailSurrogate(character); | 319 *data++ = Utf16::TrailSurrogate(character); |
320 ASSERT(data_length > 1); | 320 DCHECK(data_length > 1); |
321 data_length -= 2; | 321 data_length -= 2; |
322 } else { | 322 } else { |
323 *data++ = character; | 323 *data++ = character; |
324 data_length -= 1; | 324 data_length -= 1; |
325 } | 325 } |
326 } | 326 } |
327 } | 327 } |
328 | 328 |
329 | 329 |
330 // Uppercase: point.category == 'Lu' | 330 // Uppercase: point.category == 'Lu' |
(...skipping 1486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1817 + kEcma262UnCanonicalizeMultiStrings0Size * sizeof(MultiCharacterSpecialCa
se<4>) // NOLINT | 1817 + kEcma262UnCanonicalizeMultiStrings0Size * sizeof(MultiCharacterSpecialCa
se<4>) // NOLINT |
1818 + kEcma262UnCanonicalizeMultiStrings1Size * sizeof(MultiCharacterSpecialCa
se<2>) // NOLINT | 1818 + kEcma262UnCanonicalizeMultiStrings1Size * sizeof(MultiCharacterSpecialCa
se<2>) // NOLINT |
1819 + kEcma262UnCanonicalizeMultiStrings5Size * sizeof(MultiCharacterSpecialCa
se<2>) // NOLINT | 1819 + kEcma262UnCanonicalizeMultiStrings5Size * sizeof(MultiCharacterSpecialCa
se<2>) // NOLINT |
1820 + kEcma262UnCanonicalizeMultiStrings7Size * sizeof(MultiCharacterSpecialCa
se<2>) // NOLINT | 1820 + kEcma262UnCanonicalizeMultiStrings7Size * sizeof(MultiCharacterSpecialCa
se<2>) // NOLINT |
1821 + kCanonicalizationRangeMultiStrings0Size * sizeof(MultiCharacterSpecialCa
se<1>) // NOLINT | 1821 + kCanonicalizationRangeMultiStrings0Size * sizeof(MultiCharacterSpecialCa
se<1>) // NOLINT |
1822 + kCanonicalizationRangeMultiStrings1Size * sizeof(MultiCharacterSpecialCa
se<1>) // NOLINT | 1822 + kCanonicalizationRangeMultiStrings1Size * sizeof(MultiCharacterSpecialCa
se<1>) // NOLINT |
1823 + kCanonicalizationRangeMultiStrings7Size * sizeof(MultiCharacterSpecialCa
se<1>); // NOLINT | 1823 + kCanonicalizationRangeMultiStrings7Size * sizeof(MultiCharacterSpecialCa
se<1>); // NOLINT |
1824 } | 1824 } |
1825 | 1825 |
1826 } // namespace unicode | 1826 } // namespace unicode |
OLD | NEW |