[英]Hello World and V8
我正在窗戶上工作。 我試圖通過underscorediscovery中的V8在V8中運行hello world 。 這無法在線編譯
// Get the default Isolate created at startup.
Isolate* isolate = Isolate::GetCurrent();
我查看了underscorediscovery標頭,當此類不在標頭中時,它確實具有舊的lib和標頭。 很好 我刪除了這一行,並用替換前四行
// 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 插件開發的說明。 它的“ hello world nodejs”成功了。 我認為實際的Google代碼也應該在標頭中使用類Isolate。 但是它沒有編譯錯誤:
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的標題中查找
它具有定義的類Isolate。 也,
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) {}
...........
...........
和
class HandleScope {
public:
inline HandleScope();
explicit inline HandleScope(Isolate* isolate);
.....
因此,Google的Hello世界的這一部分應該有效:
// 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);
問題是什么 ?
穩定節點v0.10.15使用Google V8版本3.14.5
(2012-10-22)C:\\ Documents \\ github \\ node \\ deps \\ v8 \\ include \\ v8.h
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
class V8_EXPORT HandleScope {
public:
// TODO(svenpanne) Deprecate me when Chrome is fixed!
HandleScope();
HandleScope(Isolate* isolate);
~HandleScope();
從node \\ deps \\ v8 \\ ChangeLog文件中:
2013-03-15:版本3.17.11
添加了帶有v8 :: Isolate參數的v8 :: HandleScope構造函數版本,並使AdjustAmountOfExternalAllocatedMemory成為v8 :: Isolate的實例方法。 (問題2487)
指針與引用。 似乎HandleScope()需要引用,而New()返回指針。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.