isolate already entered in this moment. Context can't be entered before 
Set, because context takes global as param:

Local<Context> context = Context::New(isolate, nullptr, *global*);

if create *global* before Context::New, and call Set after, then:

<unknown>:0: Uncaught ReferenceError: i is not defined

#
# Fatal error in v8::ToLocalChecked
# Empty MaybeLocal.
#

in string:
auto i = context->Global()->Get(context, v8_str(isolate, 
"i")).ToLocalChecked();







вторник, 8 августа 2017 г., 13:58:16 UTC+3 пользователь Ben Noordhuis 
написал:
>
> On Tue, Aug 8, 2017 at 11:51 AM,  <dark...@gmail.com <javascript:>> 
> wrote: 
> > Here is sample: 
> > 
> > auto isolate = v8::Isolate::GetCurrent(); 
> > 
> > Local<ObjectTemplate> global = ObjectTemplate::New(isolate); 
> > 
> > global->Set(v8_str(isolate, "i"), Number::New(isolate, 4)); 
> > 
> > Local<Context> context = Context::New(isolate, nullptr, global); 
> > Context::Scope context_scope(context); 
> > 
> > auto i = context->Global()->Get(context, v8_str(isolate, 
> > "i")).ToLocalChecked(); 
> > 
> > std::cout << "i: " << i->NumberValue() << std::endl; 
> > 
> > out: 
> > 
> > i: 4 
> > 
> > But replace: 
> > 
> > global->Set(v8_str(isolate, "i"), Number::New(isolate, 4)); 
> > 
> > with 
> > 
> > global->Set(v8_str(isolate, "i"), Number::New(isolate, 4.4)); 
> > 
> > and out: 
> > 
> > i: nan 
> > 
> > Why?? 
>
> Does it work when you enter the isolate and the context before setting 
> the property? 
>

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
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 v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to