Open eaglexiang opened 5 years ago
In a go-based JS runtime I used before called otto
, I can use method like:
func each(call otto.FunctionCall) otto.Value {
this := call.This // this is caller
}
Unfortunately it's not possible with the current code, but it doesn't look too hard to add.
This *Value
to v8.CallbackArgs
here: https://github.com/augustoroman/v8/blob/master/v8.go#L39-L48this C.ValueTuple
parameter to go_callback_handler
here: https://github.com/augustoroman/v8/blob/master/v8.go#L39-L48args.This()
from the FunctionCallbackInfo
class passed in (ref: https://v8docs.nodesource.com/node-4.8/dd/d0d/classv8_1_1_function_callback_info.html), similar to how each arg is converted to a ValueTuple here: https://github.com/augustoroman/v8/blob/master/v8_c_bridge.cc#L292
I'd like to implementate and import a go-code lib, but I found no property or method of
v8.CallbackArgs
to get method caller.In other words, I can get function args with
v8.CallbackArgs.Args
orv8.CallbackArgs.Arg(int)
, but I cannot get receiver(sometimes called caller), which is usually used like below:If I implementate
$
in golang, that's easy, how can I implementate theeach
method? or how can I get value of caller$("test)
in a standard v8-style callback function?