I just tried splitting the line into two lines.

Local<Function> function;
> function = Handle<Function>::Cast(args[0]);


The error already occurs at Local<Function> function;. What am I doing 
wrong? Other local handles can be created just fine. Changing Local to 
Handle doesn't work either.

Am Mittwoch, 26. März 2014 09:18:11 UTC+1 schrieb danijar:
>
> In a C++ callback, one argument is a function and I want to get the 
> Local<Function> handle of it. With an earlier version of V8, this worked.
>
> Local<Function> function = Local<Function>::Cast(args[0]->ToObject());
>
>
> Now, I tried to directly cast the argument like I've seen it in an 
> example. This is my whole C++ callback.
>
> void callback(const FunctionCallbackInfo<Value> &args)
>> {
>>     Isolate* isolate = args.GetIsolate();
>>     HandleScope scope(isolate);
>>     if (args.Length() < 1 || !args[0]->IsFunction()) {
>>         
>> isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, 
>> "first argument must be a function")));
>>         return;
>>     }
>>     Local<Function> function = Local<Function>::Cast(args[0]); // error 
>> is at this line
>
>     // ...
>
> }
>
>
> However, I get the following compile error.
>
> 1> v8/v8.h(5571): error C2248: 'v8::HandleScope::CreateHandle' : cannot 
>> access protected member declared in class 'v8::HandleScope'
>> 1> v8/v8.h(837) : see declaration of 'v8::HandleScope::CreateHandle'
>> 1> v8/v8.h(817) : see declaration of 'v8::HandleScope'
>> 1> v8/v8.h(5566) : while compiling class template member function 
>> 'v8::Handle<v8::Function> v8::Handle<v8::Function>::New(v8::Isolate *,T *)'
>> 1> with
>> 1> [
>> 1>     T=v8::Function
>> 1> ]
>> 1> v8/v8.h(311) : see reference to function template instantiation 
>> 'v8::Handle<v8::Function> v8::Handle<v8::Function>::New(v8::Isolate *,T *)' 
>> being compiled
>> 1> with
>> 1> [
>> 1>     T=v8::Function
>> 1> ]
>> 1> v8/v8.h(354) : see reference to class template instantiation 
>> 'v8::Handle<v8::Function>' being compiled
>> 1> source.cpp(48) : see reference to class template instantiation 
>> 'v8::Local<v8::Function>' being compiled
>
>  
> How can I cast a callback argument to Local<Function>?
>

-- 
-- 
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