func NewJSFunction(js *JS, function C.jsval) *JSFunction { rval := &JSFunction{js, function} C.JS_AddValueRoot(rval.js.context, &(rval.function)) runtime.SetFinalizer(rval, func(f *JSFunction) { C.JS_RemoveValueRoot(f.js.context, &(f.function)) }) return rval }
func newValue(cx *Context, val C.jsval) *Value { result := &Value{cx, val} C.JS_AddValueRoot(cx.jscx, &result.val) runtime.SetFinalizer(result, func(v *Value) { cx.rt.valDisposeChan <- v }) return result }