Skip to content

Commit da3660d

Browse files
committed
Removed a redundant code
1 parent 4953fe1 commit da3660d

17 files changed

+29
-435
lines changed

src/MsieJavaScriptEngine/ActiveScript/ActiveScriptWrapper32.cs

Lines changed: 9 additions & 31 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
@@ -49,18 +38,11 @@ public ActiveScriptWrapper32(string clsid, ScriptLanguageVersion languageVersion
4938
bool enableDebugging)
5039
: base(clsid, languageVersion, enableDebugging)
5140
{
52-
_pActiveScriptParse32 = ComHelpers.QueryInterface<IActiveScriptParse32>(_pActiveScript);
5341
_activeScriptParse32 = (IActiveScriptParse32)_activeScript;
54-
5542
if (_enableDebugging)
5643
{
57-
_pActiveScriptDebug32 = ComHelpers.QueryInterface<IActiveScriptDebug32>(_pActiveScript);
58-
_pDebugStackFrameSniffer32 = ComHelpers.QueryInterfaceNoThrow<IDebugStackFrameSnifferEx32>(
59-
_pActiveScript);
60-
if (_pDebugStackFrameSniffer32 != IntPtr.Zero)
61-
{
62-
_debugStackFrameSniffer32 = _activeScript as IDebugStackFrameSnifferEx32;
63-
}
44+
_activeScriptDebug32 = (IActiveScriptDebug32)_activeScript;
45+
_debugStackFrameSniffer32 = _activeScript as IDebugStackFrameSnifferEx32;
6446
}
6547
}
6648

@@ -70,9 +52,8 @@ public ActiveScriptWrapper32(string clsid, ScriptLanguageVersion languageVersion
7052
protected override uint InnerEnumCodeContextsOfPosition(UIntPtr sourceContext, uint offset,
7153
uint length, out IEnumDebugCodeContexts enumContexts)
7254
{
73-
var del = ComHelpers.GetMethodDelegate<RawEnumCodeContextsOfPosition32>(_pActiveScriptDebug32, 5);
74-
uint result = del(_pActiveScriptDebug32, sourceContext.ToUInt32(), offset, length,
75-
out enumContexts);
55+
uint result = _activeScriptDebug32.EnumCodeContextsOfPosition(sourceContext.ToUInt32(),
56+
offset, length, out enumContexts);
7657

7758
return result;
7859
}
@@ -125,12 +106,9 @@ public override void Dispose()
125106
if (_disposedFlag.Set())
126107
{
127108
_debugStackFrameSniffer32 = null;
109+
_activeScriptDebug32 = null;
128110
_activeScriptParse32 = null;
129111

130-
ComHelpers.ReleaseAndEmpty(ref _pDebugStackFrameSniffer32);
131-
ComHelpers.ReleaseAndEmpty(ref _pActiveScriptDebug32);
132-
ComHelpers.ReleaseAndEmpty(ref _pActiveScriptParse32);
133-
134112
base.Dispose();
135113
}
136114
}

src/MsieJavaScriptEngine/ActiveScript/ActiveScriptWrapper64.cs

Lines changed: 9 additions & 31 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
@@ -49,18 +38,11 @@ public ActiveScriptWrapper64(string clsid, ScriptLanguageVersion languageVersion
4938
bool enableDebugging)
5039
: base(clsid, languageVersion, enableDebugging)
5140
{
52-
_pActiveScriptParse64 = ComHelpers.QueryInterface<IActiveScriptParse64>(_pActiveScript);
5341
_activeScriptParse64 = (IActiveScriptParse64)_activeScript;
54-
5542
if (_enableDebugging)
5643
{
57-
_pActiveScriptDebug64 = ComHelpers.QueryInterface<IActiveScriptDebug64>(_pActiveScript);
58-
_pDebugStackFrameSniffer64 = ComHelpers.QueryInterfaceNoThrow<IDebugStackFrameSnifferEx64>(
59-
_pActiveScript);
60-
if (_pDebugStackFrameSniffer64 != IntPtr.Zero)
61-
{
62-
_debugStackFrameSniffer64 = _activeScript as IDebugStackFrameSnifferEx64;
63-
}
44+
_activeScriptDebug64 = (IActiveScriptDebug64)_activeScript;
45+
_debugStackFrameSniffer64 = _activeScript as IDebugStackFrameSnifferEx64;
6446
}
6547
}
6648

