Esempio n. 1
0
 public bool IsNumber()
 {
     return(JSApi.JS_IsNumber(this));
 }
Esempio n. 2
0
 public bool IsObject()
 {
     return(JSApi.JS_IsObject(this));
 }
Esempio n. 3
0
 public bool IsBoolean()
 {
     return(JSApi.JS_IsBool(this));
 }
Esempio n. 4
0
 public bool IsString()
 {
     return(JSApi.JS_IsString(this));
 }
Esempio n. 5
0
 public bool IsUndefined()
 {
     return(JSApi.JS_IsUndefined(this));
 }
Esempio n. 6
0
 public bool IsNullish()
 {
     return(JSApi.JS_IsNull(this) || JSApi.JS_IsUndefined(this));
 }
Esempio n. 7
0
 public bool IsException()
 {
     return(JSApi.JS_IsException(this));
 }
Esempio n. 8
0
        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);
            }
        }
Esempio n. 9
0
 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));
 }