Thanks Stephan,
But if you look at the way I create an object in the original e-mail casting
to a function fails in the callback - when I get the object from args[0]...
Vlad

On Tue, Jun 1, 2010 at 12:56 PM, Stephan Beal <[email protected]> wrote:

>
>
> On Tue, Jun 1, 2010 at 9:34 PM, vlad vladbph <[email protected]> wrote:
>
>> Thanks Anton, that was stupid of me.... :)
>> ...another question related to that. Is there anyway to get v8::Function
>> from args[0]? to make the same call from c++.
>>
>
> First use arg->IsFunction() to ensure it's a function, then use
> Function::Cast() to convert the arg to a function.
>
> here are some random functions which use Function::Cast():
>
>
>     typedef v8::Handle<v8::Function> FuncHnd;
>
>         /**
>            Installs the handler for a given callback routine. If
>            !func->IsFunction() it throws a JS-side exception.
>         */
>         void setHandler( char const * n, v8::Handle<v8::Value> func )
>         {
>             if( func.IsEmpty() || !func->IsFunction() )
>             {
>                 cv::StringBuffer msg;
>                 msg << v8::juice::cw::ClassName<ExpatJS>::Value() << '.' <<
> n
>                     << " must be-a Function!";
>                 TOSSV(msg);
>                 return;
>             }
>             this->jself->Set( JSTR(n), FuncHnd( v8::Function::Cast(*func) )
> );
>         }
>         /**
>            Gets the handler callback function associated with n, or an
>            empty handle if n is not set or is not-a Function.
>         */
>         FuncHnd getHandler( char const * n )
>         {
>             ValHnd const h = this->jself->Get( JSTR(n) );
>             return (!h.IsEmpty() && h->IsFunction() )
>                 ? FuncHnd( v8::Function::Cast(*h) )
>                 : FuncHnd();
>         }
>
>
> --
> ----- stephan beal
> http://wanderinghorse.net/home/stephan/
>
> --
> v8-users mailing list
> [email protected]
> http://groups.google.com/group/v8-users
>

-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users

Reply via email to