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

static v8::Handle<v8::Value> func(const v8::Arguments& args) {
   if (args.IsConstructCall())
       return v8::Undefined();

   args[0]  to v8::Function function; ???

   function.As<v8::Function>()->Call(args.This(), 0, NULL)
...
}

On Tue, Jun 1, 2010 at 12:23 PM, Anton Muhin <[email protected]> wrote:

> I think you should use Unwrap.
>
> Technically most probably &a is aligned at 2 bytes at least and thus
> is saved as a smi (small integer).  But Value cannot cope with it.
>
> yours,
> anton.
>
> On Tue, Jun 1, 2010 at 11:10 PM, vlad <[email protected]> wrote:
> > Hi
> > A little artificial example but illustrates a problem I'm having:
> >
> > static v8::Handle<v8::Value> func(const v8::Arguments& args) {
> >    if (args.IsConstructCall())
> >        return v8::Undefined();
> >
> >    v8::Local<v8::Object> obj = args[0]->ToObject();
> >    int* pThis = static_cast<int*>(v8::Local<v8::External>::Cast(obj-
> >>GetInternalField(0))->Value()); <-- CRASH
> >    return v8::Undefined();
> > }
> >
> >        int a = 5;
> >        v8::Handle<v8::ObjectTemplate> pt = v8::ObjectTemplate::New();
> >        pt->SetCallAsFunctionHandler(func);
> >        pt->SetInternalFieldCount(1);
> >        v8::Handle<v8::Object> obj = pt->NewInstance();
> >        obj->SetInternalField(0, v8::External::Wrap(&a));
> >        g->Set(v8::String::New("myfunc"), obj);
> >        V8RUN("myfunc(myfunc);");
> >
> > I'm expecting to get in args[0] myfunc v8 object, but it is not the
> > case....
> >
> > Thanks
> > Vlad
> >
> > --
> > 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

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

Reply via email to