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

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

Issue 1097703002: Wrap JSON and generator implementation in functions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 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
« no previous file with comments | « src/json.js ('k') | 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 // 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/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/conversions.h" 10 #include "src/conversions.h"
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 return SerializeGeneric(object, key, comma, deferred_string_key); 354 return SerializeGeneric(object, key, comma, deferred_string_key);
355 } 355 }
356 356
357 357
358 BasicJsonStringifier::Result BasicJsonStringifier::SerializeGeneric( 358 BasicJsonStringifier::Result BasicJsonStringifier::SerializeGeneric(
359 Handle<Object> object, 359 Handle<Object> object,
360 Handle<Object> key, 360 Handle<Object> key,
361 bool deferred_comma, 361 bool deferred_comma,
362 bool deferred_key) { 362 bool deferred_key) {
363 Handle<JSObject> builtins(isolate_->native_context()->builtins(), isolate_); 363 Handle<JSObject> builtins(isolate_->native_context()->builtins(), isolate_);
364 Handle<JSFunction> builtin = Handle<JSFunction>::cast(Object::GetProperty( 364 Handle<JSFunction> builtin = Handle<JSFunction>::cast(
365 isolate_, builtins, "JSONSerializeAdapter").ToHandleChecked()); 365 Object::GetProperty(isolate_, builtins, "$jsonSerializeAdapter")
366 .ToHandleChecked());
366 367
367 Handle<Object> argv[] = { key, object }; 368 Handle<Object> argv[] = { key, object };
368 Handle<Object> result; 369 Handle<Object> result;
369 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 370 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
370 isolate_, result, 371 isolate_, result,
371 Execution::Call(isolate_, builtin, object, 2, argv), 372 Execution::Call(isolate_, builtin, object, 2, argv),
372 EXCEPTION); 373 EXCEPTION);
373 if (result->IsUndefined()) return UNCHANGED; 374 if (result->IsUndefined()) return UNCHANGED;
374 if (deferred_key) { 375 if (deferred_key) {
375 if (key->IsSmi()) key = factory()->NumberToString(key); 376 if (key->IsSmi()) key = factory()->NumberToString(key);
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 SerializeString_<uint8_t, uc16>(object); 677 SerializeString_<uint8_t, uc16>(object);
677 } else { 678 } else {
678 SerializeString_<uc16, uc16>(object); 679 SerializeString_<uc16, uc16>(object);
679 } 680 }
680 } 681 }
681 } 682 }
682 683
683 } } // namespace v8::internal 684 } } // namespace v8::internal
684 685
685 #endif // V8_JSON_STRINGIFIER_H_ 686 #endif // V8_JSON_STRINGIFIER_H_
OLDNEW
« no previous file with comments | « src/json.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698