I have an application that embeds v8 and I want to include a series of helper javascript functions at the time of compiling a code snippet so that the user is able to use my helper functions.
These functions don't interact with C++ at all and are merely there as helper functions.
i.e.
function doStuff(x, y){
return x + y + "weeee";
}
function doSomethingElse(){
}
Is there a sample of the above?
I have tried to use an v8::ObjectTemplate and merely doing the following without any success as I get `Reference error: doSomethingElse is not defined`
v8::Handle<v8::ObjectTemplate> result = v8::ObjectTemplate::New();
result->Set(v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), *functionName), v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), *functionSource));
functionName is set to "doStuff" and the definition of the function lives inside of the functionSource.
I have then created a context with this template and I get the above mentioned error message when I attempt to access these functions.
Regards
Renier