| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent d9a58a6 commit a02a01f
32 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,7 +5,7 @@ | |||
| 5 | 5 | ||
| 6 | 6 | #pragma once | |
| 7 | 7 | ||
| 8 | - #define CLEARSCRIPT_VERSION_STRING "7.4.1" | ||
| 9 | - #define CLEARSCRIPT_VERSION_COMMA_SEPARATED 7,4,1 | ||
| 10 | - #define CLEARSCRIPT_VERSION_STRING_INFORMATIONAL "7.4.1" | ||
| 8 | + #define CLEARSCRIPT_VERSION_STRING "7.4.2" | ||
| 9 | + #define CLEARSCRIPT_VERSION_COMMA_SEPARATED 7,4,2 | ||
| 10 | + #define CLEARSCRIPT_VERSION_STRING_INFORMATIONAL "7.4.2" | ||
| 11 | 11 | #define CLEARSCRIPT_FILE_FLAGS 0L | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1408,6 +1408,30 @@ private object GetHostProperty(string name, BindingFlags invokeFlags, object[] a | |||
| 1408 | 1408 | return GetHostProperty(signature, defaultProperty, invokeFlags, args); | |
| 1409 | 1409 | } | |
| 1410 | 1410 | ||
| 1411 | + if (Target.Type.IsArray && (Target.Type.GetArrayRank() == args.Length)) | ||
| 1412 | + { | ||
| 1413 | + // special case to enable VBScript "x(a, b, ...)" syntax when x is a multidimensional array | ||
| 1414 | + | ||
| 1415 | + var indices = new long[args.Length]; | ||
| 1416 | + var failed = false; | ||
| 1417 | + | ||
| 1418 | + for (var position = 0; position < args.Length; position++) | ||
| 1419 | + { | ||
| 1420 | + if (!MiscHelpers.TryGetNumericIndex(args[position], out long index)) | ||
| 1421 | + { | ||
| 1422 | + failed = true; | ||
| 1423 | + break; | ||
| 1424 | + } | ||
| 1425 | + | ||
| 1426 | + indices[position] = index; | ||
| 1427 | + } | ||
| 1428 | + | ||
| 1429 | + if (!failed) | ||
| 1430 | + { | ||
| 1431 | + return ((Array)Target.InvokeTarget).GetValue(indices); | ||
| 1432 | + } | ||
| 1433 | + } | ||
| 1434 | + | ||
| 1411 | 1435 | if (TargetDynamicMetaObject != null) | |
| 1412 | 1436 | { | |
| 1413 | 1437 | if (TargetDynamicMetaObject.TryGetIndex(args, out var result)) | |
@@ -1641,6 +1665,32 @@ private object SetHostProperty(string name, BindingFlags invokeFlags, object[] a | |||
| 1641 | 1665 | throw new InvalidOperationException("Invalid argument count"); | |
| 1642 | 1666 | } | |
| 1643 | 1667 | ||
| 1668 | + if (Target.Type.IsArray && (Target.Type.GetArrayRank() == (args.Length - 1))) | ||
| 1669 | + { | ||
| 1670 | + // special case to enable VBScript "x(a, b, ...) = value" syntax when x is a multidimensional array | ||
| 1671 | + | ||
| 1672 | + var indices = new long[args.Length - 1]; | ||
| 1673 | + var failed = false; | ||
| 1674 | + | ||
| 1675 | + for (var position = 0; position < (args.Length - 1); position++) | ||
| 1676 | + { | ||
| 1677 | + if (!MiscHelpers.TryGetNumericIndex(args[position], out long index)) | ||
| 1678 | + { | ||
| 1679 | + failed = true; | ||
| 1680 | + break; | ||
| 1681 | + } | ||
| 1682 | + | ||
| 1683 | + indices[position] = index; | ||
| 1684 | + } | ||
| 1685 | + | ||
| 1686 | + if (!failed) | ||
| 1687 | + { | ||
| 1688 | + var value = args[args.Length - 1]; | ||
| 1689 | + ((Array)Target.InvokeTarget).SetValue(value, indices); | ||
| 1690 | + return value; | ||
| 1691 | + } | ||
| 1692 | + } | ||
| 1693 | + | ||
| 1644 | 1694 | if (TargetDynamicMetaObject != null) | |
| 1645 | 1695 | { | |
| 1646 | 1696 | if (TargetDynamicMetaObject.TrySetIndex(args.Take(args.Length - 1).ToArray(), args[args.Length - 1], out result)) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,15 +18,15 @@ | |||
| 18 | 18 | [assembly: InternalsVisibleTo("ClearScriptTest")] | |
| 19 | 19 | ||
| 20 | 20 | [assembly: ComVisible(false)] | |
| 21 | - [assembly: AssemblyVersion("7.4.1")] | ||
| 22 | - [assembly: AssemblyFileVersion("7.4.1")] | ||
| 23 | - [assembly: AssemblyInformationalVersion("7.4.1")] | ||
| 21 | + [assembly: AssemblyVersion("7.4.2")] | ||
| 22 | + [assembly: AssemblyFileVersion("7.4.2")] | ||
| 23 | + [assembly: AssemblyInformationalVersion("7.4.2")] | ||
| 24 | 24 | ||
| 25 | 25 | namespace Microsoft.ClearScript.Properties | |
| 26 | 26 | { | |
| 27 | 27 | internal static class ClearScriptVersion | |
| 28 | 28 | { | |
| 29 | - public const string Triad = "7.4.1"; | ||
| 30 | - public const string Informational = "7.4.1"; | ||
| 29 | + public const string Triad = "7.4.2"; | ||
| 30 | + public const string Informational = "7.4.2"; | ||
| 31 | 31 | } | |
| 32 | 32 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,6 +15,6 @@ | |||
| 15 | 15 | [assembly: InternalsVisibleTo("ClearScript.V8")] | |
| 16 | 16 | ||
| 17 | 17 | [assembly: ComVisible(false)] | |
| 18 | - [assembly: AssemblyVersion("7.4.1")] | ||
| 19 | - [assembly: AssemblyFileVersion("7.4.1")] | ||
| 20 | - [assembly: AssemblyInformationalVersion("7.4.1")] | ||
| 18 | + [assembly: AssemblyVersion("7.4.2")] | ||
| 19 | + [assembly: AssemblyFileVersion("7.4.2")] | ||
| 20 | + [assembly: AssemblyInformationalVersion("7.4.2")] | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,6 +15,6 @@ | |||
| 15 | 15 | [assembly: InternalsVisibleTo("ClearScriptTest")] | |
| 16 | 16 | ||
| 17 | 17 | [assembly: ComVisible(false)] | |
| 18 | - [assembly: AssemblyVersion("7.4.1")] | ||
| 19 | - [assembly: AssemblyFileVersion("7.4.1")] | ||
| 20 | - [assembly: AssemblyInformationalVersion("7.4.1")] | ||
| 18 | + [assembly: AssemblyVersion("7.4.2")] | ||
| 19 | + [assembly: AssemblyFileVersion("7.4.2")] | ||
| 20 | + [assembly: AssemblyInformationalVersion("7.4.2")] | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,6 +16,6 @@ | |||
| 16 | 16 | [assembly: InternalsVisibleTo("ClearScriptTest")] | |
| 17 | 17 | ||
| 18 | 18 | [assembly: ComVisible(false)] | |
| 19 | - [assembly: AssemblyVersion("7.4.1")] | ||
| 20 | - [assembly: AssemblyFileVersion("7.4.1")] | ||
| 21 | - [assembly: AssemblyInformationalVersion("7.4.1")] | ||
| 19 | + [assembly: AssemblyVersion("7.4.2")] | ||
| 20 | + [assembly: AssemblyFileVersion("7.4.2")] | ||
| 21 | + [assembly: AssemblyInformationalVersion("7.4.2")] | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,6 +15,6 @@ | |||
| 15 | 15 | [assembly: InternalsVisibleTo("ClearScriptTest")] | |
| 16 | 16 | ||
| 17 | 17 | [assembly: ComVisible(false)] | |
| 18 | - [assembly: AssemblyVersion("7.4.1")] | ||
| 19 | - [assembly: AssemblyFileVersion("7.4.1")] | ||
| 20 | - [assembly: AssemblyInformationalVersion("7.4.1")] | ||
| 18 | + [assembly: AssemblyVersion("7.4.2")] | ||
| 19 | + [assembly: AssemblyFileVersion("7.4.2")] | ||
| 20 | + [assembly: AssemblyInformationalVersion("7.4.2")] | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,24 +2,31 @@ | |||
| 2 | 2 | // Licensed under the MIT license. | |
| 3 | 3 | ||
| 4 | 4 | using System; | |
| 5 | + using System.Collections.Concurrent; | ||
| 5 | 6 | using System.Runtime.InteropServices; | |
| 6 | 7 | using System.Runtime.InteropServices.ComTypes; | |
| 7 | 8 | ||
| 8 | 9 | namespace Microsoft.ClearScript.Util.COM | |
| 9 | 10 | { | |
| 10 | 11 | internal static partial class TypeInfoHelpers | |
| 11 | 12 | { | |
| 13 | + private static readonly ConcurrentDictionary<Guid, Type> managedTypeMap = new ConcurrentDictionary<Guid, Type>(); | ||
| 14 | + | ||
| 12 | 15 | public static Type GetManagedType(this ITypeInfo typeInfo) | |
| 13 | 16 | { | |
| 14 | - var pTypeInfo = Marshal.GetComInterfaceForObject(typeInfo, typeof(ITypeInfo)); | ||
| 15 | - try | ||
| 16 | - { | ||
| 17 | - return Marshal.GetTypeForITypeInfo(pTypeInfo); | ||
| 18 | - } | ||
| 19 | - finally | ||
| 17 | + var guid = typeInfo.GetGuid(); | ||
| 18 | + return (guid == Guid.Empty) ? null : managedTypeMap.GetOrAdd(guid, _ => | ||
| 20 | 19 | { | |
| 21 | - Marshal.Release(pTypeInfo); | ||
| 22 | - } | ||
| 20 | + var pTypeInfo = Marshal.GetComInterfaceForObject(typeInfo, typeof(ITypeInfo)); | ||
| 21 | + try | ||
| 22 | + { | ||
| 23 | + return Marshal.GetTypeForITypeInfo(pTypeInfo); | ||
| 24 | + } | ||
| 25 | + finally | ||
| 26 | + { | ||
| 27 | + Marshal.Release(pTypeInfo); | ||
| 28 | + } | ||
| 29 | + }); | ||
| 23 | 30 | } | |
| 24 | 31 | } | |
| 25 | 32 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -487,7 +487,7 @@ public static object CreateInstance(this Type type, BindingFlags flags, params o | |||
| 487 | 487 | ||
| 488 | 488 | public static object CreateInstance(this Type type, IHostInvokeContext invokeContext, HostTarget target, object[] args, object[] bindArgs) | |
| 489 | 489 | { | |
| 490 | - if (type.IsCOMObject || (type.IsValueType && (args.Length < 1))) | ||
| 490 | + if (type.IsCOMObject) | ||
| 491 | 491 | { | |
| 492 | 492 | return type.CreateInstance(args); | |
| 493 | 493 | } | |
@@ -500,7 +500,13 @@ public static object CreateInstance(this Type type, IHostInvokeContext invokeCon | |||
| 500 | 500 | return InvokeHelpers.InvokeConstructor(invokeContext, boundConstructor, args); | |
| 501 | 501 | } | |
| 502 | 502 | ||
| 503 | - var candidates = type.GetConstructors(flags).Where(testConstructor => testConstructor.IsAccessible(invokeContext.AccessContext) && !testConstructor.IsBlockedFromScript(invokeContext.DefaultAccess)).ToArray(); | ||
| 503 | + var constructors = type.GetConstructors(flags); | ||
| 504 | + if (type.IsValueType && (args.Length < 1) && !constructors.Any(testConstructor => testConstructor.GetParameters().Length < 1)) | ||
| 505 | + { | ||
| 506 | + return type.CreateInstance(); | ||
| 507 | + } | ||
| 508 | + | ||
| 509 | + var candidates = constructors.Where(testConstructor => testConstructor.IsAccessible(invokeContext.AccessContext) && !testConstructor.IsBlockedFromScript(invokeContext.DefaultAccess)).ToArray(); | ||
| 504 | 510 | if (candidates.Length < 1) | |
| 505 | 511 | { | |
| 506 | 512 | throw new MissingMethodException(MiscHelpers.FormatInvariant("Type '{0}' has no constructor that matches the specified arguments", type.GetFullFriendlyName())); | |
@@ -1271,14 +1277,16 @@ public int CompareTo(BindArgCost other) | |||
| 1271 | 1277 | ||
| 1272 | 1278 | private sealed class BindCandidate<T> : IComparable<BindCandidate<T>> where T : MemberInfo | |
| 1273 | 1279 | { | |
| 1280 | + private readonly int defaultArgCount; | ||
| 1274 | 1281 | private readonly bool paramArray; | |
| 1275 | 1282 | private readonly List<BindArgCost> argCosts; | |
| 1276 | 1283 | ||
| 1277 | 1284 | public T Candidate { get; } | |
| 1278 | 1285 | ||
| 1279 | - private BindCandidate(T candidate, bool paramArray, List<BindArgCost> argCosts) | ||
| 1286 | + private BindCandidate(T candidate, int defaultArgCount, bool paramArray, List<BindArgCost> argCosts) | ||
| 1280 | 1287 | { | |
| 1281 | 1288 | Candidate = candidate; | |
| 1289 | + this.defaultArgCount = defaultArgCount; | ||
| 1282 | 1290 | this.paramArray = paramArray; | |
| 1283 | 1291 | this.argCosts = argCosts; | |
| 1284 | 1292 | } | |
@@ -1297,6 +1305,12 @@ public int CompareTo(BindCandidate<T> other) | |||
| 1297 | 1305 | } | |
| 1298 | 1306 | } | |
| 1299 | 1307 | ||
| 1308 | + result = defaultArgCount.CompareTo(other.defaultArgCount); | ||
| 1309 | + if (result != 0) | ||
| 1310 | + { | ||
| 1311 | + return result; | ||
| 1312 | + } | ||
| 1313 | + | ||
| 1300 | 1314 | result = paramArray.CompareTo(other.paramArray); | |
| 1301 | 1315 | if (result != 0) | |
| 1302 | 1316 | { | |
@@ -1316,6 +1330,7 @@ public int CompareTo(BindCandidate<T> other) | |||
| 1316 | 1330 | ||
| 1317 | 1331 | public static BindCandidate<T> TryCreateInstance(T candidate, ParameterInfo[] parameters, object[] args, Type[] argTypes) | |
| 1318 | 1332 | { | |
| 1333 | + var defaultArgCount = 0; | ||
| 1319 | 1334 | var paramArray = false; | |
| 1320 | 1335 | var argCosts = new List<BindArgCost>(); | |
| 1321 | 1336 | ||
@@ -1343,6 +1358,7 @@ public static BindCandidate<T> TryCreateInstance(T candidate, ParameterInfo[] pa | |||
| 1343 | 1358 | return null; | |
| 1344 | 1359 | } | |
| 1345 | 1360 | ||
| 1361 | + defaultArgCount += 1; | ||
| 1346 | 1362 | continue; | |
| 1347 | 1363 | } | |
| 1348 | 1364 | ||
@@ -1359,13 +1375,13 @@ public static BindCandidate<T> TryCreateInstance(T candidate, ParameterInfo[] pa | |||
| 1359 | 1375 | { | |
| 1360 | 1376 | if (argIndex >= args.Length) | |
| 1361 | 1377 | { | |
| 1362 | - return new BindCandidate<T>(candidate, true, argCosts); | ||
| 1378 | + return new BindCandidate<T>(candidate, defaultArgCount, true, argCosts); | ||
| 1363 | 1379 | } | |
| 1364 | 1380 | ||
| 1365 | 1381 | if ((argIndex == (args.Length - 1)) && paramType.IsBindableFromArg(args[argIndex], argTypes[argIndex], out cost)) | |
| 1366 | 1382 | { | |
| 1367 | 1383 | argCosts.Add(cost); | |
| 1368 | - return new BindCandidate<T>(candidate, true, argCosts); | ||
| 1384 | + return new BindCandidate<T>(candidate, defaultArgCount, true, argCosts); | ||
| 1369 | 1385 | } | |
| 1370 | 1386 | ||
| 1371 | 1387 | paramType = paramType.GetElementType(); | |
@@ -1385,7 +1401,7 @@ public static BindCandidate<T> TryCreateInstance(T candidate, ParameterInfo[] pa | |||
| 1385 | 1401 | return null; | |
| 1386 | 1402 | } | |
| 1387 | 1403 | ||
| 1388 | - return new BindCandidate<T>(candidate, paramArray, argCosts); | ||
| 1404 | + return new BindCandidate<T>(candidate, defaultArgCount, paramArray, argCosts); | ||
| 1389 | 1405 | } | |
| 1390 | 1406 | } | |
| 1391 | 1407 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,6 +11,6 @@ | |||
| 11 | 11 | [assembly: AssemblyCopyright("(c) Microsoft Corporation")] | |
| 12 | 12 | ||
| 13 | 13 | [assembly: ComVisible(false)] | |
| 14 | - [assembly: AssemblyVersion("7.4.1")] | ||
| 15 | - [assembly: AssemblyFileVersion("7.4.1")] | ||
| 16 | - [assembly: AssemblyInformationalVersion("7.4.1")] | ||
| 14 | + [assembly: AssemblyVersion("7.4.2")] | ||
| 15 | + [assembly: AssemblyFileVersion("7.4.2")] | ||
| 16 | + [assembly: AssemblyInformationalVersion("7.4.2")] | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments