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

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

Issue 1824533002: [json] Allow any callable object for toJSON. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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 | « no previous file | test/mjsunit/regress/regress-crbug-595738.js » ('j') | 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/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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 } 238 }
239 } 239 }
240 240
241 241
242 MaybeHandle<Object> BasicJsonStringifier::ApplyToJsonFunction( 242 MaybeHandle<Object> BasicJsonStringifier::ApplyToJsonFunction(
243 Handle<Object> object, Handle<Object> key) { 243 Handle<Object> object, Handle<Object> key) {
244 LookupIterator it(object, tojson_string_, 244 LookupIterator it(object, tojson_string_,
245 LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); 245 LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR);
246 Handle<Object> fun; 246 Handle<Object> fun;
247 ASSIGN_RETURN_ON_EXCEPTION(isolate_, fun, Object::GetProperty(&it), Object); 247 ASSIGN_RETURN_ON_EXCEPTION(isolate_, fun, Object::GetProperty(&it), Object);
248 if (!fun->IsJSFunction()) return object; 248 if (!fun->IsCallable()) return object;
249 249
250 // Call toJSON function. 250 // Call toJSON function.
251 if (key->IsSmi()) key = factory()->NumberToString(key); 251 if (key->IsSmi()) key = factory()->NumberToString(key);
252 Handle<Object> argv[] = { key }; 252 Handle<Object> argv[] = { key };
253 HandleScope scope(isolate_); 253 HandleScope scope(isolate_);
254 ASSIGN_RETURN_ON_EXCEPTION( 254 ASSIGN_RETURN_ON_EXCEPTION(
255 isolate_, object, 255 isolate_, object,
256 Execution::Call(isolate_, fun, object, 1, argv), 256 Execution::Call(isolate_, fun, object, 1, argv),
257 Object); 257 Object);
258 return scope.CloseAndEscape(object); 258 return scope.CloseAndEscape(object);
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 } else { 677 } else {
678 SerializeString_<uc16, uc16>(object); 678 SerializeString_<uc16, uc16>(object);
679 } 679 }
680 } 680 }
681 } 681 }
682 682
683 } // namespace internal 683 } // namespace internal
684 } // namespace v8 684 } // namespace v8
685 685
686 #endif // V8_JSON_STRINGIFIER_H_ 686 #endif // V8_JSON_STRINGIFIER_H_
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-crbug-595738.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698