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

Function getContextFromJS

bridge_mapping.go:30–44  ·  view source on GitHub ↗

getContextFromJS gets Go Context from C JSContext (internal use).

(cCtx *C.JSContext)

Source from the content-addressed store, hash-verified

28
29// getContextFromJS gets Go Context from C JSContext (internal use).
30func getContextFromJS(cCtx *C.JSContext) *Context {
31 if value, ok := contextMapping.Load(cCtx); ok {
32 ctx, ok := value.(*Context)
33 if !ok {
34 contextMapping.Delete(cCtx)
35 return nil
36 }
37 if !ctx.hasValidRef() {
38 contextMapping.Delete(cCtx)
39 return nil
40 }
41 return ctx
42 }
43 return nil
44}
45
46// registerRuntime registers Runtime for interrupt handler access.
47func registerRuntime(cRt *C.JSRuntime, goRt *Runtime) {

Calls 3

LoadMethod · 0.80
hasValidRefMethod · 0.80
DeleteMethod · 0.45