I’m trying to hardcode a function as string, turn it into a function and run it.
Local<Function> cb = "function(){ console.log('HELLO BOSS'); }";
int argc=0;
v8::Handle<v8::Value> * argv;
cb->Call(Context::GetCurrent()->Global(),argc,argv);
Compiler sais I can’t do it directly:
error C2664: 'v8::Handle<T>::Handle(T *)' : cannot convert parameter 1 from 'const char *' to 'v8::Function *'
with
[
T=v8::Function
]
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
x.cpp(15) : see reference to function template instantiation 'v8::Local<T>::Local<const char>(S *)' being compiled
with
[
T=v8::Function,
S=const char
]
How can I do it then? Also, where are all the goodies (eval, new Function, etc)?
I did it. Boy I love this stuff.
I don’t know if it’s right (right as in “any risk associated”) but it seems to work.