@@ -70,9 +52,8 @@ public ActiveScriptWrapper64(string clsid, ScriptLanguageVersion languageVersion
7052
protected override uint InnerEnumCodeContextsOfPosition(UIntPtr sourceContext, uint offset,
7153
uint length, out IEnumDebugCodeContexts enumContexts)
7254
{
73-
var del = ComHelpers.GetMethodDelegate<RawEnumCodeContextsOfPosition64>(_pActiveScriptDebug64,5);
74-
uint result = del(_pActiveScriptDebug64, sourceContext.ToUInt64(), offset, length,
75-
out enumContexts);
55+
uint result = _activeScriptDebug64.EnumCodeContextsOfPosition(sourceContext.ToUInt64(),
56+
offset, length, out enumContexts);
7657

7758
return result;
7859
}
@@ -125,12 +106,9 @@ public override void Dispose()
125106
if (_disposedFlag.Set())
126107
{
127108
_debugStackFrameSniffer64 = null;
109+
_activeScriptDebug64 = null;
128110
_activeScriptParse64 = null;
129111

130-
ComHelpers.ReleaseAndEmpty(ref _pDebugStackFrameSniffer64);
131-
ComHelpers.ReleaseAndEmpty(ref _pActiveScriptDebug64);
132-
ComHelpers.ReleaseAndEmpty(ref _pActiveScriptParse64);
133-
134112
base.Dispose();
135113
}
136114
}

src/MsieJavaScriptEngine/ActiveScript/ActiveScriptWrapperBase.cs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,7 @@ internal abstract class ActiveScriptWrapperBase : IActiveScriptWrapper
2525
/// <summary>
2626
/// Pointer to an instance of Active Script engine
2727
/// </summary>
28-
protected IntPtr _pActiveScript;
29-
30-
/// <summary>
31-
/// Pointer to an instance of Active Script garbage collector
32-
/// </summary>
33-
private IntPtr _pActiveScriptGarbageCollector;
28+
private IntPtr _pActiveScript;
3429

3530
/// <summary>
3631
/// Instance of Active Script engine
@@ -60,9 +55,6 @@ protected ActiveScriptWrapperBase(string clsid, ScriptLanguageVersion languageVe
6055
_enableDebugging = enableDebugging;
6156

6257
_pActiveScript = ComHelpers.CreateInstanceByClsid<IActiveScript>(clsid);
63-
_pActiveScriptGarbageCollector = ComHelpers.QueryInterfaceNoThrow<IActiveScriptGarbageCollector>(
64-
_pActiveScript);
65-
6658
_activeScript = (IActiveScript)Marshal.GetObjectForIUnknown(_pActiveScript);
6759
_activeScriptGarbageCollector = _activeScript as IActiveScriptGarbageCollector;
6860

@@ -241,7 +233,6 @@ public virtual void Dispose()
241233
{
242234
_activeScriptGarbageCollector = null;
243235

244-
ComHelpers.ReleaseAndEmpty(ref _pActiveScriptGarbageCollector);
245236
ComHelpers.ReleaseAndEmpty(ref _pActiveScript);
246237

247238
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/ActiveScript/Profiling/IActiveScriptProfilerCallback.cs

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

src/MsieJavaScriptEngine/ActiveScript/Profiling/IActiveScriptProfilerHeapEnum.cs

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

src/MsieJavaScriptEngine/ActiveScript/Profiling/ProfilerEventMask.cs

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

0 commit comments

Comments
 (0)