Пример #1
0
        internal static JsException Create(JsConvert convert, JsError error)
        {
            string type     = (string)convert.FromJsValue(error.Type);
            string resource = (string)convert.FromJsValue(error.Resource);
            string message  = (string)convert.FromJsValue(error.Message);
            int    line     = error.Line;
            int    column   = error.Column + 1;        // because zero based.
            //

            JsException exception;

            if (error.Exception.Type == JsValueType.String)
            {
                exception = new JsException(type, resource, message, line, column, null);
            }
            else if (type == "SyntaxError")
            {
                exception = new JsSyntaxError(type, resource, message, line, column);
            }
            else
            {
                JsObject nativeException = (JsObject)convert.FromJsValue(error.Exception);
                exception = new JsException(type, resource, message, line, column, nativeException);
            }
            return(exception);
        }
Пример #2
0
        internal JsContext(int id, JsEngine engine, IntPtr engineHandle, Action <int> notifyDispose)
        {
            _id            = id;
            _engine        = engine;
            _notifyDispose = notifyDispose;

            _keepalives = new KeepAliveDictionaryStore();
            _context    = jscontext_new(id, engineHandle);
            _convert    = new JsConvert(this);
        }
Пример #3
0
        internal JsContext(int id, JsEngine engine, IntPtr engineHandle, Action<int> notifyDispose)
        {
            _id = id;
            _engine = engine;
            _notifyDispose = notifyDispose;

            _keepalives = new KeepAliveDictionaryStore();
            _context = jscontext_new(id, engineHandle);
            _convert = new JsConvert(this);
        }
Пример #4
0
        internal JsScript(int id, JsEngine engine, IntPtr engineHandle, JsConvert convert, string code, string name, Action<int> notifyDispose)
        {
            _id = id;
            _engine = engine;
            _notifyDispose = notifyDispose;

            _script = jsscript_new(engineHandle);

            JsValue v = jsscript_compile(_script, code, name);
            object res = convert.FromJsValue(v);
            Exception e = res as JsException;
            if (e != null) {
                throw e;
            }
        }
Пример #5
0
        public JsEngine()
        {
            _keepalives = new KeepAliveDictionaryStore();

            _keepalive_remove = new KeepaliveRemoveDelegate(KeepAliveRemove);
            _keepalive_get_property_value = new KeepAliveGetPropertyValueDelegate(KeepAliveGetPropertyValue);
            _keepalive_set_property_value = new KeepAliveSetPropertyValueDelegate(KeepAliveSetPropertyValue);
            _keepalive_invoke = new KeepAliveInvokeDelegate(KeepAliveInvoke);

            _engine = new HandleRef(this, jsengine_new(
                _keepalive_remove,
                _keepalive_get_property_value, _keepalive_set_property_value,
                _keepalive_invoke));

            _convert = new JsConvert(this);
        }
Пример #6
0
        public JsEngine()
        {
            _keepalives = new KeepAliveDictionaryStore();

            _keepalive_remove             = new KeepaliveRemoveDelegate(KeepAliveRemove);
            _keepalive_get_property_value = new KeepAliveGetPropertyValueDelegate(KeepAliveGetPropertyValue);
            _keepalive_set_property_value = new KeepAliveSetPropertyValueDelegate(KeepAliveSetPropertyValue);
            _keepalive_invoke             = new KeepAliveInvokeDelegate(KeepAliveInvoke);

            _engine = new HandleRef(this, jsengine_new(
                                        _keepalive_remove,
                                        _keepalive_get_property_value, _keepalive_set_property_value,
                                        _keepalive_invoke));

            _convert = new JsConvert(this);
        }
Пример #7
0
        internal JsScript(int id, JsEngine engine, IntPtr engineHandle, JsConvert convert, string code, string name, Action <int> notifyDispose)
        {
            _id            = id;
            _engine        = engine;
            _notifyDispose = notifyDispose;

            _script = jsscript_new(engineHandle);

            JsValue   v   = jsscript_compile(_script, code, name);
            object    res = convert.FromJsValue(v);
            Exception e   = res as JsException;

            if (e != null)
            {
                throw e;
            }
        }
Пример #8
0
        internal JsScript(int id, JsEngine engine, HandleRef engineHandle, JsConvert convert, string code, string name, Action <int> notifyDispose)
        {
            _id            = id;
            _engine        = engine;
            _notifyDispose = notifyDispose;

            _script = new HandleRef(this, jsscript_new(engineHandle));

            IntPtr v2 = jsscript_compile(_script, code, name);
            //JsValue v = jsscript_compile(_script, code, name);

            //object res = convert.FromJsValue(v);
            //Exception e = res as JsException;
            //if (e != null)
            //{
            //    throw e;
            //}
        }
Пример #9
0
        internal JsScript(int id, JsEngine engine, HandleRef engineHandle, JsConvert convert, string code, string name, Action<int> notifyDispose)
        {
            _id = id;
            _engine = engine;
            _notifyDispose = notifyDispose;

            _script = new HandleRef(this, jsscript_new(engineHandle));

            IntPtr v2 = jsscript_compile(_script, code, name);
            //JsValue v = jsscript_compile(_script, code, name);

            //object res = convert.FromJsValue(v);
            //Exception e = res as JsException;
            //if (e != null)
            //{
            //    throw e;
            //}
        }
Пример #10
0
        internal JsContext(int id,
                           JsEngine engine,
                           HandleRef engineHandle,
                           Action <int> notifyDispose,
                           JsTypeDefinitionBuilder jsTypeDefBuilder)
        {
            _id            = id;
            _engine        = engine;
            _notifyDispose = notifyDispose;

            _keepalives = new KeepAliveDictionaryStore();
            _context    = new HandleRef(this, jscontext_new(id, engineHandle));
            _convert    = new JsConvert(this);

            this.jsTypeDefBuilder = jsTypeDefBuilder;

            engineMethodCallbackDel = new ManagedMethodCallDel(EngineListener_MethodCall);
            NativeV8JsInterOp.CtxRegisterManagedMethodCall(this, engineMethodCallbackDel);
            registerMethods.Add(null);    //first is null
            registerProperties.Add(null); //first is null


            proxyStore = new NativeObjectProxyStore(this);
        }
Пример #11
0
        internal static JsException Create(JsConvert convert, JsError error)
        {
            string type = (string)convert.FromJsValue(error.Type);
            string resource = (string)convert.FromJsValue(error.Resource);
            string message = (string)convert.FromJsValue(error.Message);
            int line = error.Line;
            int column = error.Column + 1; // because zero based.
            JsObject nativeException = (JsObject)convert.FromJsValue(error.Exception);

            JsException exception;
            if (type == "SyntaxError") {
                exception = new JsSyntaxError(type, resource, message, line, column);
            } else {
                exception = new JsException(type, resource, message, line, column, nativeException);
            }
            return exception;
        }