Skip to content

Commit 1318942

Browse files
committed
Removed a redundant code
1 parent 0bcddaf commit 1318942

17 files changed

+22
-436
lines changed

src/MsieJavaScriptEngine.Net4/MsieJavaScriptEngine.Net40.csproj

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -222,12 +222,6 @@
222222
<Compile Include="..\MsieJavaScriptEngine\ActiveScript\Debugging\ProcessDebugManagerWrapper.cs">
223223
<Link>ActiveScript\Debugging\ProcessDebugManagerWrapper.cs</Link>
224224
</Compile>
225-
<Compile Include="..\MsieJavaScriptEngine\ActiveScript\Debugging\RawEnumCodeContextsOfPosition32.cs">
226-
<Link>ActiveScript\Debugging\RawEnumCodeContextsOfPosition32.cs</Link>
227-
</Compile>
228-
<Compile Include="..\MsieJavaScriptEngine\ActiveScript\Debugging\RawEnumCodeContextsOfPosition64.cs">
229-
<Link>ActiveScript\Debugging\RawEnumCodeContextsOfPosition64.cs</Link>
230-
</Compile>
231225
<Compile Include="..\MsieJavaScriptEngine\ActiveScript\Debugging\SourceTextAttrs.cs">
232226
<Link>ActiveScript\Debugging\SourceTextAttrs.cs</Link>
233227
</Compile>
@@ -387,15 +381,6 @@
387381
<Compile Include="..\MsieJavaScriptEngine\JsRt\Edge\EdgeNativeMethods.cs">
388382
<Link>JsRt\Edge\EdgeNativeMethods.cs</Link>
389383
</Compile>
390-
<Compile Include="..\MsieJavaScriptEngine\JsRt\IActiveScriptProfilerCallback.cs">
391-
<Link>JsRt\IActiveScriptProfilerCallback.cs</Link>
392-
</Compile>
393-
<Compile Include="..\MsieJavaScriptEngine\JsRt\IActiveScriptProfilerCallback2.cs">
394-
<Link>JsRt\IActiveScriptProfilerCallback2.cs</Link>
395-
</Compile>
396-
<Compile Include="..\MsieJavaScriptEngine\JsRt\IActiveScriptProfilerHeapEnum.cs">
397-
<Link>JsRt\IActiveScriptProfilerHeapEnum.cs</Link>
398-
</Compile>
399384
<Compile Include="..\MsieJavaScriptEngine\JsRt\Ie\ChakraIeJsRtJsEngine.cs">
400385
<Link>JsRt\Ie\ChakraIeJsRtJsEngine.cs</Link>
401386
</Compile>
@@ -474,12 +459,6 @@
474459
<Compile Include="..\MsieJavaScriptEngine\JsRt\JsValueType.cs">
475460
<Link>JsRt\JsValueType.cs</Link>
476461
</Compile>
477-
<Compile Include="..\MsieJavaScriptEngine\JsRt\ProfilerEventMask.cs">
478-
<Link>JsRt\ProfilerEventMask.cs</Link>
479-
</Compile>
480-
<Compile Include="..\MsieJavaScriptEngine\JsRt\ProfilerScriptType.cs">
481-
<Link>JsRt\ProfilerScriptType.cs</Link>
482-
</Compile>
483462
<Compile Include="..\MsieJavaScriptEngine\JsRuntimeException.cs">
484463
<Link>JsRuntimeException.cs</Link>
485464
</Compile>

src/MsieJavaScriptEngine/ActiveScript/ActiveScriptWrapper32.cs

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using EXCEPINFO = System.Runtime.InteropServices.ComTypes.EXCEPINFO;
55

66
using MsieJavaScriptEngine.ActiveScript.Debugging;
7-
using MsieJavaScriptEngine.Helpers;
87

