Thanks. So, once I have a non-empty v8::Local object (v8obj_json in this 
case), am I guaranteed that its value won't turn empty? - I'm asking this 
in the context of calling v8::V8::TerminateExecution(isolate). Please 
consider the following code -

v8::Local<v8::Object> v8obj_json;
if (!v8val_json.ToLocal(&v8obj_json)) { // v8val_json is a v8::MaybeLocal 
  return;
}

// Let's say we terminate the execution after getting a v8::Local object
v8::V8::TerminateExecution(isolate);

// Will v8obj_json become empty?
auto field_zero = v8obj_json->Get(0);





On Tuesday, 15 May 2018 15:46:43 UTC+5:30, Ben Noordhuis wrote:
>
> On Tue, May 15, 2018 at 12:10 PM, Gautham B A 
> <[email protected] <javascript:>> wrote: 
> > Hi all, 
> > 
> > Please consider the following code - 
> > void ParseJSON(v8::Isolate *isolate, const v8::Local<v8::String> 
> &v8_str) { 
> >   v8::HandleScope handle_scope(isolate); 
> > 
> >   auto v8val_json = v8::JSON::Parse(isolate, v8_str); 
> > 
> >   v8::Local<v8::Object> v8obj_json; 
> >   if (!v8val_json.ToLocal(&v8obj_json)) { 
> >     // Empty 
> >     return; 
> >   } 
> > 
> >   // v8obj_json is a v8::Local. Is this check necessary? 
> >   if (!v8obj_json.IsEmpty()) { 
> >     return; 
> >   } 
> > 
> >   auto field_zero = v8obj_json->Get(0); 
> > } 
> > 
> > When I obtain a v8::Local object from a v8::MaybeLocal, is it necessary 
> to 
> > check if the v8::Local object is empty before accessing it? 
>
> No, the .ToLocal() call took care of that. 
>

-- 
-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to