diff --git a/function.go b/function.go index d8e479e6..d9972f90 100644 --- a/function.go +++ b/function.go @@ -16,7 +16,7 @@ type Function struct { } // Call this JavaScript function with the given arguments. -func (fn *Function) Call(recv *Object, args ...Valuer) (*Value, error) { +func (fn *Function) Call(recv *Value, args ...Valuer) (*Value, error) { var argptr *C.ValuePtr if len(args) > 0 { var cArgs = make([]C.ValuePtr, len(args)) diff --git a/function_template_test.go b/function_template_test.go index b2fed391..1f9dca15 100644 --- a/function_template_test.go +++ b/function_template_test.go @@ -71,7 +71,7 @@ func TestFunctionTemplateGetFunction(t *testing.T) { if err != nil { t.Fatal(err) } - ret, err := fn.Call(ctx.Global(), ten) + ret, err := fn.Call(v8go.Undefined(iso), ten) if err != nil { t.Fatal(err) } diff --git a/function_test.go b/function_test.go index d9a039e2..8ba9de64 100644 --- a/function_test.go +++ b/function_test.go @@ -28,7 +28,7 @@ func TestFunctionCall(t *testing.T) { failIf(t, err) fn, _ := addValue.AsFunction() - resultValue, err := fn.Call(ctx.Global(), arg1, arg1) + resultValue, err := fn.Call(v8go.Undefined(iso), arg1, arg1) failIf(t, err) if resultValue.Int32() != 2 { @@ -60,7 +60,7 @@ func TestFunctionCallToGoFunc(t *testing.T) { failIf(t, err) fn, err := val.AsFunction() failIf(t, err) - resultValue, err := fn.Call(ctx.Global()) + resultValue, err := fn.Call(v8go.Undefined(iso)) failIf(t, err) if !called { @@ -87,7 +87,7 @@ func TestFunctionCallWithObjectReceiver(t *testing.T) { failIf(t, err) fn, err := fnVal.AsFunction() failIf(t, err) - resultValue, err := fn.Call(obj) + resultValue, err := fn.Call(obj.Value) failIf(t, err) if !resultValue.IsString() || resultValue.String() != "some val" { @@ -100,7 +100,8 @@ func TestFunctionCallError(t *testing.T) { ctx, err := v8go.NewContext() failIf(t, err) - defer ctx.Isolate().Dispose() + iso := ctx.Isolate() + defer iso.Dispose() defer ctx.Close() _, err = ctx.RunScript("function throws() { throw 'error'; }", "script.js") @@ -109,7 +110,7 @@ func TestFunctionCallError(t *testing.T) { failIf(t, err) fn, _ := addValue.AsFunction() - _, err = fn.Call(ctx.Global()) + _, err = fn.Call(v8go.Undefined(iso)) if err == nil { t.Errorf("expected an error, got none") } diff --git a/object.go b/object.go index 11ef9f63..c52f42d0 100644 --- a/object.go +++ b/object.go @@ -32,7 +32,7 @@ func (o *Object) MethodCall(methodName string, args ...Valuer) (*Value, error) { if err != nil { return nil, err } - return fn.Call(o, args...) + return fn.Call(o.Value, args...) } // Set will set a property on the Object to a given value.