]>
Commit | Line | Data |
---|---|---|
c093abd6 A |
1 | /* |
2 | * Copyright (c) 2011-2012 Apple Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_APACHE_LICENSE_HEADER_START@ | |
5 | * | |
6 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
7 | * you may not use this file except in compliance with the License. | |
8 | * You may obtain a copy of the License at | |
9 | * | |
10 | * http://www.apache.org/licenses/LICENSE-2.0 | |
11 | * | |
12 | * Unless required by applicable law or agreed to in writing, software | |
13 | * distributed under the License is distributed on an "AS IS" BASIS, | |
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
15 | * See the License for the specific language governing permissions and | |
16 | * limitations under the License. | |
17 | * | |
18 | * @APPLE_APACHE_LICENSE_HEADER_END@ | |
19 | */ | |
20 | ||
21 | /* | |
22 | * IMPORTANT: This header file describes INTERNAL interfaces to libdispatch | |
23 | * which are subject to change in future releases of Mac OS X. Any applications | |
24 | * relying on these interfaces WILL break. | |
25 | */ | |
26 | ||
27 | #ifndef __OS_OBJECT_PRIVATE__ | |
28 | #define __OS_OBJECT_PRIVATE__ | |
29 | ||
c093abd6 | 30 | #include <os/object.h> |
6b746eb4 A |
31 | #include <stddef.h> |
32 | #include <stdint.h> | |
c093abd6 A |
33 | |
34 | #if __GNUC__ | |
35 | #define OS_OBJECT_NOTHROW __attribute__((__nothrow__)) | |
36 | #define OS_OBJECT_NONNULL __attribute__((__nonnull__)) | |
37 | #define OS_OBJECT_WARN_RESULT __attribute__((__warn_unused_result__)) | |
38 | #define OS_OBJECT_MALLOC __attribute__((__malloc__)) | |
6b746eb4 | 39 | #ifndef OS_OBJECT_EXPORT |
c093abd6 | 40 | #define OS_OBJECT_EXPORT extern __attribute__((visibility("default"))) |
6b746eb4 | 41 | #endif |
c093abd6 A |
42 | #else |
43 | /*! @parseOnly */ | |
44 | #define OS_OBJECT_NOTHROW | |
45 | /*! @parseOnly */ | |
46 | #define OS_OBJECT_NONNULL | |
47 | /*! @parseOnly */ | |
48 | #define OS_OBJECT_WARN_RESULT | |
49 | /*! @parseOnly */ | |
50 | #define OS_OBJECT_MALLOC | |
6b746eb4 A |
51 | #ifndef OS_OBJECT_EXPORT |
52 | /*! @parseOnly */ | |
c093abd6 A |
53 | #define OS_OBJECT_EXPORT extern |
54 | #endif | |
6b746eb4 | 55 | #endif |
c093abd6 | 56 | |
beb15981 | 57 | #if OS_OBJECT_USE_OBJC && __has_feature(objc_arc) |
c093abd6 A |
58 | #define _OS_OBJECT_OBJC_ARC 1 |
59 | #else | |
60 | #define _OS_OBJECT_OBJC_ARC 0 | |
61 | #endif | |
62 | ||
63 | #define _OS_OBJECT_GLOBAL_REFCNT INT_MAX | |
64 | ||
65 | #define _OS_OBJECT_HEADER(isa, ref_cnt, xref_cnt) \ | |
66 | isa; /* must be pointer-sized */ \ | |
67 | int volatile ref_cnt; \ | |
68 | int volatile xref_cnt | |
69 | ||
70 | #if OS_OBJECT_HAVE_OBJC_SUPPORT | |
beb15981 A |
71 | #define OS_OBJECT_CLASS_SYMBOL(name) OS_##name##_class |
72 | #if TARGET_OS_MAC && !TARGET_OS_SIMULATOR && defined(__i386__) | |
73 | #define OS_OBJECT_HAVE_OBJC1 1 | |
74 | #define OS_OBJECT_HAVE_OBJC2 0 | |
75 | #define OS_OBJC_CLASS_RAW_SYMBOL_NAME(name) \ | |
76 | ".objc_class_name_" OS_STRINGIFY(name) | |
77 | #define _OS_OBJECT_CLASS_HEADER() \ | |
78 | const void *_os_obj_objc_isa | |
79 | #else | |
80 | #define OS_OBJECT_HAVE_OBJC1 0 | |
81 | #define OS_OBJECT_HAVE_OBJC2 1 | |
82 | #define OS_OBJC_CLASS_RAW_SYMBOL_NAME(name) "_OBJC_CLASS_$_" OS_STRINGIFY(name) | |
c093abd6 A |
83 | // Must match size of compiler-generated OBJC_CLASS structure rdar://10640168 |
84 | #define _OS_OBJECT_CLASS_HEADER() \ | |
85 | void *_os_obj_objc_class_t[5] | |
beb15981 A |
86 | #endif |
87 | #define OS_OBJECT_OBJC_CLASS_DECL(name) \ | |
88 | extern void *OS_OBJECT_CLASS_SYMBOL(name) \ | |
89 | asm(OS_OBJC_CLASS_RAW_SYMBOL_NAME(OS_OBJECT_CLASS(name))) | |
c093abd6 | 90 | #else |
beb15981 A |
91 | #define OS_OBJECT_HAVE_OBJC1 0 |
92 | #define OS_OBJECT_HAVE_OBJC2 0 | |
c093abd6 A |
93 | #define _OS_OBJECT_CLASS_HEADER() \ |
94 | void (*_os_obj_xref_dispose)(_os_object_t); \ | |
95 | void (*_os_obj_dispose)(_os_object_t) | |
96 | #endif | |
97 | ||
98 | #define OS_OBJECT_CLASS(name) OS_##name | |
99 | ||
beb15981 A |
100 | #if OS_OBJECT_USE_OBJC && OS_OBJECT_SWIFT3 |
101 | @interface OS_OBJECT_CLASS(object) (OSObjectPrivate) | |
102 | - (void)_xref_dispose; | |
103 | - (void)_dispose; | |
104 | @end | |
105 | OS_OBJECT_DECL_PROTOCOL(object, <NSObject>); | |
106 | typedef OS_OBJECT_CLASS(object) *_os_object_t; | |
107 | #define _OS_OBJECT_DECL_SUBCLASS_INTERFACE(name, super) \ | |
108 | @interface OS_OBJECT_CLASS(name) : OS_OBJECT_CLASS(super) \ | |
109 | <OS_OBJECT_CLASS(name)> \ | |
110 | @end | |
111 | #define _OS_OBJECT_DECL_PROTOCOL(name, super) \ | |
112 | OS_OBJECT_DECL_PROTOCOL(name, <OS_OBJECT_CLASS(super)>) | |
113 | #define _OS_OBJECT_CLASS_IMPLEMENTS_PROTOCOL(name, super) \ | |
114 | OS_OBJECT_CLASS_IMPLEMENTS_PROTOCOL(name, super) | |
115 | #elif OS_OBJECT_USE_OBJC | |
6b746eb4 | 116 | API_AVAILABLE(macos(10.8), ios(6.0)) |
c093abd6 A |
117 | OS_OBJECT_EXPORT |
118 | @interface OS_OBJECT_CLASS(object) : NSObject | |
119 | - (void)_xref_dispose; | |
120 | - (void)_dispose; | |
121 | @end | |
122 | typedef OS_OBJECT_CLASS(object) *_os_object_t; | |
123 | #define _OS_OBJECT_DECL_SUBCLASS_INTERFACE(name, super) \ | |
124 | @interface OS_OBJECT_CLASS(name) : OS_OBJECT_CLASS(super) \ | |
125 | <OS_OBJECT_CLASS(name)> \ | |
126 | @end | |
127 | #else | |
beb15981 A |
128 | #define _OS_OBJECT_DECL_SUBCLASS_INTERFACE(name, super) |
129 | #define _OS_OBJECT_DECL_PROTOCOL(name, super) | |
130 | #define _OS_OBJECT_CLASS_IMPLEMENTS_PROTOCOL(name, super) | |
c093abd6 A |
131 | typedef struct _os_object_s *_os_object_t; |
132 | #endif | |
133 | ||
beb15981 A |
134 | OS_ASSUME_NONNULL_BEGIN |
135 | ||
c093abd6 A |
136 | __BEGIN_DECLS |
137 | ||
138 | #if !_OS_OBJECT_OBJC_ARC | |
139 | ||
6b746eb4 | 140 | API_AVAILABLE(macos(10.8), ios(6.0)) |
c093abd6 | 141 | OS_OBJECT_EXPORT OS_OBJECT_MALLOC OS_OBJECT_WARN_RESULT OS_OBJECT_NOTHROW |
beb15981 | 142 | OS_SWIFT_UNAVAILABLE("Unavailable in Swift") |
c093abd6 A |
143 | _os_object_t |
144 | _os_object_alloc(const void *cls, size_t size); | |
145 | ||
6b746eb4 | 146 | API_AVAILABLE(macos(10.8), ios(6.0)) |
517da941 | 147 | OS_OBJECT_EXPORT OS_OBJECT_MALLOC OS_OBJECT_WARN_RESULT OS_OBJECT_NOTHROW |
beb15981 | 148 | OS_SWIFT_UNAVAILABLE("Unavailable in Swift") |
517da941 A |
149 | _os_object_t |
150 | _os_object_alloc_realized(const void *cls, size_t size); | |
151 | ||
6b746eb4 | 152 | API_AVAILABLE(macos(10.8), ios(6.0)) |
c093abd6 | 153 | OS_OBJECT_EXPORT OS_OBJECT_NONNULL OS_OBJECT_NOTHROW |
beb15981 | 154 | OS_SWIFT_UNAVAILABLE("Unavailable in Swift") |
c093abd6 A |
155 | void _os_object_dealloc(_os_object_t object); |
156 | ||
6b746eb4 | 157 | API_AVAILABLE(macos(10.8), ios(6.0)) |
c093abd6 | 158 | OS_OBJECT_EXPORT OS_OBJECT_NONNULL OS_OBJECT_NOTHROW |
beb15981 | 159 | OS_SWIFT_UNAVAILABLE("Unavailable in Swift") |
c093abd6 A |
160 | _os_object_t |
161 | _os_object_retain(_os_object_t object); | |
162 | ||
6b746eb4 | 163 | API_AVAILABLE(macos(10.8), ios(6.0)) |
45201a42 | 164 | OS_OBJECT_EXPORT OS_OBJECT_NONNULL OS_OBJECT_NOTHROW |
beb15981 | 165 | OS_SWIFT_UNAVAILABLE("Unavailable in Swift") |
45201a42 A |
166 | _os_object_t |
167 | _os_object_retain_with_resurrect(_os_object_t obj); | |
168 | ||
6b746eb4 | 169 | API_AVAILABLE(macos(10.8), ios(6.0)) |
c093abd6 | 170 | OS_OBJECT_EXPORT OS_OBJECT_NONNULL OS_OBJECT_NOTHROW |
beb15981 | 171 | OS_SWIFT_UNAVAILABLE("Unavailable in Swift") |
c093abd6 A |
172 | void |
173 | _os_object_release(_os_object_t object); | |
174 | ||
6b746eb4 | 175 | API_AVAILABLE(macos(10.8), ios(6.0)) |
c093abd6 | 176 | OS_OBJECT_EXPORT OS_OBJECT_NONNULL OS_OBJECT_NOTHROW |
beb15981 | 177 | OS_SWIFT_UNAVAILABLE("Unavailable in Swift") |
c093abd6 A |
178 | _os_object_t |
179 | _os_object_retain_internal(_os_object_t object); | |
180 | ||
6b746eb4 | 181 | API_AVAILABLE(macos(10.8), ios(6.0)) |
c093abd6 | 182 | OS_OBJECT_EXPORT OS_OBJECT_NONNULL OS_OBJECT_NOTHROW |
beb15981 | 183 | OS_SWIFT_UNAVAILABLE("Unavailable in Swift") |
c093abd6 A |
184 | void |
185 | _os_object_release_internal(_os_object_t object); | |
186 | ||
6b746eb4 A |
187 | API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0)) |
188 | OS_OBJECT_EXPORT OS_OBJECT_NONNULL OS_OBJECT_NOTHROW | |
189 | OS_SWIFT_UNAVAILABLE("Unavailable in Swift") | |
190 | _os_object_t | |
191 | _os_object_retain_internal_n(_os_object_t object, uint16_t n); | |
192 | ||
193 | API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0)) | |
194 | OS_OBJECT_EXPORT OS_OBJECT_NONNULL OS_OBJECT_NOTHROW | |
195 | OS_SWIFT_UNAVAILABLE("Unavailable in Swift") | |
196 | void | |
197 | _os_object_release_internal_n(_os_object_t object, uint16_t n); | |
198 | ||
c093abd6 A |
199 | #endif // !_OS_OBJECT_OBJC_ARC |
200 | ||
201 | __END_DECLS | |
202 | ||
beb15981 A |
203 | OS_ASSUME_NONNULL_END |
204 | ||
c093abd6 | 205 | #endif |