Hi,

I am not 100% sure if I understand your issue correctly, so please
forgive me if my advice is completely bogus :)

I see two possible solutions:

a) if you need to use a getter function for file.path, then store the
path instance in an internal field of the file:

file_open(path) {
  args.This()->SetInternalField(1, path);
}

b) alternatively, do *not* define a getter for file.path and simply
store the path value via Set:

file_open(path) {
  args.This()->Set(v8::String::New("path"), path);
}

In the second scenario, you can easily retrieve the stored path using
args.This()->Get(v8::String::New("path")) - no getter is called, no
stack overflow happens :)



Hope this helps,
Ondrej


2010/12/13 fuzzy spoon <[email protected]>:
> Hi!
> I have run into something that is confusing me again.
> Steps that i have done :
>    1) Expose a new type to JS (lets call it file class).
>               var f = new file();
>               file.open( path )
>               file.close();
>               file.path ( a property with a get, set function)
>     2) Expose a second type, path :
>             var  p = new path('some/file/on/disk.txt');
>
>     3) Accessing file.path from c++ -> This is the problem
>     myFileClass::Path_SET(...)
>         v8::Local<v8::Object> self = info.Holder();
>         v8::Local<v8::External> external =
> v8::Local<v8::External>::Cast(self->GetInternalField(0));
>         myFileClass* myFile = static_cast<myFileClass*>( external->Value()
> );
>  How can i access the path from the file?  ie ; fileInstance->Get( "path" )
>               i tried self->Get(v8::String::New("path")); but of course,
> that calls my accessor on the FILE, not the path.
>               so inside of myFileClass::Path_GET i still cannot obtain the
> instance of the c++ side version of the path.
>           using Get = stack overflow (calling itself recursively)
> So in short :
>       file.path = new Path();  <- how do i access, and replace the existing
> path instance from c++ from the parent class (file).
>
> I hope this made sense :)
>
>
>
>
>
> --
> 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