Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top