Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename TypedArrayInstance to JsTypedArray #1592

Merged
merged 1 commit into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 18 additions & 18 deletions Jint/JsValueExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public static string AsString(this JsValue value)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool IsUint8Array(this JsValue value)
{
return value is TypedArrayInstance { _arrayElementType: TypedArrayElementType.Uint8 };
return value is JsTypedArray { _arrayElementType: TypedArrayElementType.Uint8 };
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand All @@ -253,13 +253,13 @@ public static byte[] AsUint8Array(this JsValue value)
ThrowWrongTypeException(value, "Uint8Array");
}

return ((TypedArrayInstance) value).ToNativeArray<byte>();
return ((JsTypedArray) value).ToNativeArray<byte>();
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool IsUint8ClampedArray(this JsValue value)
{
return value is TypedArrayInstance { _arrayElementType: TypedArrayElementType.Uint8C };
return value is JsTypedArray { _arrayElementType: TypedArrayElementType.Uint8C };
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand All @@ -270,13 +270,13 @@ public static byte[] AsUint8ClampedArray(this JsValue value)
ThrowWrongTypeException(value, "Uint8ClampedArray");
}

return ((TypedArrayInstance) value).ToNativeArray<byte>();
return ((JsTypedArray) value).ToNativeArray<byte>();
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool IsInt8Array(this JsValue value)
{
return value is TypedArrayInstance { _arrayElementType: TypedArrayElementType.Int8 };
return value is JsTypedArray { _arrayElementType: TypedArrayElementType.Int8 };
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand All @@ -287,13 +287,13 @@ public static sbyte[] AsInt8Array(this JsValue value)
ThrowWrongTypeException(value, "Int8Array");
}

return ((TypedArrayInstance) value).ToNativeArray<sbyte>();
return ((JsTypedArray) value).ToNativeArray<sbyte>();
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool IsInt16Array(this JsValue value)
{
return value is TypedArrayInstance { _arrayElementType: TypedArrayElementType.Int16 };
return value is JsTypedArray { _arrayElementType: TypedArrayElementType.Int16 };
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand All @@ -304,13 +304,13 @@ public static short[] AsInt16Array(this JsValue value)
ThrowWrongTypeException(value, "Int16Array");
}

return ((TypedArrayInstance) value).ToNativeArray<short>();
return ((JsTypedArray) value).ToNativeArray<short>();
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool IsUint16Array(this JsValue value)
{
return value is TypedArrayInstance { _arrayElementType: TypedArrayElementType.Uint16 };
return value is JsTypedArray { _arrayElementType: TypedArrayElementType.Uint16 };
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand All @@ -321,13 +321,13 @@ public static ushort[] AsUint16Array(this JsValue value)
ThrowWrongTypeException(value, "Uint16Array");
}

return ((TypedArrayInstance) value).ToNativeArray<ushort>();
return ((JsTypedArray) value).ToNativeArray<ushort>();
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool IsInt32Array(this JsValue value)
{
return value is TypedArrayInstance { _arrayElementType: TypedArrayElementType.Int32 };
return value is JsTypedArray { _arrayElementType: TypedArrayElementType.Int32 };
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand All @@ -338,13 +338,13 @@ public static int[] AsInt32Array(this JsValue value)
ThrowWrongTypeException(value, "Int32Array");
}

return ((TypedArrayInstance) value).ToNativeArray<int>();
return ((JsTypedArray) value).ToNativeArray<int>();
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool IsUint32Array(this JsValue value)
{
return value is TypedArrayInstance { _arrayElementType: TypedArrayElementType.Uint32 };
return value is JsTypedArray { _arrayElementType: TypedArrayElementType.Uint32 };
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand All @@ -355,13 +355,13 @@ public static uint[] AsUint32Array(this JsValue value)
ThrowWrongTypeException(value, "Uint32Array");
}

return ((TypedArrayInstance) value).ToNativeArray<uint>();
return ((JsTypedArray) value).ToNativeArray<uint>();
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool IsBigInt64Array(this JsValue value)
{
return value is TypedArrayInstance { _arrayElementType: TypedArrayElementType.BigInt64 };
return value is JsTypedArray { _arrayElementType: TypedArrayElementType.BigInt64 };
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand All @@ -372,13 +372,13 @@ public static long[] AsBigInt64Array(this JsValue value)
ThrowWrongTypeException(value, "BigInt64Array");
}

return ((TypedArrayInstance) value).ToNativeArray<long>();
return ((JsTypedArray) value).ToNativeArray<long>();
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool IsBigUint64Array(this JsValue value)
{
return value is TypedArrayInstance { _arrayElementType: TypedArrayElementType.BigUint64 };
return value is JsTypedArray { _arrayElementType: TypedArrayElementType.BigUint64 };
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand All @@ -389,7 +389,7 @@ public static ulong[] AsBigUint64Array(this JsValue value)
ThrowWrongTypeException(value, "BigUint64Array");
}

return ((TypedArrayInstance) value).ToNativeArray<ulong>();
return ((JsTypedArray) value).ToNativeArray<ulong>();
}

