| 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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 if (object->IsOneByteRepresentationUnderneath()) { | 215 if (object->IsOneByteRepresentationUnderneath()) { |
| 216 result = isolate->factory() | 216 result = isolate->factory() |
| 217 ->NewRawOneByteString(worst_case_length) | 217 ->NewRawOneByteString(worst_case_length) |
| 218 .ToHandleChecked(); | 218 .ToHandleChecked(); |
| 219 IncrementalStringBuilder::NoExtendString<uint8_t> no_extend( | 219 IncrementalStringBuilder::NoExtendString<uint8_t> no_extend( |
| 220 result, worst_case_length); | 220 result, worst_case_length); |
| 221 no_extend.Append('\"'); | 221 no_extend.Append('\"'); |
| 222 SerializeStringUnchecked_(object->GetFlatContent().ToOneByteVector(), | 222 SerializeStringUnchecked_(object->GetFlatContent().ToOneByteVector(), |
| 223 &no_extend); | 223 &no_extend); |
| 224 no_extend.Append('\"'); | 224 no_extend.Append('\"'); |
| 225 return no_extend.Finalize(); | |
| 226 } else { | 225 } else { |
| 227 result = isolate->factory() | 226 result = isolate->factory() |
| 228 ->NewRawTwoByteString(worst_case_length) | 227 ->NewRawTwoByteString(worst_case_length) |
| 229 .ToHandleChecked(); | 228 .ToHandleChecked(); |
| 230 IncrementalStringBuilder::NoExtendString<uc16> no_extend(result, | 229 IncrementalStringBuilder::NoExtendString<uc16> no_extend(result, |
| 231 worst_case_length); | 230 worst_case_length); |
| 232 no_extend.Append('\"'); | 231 no_extend.Append('\"'); |
| 233 SerializeStringUnchecked_(object->GetFlatContent().ToUC16Vector(), | 232 SerializeStringUnchecked_(object->GetFlatContent().ToUC16Vector(), |
| 234 &no_extend); | 233 &no_extend); |
| 235 no_extend.Append('\"'); | 234 no_extend.Append('\"'); |
| 236 return no_extend.Finalize(); | |
| 237 } | 235 } |
| 236 return result; |
| 238 } | 237 } |
| 239 | 238 |
| 240 | 239 |
| 241 MaybeHandle<Object> BasicJsonStringifier::ApplyToJsonFunction( | 240 MaybeHandle<Object> BasicJsonStringifier::ApplyToJsonFunction( |
| 242 Handle<Object> object, Handle<Object> key) { | 241 Handle<Object> object, Handle<Object> key) { |
| 243 LookupIterator it(object, tojson_string_, | 242 LookupIterator it(object, tojson_string_, |
| 244 LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); | 243 LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); |
| 245 Handle<Object> fun; | 244 Handle<Object> fun; |
| 246 ASSIGN_RETURN_ON_EXCEPTION(isolate_, fun, Object::GetProperty(&it), Object); | 245 ASSIGN_RETURN_ON_EXCEPTION(isolate_, fun, Object::GetProperty(&it), Object); |
| 247 if (!fun->IsJSFunction()) return object; | 246 if (!fun->IsJSFunction()) return object; |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 } else { | 672 } else { |
| 674 SerializeString_<uc16, uc16>(object); | 673 SerializeString_<uc16, uc16>(object); |
| 675 } | 674 } |
| 676 } | 675 } |
| 677 } | 676 } |
| 678 | 677 |
| 679 } // namespace internal | 678 } // namespace internal |
| 680 } // namespace v8 | 679 } // namespace v8 |
| 681 | 680 |
| 682 #endif // V8_JSON_STRINGIFIER_H_ | 681 #endif // V8_JSON_STRINGIFIER_H_ |
| OLD | NEW |