Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/thirdparty/metal-cpp/QuartzCore/CAPrivate.hpp
21059 views
1
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
2
//
3
// QuartzCore/CAPrivate.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 "CADefines.hpp"
26
27
#include <objc/runtime.h>
28
29
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
30
31
#define _CA_PRIVATE_CLS(symbol) (Private::Class::s_k##symbol)
32
#define _CA_PRIVATE_SEL(accessor) (Private::Selector::s_k##accessor)
33
34
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
35
36
#if defined(CA_PRIVATE_IMPLEMENTATION)
37
38
#ifdef METALCPP_SYMBOL_VISIBILITY_HIDDEN
39
#define _CA_PRIVATE_VISIBILITY __attribute__((visibility("hidden")))
40
#else
41
#define _CA_PRIVATE_VISIBILITY __attribute__((visibility("default")))
42
#endif // METALCPP_SYMBOL_VISIBILITY_HIDDEN
43
44
#define _CA_PRIVATE_IMPORT __attribute__((weak_import))
45
46
#ifdef __OBJC__
47
#define _CA_PRIVATE_OBJC_LOOKUP_CLASS(symbol) ((__bridge void*)objc_lookUpClass(#symbol))
48
#define _CA_PRIVATE_OBJC_GET_PROTOCOL(symbol) ((__bridge void*)objc_getProtocol(#symbol))
49
#else
50
#define _CA_PRIVATE_OBJC_LOOKUP_CLASS(symbol) objc_lookUpClass(#symbol)
51
#define _CA_PRIVATE_OBJC_GET_PROTOCOL(symbol) objc_getProtocol(#symbol)
52
#endif // __OBJC__
53
54
#define _CA_PRIVATE_DEF_CLS(symbol) void* s_k##symbol _CA_PRIVATE_VISIBILITY = _CA_PRIVATE_OBJC_LOOKUP_CLASS(symbol)
55
#define _CA_PRIVATE_DEF_PRO(symbol) void* s_k##symbol _CA_PRIVATE_VISIBILITY = _CA_PRIVATE_OBJC_GET_PROTOCOL(symbol)
56
#define _CA_PRIVATE_DEF_SEL(accessor, symbol) SEL s_k##accessor _CA_PRIVATE_VISIBILITY = sel_registerName(symbol)
57
#define _CA_PRIVATE_DEF_STR(type, symbol) \
58
_CA_EXTERN type const CA##symbol _CA_PRIVATE_IMPORT; \
59
type const CA::symbol = (nullptr != &CA##symbol) ? CA##symbol : nullptr
60
61
#else
62
63
#define _CA_PRIVATE_DEF_CLS(symbol) extern void* s_k##symbol
64
#define _CA_PRIVATE_DEF_PRO(symbol) extern void* s_k##symbol
65
#define _CA_PRIVATE_DEF_SEL(accessor, symbol) extern SEL s_k##accessor
66
#define _CA_PRIVATE_DEF_STR(type, symbol) extern type const CA::symbol
67
68
#endif // CA_PRIVATE_IMPLEMENTATION
69
70
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
71
72
namespace CA
73
{
74
namespace Private
75
{
76
namespace Class
77
{
78
_CA_PRIVATE_DEF_CLS(CAMetalLayer);
79
} // Class
80
} // Private
81
} // CA
82
83
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
84
85
namespace CA
86
{
87
namespace Private
88
{
89
namespace Protocol
90
{
91
92
_CA_PRIVATE_DEF_PRO(CAMetalDrawable);
93
94
} // Protocol
95
} // Private
96
} // CA
97
98
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
99
100
namespace CA
101
{
102
namespace Private
103
{
104
namespace Selector
105
{
106
_CA_PRIVATE_DEF_SEL(allowsNextDrawableTimeout,
107
"allowsNextDrawableTimeout");
108
_CA_PRIVATE_DEF_SEL(colorspace,
109
"colorspace");
110
_CA_PRIVATE_DEF_SEL(device,
111
"device");
112
_CA_PRIVATE_DEF_SEL(displaySyncEnabled,
113
"displaySyncEnabled");
114
_CA_PRIVATE_DEF_SEL(drawableSize,
115
"drawableSize");
116
_CA_PRIVATE_DEF_SEL(framebufferOnly,
117
"framebufferOnly");
118
_CA_PRIVATE_DEF_SEL(layer,
119
"layer");
120
_CA_PRIVATE_DEF_SEL(maximumDrawableCount,
121
"maximumDrawableCount");
122
_CA_PRIVATE_DEF_SEL(nextDrawable,
123
"nextDrawable");
124
_CA_PRIVATE_DEF_SEL(pixelFormat,
125
"pixelFormat");
126
_CA_PRIVATE_DEF_SEL(residencySet,
127
"residencySet");
128
_CA_PRIVATE_DEF_SEL(setAllowsNextDrawableTimeout_,
129
"setAllowsNextDrawableTimeout:");
130
_CA_PRIVATE_DEF_SEL(setColorspace_,
131
"setColorspace:");
132
_CA_PRIVATE_DEF_SEL(setDevice_,
133
"setDevice:");
134
_CA_PRIVATE_DEF_SEL(setDisplaySyncEnabled_,
135
"setDisplaySyncEnabled:");
136
_CA_PRIVATE_DEF_SEL(setDrawableSize_,
137
"setDrawableSize:");
138
_CA_PRIVATE_DEF_SEL(setFramebufferOnly_,
139
"setFramebufferOnly:");
140
_CA_PRIVATE_DEF_SEL(setMaximumDrawableCount_,
141
"setMaximumDrawableCount:");
142
_CA_PRIVATE_DEF_SEL(setPixelFormat_,
143
"setPixelFormat:");
144
_CA_PRIVATE_DEF_SEL(texture,
145
"texture");
146
} // Class
147
} // Private
148
} // CA
149
150
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
151
152