func (v *Value) TypeName() string { var result string v.cx.rt.Use(func() { result = C.GoString(C.JS_GetTypeName(v.cx.jscx, C.JS_TypeOfValue(v.cx.jscx, v.val))) }) return result }
func (self *JS) jsval2goval(val C.jsval) interface{} { t := C.JS_TypeOfValue(self.context, val) if t == C.JSTYPE_VOID { return nil } else if t == C.JSTYPE_OBJECT { return &JSObject{self, C.Jsval2JSObject(self.context, val)} } else if t == C.JSTYPE_FUNCTION { return NewJSFunction(self, val) } else if t == C.JSTYPE_STRING { c_string := C.JS_EncodeString(self.context, C.Jsval2JSString(self.context, val)) defer C.free(unsafe.Pointer(c_string)) return C.GoString(c_string) } else if t == C.JSTYPE_NUMBER { return float64(C.Jsval2jsdouble(self.context, val)) } else if t == C.JSTYPE_BOOLEAN { return C.Jsval2JSBool(self.context, val) == C.JS_TRUE } return nil }