// Call a function value func (v *Value) Call(argv []*Value) *Value { var result *Value v.cx.rt.Use(func() { argv2 := make([]C.jsval, len(argv)) for i := 0; i < len(argv); i++ { argv2[i] = argv[i].val } argv3 := unsafe.Pointer(&argv2) argv4 := (*reflect.SliceHeader)(argv3).Data argv5 := (*C.jsval)(unsafe.Pointer(argv4)) var rval C.jsval if C.JS_CallFunctionValue(v.cx.jscx, nil, v.val, C.uintN(len(argv)), argv5, &rval) == C.JS_TRUE { result = newValue(v.cx, rval) } }) return result }
func (self *JSFunction) Call(receiver *JSObject, params ...interface{}) interface{} { var c_receiver *C.JSObject if receiver == nil { c_receiver = nil } else { c_receiver = receiver.object } var rval C.jsval c_params := C.AllocateJsvalArray(C.int(len(params))) for index, param := range params { C.SetJsvalArray(c_params, C.int(index), self.js.goval2jsval(param)) } C.JS_CallFunctionValue(self.js.context, c_receiver, self.function, C.uintN(len(params)), c_params, &rval) return self.js.jsval2goval(rval) }