public bool IsNumber() { return(JSApi.JS_IsNumber(this)); }
public bool IsObject() { return(JSApi.JS_IsObject(this)); }
public bool IsBoolean() { return(JSApi.JS_IsBool(this)); }
public bool IsString() { return(JSApi.JS_IsString(this)); }
public bool IsUndefined() { return(JSApi.JS_IsUndefined(this)); }
public bool IsNullish() { return(JSApi.JS_IsNull(this) || JSApi.JS_IsUndefined(this)); }
public bool IsException() { return(JSApi.JS_IsException(this)); }
public void print_exception(Utils.IScriptLogger logger, Utils.LogLevel logLevel, string title) { var ex = JSApi.JS_GetException(this); try { if (logger != null) { var err_fileName = JSApi.JS_GetProperty(this, ex, JSApi.JS_ATOM_fileName); var err_lineNumber = JSApi.JS_GetProperty(this, ex, JSApi.JS_ATOM_lineNumber); var err_message = JSApi.JS_GetProperty(this, ex, JSApi.JS_ATOM_message); var err_stack = JSApi.JS_GetProperty(this, ex, JSApi.JS_ATOM_stack); try { var fileName = err_fileName.IsNullish() ? "native" : JSApi.GetString(this, err_fileName); var lineNumber = err_lineNumber.IsNullish() ? null : JSApi.GetString(this, err_lineNumber); var message = JSApi.GetString(this, err_message); var stack = JSApi.GetString(this, err_stack); if (string.IsNullOrEmpty(lineNumber)) { if (string.IsNullOrEmpty(stack)) { logger.Write(logLevel, "[{0}] {1} {2}", fileName, title, message); } else { logger.Write(logLevel, "[{0}] {1} {2}\nJavascript stack:\n{3}", fileName, title, message, stack); } } else { if (string.IsNullOrEmpty(stack)) { logger.Write(logLevel, "[{0}:{1}] {2} {3}", fileName, lineNumber, title, message); } else { logger.Write(logLevel, "[{0}:{1}] {2} {3}\nJavascript stack:\n{4}", fileName, lineNumber, title, message, stack); } } } finally { JSApi.JS_FreeValue(this, err_fileName); JSApi.JS_FreeValue(this, err_lineNumber); JSApi.JS_FreeValue(this, err_message); JSApi.JS_FreeValue(this, err_stack); } } } finally { JSApi.JS_FreeValue(this, ex); } }
public void SetProperty(JSValue this_obj, string name, JSCFunction fn, int length = 0) { JSApi.JS_SetPropertyStr(this, this_obj, name, JSApi.JS_NewCFunction(this, fn, name, length)); }