コード例 #1
0
 /// <summary>
 /// Creates a new V8 script engine instance with the specified options and debug port.
 /// </summary>
 /// <param name="flags">A value that selects options for the operation.</param>
 /// <param name="debugPort">A TCP/IP port on which to listen for a debugger connection.</param>
 /// <returns>A new V8 script engine instance.</returns>
 /// <remarks>
 /// The new script engine instance shares the V8 runtime with other instances created by
 /// this method and any of its overloads.
 /// <para>
 /// V8 supports one script debugger per runtime. If script debugging has been enabled in
 /// the current runtime, additional script engine instances cannot disable it or change its
 /// TCP/IP port, nor can they enable script debugging on a different port.
 /// </para>
 /// </remarks>
 public V8ScriptEngine CreateScriptEngine(V8ScriptEngineFlags flags, int debugPort)
 {
     return CreateScriptEngine(null, flags, debugPort);
 }
コード例 #2
0
        internal V8ScriptEngine(V8Runtime runtime, string name, V8RuntimeConstraints constraints, V8ScriptEngineFlags flags, int debugPort)
            : base((runtime != null) ? runtime.Name + ":" + name : name)
        {
            using (var localRuntime = (runtime != null) ? null : new V8Runtime(name, constraints))
            {
                var activeRuntime = runtime ?? localRuntime;
                hostItemCollateral = activeRuntime.HostItemCollateral;

                engineFlags = flags;
                proxy       = V8ContextProxy.Create(activeRuntime.IsolateProxy, Name, flags.HasFlag(V8ScriptEngineFlags.EnableDebugging), flags.HasFlag(V8ScriptEngineFlags.DisableGlobalMembers), debugPort);
                script      = GetRootItem();

                var engineInternal = Evaluate(
                    MiscHelpers.FormatInvariant("{0} [internal]", GetType().Name),
                    false,
                    @"
                        EngineInternal = (function () {

                            function convertArgs(args) {
                                var result = [];
                                var count = args.Length;
                                for (var i = 0; i < count; i++) {
                                    result.push(args[i]);
                                }
                                return result;
                            }

                            function construct(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15) {
                                return new this(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15);
                            }

                            return {

                                getCommandResult: function (value) {
                                    if (value != null) {
                                        if (((typeof(value) == 'object') && !value.hasOwnProperty('{c2cf47d3-916b-4a3f-be2a-6ff567425808}')) || (typeof(value) == 'function')) {
                                            if (typeof(value.toString) == 'function') {
                                                return value.toString();
                                            }
                                        }
                                    }
                                    return value;
                                },

                                invokeConstructor: function (constructor, args) {
                                    if (typeof(constructor) != 'function') {
                                        throw new Error('Function expected');
                                    }
                                    return construct.apply(constructor, convertArgs(args));
                                },

                                invokeMethod: function (target, method, args) {
                                    if (typeof(method) != 'function') {
                                        throw new Error('Function expected');
                                    }
                                    return method.apply(target, convertArgs(args));
                                },

                                getStackTrace: function () {
                                    try {
                                        throw new Error('[stack trace]');
                                    }
                                    catch (exception) {
                                        return exception.stack;
                                    }
                                    return '';
                                }
                            };
                        })();
                    "
                    );

                ((IDisposable)engineInternal).Dispose();
            }
        }
コード例 #3
0
 /// <summary>
 /// Creates a new V8 script engine instance with the specified options.
 /// </summary>
 /// <param name="flags">A value that selects options for the operation.</param>
 /// <returns>A new V8 script engine instance.</returns>
 /// <remarks>
 /// The new script engine instance shares the V8 runtime with other instances created by
 /// this method and any of its overloads.
 /// <para>
 /// V8 supports one script debugger per runtime. If script debugging has been enabled in
 /// the current runtime, additional script engine instances cannot disable it or change its
 /// TCP/IP port, nor can they enable script debugging on a different port.
 /// </para>
 /// </remarks>
 public V8ScriptEngine CreateScriptEngine(V8ScriptEngineFlags flags)
 {
     return CreateScriptEngine(null, flags);
 }
コード例 #4
0
 /// <summary>
 /// Initializes a new V8 script engine instance with the specified name, resource constraints, and options.
 /// </summary>
 /// <param name="name">A name to associate with the instance. Currently this name is used only as a label in presentation contexts such as debugger user interfaces.</param>
 /// <param name="constraints">Resource constraints for the V8 runtime (see remarks).</param>
 /// <param name="flags">A value that selects options for the operation.</param>
 /// <remarks>
 /// A separate V8 runtime is created for the new script engine instance.
 /// </remarks>
 public V8ScriptEngine(string name, V8RuntimeConstraints constraints, V8ScriptEngineFlags flags)
     : this(name, constraints, flags, 0)
 {
 }
