MCPcopy Create free account
hub / github.com/buke/quickjs-go / goFunctionProxy

Function goFunctionProxy

callback_dispatch.go:52–72  ·  view source on GitHub ↗

export goFunctionProxy

(ctx *C.JSContext, thisVal C.JSValueConst,
	argc C.int, argv *C.JSValueConst, magic C.int)

Source from the content-addressed store, hash-verified

50
51//export goFunctionProxy
52func goFunctionProxy(ctx *C.JSContext, thisVal C.JSValueConst,
53 argc C.int, argv *C.JSValueConst, magic C.int) C.JSValue {
54
55 goCtx, fn, err := getContextAndObject(ctx, magic, errFunctionNotFound)
56 if err != nil {
57 return throwProxyError(ctx, *err)
58 }
59
60 goFn, ok := fn.(func(*Context, *Value, []*Value) *Value)
61 if !ok {
62 return throwProxyError(ctx, errInvalidFunctionType)
63 }
64
65 args := convertCArgsToGoValues(argc, argv, goCtx)
66 thisValue := &Value{ctx: goCtx, ref: C.JSValue(thisVal)}
67 result := goFn(goCtx, thisValue, args)
68 if result == nil {
69 return C.JS_NewUndefined()
70 }
71 return result.ref
72}
73
74//export goClassMethodProxy
75func goClassMethodProxy(ctx *C.JSContext, thisVal C.JSValueConst,

Callers 1

GoFunctionProxyFunction · 0.85

Calls 3

getContextAndObjectFunction · 0.85
throwProxyErrorFunction · 0.85
convertCArgsToGoValuesFunction · 0.85

Tested by

no test coverage detected