-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Version 7.2.2: Added V8Settings.GlobalFlags and V8GlobalFlags.Disable…
…JITCompilation; added IArrayBuffer.InvokeWithDirectAccess and IArrayBufferView.InvokeWithDirectAccess (GitHub Issue #349); added disposal of enumerators created for JavaScript iteration (GitHub Issue #348); fixed dynamic module import from host-invoked functions (GitHub Issue #339); updated API documentation. Tested with V8 9.8.177.9.
- Loading branch information
1 parent
b1fb84b
commit c00be79
Showing
683 changed files
with
2,318 additions
and
1,138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. | ||
|
||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using Microsoft.ClearScript.JavaScript; | ||
|
||
namespace Microsoft.ClearScript.Util | ||
{ | ||
/// <exclude/> | ||
public interface IAsyncEnumeratorPromise<out T> | ||
{ | ||
/// <exclude/> | ||
T Current { get; } | ||
|
||
/// <exclude/> | ||
Task<bool> MoveNextAsync(); | ||
|
||
/// <exclude/> | ||
Task DisposeAsync(); | ||
|
||
/// <exclude/> | ||
object MoveNextPromise(); | ||
|
||
/// <exclude/> | ||
object DisposePromise(); | ||
} | ||
|
||
internal static partial class EnumerableHelpers | ||
{ | ||
public static IAsyncEnumeratorPromise<T> ToAsyncEnumerator<T>(this IEnumerator<T> enumerator, ScriptEngine engine) | ||
{ | ||
return new AsyncEnumeratorPromiseOnEnumerator<T>(engine, enumerator); | ||
} | ||
|
||
public static IAsyncEnumeratorPromise<object> ToAsyncEnumerator(this IEnumerator enumerator, ScriptEngine engine) | ||
{ | ||
return new AsyncEnumeratorPromiseOnEnumerator(engine, enumerator); | ||
} | ||
|
||
public static IAsyncEnumeratorPromise<T> GetAsyncEnumerator<T>(IEnumerable<T> source, ScriptEngine engine) | ||
{ | ||
return source.GetEnumerator().ToAsyncEnumerator(engine); | ||
} | ||
|
||
public static IAsyncEnumeratorPromise<object> GetAsyncEnumerator(IEnumerable source, ScriptEngine engine) | ||
{ | ||
return source.GetEnumerator().ToAsyncEnumerator(engine); | ||
} | ||
} | ||
|
||
internal abstract class AsyncEnumeratorPromiseBase | ||
{ | ||
protected static readonly Task CompletedTask = Task.FromResult(0); | ||
} | ||
|
||
internal abstract class AsyncEnumeratorPromise<T> : AsyncEnumeratorPromiseBase, IAsyncEnumeratorPromise<T> | ||
{ | ||
private readonly ScriptEngine engine; | ||
|
||
protected AsyncEnumeratorPromise(ScriptEngine engine) | ||
{ | ||
this.engine = engine; | ||
} | ||
|
||
public abstract T Current { get; } | ||
|
||
public abstract Task<bool> MoveNextAsync(); | ||
|
||
public abstract Task DisposeAsync(); | ||
|
||
public object MoveNextPromise() | ||
{ | ||
return MoveNextAsync().ToPromise(engine); | ||
} | ||
|
||
public object DisposePromise() | ||
{ | ||
return DisposeAsync().ToPromise(engine); | ||
} | ||
} | ||
|
||
internal sealed class AsyncEnumeratorPromiseOnEnumerator<T> : AsyncEnumeratorPromise<T> | ||
{ | ||
private readonly IEnumerator<T> enumerator; | ||
|
||
public AsyncEnumeratorPromiseOnEnumerator(ScriptEngine engine, IEnumerator<T> enumerator) | ||
: base(engine) | ||
{ | ||
this.enumerator = enumerator; | ||
} | ||
|
||
public override T Current => enumerator.Current; | ||
|
||
public override Task<bool> MoveNextAsync() | ||
{ | ||
return Task.FromResult(enumerator.MoveNext()); | ||
} | ||
|
||
public override Task DisposeAsync() | ||
{ | ||
enumerator.Dispose(); | ||
return CompletedTask; | ||
} | ||
} | ||
|
||
internal sealed class AsyncEnumeratorPromiseOnEnumerator : AsyncEnumeratorPromise<object> | ||
{ | ||
private readonly IEnumerator enumerator; | ||
|
||
public AsyncEnumeratorPromiseOnEnumerator(ScriptEngine engine, IEnumerator enumerator) | ||
: base(engine) | ||
{ | ||
this.enumerator = enumerator; | ||
} | ||
|
||
public override object Current => enumerator.Current; | ||
|
||
public override Task<bool> MoveNextAsync() | ||
{ | ||
return Task.FromResult(enumerator.MoveNext()); | ||
} | ||
|
||
public override Task DisposeAsync() | ||
{ | ||
(enumerator as IDisposable)?.Dispose(); | ||
return CompletedTask; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.