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

Side by Side Diff: src/api.cc

Issue 223553003: Return MaybeHandle from JsonParser. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/json-parser.h » ('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 2297 matching lines...) Expand 10 before | Expand all | Expand 10 after
2308 // --- J S O N --- 2308 // --- J S O N ---
2309 2309
2310 Local<Value> JSON::Parse(Local<String> json_string) { 2310 Local<Value> JSON::Parse(Local<String> json_string) {
2311 i::Isolate* isolate = i::Isolate::Current(); 2311 i::Isolate* isolate = i::Isolate::Current();
2312 EnsureInitializedForIsolate(isolate, "v8::JSON::Parse"); 2312 EnsureInitializedForIsolate(isolate, "v8::JSON::Parse");
2313 ENTER_V8(isolate); 2313 ENTER_V8(isolate);
2314 i::HandleScope scope(isolate); 2314 i::HandleScope scope(isolate);
2315 i::Handle<i::String> source = i::Handle<i::String>( 2315 i::Handle<i::String> source = i::Handle<i::String>(
2316 FlattenGetString(Utils::OpenHandle(*json_string))); 2316 FlattenGetString(Utils::OpenHandle(*json_string)));
2317 EXCEPTION_PREAMBLE(isolate); 2317 EXCEPTION_PREAMBLE(isolate);
2318 i::MaybeHandle<i::Object> maybe_result =
2319 source->IsSeqOneByteString() ? i::JsonParser<true>::Parse(source)
2320 : i::JsonParser<false>::Parse(source);
2318 i::Handle<i::Object> result; 2321 i::Handle<i::Object> result;
2319 if (source->IsSeqOneByteString()) { 2322 has_pending_exception = !maybe_result.ToHandle(&result);
2320 result = i::JsonParser<true>::Parse(source);
2321 } else {
2322 result = i::JsonParser<false>::Parse(source);
2323 }
2324 has_pending_exception = result.is_null();
2325 EXCEPTION_BAILOUT_CHECK(isolate, Local<Object>()); 2323 EXCEPTION_BAILOUT_CHECK(isolate, Local<Object>());
2326 return Utils::ToLocal( 2324 return Utils::ToLocal(
2327 i::Handle<i::Object>::cast(scope.CloseAndEscape(result))); 2325 i::Handle<i::Object>::cast(scope.CloseAndEscape(result)));
2328 } 2326 }
2329 2327
2330 2328
2331 // --- D a t a --- 2329 // --- D a t a ---
2332 2330
2333 bool Value::FullIsUndefined() const { 2331 bool Value::FullIsUndefined() const {
2334 bool result = Utils::OpenHandle(this)->IsUndefined(); 2332 bool result = Utils::OpenHandle(this)->IsUndefined();
(...skipping 5325 matching lines...) Expand 10 before | Expand all | Expand 10 after
7660 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7658 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7661 Address callback_address = 7659 Address callback_address =
7662 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7660 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7663 VMState<EXTERNAL> state(isolate); 7661 VMState<EXTERNAL> state(isolate);
7664 ExternalCallbackScope call_scope(isolate, callback_address); 7662 ExternalCallbackScope call_scope(isolate, callback_address);
7665 callback(info); 7663 callback(info);
7666 } 7664 }
7667 7665
7668 7666
7669 } } // namespace v8::internal 7667 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/json-parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698