Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/thirdparty/metal-cpp/Foundation/NSEnumerator.hpp
21066 views
1
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
2
//
3
// Foundation/NSEnumerator.hpp
4
//
5
// Copyright 2020-2024 Apple Inc.
6
//
7
// Licensed under the Apache License, Version 2.0 (the "License");
8
// you may not use this file except in compliance with the License.
9
// You may obtain a copy of the License at
10
//
11
// http://www.apache.org/licenses/LICENSE-2.0
12
//
13
// Unless required by applicable law or agreed to in writing, software
14
// distributed under the License is distributed on an "AS IS" BASIS,
15
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
// See the License for the specific language governing permissions and
17
// limitations under the License.
18
//
19
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
20
21
#pragma once
22
23
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
24
25
#include "NSObject.hpp"
26
#include "NSTypes.hpp"
27
28
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
29
30
namespace NS
31
{
32
struct FastEnumerationState
33
{
34
unsigned long state;
35
Object** itemsPtr;
36
unsigned long* mutationsPtr;
37
unsigned long extra[5];
38
} _NS_PACKED;
39
40
class FastEnumeration : public Referencing<FastEnumeration>
41
{
42
public:
43
NS::UInteger countByEnumerating(FastEnumerationState* pState, Object** pBuffer, NS::UInteger len);
44
};
45
46
template <class _ObjectType>
47
class Enumerator : public Referencing<Enumerator<_ObjectType>, FastEnumeration>
48
{
49
public:
50
_ObjectType* nextObject();
51
class Array* allObjects();
52
};
53
}
54
55
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
56
57
_NS_INLINE NS::UInteger NS::FastEnumeration::countByEnumerating(FastEnumerationState* pState, Object** pBuffer, NS::UInteger len)
58
{
59
return Object::sendMessage<UInteger>(this, _NS_PRIVATE_SEL(countByEnumeratingWithState_objects_count_), pState, pBuffer, len);
60
}
61
62
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
63
64
template <class _ObjectType>
65
_NS_INLINE _ObjectType* NS::Enumerator<_ObjectType>::nextObject()
66
{
67
return Object::sendMessage<_ObjectType*>(this, _NS_PRIVATE_SEL(nextObject));
68
}
69
70
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
71
72
template <class _ObjectType>
73
_NS_INLINE NS::Array* NS::Enumerator<_ObjectType>::allObjects()
74
{
75
return Object::sendMessage<Array*>(this, _NS_PRIVATE_SEL(allObjects));
76
}
77
78
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
79
80