getContextFromJS gets Go Context from C JSContext (internal use).
(cCtx *C.JSContext)
| 28 | |
| 29 | // getContextFromJS gets Go Context from C JSContext (internal use). |
| 30 | func 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. |
| 47 | func registerRuntime(cRt *C.JSRuntime, goRt *Runtime) { |