Skip to content

Commit f764372

Browse files
Version 7.3.1: Added script indexing support for IReadOnlyList<T> (GitHub Issue #393); added ScriptEngine.NullExportValue; added V8RuntimeHeapInfo.TotalAvailableSize and TotalExternalSize (GitHub Issue #391); added partial workaround for VT_BSTR/NULL bug in COM interop (GitHub Issue #390); updated API documentation. Tested with V8 10.3.174.17.
1 parent 2812f30 commit f764372

File tree

674 files changed

+1504
-1071
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

674 files changed

+1504
-1071
lines changed

ClearScript/Exports/VersionSymbols.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
#pragma once
77

8-
#define CLEARSCRIPT_VERSION_STRING "7.3.0"
9-
#define CLEARSCRIPT_VERSION_COMMA_SEPARATED 7,3,0
10-
#define CLEARSCRIPT_VERSION_STRING_INFORMATIONAL "7.3.0"
8+
#define CLEARSCRIPT_VERSION_STRING "7.3.1"
9+
#define CLEARSCRIPT_VERSION_COMMA_SEPARATED 7,3,1
10+
#define CLEARSCRIPT_VERSION_STRING_INFORMATIONAL "7.3.1"
1111
#define CLEARSCRIPT_FILE_FLAGS 0L

ClearScript/HostItem.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,12 @@ private bool BindSpecialTarget<T>(out T specialTarget) where T : class
537537
return specialTarget != null;
538538
}
539539