コード例 #5
0
 /// <summary>
 /// Initializes a new V8 script engine instance with the specified name, resource constraints, options, and debug port.
 /// </summary>
 /// <param name="name">A name to associate with the instance. Currently this name is used only as a label in presentation contexts such as debugger user interfaces.</param>
 /// <param name="constraints">Resource constraints for the V8 runtime (see remarks).</param>
 /// <param name="flags">A value that selects options for the operation.</param>
 /// <param name="debugPort">A TCP/IP port on which to listen for a debugger connection.</param>
 /// <remarks>
 /// A separate V8 runtime is created for the new script engine instance.
 /// </remarks>
 public V8ScriptEngine(string name, V8RuntimeConstraints constraints, V8ScriptEngineFlags flags, int debugPort)
     : this(null, name, constraints, flags, debugPort)
 {
 }
コード例 #6
0
 public V8ContextProxyImpl(V8IsolateProxy isolateProxy, string name, V8ScriptEngineFlags flags, int debugPort)
 {
     holder = new V8EntityHolder("V8 script engine", () => ((V8IsolateProxyImpl)isolateProxy).CreateContext(name, flags, debugPort));
 }
コード例 #7
0
 /// <summary>
 /// Initializes a new V8 script engine instance with the specified resource constraints and options.
 /// </summary>
 /// <param name="constraints">Resource constraints for the V8 runtime (see remarks).</param>
 /// <param name="flags">A value that selects options for the operation.</param>
 /// <remarks>
 /// A separate V8 runtime is created for the new script engine instance.
 /// </remarks>
 public V8ScriptEngine(V8RuntimeConstraints constraints, V8ScriptEngineFlags flags)
     : this(constraints, flags, 0)
 {
 }
コード例 #8
0
 /// <summary>
 /// Initializes a new V8 script engine instance with the specified options and debug port.
 /// </summary>
 /// <param name="flags">A value that selects options for the operation.</param>
 /// <param name="debugPort">A TCP/IP port on which to listen for a debugger connection.</param>
 /// <remarks>
 /// A separate V8 runtime is created for the new script engine instance.
 /// </remarks>
 public V8ScriptEngine(V8ScriptEngineFlags flags, int debugPort)
     : this(null, null, flags, debugPort)
 {
 }
コード例 #9
0
 /// <summary>
 /// Initializes a new V8 script engine instance with the specified name and options.
 /// </summary>
 /// <param name="name">A name to associate with the instance. Currently this name is used only as a label in presentation contexts such as debugger user interfaces.</param>
 /// <param name="flags">A value that selects options for the operation.</param>
 /// <remarks>
 /// A separate V8 runtime is created for the new script engine instance.
 /// </remarks>
 public V8ScriptEngine(string name, V8ScriptEngineFlags flags)
     : this(name, flags, 0)
 {
 }
コード例 #10
0
 public static V8ContextProxy Create(V8IsolateProxy isolateProxy, string name, V8ScriptEngineFlags flags, int debugPort)
 {
     return(new V8ContextProxyImpl(isolateProxy, name, flags, debugPort));
 }
コード例 #11
0
 /// <summary>
 /// Initializes a new V8 script engine instance with the specified options.
 /// </summary>
 /// <param name="flags">A value that selects options for the operation.</param>
 /// <remarks>
 /// A separate V8 runtime is created for the new script engine instance.
 /// </remarks>
 public V8ScriptEngine(V8ScriptEngineFlags flags)
     : this(flags, 0)
 {
 }
コード例 #12
0
 /// <summary>
 /// Creates a new V8 script engine instance with the specified name and options.
 /// </summary>
 /// <param name="engineName">A name to associate with the instance. Currently this name is used only as a label in presentation contexts such as debugger user interfaces.</param>
 /// <param name="flags">A value that selects options for the operation.</param>
 /// <returns>A new V8 script engine instance.</returns>
 /// <remarks>
 /// <para>
 /// The new script engine instance shares the V8 runtime with other instances created by
 /// this method and any of its overloads.
 /// </para>
 /// <para>
 /// V8 supports one script debugger per runtime. If script debugging has been enabled in
 /// the current runtime, additional script engine instances cannot disable it or change its
 /// TCP port, nor can they enable script debugging on a different port.
 /// </para>
 /// </remarks>
 public V8ScriptEngine CreateScriptEngine(string engineName, V8ScriptEngineFlags flags)
 {
     return(CreateScriptEngine(engineName, flags, 0));
 }
