forked from Taritsyn/JavaScriptEngineSwitcher
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMsieSettings.cs
More file actions
122 lines (108 loc) · 2.57 KB
/
MsieSettings.cs
File metadata and controls
122 lines (108 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
using System;
using JavaScriptEngineSwitcher.Core.Utilities;
using JavaScriptEngineSwitcher.Msie.Resources;
namespace JavaScriptEngineSwitcher.Msie
{
/// <summary>
/// Settings of the MSIE JS engine
/// </summary>
public sealed class MsieSettings
{
#if !NETSTANDARD1_3
/// <summary>
/// The stack size is sufficient to run the code of modern JavaScript libraries in 32-bit process
/// </summary>
const int STACK_SIZE_32 = 492 * 1024; // like 32-bit Node.js
/// <summary>
/// The stack size is sufficient to run the code of modern JavaScript libraries in 64-bit process
/// </summary>
const int STACK_SIZE_64 = 984 * 1024; // like 64-bit Node.js
/// <summary>
/// The maximum stack size in bytes
/// </summary>
private int _maxStackSize;
#endif
/// <summary>
/// Gets or sets a flag for whether to allow the usage of reflection API in the script code
/// </summary>
/// <remarks>
/// This affects <see cref="Object.GetType"/>, <c>Exception.GetType</c>,
/// <c>Exception.TargetSite</c> and <c>Delegate.Method</c>.
/// </remarks>
public bool AllowReflection
{
get;
set;
}
/// <summary>
/// Gets or sets a flag for whether to enable script debugging features
/// </summary>
public bool EnableDebugging
{
get;
set;
}
/// <summary>
/// Gets or sets a JS engine mode
/// </summary>
public JsEngineMode EngineMode
{
get;
set;
}
#if !NETSTANDARD1_3
/// <summary>
/// Gets or sets a maximum stack size in bytes
/// </summary>
/// <remarks>
/// Set a <c>0</c> to use the default maximum stack size specified in the header
/// for the executable.
/// </remarks>
public int MaxStackSize
{
get { return _maxStackSize; }
set
{
if (value < 0)
{
throw new ArgumentOutOfRangeException(
nameof(value),
Strings.Engine_MaxStackSizeMustBeNonNegative
);
}
_maxStackSize = value;
}
}
#endif
/// <summary>
/// Gets or sets a flag for whether to use the ECMAScript 5 Polyfill
/// </summary>
public bool UseEcmaScript5Polyfill
{
get;
set;
}
/// <summary>
/// Gets or sets a flag for whether to use the JSON2 library
/// </summary>
public bool UseJson2Library
{
get;
set;
}
/// <summary>
/// Constructs an instance of the MSIE settings
/// </summary>
public MsieSettings()
{
AllowReflection = false;
EnableDebugging = false;
EngineMode = JsEngineMode.Auto;
#if !NETSTANDARD1_3
MaxStackSize = Utils.Is64BitProcess() ? STACK_SIZE_64 : STACK_SIZE_32;
#endif
UseEcmaScript5Polyfill = false;
UseJson2Library = false;
}
}
}