OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 *cursor += 1; | 269 *cursor += 1; |
270 return kBadChar; | 270 return kBadChar; |
271 } | 271 } |
272 *cursor += 4; | 272 *cursor += 4; |
273 return code_point; | 273 return code_point; |
274 } | 274 } |
275 *cursor += 1; | 275 *cursor += 1; |
276 return kBadChar; | 276 return kBadChar; |
277 } | 277 } |
278 | 278 |
| 279 |
279 const byte* Utf8::ReadBlock(Buffer<const char*> str, byte* buffer, | 280 const byte* Utf8::ReadBlock(Buffer<const char*> str, byte* buffer, |
280 unsigned capacity, unsigned* chars_read_ptr, unsigned* offset_ptr) { | 281 unsigned capacity, unsigned* chars_read_ptr, unsigned* offset_ptr) { |
281 unsigned offset = *offset_ptr; | 282 unsigned offset = *offset_ptr; |
282 // Bail out early if we've reached the end of the string. | 283 // Bail out early if we've reached the end of the string. |
283 if (offset == str.length()) { | 284 if (offset == str.length()) { |
284 *chars_read_ptr = 0; | 285 *chars_read_ptr = 0; |
285 return NULL; | 286 return NULL; |
286 } | 287 } |
287 const byte* data = reinterpret_cast<const byte*>(str.data()); | 288 const byte* data = reinterpret_cast<const byte*>(str.data()); |
288 if (data[offset] <= kMaxOneByteChar) { | 289 if (data[offset] <= kMaxOneByteChar) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 unsigned CharacterStream::Length() { | 332 unsigned CharacterStream::Length() { |
332 unsigned result = 0; | 333 unsigned result = 0; |
333 while (has_more()) { | 334 while (has_more()) { |
334 result++; | 335 result++; |
335 GetNext(); | 336 GetNext(); |
336 } | 337 } |
337 Rewind(); | 338 Rewind(); |
338 return result; | 339 return result; |
339 } | 340 } |
340 | 341 |
| 342 unsigned CharacterStream::Utf16Length() { |
| 343 unsigned result = 0; |
| 344 while (has_more()) { |
| 345 uchar c = GetNext(); |
| 346 result += c > Utf16::kMaxNonSurrogateCharCode ? 2 : 1; |
| 347 } |
| 348 Rewind(); |
| 349 return result; |
| 350 } |
| 351 |
341 void CharacterStream::Seek(unsigned position) { | 352 void CharacterStream::Seek(unsigned position) { |
342 Rewind(); | 353 Rewind(); |
343 for (unsigned i = 0; i < position; i++) { | 354 for (unsigned i = 0; i < position; i++) { |
344 GetNext(); | 355 GetNext(); |
345 } | 356 } |
346 } | 357 } |
347 | 358 |
348 // Uppercase: point.category == 'Lu' | 359 // Uppercase: point.category == 'Lu' |
349 | 360 |
350 static const uint16_t kUppercaseTable0Size = 450; | 361 static const uint16_t kUppercaseTable0Size = 450; |
(...skipping 1500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1851 + kEcma262UnCanonicalizeMultiStrings0Size * sizeof(MultiCharacterSpecialCa
se<4>) // NOLINT | 1862 + kEcma262UnCanonicalizeMultiStrings0Size * sizeof(MultiCharacterSpecialCa
se<4>) // NOLINT |
1852 + kEcma262UnCanonicalizeMultiStrings1Size * sizeof(MultiCharacterSpecialCa
se<2>) // NOLINT | 1863 + kEcma262UnCanonicalizeMultiStrings1Size * sizeof(MultiCharacterSpecialCa
se<2>) // NOLINT |
1853 + kEcma262UnCanonicalizeMultiStrings5Size * sizeof(MultiCharacterSpecialCa
se<2>) // NOLINT | 1864 + kEcma262UnCanonicalizeMultiStrings5Size * sizeof(MultiCharacterSpecialCa
se<2>) // NOLINT |
1854 + kEcma262UnCanonicalizeMultiStrings7Size * sizeof(MultiCharacterSpecialCa
se<2>) // NOLINT | 1865 + kEcma262UnCanonicalizeMultiStrings7Size * sizeof(MultiCharacterSpecialCa
se<2>) // NOLINT |
1855 + kCanonicalizationRangeMultiStrings0Size * sizeof(MultiCharacterSpecialCa
se<1>) // NOLINT | 1866 + kCanonicalizationRangeMultiStrings0Size * sizeof(MultiCharacterSpecialCa
se<1>) // NOLINT |
1856 + kCanonicalizationRangeMultiStrings1Size * sizeof(MultiCharacterSpecialCa
se<1>) // NOLINT | 1867 + kCanonicalizationRangeMultiStrings1Size * sizeof(MultiCharacterSpecialCa
se<1>) // NOLINT |
1857 + kCanonicalizationRangeMultiStrings7Size * sizeof(MultiCharacterSpecialCa
se<1>); // NOLINT | 1868 + kCanonicalizationRangeMultiStrings7Size * sizeof(MultiCharacterSpecialCa
se<1>); // NOLINT |
1858 } | 1869 } |
1859 | 1870 |
1860 } // namespace unicode | 1871 } // namespace unicode |
OLD | NEW |