Dear experts,

Consider the following (javaScript) scripts:

  "function fnc(val) { var a = []; a[0] = 1; a[1] = 2; array = a; \n\
                       b = array; b[0] = 3; array = b; }";
  "function fnc(val) { array[0] = 1; array[1] = 2; }";
 

I'd like to call the function 'fnc' from within the v8-engine C++ code and 
intercept all accesses to 'array', whether indexed or not. The code below 
fails, cause the last 2 statements override each other, but may give you a 
clue where I'm heading.

  v8::Handle<v8::ObjectTemplate> tmpl = v8::ObjectTemplate::New(isolate);
  tmpl->SetIndexedPropertyHandler(indexed_getter, indexed_setter);
  context->Global()->Set(name, tmpl->NewInstance());
  context->Global()->SetAccessor(name, getter, setter);
 

I know I can do something like:

  global_tmpl->SetNamedPropertyHandler(named_getter, named_setter);

  v8::Handle<v8::Context> context = v8::Context::New(isolate, NULL, 
global_tmpl);
  v8::Context::Scope context_scope(context);

  v8::Handle<v8::ObjectTemplate> tmpl = v8::ObjectTemplate::New(isolate);
  tmpl->SetIndexedPropertyHandler(indexed_getter, indexed_setter);
  context->Global()->Set(name, tmpl->NewInstance());
 

The problem is that with SetNamedPropertyHandler() I get callbacks on 
access to every token in the script, which I'd like to avoid. I would like 
to do something similar to the first code snippet. Any idea how?

BW, I've posted the question above in StackOverflow; see 
here<http://stackoverflow.com/questions/22758724/is-there-a-way-to-intercept-a-plain-access-and-an-indexed-access-at-the-same-tim>
.

Also, I'm new to v8 in general and to this mailing list in particular, so 
apologies ahead for improper use (of either v8 or the mailing list...)
Thanks,Efi 

-- 
-- 
v8-users mailing list
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to