I also wrap a C++ global object -- although I don't allow accessors on  
it, only on objects inside of it.

However, you can pass to an accessor a data object. See this from v8.h:
void SetAccessor(Handle<String> name,
                    AccessorGetter getter,
                    AccessorSetter setter = 0,
                    Handle<Value> data = Handle<Value>(),
                    AccessControl settings = DEFAULT,
                    PropertyAttribute attribute = None);

You can just set data to a v8::External holding your global object.  
This would mean that each global object would have to have its own  
template, but it will work. You retrieve it from the AccessorInfo  
object passed to your accessor, by using the Data() function.

I'm not sure how you'd do it with one template, though, without an  
internal field, which apparently doesn't work.

I hope that helps,

Alex


On Mar 27, 2009, at 1:46 PM, [email protected] wrote:

>
> hi!
>
>> I was not aware it was possible or supported to have an internal  
>> field
>> for a global object. Out of curiosity, what are you trying to do with
>> that functionality?
>
> Well, I am just using it as a wrapper over my own global object which
> in turn,
> provides various functions, properties etc. If I wouldn't be able to
> have internal
> fields on the global object, I am curious how I could then simply have
> my own global
> object wrapped up? As I am using static accessors I wouldn't have any
> other way to
> get my global (c++) object instance besides using the same mechanism
> as on
> my other v8 wrappers..
>
> Alex
> >

Alex Iskander, TPSi





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

Reply via email to