javascript代码实例教程-nodejs c++启动过程3

发布时间:2019-02-17 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了javascript代码实例教程-nodejs c++启动过程3脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
小宝典致力于为广大程序猿(媛)提供高品质的代码服务,请大家多多光顾小站,小宝典在此谢过。

PErsistent v8::Context::New(
v8::Extensionconfiguration* extensions,
v8::Handle global_template,
v8::Handle global_object) {
i::Isolate::EnsuredefaultIsolate();
i::Isolate* isolate = i::Isolate::current();
EnsureinITializeDForIsolate(isolate, "v8::Context::New()");
LOG_API(isolate, "Context::New");
ON_BaiLOUT(isolate, "v8::Context::New()", return Persistent());


// 下面的内容,上接博客1
// Enter V8 via an ENTER_V8 scope.
i::Handle env;

{

// 这个是进入引擎,使用VMState类,在析构的时候,离开引擎

ENTER_V8(isolate);
v8::Handle Proxy_template = global_template;
i::Handle PRoxy_constructor;
i::Handle global_constructor;




if (!global_template.ISEMpty()) {
// Make sure that the global_template has a constructor.
global_constructor =
EnsureConstructor(Utils::OpenHandle(*global_template));




// Create a fresh template for the global proxy object.
proxy_template = ObjectTemplate::New();
proxy_constructor =
EnsureConstructor(Utils::OpenHandle(*proxy_template));




// Set the global template to be the prototype template of
// global proxy template.
proxy_constructor->set_prototype_template(
*Utils::OpenHandle(*global_template));




// Migrate security handlers From global_template to
// proxy_template. Temporarily removing access check
// information from the global template.
if (!global_constructor->access_check_info()->IsUndefined()) {
proxy_constructor->set_access_check_info(
global_constructor->access_check_info());
proxy_constructor->set_needs_access_check(
global_constructor->needs_access_check());
global_constructor->set_needs_access_check(false);
global_constructor->set_access_check_info(
isolate->heap()->undefined_value());
}
}




// Create the environment.
env = isolate->bootstrapper()->CreateEnvironment(
isolate,
Utils::OpenHandle(*global_object, true),
proxy_template,
extensions);




// Restore the access check info on the global template.
if (!global_template.IsEmpty()) {
ASSERT(!global_constructor.is_null());
ASSERT(!proxy_constructor.is_null());
global_constructor->set_access_check_info(
proxy_constructor->access_check_info());
global_constructor->set_needs_access_check(
proxy_constructor->needs_access_check());
}
isolate->runtime_profiler()->Reset();
}
// Leave V8.




if (env.is_null()) {
return Persistent();
}
return Persistent(Utils::ToLocal(env));
}

觉得可用,就经常来吧! 脚本宝典 欢迎评论哦! js脚本,巧夺天工,精雕玉琢。小宝典献丑了!

脚本宝典总结

以上是脚本宝典为你收集整理的javascript代码实例教程-nodejs c++启动过程3全部内容,希望文章能够帮你解决javascript代码实例教程-nodejs c++启动过程3所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。