コード例 #13
0
 /// <summary>
 /// Creates a new V8 script engine instance with the specified options and debug port.
 /// </summary>
 /// <param name="flags">A value that selects options for the operation.</param>
 /// <param name="debugPort">A TCP port on which to listen for a debugger connection.</param>
 /// <returns>A new V8 script engine instance.</returns>
 /// <remarks>
 /// <para>
 /// The new script engine instance shares the V8 runtime with other instances created by
 /// this method and any of its overloads.
 /// </para>
 /// <para>
 /// V8 supports one script debugger per runtime. If script debugging has been enabled in
 /// the current runtime, additional script engine instances cannot disable it or change its
 /// TCP port, nor can they enable script debugging on a different port.
 /// </para>
 /// </remarks>
 public V8ScriptEngine CreateScriptEngine(V8ScriptEngineFlags flags, int debugPort)
 {
     return(CreateScriptEngine(null, flags, debugPort));
 }
コード例 #14
0
 /// <summary>
 /// Creates a new V8 script engine instance with the specified options.
 /// </summary>
 /// <param name="flags">A value that selects options for the operation.</param>
 /// <returns>A new V8 script engine instance.</returns>
 /// <remarks>
 /// <para>
 /// The new script engine instance shares the V8 runtime with other instances created by
 /// this method and any of its overloads.
 /// </para>
 /// <para>
 /// V8 supports one script debugger per runtime. If script debugging has been enabled in
 /// the current runtime, additional script engine instances cannot disable it or change its
 /// TCP port, nor can they enable script debugging on a different port.
 /// </para>
 /// </remarks>
 public V8ScriptEngine CreateScriptEngine(V8ScriptEngineFlags flags)
 {
     return(CreateScriptEngine(null, flags));
 }
コード例 #15
0
 /// <summary>
 /// Creates a new V8 script engine instance with the specified name and options.
 /// </summary>
 /// <param name="engineName">A name to associate with the instance. Currently this name is used only as a label in presentation contexts such as debugger user interfaces.</param>
 /// <param name="flags">A value that selects options for the operation.</param>
 /// <returns>A new V8 script engine instance.</returns>
 /// <remarks>
 /// The new script engine instance shares the V8 runtime with other instances created by
 /// this method and any of its overloads.
 /// <para>
 /// V8 supports one script debugger per runtime. If script debugging has been enabled in
 /// the current runtime, additional script engine instances cannot disable it or change its
 /// TCP/IP port, nor can they enable script debugging on a different port.
 /// </para>
 /// </remarks>
 public V8ScriptEngine CreateScriptEngine(string engineName, V8ScriptEngineFlags flags)
 {
     return CreateScriptEngine(engineName, flags, 0);
 }
コード例 #16
0
 /// <summary>
 /// Initializes a new V8 script engine instance with the specified name, options, and debug port.
 /// </summary>
 /// <param name="name">A name to associate with the instance. Currently this name is used only as a label in presentation contexts such as debugger user interfaces.</param>
 /// <param name="flags">A value that selects options for the operation.</param>
 /// <param name="debugPort">A TCP/IP port on which to listen for a debugger connection.</param>
 /// <remarks>
 /// A separate V8 runtime is created for the new script engine instance.
 /// </remarks>
 public V8ScriptEngine(string name, V8ScriptEngineFlags flags, int debugPort)
     : this(name, null, flags, debugPort)
 {
 }
コード例 #17
0
 /// <summary>
 /// Creates a new V8 script engine instance with the specified name, options, and debug port.
 /// </summary>
 /// <param name="engineName">A name to associate with the instance. Currently this name is used only as a label in presentation contexts such as debugger user interfaces.</param>
 /// <param name="flags">A value that selects options for the operation.</param>
 /// <param name="debugPort">A TCP/IP port on which to listen for a debugger connection.</param>
 /// <returns>A new V8 script engine instance.</returns>
 /// <remarks>
 /// The new script engine instance shares the V8 runtime with other instances created by
 /// this method and any of its overloads.
 /// <para>
 /// V8 supports one script debugger per runtime. If script debugging has been enabled in
 /// the current runtime, additional script engine instances cannot disable it or change its
 /// TCP/IP port, nor can they enable script debugging on a different port.
 /// </para>
 /// </remarks>
 public V8ScriptEngine CreateScriptEngine(string engineName, V8ScriptEngineFlags flags, int debugPort)
 {
     VerifyNotDisposed();
     return new V8ScriptEngine(this, engineName, null, flags, debugPort) { FormatCode = FormatCode };
 }
コード例 #18
0
 public V8JavaScriptEngine(string name, V8RuntimeConstraints constraints, V8ScriptEngineFlags flags)
     : base(name, constraints, flags)
 {
 }