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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 "T\0 U\0 V\0 W\0 " | 199 "T\0 U\0 V\0 W\0 " |
200 "X\0 Y\0 Z\0 [\0 " | 200 "X\0 Y\0 Z\0 [\0 " |
201 "\\\\\0 ]\0 ^\0 _\0 " | 201 "\\\\\0 ]\0 ^\0 _\0 " |
202 "`\0 a\0 b\0 c\0 " | 202 "`\0 a\0 b\0 c\0 " |
203 "d\0 e\0 f\0 g\0 " | 203 "d\0 e\0 f\0 g\0 " |
204 "h\0 i\0 j\0 k\0 " | 204 "h\0 i\0 j\0 k\0 " |
205 "l\0 m\0 n\0 o\0 " | 205 "l\0 m\0 n\0 o\0 " |
206 "p\0 q\0 r\0 s\0 " | 206 "p\0 q\0 r\0 s\0 " |
207 "t\0 u\0 v\0 w\0 " | 207 "t\0 u\0 v\0 w\0 " |
208 "x\0 y\0 z\0 {\0 " | 208 "x\0 y\0 z\0 {\0 " |
209 "|\0 }\0 ~\0 \177\0 "; | 209 "|\0 }\0 ~\0 \177\0 " |
210 | 210 "\200\0 \201\0 \202\0 \203\0 " |
| 211 "\204\0 \205\0 \206\0 \207\0 " |
| 212 "\210\0 \211\0 \212\0 \213\0 " |
| 213 "\214\0 \215\0 \216\0 \217\0 " |
| 214 "\220\0 \221\0 \222\0 \223\0 " |
| 215 "\224\0 \225\0 \226\0 \227\0 " |
| 216 "\230\0 \231\0 \232\0 \233\0 " |
| 217 "\234\0 \235\0 \236\0 \237\0 " |
| 218 "\240\0 \241\0 \242\0 \243\0 " |
| 219 "\244\0 \245\0 \246\0 \247\0 " |
| 220 "\250\0 \251\0 \252\0 \253\0 " |
| 221 "\254\0 \255\0 \256\0 \257\0 " |
| 222 "\260\0 \261\0 \262\0 \263\0 " |
| 223 "\264\0 \265\0 \266\0 \267\0 " |
| 224 "\270\0 \271\0 \272\0 \273\0 " |
| 225 "\274\0 \275\0 \276\0 \277\0 " |
| 226 "\300\0 \301\0 \302\0 \303\0 " |
| 227 "\304\0 \305\0 \306\0 \307\0 " |
| 228 "\310\0 \311\0 \312\0 \313\0 " |
| 229 "\314\0 \315\0 \316\0 \317\0 " |
| 230 "\320\0 \321\0 \322\0 \323\0 " |
| 231 "\324\0 \325\0 \326\0 \327\0 " |
| 232 "\330\0 \331\0 \332\0 \333\0 " |
| 233 "\334\0 \335\0 \336\0 \337\0 " |
| 234 "\340\0 \341\0 \342\0 \343\0 " |
| 235 "\344\0 \345\0 \346\0 \347\0 " |
| 236 "\350\0 \351\0 \352\0 \353\0 " |
| 237 "\354\0 \355\0 \356\0 \357\0 " |
| 238 "\360\0 \361\0 \362\0 \363\0 " |
| 239 "\364\0 \365\0 \366\0 \367\0 " |
| 240 "\370\0 \371\0 \372\0 \373\0 " |
| 241 "\374\0 \375\0 \376\0 \377\0 "; |
211 | 242 |
212 BasicJsonStringifier::BasicJsonStringifier(Isolate* isolate) | 243 BasicJsonStringifier::BasicJsonStringifier(Isolate* isolate) |
213 : isolate_(isolate), current_index_(0), is_ascii_(true) { | 244 : isolate_(isolate), current_index_(0), is_ascii_(true) { |
214 factory_ = isolate_->factory(); | 245 factory_ = isolate_->factory(); |
215 accumulator_store_ = Handle<JSValue>::cast( | 246 accumulator_store_ = Handle<JSValue>::cast( |
216 factory_->ToObject(factory_->empty_string())); | 247 factory_->ToObject(factory_->empty_string())); |
217 part_length_ = kInitialPartLength; | 248 part_length_ = kInitialPartLength; |
218 current_part_ = factory_->NewRawOneByteString(kInitialPartLength); | 249 current_part_ = factory_->NewRawOneByteString(kInitialPartLength); |
219 tojson_symbol_ = | 250 tojson_symbol_ = |
220 factory_->LookupOneByteSymbol(STATIC_ASCII_VECTOR("toJSON")); | 251 factory_->LookupOneByteSymbol(STATIC_ASCII_VECTOR("toJSON")); |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
691 vector = GetCharVector<Char>(string); | 722 vector = GetCharVector<Char>(string); |
692 string_location = *string; | 723 string_location = *string; |
693 } | 724 } |
694 } | 725 } |
695 } | 726 } |
696 | 727 |
697 Append_<is_ascii, uint8_t>('"'); | 728 Append_<is_ascii, uint8_t>('"'); |
698 } | 729 } |
699 | 730 |
700 | 731 |
701 template <typename Char> | 732 template <> |
702 bool BasicJsonStringifier::DoNotEscape(Char c) { | 733 bool BasicJsonStringifier::DoNotEscape(uint8_t c) { |
703 return (c >= 0x80) || (c >= '#' && c <= '~' && c != '\\'); | 734 return c >= '#' && c <= '~' && c != '\\'; |
704 } | 735 } |
705 | 736 |
706 | 737 |
| 738 template <> |
| 739 bool BasicJsonStringifier::DoNotEscape(uint16_t c) { |
| 740 return c >= '#' && c != '\\' && c != 0x7f; |
| 741 } |
| 742 |
| 743 |
707 template <> | 744 template <> |
708 Vector<const uint8_t> BasicJsonStringifier::GetCharVector( | 745 Vector<const uint8_t> BasicJsonStringifier::GetCharVector( |
709 Handle<String> string) { | 746 Handle<String> string) { |
710 String::FlatContent flat = string->GetFlatContent(); | 747 String::FlatContent flat = string->GetFlatContent(); |
711 ASSERT(flat.IsAscii()); | 748 ASSERT(flat.IsAscii()); |
712 return flat.ToOneByteVector(); | 749 return flat.ToOneByteVector(); |
713 } | 750 } |
714 | 751 |
715 | 752 |
716 template <> | 753 template <> |
(...skipping 19 matching lines...) Expand all Loading... |
736 SerializeString_<false, uint8_t>(object); | 773 SerializeString_<false, uint8_t>(object); |
737 } else { | 774 } else { |
738 SerializeString_<false, uc16>(object); | 775 SerializeString_<false, uc16>(object); |
739 } | 776 } |
740 } | 777 } |
741 } | 778 } |
742 | 779 |
743 } } // namespace v8::internal | 780 } } // namespace v8::internal |
744 | 781 |
745 #endif // V8_JSON_STRINGIFIER_H_ | 782 #endif // V8_JSON_STRINGIFIER_H_ |
OLD | NEW |