-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathJavascriptArrayIndexStaticEnumerator.h
More file actions
62 lines (54 loc) · 1.69 KB
/
JavascriptArrayIndexStaticEnumerator.h
File metadata and controls
62 lines (54 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
#pragma once
namespace Js
{
//
// An enumerator to enumerate JavascriptArray index property names as uint32 indices.
//
class JavascriptArrayIndexStaticEnumerator
{
public:
typedef JavascriptArray ArrayType;
private:
JavascriptArray* m_array; // The JavascriptArray to enumerate on
uint32 m_index; // Current index
public:
JavascriptArrayIndexStaticEnumerator(JavascriptArray* array)
: m_array(array)
{
#if ENABLE_COPYONACCESS_ARRAY
JavascriptLibrary::CheckAndConvertCopyOnAccessNativeIntArray<Var>(m_array);
#endif
Reset();
}
//
// Reset to enumerate from beginning.
//
void Reset()
{
m_index = JavascriptArray::InvalidIndex;
}
//
// Get the current index. Valid only when MoveNext() returns true.
//
uint32 GetIndex() const
{
return m_index;
}
//
// Move to next index. If successful, use GetIndex() to get the index.
//
bool MoveNext()
{
m_index = m_array->GetNextIndex(m_index);
if (m_index != JavascriptArray::InvalidIndex)
{
return true;
}
return false;
}
};
}