Hello Everyone,
I am doing some changes in d8.cc as needed by my project. For this I need
to add and register a C++ function which will be called in Javascript
source. This C++ function must return an integer. Here is my function (in
v8 namespace)
Local<Value> test (const FunctionCallbackInfo<Value>& args)
{
return args[0];
}
And Here is how I am registering it in CreateGlobalTemplate function of
Shell.
Local<ObjectTemplate> Shell::CreateGlobalTemplate(Isolate* isolate) {
Local<ObjectTemplate> global_template = ObjectTemplate::New(isolate);
global_template->Set(String::NewFromUtf8 (isolate, "test", NewStringType::
kNormal).ToLocalChecked(),
FunctionTemplate::New (isolate, test));
When I am making d8 I get the following errors
CXX(target) /home/abhi/ssl/v/v8/out/ia32.release/obj.target/d8/src/d8.o
../src/d8.cc: In static member function ‘static v8::Local<v8::ObjectTemplate
> v8::Shell::CreateGlobalTemplate(v8::Isolate*)’:
../src/d8.cc:1059:39: error: no matching function for call to ‘v8::
FunctionTemplate::New(v8::Isolate*&, v8::Local<v8::Value> (&)(const v8::
FunctionCallbackInfo<v8::Value>&))’
FunctionTemplate::New (isolate, test));
^
../src/d8.cc:1059:39: note: candidate is:
In file included from .././src/v8.h:29:0,
from .././src/gdb-jit.h:8,
from ../src/d8.cc:30:
.././include/v8.h:4350:34: note: static v8::Local<v8::FunctionTemplate> v8::
FunctionTemplate::New(v8::Isolate*, v8::FunctionCallback, v8::Local<v8::
Value>, v8::Local<v8::Signature>, int) <near match>
static Local<FunctionTemplate> New(
^
.././include/v8.h:4350:34: note: no known conversion for argument 2 from ‘
v8::Local<v8::Value>(const v8::FunctionCallbackInfo<v8::Value>&)’ to ‘v8::
FunctionCallback {aka void (*)(const v8::FunctionCallbackInfo<v8::Value>&)}’
Can anyone please tell me what should be the function declaration if I need
to return a value. Any help will be highly appreciated.
Thank You,
Abhinav
--
--
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.