首页
学习
活动
专区
圈层
工具
发布

和V8
EN

Stack Overflow用户
提问于 2013-08-21 10:34:51
回答 2查看 2.3K关注 0票数 3

我在修窗户。我试图使用来自你好,世界的V8在V8中运行V8。这不能按行编译。

代码语言:javascript
复制
// Get the default Isolate created at startup.
  Isolate* isolate = Isolate::GetCurrent();

我看了下面的发现头,当这个类不在头中时,它确实有旧的lib和头。那很好。我删除了这一行,并将前四行替换为

代码语言:javascript
复制
  // Create a stack-allocated handle scope.
  HandleScope handle_scope;

  // Create a new context.
  Handle<Context> context = Context::New();

  // Here's how you could create a Persistent handle to the context, if needed.
  Persistent<Context> persistent_context(context);

而且起作用了。因此,该分离物被添加到V8中。

然后我安装了node.js,它的依赖项deps文件夹中也有v8。我构建了node.js,v8也构建了。我遵循nodejs的addon发展指令。它的“你好世界nodejs”很成功。我认为实际的google代码也应该工作,因为类隔离在标题中。但它并没有用错误进行编译:

代码语言:javascript
复制
error C2664: 'v8::HandleScope::HandleScope(const v8::HandleSc
ope &)' : cannot convert parameter 1 from 'v8::Isolate *' to 'const v8::HandleS
cope &' [C:\Users\asnegi\company\nodejs project\node-v0.10.15\src\my_files\buil
d\v8code.vcxproj]
          Reason: cannot convert from 'v8::Isolate *' to 'const v8::HandleScope
  '
          No constructor could take the source type, or constructor overload re
  solution was ambiguous

查看C:\Users\abc.node-gyp\0.10.15\deps\v8\include\v8.h的标头

它定义了类隔离。另外,

代码语言:javascript
复制
template <class T> class Handle {
 public:
  /**
   * Creates an empty handle.
   */
  inline Handle() : val_(0) {}

  /**
   * Creates a new handle for the specified value.
   */
  inline explicit Handle(T* val) : val_(val) {}
  ...........
  ...........

代码语言:javascript
复制
 class HandleScope {
    public:
  inline HandleScope();
  explicit inline HandleScope(Isolate* isolate);
  .....

因此,Google的Hello的这一部分应该是有效的:

代码语言:javascript
复制
// Get the default Isolate created at startup.
  Isolate* isolate = Isolate::GetCurrent();

  // Create a stack-allocated handle scope.
  HandleScope handle_scope(isolate);

  // Create a new context.
  Handle<Context> context = Context::New(isolate);

有什么问题吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-08-21 12:31:01

稳定节点v0.10.15使用Google V8版本3.14.5 (2012-10-22) C:\Documents\github\ Node \deps\v8\include\v8.h

代码语言:javascript
复制
class V8EXPORT HandleScope {
 private:
  HandleScope(const HandleScope&);

不稳定节点v0.11.5使用Google V8版本3.20.14 (2013-08-07) C:\Documents\github\ Node \deps\v8\include\v8.h

代码语言:javascript
复制
class V8_EXPORT HandleScope {
 public:
  // TODO(svenpanne) Deprecate me when Chrome is fixed!
  HandleScope();
  HandleScope(Isolate* isolate);
  ~HandleScope();

从节点\deps\v8\ChangeLog文件:

2013-03-15:版本3.17.11 添加了一个版本的v8::HandleScope构造函数,其中包含一个V8::隔离参数,并使AdjustAmountOfExternalAllocatedMemory成为V8::隔离的一个实例方法。(第2487期)

票数 4
EN

Stack Overflow用户

发布于 2013-08-21 10:45:27

指针和引用。看起来HandleScope()需要一个引用,New()返回一个指针。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18355130

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档