// Evaluate JavaScript // When you need high efficiency or run same script many times, please look at Compile() method. func (c *Context) Eval(script string) *Value { var result *Value c.rt.Use(func() { cscript := C.CString(script) defer C.free(unsafe.Pointer(cscript)) var rval C.jsval if C.JS_EvaluateScript(c.jscx, c.jsglobal, cscript, C.uintN(len(script)), C.eval_filename, 0, &rval) == C.JS_TRUE { result = newValue(c, rval) } }) return result }
func (self *JS) Eval(script string) interface{} { var rval C.jsval c_script := C.CString(script) defer C.free(unsafe.Pointer(c_script)) c_scriptname := C.CString("script") defer C.free(unsafe.Pointer(c_scriptname)) C.JS_EvaluateScript(self.context, self.global, c_script, C.uintN(len(script)), c_scriptname, 1, &rval) return self.jsval2goval(rval) }