98
namespace MsieJavaScriptEngine.ActiveScript
109
{
@@ -14,24 +13,14 @@ namespace MsieJavaScriptEngine.ActiveScript
1413
internal sealed class ActiveScriptWrapper32 : ActiveScriptWrapperBase
1514
{
1615
/// <summary>
17-
/// Pointer to an instance of 32-bit Active Script parser
18-
/// </summary>
19-
private IntPtr _pActiveScriptParse32;
20-
21-
/// <summary>
22-
/// Pointer to an instance of 32-bit Active Script debugger
23-
/// </summary>
24-
private IntPtr _pActiveScriptDebug32;
25-
26-
/// <summary>
27-
/// Pointer to an instance of 32-bit debug stack frame sniffer
16+
/// Instance of 32-bit Active Script parser
2817
/// </summary>
29-
private IntPtr _pDebugStackFrameSniffer32;
18+
private IActiveScriptParse32 _activeScriptParse32;
3019

3120
/// <summary>
32-
/// Instance of 32-bit Active Script parser
21+
/// Instance of 32-bit Active Script debugger
3322
/// </summary>
34-
private IActiveScriptParse32 _activeScriptParse32;
23+
private IActiveScriptDebug32 _activeScriptDebug32;
3524

3625
/// <summary>
3726
/// Instance of 32-bit debug stack frame sniffer
@@ -47,16 +36,12 @@ internal sealed class ActiveScriptWrapper32 : ActiveScriptWrapperBase
4736
public ActiveScriptWrapper32(JsEngineMode engineMode, bool enableDebugging)
4837
: base(engineMode, enableDebugging)
4938
{
50-
_pActiveScriptParse32 = ComHelpers.QueryInterface<IActiveScriptParse32>(_pActiveScript);
5139
_activeScriptParse32 = (IActiveScriptParse32)_activeScript;
52-
5340
if (_enableDebugging)
5441
{
55-
_pActiveScriptDebug32 = ComHelpers.QueryInterface<IActiveScriptDebug32>(_pActiveScript);
42+
_activeScriptDebug32 = (IActiveScriptDebug32)_activeScript;
5643
if (engineMode == JsEngineMode.Classic)
5744
{
58-
_pDebugStackFrameSniffer32 = ComHelpers.QueryInterfaceNoThrow<IDebugStackFrameSnifferEx32>(
59-
_pActiveScript);
6045
_debugStackFrameSniffer32 = _activeScript as IDebugStackFrameSnifferEx32;
6146
}
6247
}
@@ -68,9 +53,8 @@ public ActiveScriptWrapper32(JsEngineMode engineMode, bool enableDebugging)
6853
protected override uint InnerEnumCodeContextsOfPosition(UIntPtr sourceContext, uint offset,
6954
uint length, out IEnumDebugCodeContexts enumContexts)
7055
{
71-
var del = ComHelpers.GetMethodDelegate<RawEnumCodeContextsOfPosition32>(_pActiveScriptDebug32, 5);
72-
uint result = del(_pActiveScriptDebug32, sourceContext.ToUInt32(), offset, length,
73-
out enumContexts);
56+
uint result = _activeScriptDebug32.EnumCodeContextsOfPosition(sourceContext.ToUInt32(),
57+
offset, length, out enumContexts);
7458

7559
return result;
7660
}
@@ -123,12 +107,9 @@ public override void Dispose()
123107
if (_disposedFlag.Set())
124108
{
125109
_debugStackFrameSniffer32 = null;
110+
_activeScriptDebug32 = null;
126111
_activeScriptParse32 = null;
127112

128-
ComHelpers.ReleaseAndEmpty(ref _pDebugStackFrameSniffer32);
129-
ComHelpers.ReleaseAndEmpty(ref _pActiveScriptDebug32);
130-
ComHelpers.ReleaseAndEmpty(ref _pActiveScriptParse32);
131-
132113
base.Dispose();
133114
}
134115
}

src/MsieJavaScriptEngine/ActiveScript/ActiveScriptWrapper64.cs

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using EXCEPINFO = System.Runtime.InteropServices.ComTypes.EXCEPINFO;
55

66
using MsieJavaScriptEngine.ActiveScript.Debugging;
7-
using MsieJavaScriptEngine.Helpers;
87

98
namespace MsieJavaScriptEngine.ActiveScript
109
{
@@ -14,24 +13,14 @@ namespace MsieJavaScriptEngine.ActiveScript
1413
internal sealed class ActiveScriptWrapper64 : ActiveScriptWrapperBase
1514
{
1615
/// <summary>
17-
/// Pointer to an instance of 64-bit Active Script parser
18-
/// </summary>
19-
private IntPtr _pActiveScriptParse64;
20-
21-
/// <summary>
22-
/// Pointer to an instance of 64-bit Active Script debugger
23-
/// </summary>
24-
private IntPtr _pActiveScriptDebug64;
25-
26-
/// <summary>
27-
/// Pointer to an instance of 64-bit debug stack frame sniffer
16+
/// Instance of 64-bit Active Script parser
2817
/// </summary>
29-
private IntPtr _pDebugStackFrameSniffer64;
18+
private IActiveScriptParse64 _activeScriptParse64;
3019

3120
/// <summary>
32-
/// Instance of 64-bit Active Script parser
21+
/// Instance of 64-bit Active Script debugger
3322
/// </summary>
34-
private IActiveScriptParse64 _activeScriptParse64;
23+
private IActiveScriptDebug64 _activeScriptDebug64;
3524

3625
/// <summary>
3726
/// Instance of 64-bit debug stack frame sniffer
@@ -47,16 +36,12 @@ internal sealed class ActiveScriptWrapper64 : ActiveScriptWrapperBase
4736
public ActiveScriptWrapper64(JsEngineMode engineMode, bool enableDebugging)
4837
: base(engineMode, enableDebugging)
4938
{
50-
_pActiveScriptParse64 = ComHelpers.QueryInterface<IActiveScriptParse64>(_pActiveScript);
5139
_activeScriptParse64 = (IActiveScriptParse64)_activeScript;
52-
5340
if (_enableDebugging)
5441
{
55-
_pActiveScriptDebug64 = ComHelpers.QueryInterface<IActiveScriptDebug64>(_pActiveScript);
42+
_activeScriptDebug64 = (IActiveScriptDebug64)_activeScript;
5643
if (engineMode == JsEngineMode.Classic)
5744
{
58-
_pDebugStackFrameSniffer64 = ComHelpers.QueryInterfaceNoThrow<IDebugStackFrameSnifferEx64>(
59-
_pActiveScript);
6045
_debugStackFrameSniffer64 = _activeScript as IDebugStackFrameSnifferEx64;
6146
}
6247
}
@@ -68,9 +53,8 @@ public ActiveScriptWrapper64(JsEngineMode engineMode, bool enableDebugging)
6853
protected override uint InnerEnumCodeContextsOfPosition(UIntPtr sourceContext, uint offset,
6954
uint length, out IEnumDebugCodeContexts enumContexts)
7055
{
71-
var del = ComHelpers.GetMethodDelegate<RawEnumCodeContextsOfPosition64>(_pActiveScriptDebug64,5);
72-
uint result = del(_pActiveScriptDebug64, sourceContext.ToUInt64(), offset, length,
73-
out enumContexts);
56+
uint result = _activeScriptDebug64.EnumCodeContextsOfPosition(sourceContext.ToUInt64(),
57+
offset, length, out enumContexts);
7458

7559
return result;
7660
}
@@ -123,12 +107,9 @@ public override void Dispose()
123107
if (_disposedFlag.Set())
124108
{
125109
_debugStackFrameSniffer64 = null;
110+
_activeScriptDebug64 = null;
126111
_activeScriptParse64 = null;
127112

128-
ComHelpers.ReleaseAndEmpty(ref _pDebugStackFrameSniffer64);
129-
ComHelpers.ReleaseAndEmpty(ref _pActiveScriptDebug64);
130-
ComHelpers.ReleaseAndEmpty(ref _pActiveScriptParse64);
131-
132113
base.Dispose();
133114
}
134115
}

src/MsieJavaScriptEngine/ActiveScript/ActiveScriptWrapperBase.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@ internal abstract class ActiveScriptWrapperBase : IActiveScriptWrapper
3030
/// </summary>
3131
protected IntPtr _pActiveScript;
3232

33-
/// <summary>
34-
/// Pointer to an instance of Active Script garbage collector
35-
/// </summary>
36-
private IntPtr _pActiveScriptGarbageCollector;
37-
3833
/// <summary>
3934
/// Instance of Active Script engine
4035
/// </summary>
@@ -76,9 +71,6 @@ protected ActiveScriptWrapperBase(JsEngineMode engineMode, bool enableDebugging)
7671
}
7772

7873
_pActiveScript = ComHelpers.CreateInstanceByClsid<IActiveScript>(clsid);
79-
_pActiveScriptGarbageCollector = ComHelpers.QueryInterfaceNoThrow<IActiveScriptGarbageCollector>(
80-
_pActiveScript);
81-
8274
_activeScript = (IActiveScript)Marshal.GetObjectForIUnknown(_pActiveScript);
8375
_activeScriptGarbageCollector = _activeScript as IActiveScriptGarbageCollector;
8476

@@ -242,7 +234,6 @@ public virtual void Dispose()
242234
{
243235
_activeScriptGarbageCollector = null;
244236

245-
ComHelpers.ReleaseAndEmpty(ref _pActiveScriptGarbageCollector);
246237
ComHelpers.ReleaseAndEmpty(ref _pActiveScript);
247238

248239
if (_activeScript != null)

src/MsieJavaScriptEngine/ActiveScript/Debugging/IActiveScriptDebug32.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ [In] [Out] ref IntPtr pAttrs
5353
/// <param name="offset">Character offset relative to start of script text</param>
5454
/// <param name="length">Number of characters in this context</param>
5555
/// <param name="enumContexts">An enumerator of the code contexts in the specified range</param>
56-
void EnumCodeContextsOfPosition(
56+
/// <returns>The method returns an HRESULT</returns>
57+
[PreserveSig]
58+
uint EnumCodeContextsOfPosition(
5759
[In] uint sourceContext,
5860
[In] uint offset,
5961
[In] uint length,

src/MsieJavaScriptEngine/ActiveScript/Debugging/IActiveScriptDebug64.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ [In] [Out] ref IntPtr pAttrs
5353
/// <param name="offset">Character offset relative to start of script text</param>
5454
/// <param name="length">Number of characters in this context</param>
5555
/// <param name="enumContexts">An enumerator of the code contexts in the specified range</param>
56-
void EnumCodeContextsOfPosition(
56+
/// <returns>The method returns an HRESULT</returns>
57+
[PreserveSig]
58+
uint EnumCodeContextsOfPosition(
5759
[In] ulong sourceContext,
5860
[In] uint offset,
5961
[In] uint length,

src/MsieJavaScriptEngine/ActiveScript/Debugging/RawEnumCodeContextsOfPosition32.cs

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/MsieJavaScriptEngine/ActiveScript/Debugging/RawEnumCodeContextsOfPosition64.cs

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/MsieJavaScriptEngine/JsRt/Edge/EdgeJsContext.cs

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -79,23 +79,6 @@ public static bool HasException
7979
}
8080
}
8181

82-
/// <summary>
83-
/// Gets a value indicating whether the heap of the current context is being enumerated
84-
/// </summary>
85-
/// <remarks>
86-
/// Requires an active script context.
87-
/// </remarks>
88-
public static bool IsEnumeratingHeap
89-
{
90-
get
91-
{
92-
bool isEnumerating;
93-
EdgeJsErrorHelpers.ThrowIfError(EdgeNativeMethods.JsIsEnumeratingHeap(out isEnumerating));
94-
95-
return isEnumerating;
96-
}
97-
}
98-
9982
/// <summary>
10083
/// Gets a runtime that the context belongs to
10184
/// </summary>
@@ -366,58 +349,6 @@ public static void StartDebugging()
366349
EdgeJsErrorHelpers.ThrowIfError(EdgeNativeMethods.JsStartDebugging());
367350
}
368351

369-
/// <summary>
370-
/// Starts profiling in the current context
371-
/// </summary>
372-
/// <remarks>
373-
/// Requires an active script context.
374-
/// </remarks>
375-
/// <param name="callback">The profiling callback to use</param>
376-
/// <param name="eventMask">The profiling events to callback with</param>
377-
/// <param name="context">A context to pass to the profiling callback</param>
378-
public static void StartProfiling(IActiveScriptProfilerCallback callback, ProfilerEventMask eventMask, int context)
379-
{
380-
EdgeJsErrorHelpers.ThrowIfError(EdgeNativeMethods.JsStartProfiling(callback, eventMask, context));
381-
}
382-
383-
/// <summary>
384-
/// Stops profiling in the current context
385-
/// </summary>
386-
/// <remarks>
387-
/// <para>
388-
/// Will not return an error if profiling has not started.
389-
/// </para>
390-
/// <para>
391-
/// Requires an active script context.
392-
/// </para>
393-
/// </remarks>
394-
/// <param name="reason">The reason for stopping profiling to pass to the profiler callback</param>
395-
public static void StopProfiling(int reason)
396-
{
397-
EdgeJsErrorHelpers.ThrowIfError(EdgeNativeMethods.JsStopProfiling(reason));
398-
}
399-
400-
/// <summary>
401-
/// Enumerates a heap of the current context.
402-
/// </summary>
403-
/// <remarks>
404-
/// <para>
405-
/// While the heap is being enumerated, the current context cannot be removed, and all calls to
406-
/// modify the state of the context will fail until the heap enumerator is released.
407-
/// </para>
408-
/// <para>
409-
/// Requires an active script context.
410-
/// </para>
411-
/// </remarks>
412-
/// <returns>A heap enumerator</returns>
413-
public static IActiveScriptProfilerHeapEnum EnumerateHeap()
414-
{
415-
IActiveScriptProfilerHeapEnum enumerator;
416-
EdgeJsErrorHelpers.ThrowIfError(EdgeNativeMethods.JsEnumerateHeap(out enumerator));
417-
418-
return enumerator;
419-
}
420-
421352
/// <summary>
422353
/// Adds a reference to a script context
423354
/// </summary>

src/MsieJavaScriptEngine/JsRt/Edge/EdgeNativeMethods.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -290,18 +290,5 @@ internal static extern JsErrorCode JsCreateFunction(EdgeJsNativeFunction nativeF
290290

291291
[DllImport(DllName.Chakra, CharSet = CharSet.Unicode)]
292292
internal static extern JsErrorCode JsIsRuntimeExecutionDisabled(EdgeJsRuntime runtime, out bool isDisabled);
293-
294-
[DllImport(DllName.Chakra, CharSet = CharSet.Unicode)]
295-
internal static extern JsErrorCode JsStartProfiling(IActiveScriptProfilerCallback callback,
296-
ProfilerEventMask eventMask, int context);
297-
298-
[DllImport(DllName.Chakra, CharSet = CharSet.Unicode)]
299-
internal static extern JsErrorCode JsStopProfiling(int reason);
300-
301-
[DllImport(DllName.Chakra, CharSet = CharSet.Unicode)]
302-
internal static extern JsErrorCode JsEnumerateHeap(out IActiveScriptProfilerHeapEnum enumerator);
303-
304-
[DllImport(DllName.Chakra, CharSet = CharSet.Unicode)]
305-
internal static extern JsErrorCode JsIsEnumeratingHeap(out bool isEnumeratingHeap);
306293
}
307294
}

0 commit comments

Comments
 (0)