540+
if (Target.Type.IsAssignableToGenericType(typeof(IReadOnlyList<>), out typeArgs))
541+
{
542+
specialTarget = typeof(ReadOnlyHostList<>).MakeGenericType(typeArgs).CreateInstance(Engine, Target.InvokeTarget) as T;
543+
return specialTarget != null;
544+
}
545+
540546
specialTarget = null;
541547
return false;
542548
}
@@ -1542,7 +1548,7 @@ private object GetHostProperty(PropertyInfo property, BindingFlags invokeFlags,
15421548
var getMethod = property.GetMethod;
15431549
if ((getMethod == null) || !getMethod.IsAccessible(AccessContext) || getMethod.IsBlockedFromScript(DefaultAccess, false))
15441550
{
1545-
throw new UnauthorizedAccessException("Property get method is unavailable or inaccessible");
1551+
throw new UnauthorizedAccessException("The property get method is unavailable or inaccessible");
15461552
}
15471553

15481554
var result = property.GetValue(Target.InvokeTarget, invokeFlags, Type.DefaultBinder, args, culture);
@@ -1628,7 +1634,7 @@ private object SetHostProperty(string name, BindingFlags invokeFlags, object[] a
16281634
{
16291635
if (field.IsLiteral || field.IsInitOnly || field.IsReadOnlyForScript(DefaultAccess))
16301636
{
1631-
throw new UnauthorizedAccessException("Field is read-only");
1637+
throw new UnauthorizedAccessException("The field is read-only");
16321638
}
16331639

16341640
var value = args[0];
@@ -1651,13 +1657,13 @@ private object SetHostProperty(PropertyInfo property, BindingFlags invokeFlags,
16511657
{
16521658
if (property.IsReadOnlyForScript(DefaultAccess))
16531659
{
1654-
throw new UnauthorizedAccessException("Property is read-only");
1660+
throw new UnauthorizedAccessException("The property is read-only");
16551661
}
16561662

16571663
var setMethod = property.SetMethod;
16581664
if ((setMethod == null) || !setMethod.IsAccessible(AccessContext) || setMethod.IsBlockedFromScript(DefaultAccess, false))
16591665
{
1660-
throw new UnauthorizedAccessException("Property set method is unavailable or inaccessible");
1666+
throw new UnauthorizedAccessException("The property set method is unavailable or inaccessible");
16611667
}
16621668

16631669
var value = args[args.Length - 1];

ClearScript/HostList.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,29 @@ public object this[int index]
7272

7373
#endregion
7474
}
75+
76+
internal sealed class ReadOnlyHostList<T> : IHostList
77+
{
78+
private readonly ScriptEngine engine;
79+
private readonly IReadOnlyList<T> list;
80+
81+
public ReadOnlyHostList(ScriptEngine engine, IReadOnlyList<T> list)
82+
{
83+
this.engine = engine;
84+
this.list = list;
85+
}
86+
87+
#region IHostList implementation
88+
89+
public int Count => list.Count;
90+
91+
public object this[int index]
92+
{
93+
get => engine.PrepareResult(list[index], ScriptMemberFlags.None, true);
94+
95+
set => throw new UnauthorizedAccessException("The object is read-only");
96+
}
97+
98+
#endregion
99+
}
75100
}

ClearScript/HostTypeCollection.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System.Collections.Generic;
66
using System.Linq;
77
using System.Reflection;
8-
using System.Runtime.InteropServices;
98
using System.Runtime.InteropServices.ComTypes;
109
using Microsoft.ClearScript.Util;
1110
using Microsoft.ClearScript.Util.COM;
@@ -232,7 +231,7 @@ private PropertyBag AddEnumTypeInfoInternal(ITypeInfo typeInfo)
232231
if (varDescScope.Value.varkind == VARKIND.VAR_CONST)
233232
{
234233
var name = typeInfo.GetMemberName(varDescScope.Value.memid);
235-
node.SetPropertyNoCheck(name, Marshal.GetObjectForNativeVariant(varDescScope.Value.desc.lpvarValue));
234+
node.SetPropertyNoCheck(name, MiscHelpers.GetObjectForVariant(varDescScope.Value.desc.lpvarValue));
236235
}
237236
}
238237
}

ClearScript/Properties/AssemblyInfo.Core.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
[assembly: InternalsVisibleTo("ClearScriptTest")]
1919

2020
[assembly: ComVisible(false)]
21-
[assembly: AssemblyVersion("7.3.0")]
22-
[assembly: AssemblyFileVersion("7.3.0")]
23-
[assembly: AssemblyInformationalVersion("7.3.0")]
21+
[assembly: AssemblyVersion("7.3.1")]
22+
[assembly: AssemblyFileVersion("7.3.1")]
23+
[assembly: AssemblyInformationalVersion("7.3.1")]
2424

2525
namespace Microsoft.ClearScript.Properties
2626
{
2727
internal static class ClearScriptVersion
2828
{
29-
public const string Triad = "7.3.0";
30-
public const string Informational = "7.3.0";
29+
public const string Triad = "7.3.1";
30+
public const string Informational = "7.3.1";
3131
}
3232
}

ClearScript/Properties/AssemblyInfo.V8.ICUData.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
[assembly: InternalsVisibleTo("ClearScript.V8")]
1616

1717
[assembly: ComVisible(false)]
18-
[assembly: AssemblyVersion("7.3.0")]
19-
[assembly: AssemblyFileVersion("7.3.0")]
20-
[assembly: AssemblyInformationalVersion("7.3.0")]
18+
[assembly: AssemblyVersion("7.3.1")]
19+
[assembly: AssemblyFileVersion("7.3.1")]
20+
[assembly: AssemblyInformationalVersion("7.3.1")]

ClearScript/Properties/AssemblyInfo.V8.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
[assembly: InternalsVisibleTo("ClearScriptTest")]
1616

1717
[assembly: ComVisible(false)]
18-
[assembly: AssemblyVersion("7.3.0")]
19-
[assembly: AssemblyFileVersion("7.3.0")]
20-
[assembly: AssemblyInformationalVersion("7.3.0")]
18+
[assembly: AssemblyVersion("7.3.1")]
19+
[assembly: AssemblyFileVersion("7.3.1")]
20+
[assembly: AssemblyInformationalVersion("7.3.1")]

ClearScript/Properties/AssemblyInfo.Windows.Core.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616
[assembly: InternalsVisibleTo("ClearScriptTest")]
1717

1818
[assembly: ComVisible(false)]
19-
[assembly: AssemblyVersion("7.3.0")]
20-
[assembly: AssemblyFileVersion("7.3.0")]
21-
[assembly: AssemblyInformationalVersion("7.3.0")]
19+
[assembly: AssemblyVersion("7.3.1")]
20+
[assembly: AssemblyFileVersion("7.3.1")]
21+
[assembly: AssemblyInformationalVersion("7.3.1")]

ClearScript/Properties/AssemblyInfo.Windows.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
[assembly: InternalsVisibleTo("ClearScriptTest")]
1616

1717
[assembly: ComVisible(false)]
18-
[assembly: AssemblyVersion("7.3.0")]
19-
[assembly: AssemblyFileVersion("7.3.0")]
20-
[assembly: AssemblyInformationalVersion("7.3.0")]
18+
[assembly: AssemblyVersion("7.3.1")]
19+
[assembly: AssemblyFileVersion("7.3.1")]
20+
[assembly: AssemblyInformationalVersion("7.3.1")]

ClearScript/ScriptEngine.cs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,31 @@ public bool DisableExtensionMethods
293293
/// Some script languages support one or more special non-<c>null</c> values that represent
294294
/// nonexistent, missing, unknown, or undefined data. When such a value is marshaled to the
295295
/// host, the script engine maps it to the value of this property. The default value is
296-
/// <c><see cref="Undefined.Value"/></c>.
296+
/// <c><see cref="Undefined.Value">Undefined.Value</see></c>.
297297
/// </remarks>
298298
public object UndefinedImportValue { get; set; } = Undefined.Value;
299299

300+
/// <summary>
301+
/// Gets or sets the engine's null export value.
302+
/// </summary>
303+
/// <remarks>
304+
/// <para>
305+
/// When a null object reference is marshaled to script code, the script engine maps it to
306+
/// the value of this property. The default value is simply <c>null</c>, which corresponds
307+
/// to <c>null</c> or its closest equivalent in the script language. Other useful
308+
/// possibilities include
309+
/// <c><see cref="Undefined.Value">Undefined.Value</see></c> and
310+
/// <c><see href="https://microsoft.github.io/ClearScript/Reference/html/F_Microsoft_ClearScript_Windows_Nothing_Value.htm">Nothing.Value</see></c>.
311+
/// </para>
312+
/// <para>
313+
/// Note that <see cref="ScriptMemberFlags.WrapNullResult"/>,
314+
/// <see cref="EnableNullResultWrapping"/>, and
315+
/// <see href="https://microsoft.github.io/ClearScript/Reference/html/T_Microsoft_ClearScript_Windows_WindowsScriptEngineFlags.htm">MarshalNullAsDispatch</see>
316+
/// all take precedence over this property.
317+
/// </para>
318+
/// </remarks>
319+
public object NullExportValue { get; set; }
320+
300321
/// <summary>
301322
/// Gets or sets the engine's void result export value.
302323
/// </summary>
@@ -306,7 +327,7 @@ public bool DisableExtensionMethods
306327
/// as a C#
307328
/// <c><see href="https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/void">void</see></c>
308329
/// method), the script engine returns the value of this property as a dummy result. The
309-
/// default value is <c><see cref="VoidResult.Value"/></c>.
330+
/// default value is <c><see cref="VoidResult.Value">VoidResult.Value</see></c>.
310331
/// </remarks>
311332
public object VoidResultValue { get; set; } = VoidResult.Value;
312333

0 commit comments

Comments
 (0)