OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef V8_STRING_BUILDER_H_ | 5 #ifndef V8_STRING_BUILDER_H_ |
6 #define V8_STRING_BUILDER_H_ | 6 #define V8_STRING_BUILDER_H_ |
7 | 7 |
8 #include "src/assert-scope.h" | 8 #include "src/assert-scope.h" |
9 #include "src/factory.h" | 9 #include "src/factory.h" |
10 #include "src/handles.h" | 10 #include "src/handles.h" |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 | 286 |
287 INLINE(void AppendCString(const char* s)) { | 287 INLINE(void AppendCString(const char* s)) { |
288 const uint8_t* u = reinterpret_cast<const uint8_t*>(s); | 288 const uint8_t* u = reinterpret_cast<const uint8_t*>(s); |
289 if (encoding_ == String::ONE_BYTE_ENCODING) { | 289 if (encoding_ == String::ONE_BYTE_ENCODING) { |
290 while (*u != '\0') Append<uint8_t, uint8_t>(*(u++)); | 290 while (*u != '\0') Append<uint8_t, uint8_t>(*(u++)); |
291 } else { | 291 } else { |
292 while (*u != '\0') Append<uint8_t, uc16>(*(u++)); | 292 while (*u != '\0') Append<uint8_t, uc16>(*(u++)); |
293 } | 293 } |
294 } | 294 } |
295 | 295 |
| 296 INLINE(void AppendCString(const uc16* s)) { |
| 297 if (encoding_ == String::ONE_BYTE_ENCODING) { |
| 298 while (*s != '\0') Append<uc16, uint8_t>(*(s++)); |
| 299 } else { |
| 300 while (*s != '\0') Append<uc16, uc16>(*(s++)); |
| 301 } |
| 302 } |
| 303 |
296 INLINE(bool CurrentPartCanFit(int length)) { | 304 INLINE(bool CurrentPartCanFit(int length)) { |
297 return part_length_ - current_index_ > length; | 305 return part_length_ - current_index_ > length; |
298 } | 306 } |
299 | 307 |
300 void AppendString(Handle<String> string); | 308 void AppendString(Handle<String> string); |
301 | 309 |
302 MaybeHandle<String> Finish(); | 310 MaybeHandle<String> Finish(); |
303 | 311 |
304 // Change encoding to two-byte. | 312 // Change encoding to two-byte. |
305 void ChangeEncoding() { | 313 void ChangeEncoding() { |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 DCHECK_EQ(String::TWO_BYTE_ENCODING, encoding_); | 436 DCHECK_EQ(String::TWO_BYTE_ENCODING, encoding_); |
429 SeqTwoByteString::cast(*current_part_) | 437 SeqTwoByteString::cast(*current_part_) |
430 ->SeqTwoByteStringSet(current_index_++, c); | 438 ->SeqTwoByteStringSet(current_index_++, c); |
431 } | 439 } |
432 if (current_index_ == part_length_) Extend(); | 440 if (current_index_ == part_length_) Extend(); |
433 } | 441 } |
434 } // namespace internal | 442 } // namespace internal |
435 } // namespace v8 | 443 } // namespace v8 |
436 | 444 |
437 #endif // V8_STRING_BUILDER_H_ | 445 #endif // V8_STRING_BUILDER_H_ |
OLD | NEW |