user467526
user467526

Reputation: 527

Problem using accessors in V8

I'm writing a wrapper class around the V8 engine so that eventually I'll be able to do something like this

script->createClass("Test");
script->getClass("Test")->addFunction("funct1",testfunct1);
script->getClass("Test")->addVariable("x",setter,getter);

So far I can create classes and add functions to them and it works perfectly, however I have encountered a problem with adding variables.

My class template is stored as such

Persistent<Object> classInstance;

and I try to add an Accessor like this:

this->classInstance->SetAccessor(String::New(variableName),setter,getter);

Compiling this code gives me the error that v8::Object doesn't have a SetAccessor function (though I've seen doxygen documentation that says otherwise).

So my question is: How can I fix this? Is it possible to cast an Object to an ObjectTemplate?

Upvotes: 1

Views: 724

Answers (1)

St&#233;phan Kochen
St&#233;phan Kochen

Reputation: 19943

SetAccessor on Object is available as of V8 2.2.12, which was released May 2010. (Before that, it was indeed only available on ObjectTemplate.) You should probably update your copy of V8.

Upvotes: 4

Related Questions