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

Side by Side Diff: src/api.cc

Issue 22416003: Make JSON::Parse return Local<Value> (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « include/v8.h ('k') | test/cctest/test-api.cc » ('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 // 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 2592 matching lines...) Expand 10 before | Expand all | Expand 10 after
2603 ENTER_V8(isolate); 2603 ENTER_V8(isolate);
2604 i::HandleScope scope(isolate); 2604 i::HandleScope scope(isolate);
2605 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2605 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2606 i::Handle<i::Object> is_constructor = GetProperty(self, "isConstructor"); 2606 i::Handle<i::Object> is_constructor = GetProperty(self, "isConstructor");
2607 return is_constructor->IsTrue(); 2607 return is_constructor->IsTrue();
2608 } 2608 }
2609 2609
2610 2610
2611 // --- J S O N --- 2611 // --- J S O N ---
2612 2612
2613 Local<Object> JSON::Parse(Local<String> json_string) { 2613 Local<Value> JSON::Parse(Local<String> json_string) {
2614 i::Isolate* isolate = i::Isolate::Current(); 2614 i::Isolate* isolate = i::Isolate::Current();
2615 EnsureInitializedForIsolate(isolate, "v8::JSON::Parse"); 2615 EnsureInitializedForIsolate(isolate, "v8::JSON::Parse");
2616 ENTER_V8(isolate); 2616 ENTER_V8(isolate);
2617 i::HandleScope scope(isolate); 2617 i::HandleScope scope(isolate);
2618 i::Handle<i::String> source = i::Handle<i::String>( 2618 i::Handle<i::String> source = i::Handle<i::String>(
2619 FlattenGetString(Utils::OpenHandle(*json_string))); 2619 FlattenGetString(Utils::OpenHandle(*json_string)));
2620 EXCEPTION_PREAMBLE(isolate); 2620 EXCEPTION_PREAMBLE(isolate);
2621 i::Handle<i::Object> result; 2621 i::Handle<i::Object> result;
2622 if (source->IsSeqOneByteString()) { 2622 if (source->IsSeqOneByteString()) {
2623 result = i::JsonParser<true>::Parse(source); 2623 result = i::JsonParser<true>::Parse(source);
2624 } else { 2624 } else {
2625 result = i::JsonParser<false>::Parse(source); 2625 result = i::JsonParser<false>::Parse(source);
2626 } 2626 }
2627 has_pending_exception = result.is_null(); 2627 has_pending_exception = result.is_null();
2628 EXCEPTION_BAILOUT_CHECK(isolate, Local<Object>()); 2628 EXCEPTION_BAILOUT_CHECK(isolate, Local<Object>());
2629 return Utils::ToLocal( 2629 return Utils::ToLocal(
2630 i::Handle<i::JSObject>::cast(scope.CloseAndEscape(result))); 2630 i::Handle<i::Object>::cast(scope.CloseAndEscape(result)));
2631 } 2631 }
2632 2632
2633 2633
2634 // --- D a t a --- 2634 // --- D a t a ---
2635 2635
2636 bool Value::FullIsUndefined() const { 2636 bool Value::FullIsUndefined() const {
2637 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsUndefined()")) { 2637 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsUndefined()")) {
2638 return false; 2638 return false;
2639 } 2639 }
2640 bool result = Utils::OpenHandle(this)->IsUndefined(); 2640 bool result = Utils::OpenHandle(this)->IsUndefined();
(...skipping 5519 matching lines...) Expand 10 before | Expand all | Expand 10 after
8160 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 8160 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
8161 Address callback_address = 8161 Address callback_address =
8162 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 8162 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
8163 VMState<EXTERNAL> state(isolate); 8163 VMState<EXTERNAL> state(isolate);
8164 ExternalCallbackScope call_scope(isolate, callback_address); 8164 ExternalCallbackScope call_scope(isolate, callback_address);
8165 return callback(info); 8165 return callback(info);
8166 } 8166 }
8167 8167
8168 8168
8169 } } // namespace v8::internal 8169 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698