| 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 #ifndef V8_JSON_STRINGIFIER_H_ | 5 #ifndef V8_JSON_STRINGIFIER_H_ |
| 6 #define V8_JSON_STRINGIFIER_H_ | 6 #define V8_JSON_STRINGIFIER_H_ |
| 7 | 7 |
| 8 #include "src/conversions.h" | 8 #include "src/conversions.h" |
| 9 #include "src/lookup.h" | 9 #include "src/lookup.h" |
| 10 #include "src/messages.h" | 10 #include "src/messages.h" |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 "\364\0 \365\0 \366\0 \367\0 " | 191 "\364\0 \365\0 \366\0 \367\0 " |
| 192 "\370\0 \371\0 \372\0 \373\0 " | 192 "\370\0 \371\0 \372\0 \373\0 " |
| 193 "\374\0 \375\0 \376\0 \377\0 "; | 193 "\374\0 \375\0 \376\0 \377\0 "; |
| 194 | 194 |
| 195 BasicJsonStringifier::BasicJsonStringifier(Isolate* isolate, Handle<String> gap) | 195 BasicJsonStringifier::BasicJsonStringifier(Isolate* isolate, Handle<String> gap) |
| 196 : isolate_(isolate), builder_(isolate), gap_string_(gap), indent_(0) { | 196 : isolate_(isolate), builder_(isolate), gap_string_(gap), indent_(0) { |
| 197 tojson_string_ = factory()->toJSON_string(); | 197 tojson_string_ = factory()->toJSON_string(); |
| 198 stack_ = factory()->NewJSArray(8); | 198 stack_ = factory()->NewJSArray(8); |
| 199 int gap_length = gap->length(); | 199 int gap_length = gap->length(); |
| 200 if (gap_length != 0) { | 200 if (gap_length != 0) { |
| 201 String::Flatten(gap); | 201 gap = String::Flatten(gap); |
| 202 if (gap->IsTwoByteRepresentation()) builder_.ChangeEncoding(); |
| 202 DisallowHeapAllocation no_gc; | 203 DisallowHeapAllocation no_gc; |
| 203 String::FlatContent flat = gap->GetFlatContent(); | 204 String::FlatContent flat = gap->GetFlatContent(); |
| 204 gap_ = NewArray<uc16>(gap_length + 1); | 205 gap_ = NewArray<uc16>(gap_length + 1); |
| 205 if (flat.IsOneByte()) { | 206 if (flat.IsOneByte()) { |
| 206 CopyChars(gap_, flat.ToOneByteVector().start(), gap_length); | 207 CopyChars(gap_, flat.ToOneByteVector().start(), gap_length); |
| 207 } else { | 208 } else { |
| 208 CopyChars(gap_, flat.ToUC16Vector().start(), gap_length); | 209 CopyChars(gap_, flat.ToUC16Vector().start(), gap_length); |
| 209 builder_.ChangeEncoding(); | |
| 210 } | 210 } |
| 211 gap_[gap_length] = '\0'; | 211 gap_[gap_length] = '\0'; |
| 212 } else { | 212 } else { |
| 213 gap_ = nullptr; | 213 gap_ = nullptr; |
| 214 } | 214 } |
| 215 } | 215 } |
| 216 | 216 |
| 217 | 217 |
| 218 MaybeHandle<Object> BasicJsonStringifier::Stringify(Handle<Object> object) { | 218 MaybeHandle<Object> BasicJsonStringifier::Stringify(Handle<Object> object) { |
| 219 Result result = SerializeObject(object); | 219 Result result = SerializeObject(object); |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 } else { | 741 } else { |
| 742 SerializeString_<uc16, uc16>(object); | 742 SerializeString_<uc16, uc16>(object); |
| 743 } | 743 } |
| 744 } | 744 } |
| 745 } | 745 } |
| 746 | 746 |
| 747 } // namespace internal | 747 } // namespace internal |
| 748 } // namespace v8 | 748 } // namespace v8 |
| 749 | 749 |
| 750 #endif // V8_JSON_STRINGIFIER_H_ | 750 #endif // V8_JSON_STRINGIFIER_H_ |
| OLD | NEW |