Exemple not compiling

15 views
Skip to first unread message

Philippe Richard

unread,
Jul 7, 2021, 2:58:13 PM7/7/21
to v8-users
Hi  peop, 

When I try to compile this code with node-gyp rebuild, i get the errors : 

'HandleScope' undeclared identifier

'scope': identifier not found

'GetCurrentContext' is not a member of v8 function

v8::Function::Call : take 3 args does not take 3 args

Help please : I'm using node v12.24.1


Thanks

//-------------------------------------------------------------------------------------------------------------------//
static Persistent<v8::Function> cb; 

void PostMessage(){
 
Isolate* isolate = Isolate::GetCurrent(); v8::Locker locker(isolate); 
 HandleScope scope(isolate);

const unsigned argc = 1; Local<Value> argv[argc] = { 
String::NewFromUtf8(isolate, "test") }; 

 Local<v8::Function> PostMessageCb = Local<v8::Function>::New(isolate, cb);
(PostMessageCb)->Call(isolate->GetCurrentContext()->Global(), argc, argv); } 
//-------------------------------------------------------------------------------------------------------------------//
void SetupCallback(const FunctionCallbackInfo<Value>& args) { 
 Isolate* isolate = Isolate::GetCurrent(); 
 v8::Locker locker(isolate); HandleScope scope(isolate);
 
Local<v8::Function> local_cb = Local<v8::Function>::Cast(args[0]); cb.Reset(isolate, local_cb); } 


Error code : 
Reply all
Reply to author
Forward
0 new messages