Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: src/json-stringifier.h

Issue 11232058: Fix Windows build. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 } 564 }
565 565
566 566
567 template <typename SrcChar, typename DestChar> 567 template <typename SrcChar, typename DestChar>
568 void BasicJsonStringifier::SerializeStringUnchecked_(const SrcChar* src, 568 void BasicJsonStringifier::SerializeStringUnchecked_(const SrcChar* src,
569 DestChar* dest, 569 DestChar* dest,
570 int length) { 570 int length) {
571 dest += current_index_; 571 dest += current_index_;
572 DestChar* dest_start = dest; 572 DestChar* dest_start = dest;
573 573
574 // Assert that uc16 character is not truncated down to 8 bit.
575 // The <uc16, char> version of this method must not be called.
576 ASSERT(sizeof(*dest) >= sizeof(*src));
Michael Starzinger 2012/10/23 09:36:07 Could we turn that into a STATIC_ASSERT or does si
Yang 2012/10/23 09:39:35 As discussed offline, the <uc16, char> version is
577
574 *(dest++) = '"'; 578 *(dest++) = '"';
575 for (int i = 0; i < length; i++) { 579 for (int i = 0; i < length; i++) {
576 SrcChar c = src[i]; 580 SrcChar c = src[i];
577 if (DoNotEscape(c)) { 581 if (DoNotEscape(c)) {
578 *(dest++) = c; 582 *(dest++) = static_cast<DestChar>(c);
579 } else { 583 } else {
580 const char* chars = &JsonEscapeTable[c * kJsonEscapeTableEntrySize]; 584 const char* chars = &JsonEscapeTable[c * kJsonEscapeTableEntrySize];
581 while (*chars != '\0') *(dest++) = *(chars++); 585 while (*chars != '\0') *(dest++) = *(chars++);
582 } 586 }
583 } 587 }
584 588
585 *(dest++) = '"'; 589 *(dest++) = '"';
586 current_index_ += dest - dest_start; 590 current_index_ += dest - dest_start;
587 } 591 }
588 592
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 SerializeString_<false, char>(flat.ToAsciiVector(), object); 677 SerializeString_<false, char>(flat.ToAsciiVector(), object);
674 } else { 678 } else {
675 SerializeString_<false, uc16>(flat.ToUC16Vector(), object); 679 SerializeString_<false, uc16>(flat.ToUC16Vector(), object);
676 } 680 }
677 } 681 }
678 } 682 }
679 683
680 } } // namespace v8::internal 684 } } // namespace v8::internal
681 685
682 #endif // V8_JSON_STRINGIFIER_H_ 686 #endif // V8_JSON_STRINGIFIER_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698