[Pure]
Expand Down
4 changes: 2 additions & 2 deletions Jint/Native/Array/ArrayIteratorPrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ public override bool TryIteratorStep(out ObjectInstance nextItem)
private sealed class ArrayLikeIterator : IteratorInstance
{
private readonly ArrayIteratorType _kind;
private readonly TypedArrayInstance? _typedArray;
private readonly JsTypedArray? _typedArray;
private readonly ArrayOperations? _operations;
private uint _position;
private bool _closed;

public ArrayLikeIterator(Engine engine, ObjectInstance objectInstance, ArrayIteratorType kind) : base(engine)
{
_kind = kind;
_typedArray = objectInstance as TypedArrayInstance;
_typedArray = objectInstance as JsTypedArray;
if (_typedArray is null)
{
_operations = ArrayOperations.For(objectInstance);
Expand Down
6 changes: 3 additions & 3 deletions Jint/Native/Array/ArrayOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static ArrayOperations For(ObjectInstance instance)
return new ArrayInstanceOperations(arrayInstance);
}

if (instance is TypedArrayInstance typedArrayInstance)
if (instance is JsTypedArray typedArrayInstance)
{
return new TypedArrayInstanceOperations(typedArrayInstance);
}
Expand Down Expand Up @@ -277,9 +277,9 @@ public override void Set(ulong index, JsValue value, bool updateLength = false,

private sealed class TypedArrayInstanceOperations : ArrayOperations
{
private readonly TypedArrayInstance _target;
private readonly JsTypedArray _target;

public TypedArrayInstanceOperations(TypedArrayInstance target)
public TypedArrayInstanceOperations(JsTypedArray target)
{
_target = target;
}
Expand Down
2 changes: 1 addition & 1 deletion Jint/Native/ArrayBuffer/ArrayBufferConstructor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected override void Initialize()
private static JsValue IsView(JsValue thisObject, JsValue[] arguments)
{
var arg = arguments.At(0);
return arg is DataViewInstance or TypedArrayInstance;
return arg is DataViewInstance or JsTypedArray;
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions Jint/Native/TypedArray/IntrinsicTypedArrayConstructor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ private JsValue Of(JsValue thisObj, JsValue[] items)
/// <summary>
/// https://tc39.es/ecma262/#typedarray-species-create
/// </summary>
internal TypedArrayInstance TypedArraySpeciesCreate(TypedArrayInstance exemplar, JsValue[] argumentList)
internal JsTypedArray TypedArraySpeciesCreate(JsTypedArray exemplar, JsValue[] argumentList)
{
var defaultConstructor = exemplar._arrayElementType.GetConstructor(_realm.Intrinsics)!;
var constructor = SpeciesConstructor(exemplar, defaultConstructor);
Expand All @@ -163,7 +163,7 @@ internal TypedArrayInstance TypedArraySpeciesCreate(TypedArrayInstance exemplar,
/// <summary>
/// https://tc39.es/ecma262/#typedarray-create
/// </summary>
internal static TypedArrayInstance TypedArrayCreate(Realm realm, IConstructor constructor, JsValue[] argumentList)
internal static JsTypedArray TypedArrayCreate(Realm realm, IConstructor constructor, JsValue[] argumentList)
{
var newTypedArray = Construct(constructor, argumentList).ValidateTypedArray(realm);
if (argumentList.Length == 1 && argumentList[0] is JsNumber number)
Expand Down
24 changes: 12 additions & 12 deletions Jint/Native/TypedArray/IntrinsicTypedArrayPrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ protected override void Initialize()
/// </summary>
private JsValue Buffer(JsValue thisObj, JsValue[] arguments)
{
var o = thisObj as TypedArrayInstance;
var o = thisObj as JsTypedArray;
if (o is null)
{
ExceptionHelper.ThrowTypeError(_realm);
Expand All @@ -103,7 +103,7 @@ private JsValue Buffer(JsValue thisObj, JsValue[] arguments)
/// </summary>
private JsValue ByteLength(JsValue thisObj, JsValue[] arguments)
{
var o = thisObj as TypedArrayInstance;
var o = thisObj as JsTypedArray;
if (o is null)
{
ExceptionHelper.ThrowTypeError(_realm);
Expand All @@ -122,7 +122,7 @@ private JsValue ByteLength(JsValue thisObj, JsValue[] arguments)
/// </summary>
private JsValue ByteOffset(JsValue thisObj, JsValue[] arguments)
{
var o = thisObj as TypedArrayInstance;
var o = thisObj as JsTypedArray;
if (o is null)
{
ExceptionHelper.ThrowTypeError(_realm);
Expand All @@ -141,7 +141,7 @@ private JsValue ByteOffset(JsValue thisObj, JsValue[] arguments)
/// </summary>
private JsValue GetLength(JsValue thisObj, JsValue[] arguments)
{
var o = thisObj as TypedArrayInstance;
var o = thisObj as JsTypedArray;
if (o is null)
{
ExceptionHelper.ThrowTypeError(_realm);
Expand Down Expand Up @@ -846,7 +846,7 @@ private ObjectInstance Reverse(JsValue thisObj, JsValue[] arguments)
/// </summary>
private JsValue Set(JsValue thisObj, JsValue[] arguments)
{
var target = thisObj as TypedArrayInstance;
var target = thisObj as JsTypedArray;
if (target is null)
{
ExceptionHelper.ThrowTypeError(_realm);
Expand All @@ -861,7 +861,7 @@ private JsValue Set(JsValue thisObj, JsValue[] arguments)
ExceptionHelper.ThrowRangeError(_realm, "Invalid offset");
}

if (source is TypedArrayInstance typedArrayInstance)
if (source is JsTypedArray typedArrayInstance)
{
SetTypedArrayFromTypedArray(target, targetOffset, typedArrayInstance);
}
Expand All @@ -876,7 +876,7 @@ private JsValue Set(JsValue thisObj, JsValue[] arguments)
/// <summary>
/// https://tc39.es/ecma262/#sec-settypedarrayfromtypedarray
/// </summary>
private void SetTypedArrayFromTypedArray(TypedArrayInstance target, double targetOffset, TypedArrayInstance source)
private void SetTypedArrayFromTypedArray(JsTypedArray target, double targetOffset, JsTypedArray source)
{
var targetBuffer = target._viewedArrayBuffer;
targetBuffer.AssertNotDetached();
Expand Down Expand Up @@ -963,7 +963,7 @@ private void SetTypedArrayFromTypedArray(TypedArrayInstance target, double targe
/// <summary>
/// https://tc39.es/ecma262/#sec-settypedarrayfromarraylike
/// </summary>
private void SetTypedArrayFromArrayLike(TypedArrayInstance target, int targetOffset, JsValue source)
private void SetTypedArrayFromArrayLike(JsTypedArray target, int targetOffset, JsValue source)
{
var targetBuffer = target._viewedArrayBuffer;
targetBuffer.AssertNotDetached();
Expand Down Expand Up @@ -1170,7 +1170,7 @@ private JsValue Sort(JsValue thisObj, JsValue[] arguments)
/// </summary>
private JsValue Subarray(JsValue thisObj, JsValue[] arguments)
{
var o = thisObj as TypedArrayInstance;
var o = thisObj as JsTypedArray;
if (o is null)
{
ExceptionHelper.ThrowTypeError(_realm);
Expand Down Expand Up @@ -1299,7 +1299,7 @@ private JsValue Values(JsValue thisObj, JsValue[] arguments)
/// </summary>
private static JsValue ToStringTag(JsValue thisObj, JsValue[] arguments)
{
if (thisObj is not TypedArrayInstance o)
if (thisObj is not JsTypedArray o)
{
return Undefined;
}
Expand Down Expand Up @@ -1381,7 +1381,7 @@ private ObjectInstance With(JsValue thisObj, JsValue[] arguments)
return a;
}

private TypedArrayInstance TypedArrayCreateSameType(TypedArrayInstance exemplar, JsValue[] argumentList)
private JsTypedArray TypedArrayCreateSameType(JsTypedArray exemplar, JsValue[] argumentList)
{
var constructor = exemplar._arrayElementType.GetConstructor(_realm.Intrinsics);
var result = IntrinsicTypedArrayConstructor.TypedArrayCreate(_realm, constructor, argumentList);
Expand All @@ -1404,7 +1404,7 @@ private TypedArrayInstance TypedArrayCreateSameType(TypedArrayInstance exemplar,
return compareFn;
}

private static JsValue[] SortArray(JsArrayBuffer buffer, ICallable? compareFn, TypedArrayInstance obj)
private static JsValue[] SortArray(JsArrayBuffer buffer, ICallable? compareFn, JsTypedArray obj)
{
var comparer = TypedArrayComparer.WithFunction(buffer, compareFn);
var operations = ArrayOperations.For(obj);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Jint.Native.TypedArray
{
public sealed class TypedArrayInstance : ObjectInstance
public sealed class JsTypedArray : ObjectInstance
{
internal readonly TypedArrayContentType _contentType;
internal readonly TypedArrayElementType _arrayElementType;
Expand All @@ -18,7 +18,7 @@ public sealed class TypedArrayInstance : ObjectInstance
private readonly Intrinsics _intrinsics;
internal uint _arrayLength;

internal TypedArrayInstance(
internal JsTypedArray(
Engine engine,
Intrinsics intrinsics,
TypedArrayElementType type,
Expand Down
4 changes: 2 additions & 2 deletions Jint/Native/TypedArray/TypeArrayHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ namespace Jint.Native.TypedArray;

internal static class TypeArrayHelper
{
internal static TypedArrayInstance ValidateTypedArray(this JsValue o, Realm realm)
internal static JsTypedArray ValidateTypedArray(this JsValue o, Realm realm)
{
var typedArrayInstance = o as TypedArrayInstance;
var typedArrayInstance = o as JsTypedArray;
if (typedArrayInstance is null)
{
ExceptionHelper.ThrowTypeError(realm);
Expand Down