Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/thirdparty/metal-cpp/Foundation/NSArray.hpp
21066 views
1
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
2
//
3
// Foundation/NSArray.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
#include "NSEnumerator.hpp"
28
29
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
30
31
namespace NS
32
{
33
class Array : public Copying<Array>
34
{
35
public:
36
static Array* array();
37
static Array* array(const Object* pObject);
38
static Array* array(const Object* const* pObjects, UInteger count);
39
40
static Array* alloc();
41
42
Array* init();
43
Array* init(const Object* const* pObjects, UInteger count);
44
Array* init(const class Coder* pCoder);
45
46
template <class _Object = Object>
47
_Object* object(UInteger index) const;
48
UInteger count() const;
49
Enumerator<Object>* objectEnumerator() const;
50
};
51
}
52
53
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
54
55
_NS_INLINE NS::Array* NS::Array::array()
56
{
57
return Object::sendMessage<Array*>(_NS_PRIVATE_CLS(NSArray), _NS_PRIVATE_SEL(array));
58
}
59
60
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
61
62
_NS_INLINE NS::Array* NS::Array::array(const Object* pObject)
63
{
64
return Object::sendMessage<Array*>(_NS_PRIVATE_CLS(NSArray), _NS_PRIVATE_SEL(arrayWithObject_), pObject);
65
}
66
67
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
68
69
_NS_INLINE NS::Array* NS::Array::array(const Object* const* pObjects, UInteger count)
70
{
71
return Object::sendMessage<Array*>(_NS_PRIVATE_CLS(NSArray), _NS_PRIVATE_SEL(arrayWithObjects_count_), pObjects, count);
72
}
73
74
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
75
76
_NS_INLINE NS::Array* NS::Array::alloc()
77
{
78
return NS::Object::alloc<Array>(_NS_PRIVATE_CLS(NSArray));
79
}
80
81
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
82
83
_NS_INLINE NS::Array* NS::Array::init()
84
{
85
return NS::Object::init<Array>();
86
}
87
88
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
89
90
_NS_INLINE NS::Array* NS::Array::init(const Object* const* pObjects, UInteger count)
91
{
92
return Object::sendMessage<Array*>(this, _NS_PRIVATE_SEL(initWithObjects_count_), pObjects, count);
93
}
94
95
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
96
97
_NS_INLINE NS::Array* NS::Array::init(const class Coder* pCoder)
98
{
99
return Object::sendMessage<Array*>(this, _NS_PRIVATE_SEL(initWithCoder_), pCoder);
100
}
101
102
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
103
104
_NS_INLINE NS::UInteger NS::Array::count() const
105
{
106
return Object::sendMessage<UInteger>(this, _NS_PRIVATE_SEL(count));
107
}
108
109
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
110
111
template <class _Object>
112
_NS_INLINE _Object* NS::Array::object(UInteger index) const
113
{
114
return Object::sendMessage<_Object*>(this, _NS_PRIVATE_SEL(objectAtIndex_), index);
115
}
116
117
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
118
119
_NS_INLINE NS::Enumerator<NS::Object>* NS::Array::objectEnumerator() const
120
{
121
return NS::Object::sendMessage<Enumerator<NS::Object>*>(this, _NS_PRIVATE_SEL(objectEnumerator));
122
}
123
124
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
125
126