pyobjc-framework-CFNetwork 10.3.2__tar.gz → 12.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. {pyobjc_framework_cfnetwork-10.3.2 → pyobjc_framework_cfnetwork-12.2.1}/LICENSE.txt +1 -1
  2. {pyobjc_framework_cfnetwork-10.3.2 → pyobjc_framework_cfnetwork-12.2.1}/Lib/CFNetwork/_metadata.py +8 -10
  3. {pyobjc_framework_cfnetwork-10.3.2 → pyobjc_framework_cfnetwork-12.2.1}/Lib/pyobjc_framework_CFNetwork.egg-info/PKG-INFO +22 -9
  4. {pyobjc_framework_cfnetwork-10.3.2 → pyobjc_framework_cfnetwork-12.2.1}/Lib/pyobjc_framework_CFNetwork.egg-info/SOURCES.txt +3 -7
  5. pyobjc_framework_cfnetwork-12.2.1/Lib/pyobjc_framework_CFNetwork.egg-info/pyobjc-build-info.txt +3 -0
  6. pyobjc_framework_cfnetwork-12.2.1/Lib/pyobjc_framework_CFNetwork.egg-info/requires.txt +2 -0
  7. {pyobjc_framework_cfnetwork-10.3.2 → pyobjc_framework_cfnetwork-12.2.1}/Modules/_manual.m +63 -18
  8. {pyobjc_framework_cfnetwork-10.3.2 → pyobjc_framework_cfnetwork-12.2.1}/Modules/pyobjc-api.h +6 -3
  9. pyobjc_framework_cfnetwork-12.2.1/Modules/pyobjc-compat.h +371 -0
  10. {pyobjc_framework_cfnetwork-10.3.2 → pyobjc_framework_cfnetwork-12.2.1}/PKG-INFO +22 -9
  11. pyobjc_framework_cfnetwork-12.2.1/PyObjCTest/__init__.py +1 -0
  12. {pyobjc_framework_cfnetwork-10.3.2 → pyobjc_framework_cfnetwork-12.2.1}/PyObjCTest/test_cfproxysupport.py +5 -3
  13. {pyobjc_framework_cfnetwork-10.3.2 → pyobjc_framework_cfnetwork-12.2.1}/metadata/CFNetwork.fwinfo +90 -72
  14. pyobjc_framework_cfnetwork-10.3.2/metadata/raw/arm64-14.5.fwinfo → pyobjc_framework_cfnetwork-12.2.1/metadata/raw/arm64-26.5.fwinfo +1168 -136
  15. pyobjc_framework_cfnetwork-10.3.2/metadata/raw/x86_64-14.5.fwinfo → pyobjc_framework_cfnetwork-12.2.1/metadata/raw/x86_64-26.5.fwinfo +1168 -136
  16. {pyobjc_framework_cfnetwork-10.3.2 → pyobjc_framework_cfnetwork-12.2.1}/pyobjc_setup.py +75 -54
  17. {pyobjc_framework_cfnetwork-10.3.2 → pyobjc_framework_cfnetwork-12.2.1}/setup.py +1 -3
  18. pyobjc_framework_cfnetwork-10.3.2/Lib/pyobjc_framework_CFNetwork.egg-info/requires.txt +0 -2
  19. pyobjc_framework_cfnetwork-10.3.2/Modules/pyobjc-compat.h +0 -245
  20. pyobjc_framework_cfnetwork-10.3.2/PyObjCTest/__init__.py +0 -1
  21. pyobjc_framework_cfnetwork-10.3.2/metadata/raw/arm64-12.3.fwinfo +0 -2323
  22. pyobjc_framework_cfnetwork-10.3.2/metadata/raw/x86_64-10.10.fwinfo +0 -2356
  23. pyobjc_framework_cfnetwork-10.3.2/metadata/raw/x86_64-10.15.fwinfo +0 -2290
  24. pyobjc_framework_cfnetwork-10.3.2/metadata/raw/x86_64-10.16.fwinfo +0 -2293
  25. pyobjc_framework_cfnetwork-10.3.2/metadata/raw/x86_64-12.3.fwinfo +0 -2323
  26. {pyobjc_framework_cfnetwork-10.3.2 → pyobjc_framework_cfnetwork-12.2.1}/Lib/CFNetwork/__init__.py +0 -0
  27. {pyobjc_framework_cfnetwork-10.3.2 → pyobjc_framework_cfnetwork-12.2.1}/Lib/pyobjc_framework_CFNetwork.egg-info/dependency_links.txt +0 -0
  28. {pyobjc_framework_cfnetwork-10.3.2 → pyobjc_framework_cfnetwork-12.2.1}/Lib/pyobjc_framework_CFNetwork.egg-info/not-zip-safe +0 -0
  29. {pyobjc_framework_cfnetwork-10.3.2 → pyobjc_framework_cfnetwork-12.2.1}/Lib/pyobjc_framework_CFNetwork.egg-info/top_level.txt +0 -0
  30. {pyobjc_framework_cfnetwork-10.3.2 → pyobjc_framework_cfnetwork-12.2.1}/MANIFEST.in +0 -0
  31. {pyobjc_framework_cfnetwork-10.3.2 → pyobjc_framework_cfnetwork-12.2.1}/PyObjCTest/proxy.pac +0 -0
  32. {pyobjc_framework_cfnetwork-10.3.2 → pyobjc_framework_cfnetwork-12.2.1}/PyObjCTest/test_cfftpstream.py +0 -0
  33. {pyobjc_framework_cfnetwork-10.3.2 → pyobjc_framework_cfnetwork-12.2.1}/PyObjCTest/test_cfhost.py +0 -0
  34. {pyobjc_framework_cfnetwork-10.3.2 → pyobjc_framework_cfnetwork-12.2.1}/PyObjCTest/test_cfhttpauthentication.py +0 -0
  35. {pyobjc_framework_cfnetwork-10.3.2 → pyobjc_framework_cfnetwork-12.2.1}/PyObjCTest/test_cfhttpmessage.py +0 -0
  36. {pyobjc_framework_cfnetwork-10.3.2 → pyobjc_framework_cfnetwork-12.2.1}/PyObjCTest/test_cfhttpstream.py +0 -0
  37. {pyobjc_framework_cfnetwork-10.3.2 → pyobjc_framework_cfnetwork-12.2.1}/PyObjCTest/test_cfnetservices.py +0 -0
  38. {pyobjc_framework_cfnetwork-10.3.2 → pyobjc_framework_cfnetwork-12.2.1}/PyObjCTest/test_cfnetwork.py +0 -0
  39. {pyobjc_framework_cfnetwork-10.3.2 → pyobjc_framework_cfnetwork-12.2.1}/PyObjCTest/test_cfnetworkdiagnostics.py +0 -0
  40. {pyobjc_framework_cfnetwork-10.3.2 → pyobjc_framework_cfnetwork-12.2.1}/PyObjCTest/test_cfnetworkerrors.py +0 -0
  41. {pyobjc_framework_cfnetwork-10.3.2 → pyobjc_framework_cfnetwork-12.2.1}/PyObjCTest/test_cfsocketstream.py +0 -0
  42. {pyobjc_framework_cfnetwork-10.3.2 → pyobjc_framework_cfnetwork-12.2.1}/README.txt +0 -0
  43. {pyobjc_framework_cfnetwork-10.3.2 → pyobjc_framework_cfnetwork-12.2.1}/metadata/metadata.ini +0 -0
  44. {pyobjc_framework_cfnetwork-10.3.2 → pyobjc_framework_cfnetwork-12.2.1}/pyproject.toml +0 -0
  45. {pyobjc_framework_cfnetwork-10.3.2 → pyobjc_framework_cfnetwork-12.2.1}/setup.cfg +0 -0
@@ -1,7 +1,7 @@
1
1
  (This is the MIT license, note that libffi-src is a separate product with its own license)
2
2
 
3
3
  Copyright 2002, 2003 - Bill Bumgarner, Ronald Oussoren, Steve Majewski, Lele Gaifax, et.al.
4
- Copyright 2003-2024 - Ronald Oussoren
4
+ Copyright 2003-2025 - Ronald Oussoren
5
5
 
6
6
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
7
7
 
@@ -1,6 +1,6 @@
1
1
  # This file is generated by objective.metadata
2
2
  #
3
- # Last update: Sat May 18 09:18:04 2024
3
+ # Last update: Wed May 27 16:59:26 2026
4
4
  #
5
5
  # flake8: noqa
6
6
 
@@ -233,7 +233,7 @@ functions = {
233
233
  {
234
234
  "retval": {"already_cfretained": True},
235
235
  "arguments": {
236
- 1: {"c_array_length_in_arg": 2, "type_modifier": "n"},
236
+ 1: {"type_modifier": "n", "c_array_length_in_arg": 2},
237
237
  3: {"already_cfretained": True, "type_modifier": "o"},
238
238
  },
239
239
  },
@@ -247,7 +247,7 @@ functions = {
247
247
  "CFHTTPMessageAppendBytes": (
248
248
  b"Z^{__CFHTTPMessage=}^vq",
249
249
  "",
250
- {"arguments": {1: {"c_array_length_in_arg": 2, "type_modifier": "n"}}},
250
+ {"arguments": {1: {"type_modifier": "n", "c_array_length_in_arg": 2}}},
251
251
  ),
252
252
  "CFHostCancelInfoResolution": (b"v^{__CFHost=}i",),
253
253
  "CFNetServiceBrowserSearchForServices": (
@@ -278,7 +278,6 @@ functions = {
278
278
  "",
279
279
  {"arguments": {4: {"type_modifier": "o"}}},
280
280
  ),
281
- "CFHTTPReadStreamSetRedirectsAutomatically": (b"v^{__CFReadStream=}Z",),
282
281
  "CFNetServiceRegisterWithOptions": (
283
282
  b"Z^{__CFNetService=}Q^{CFStreamError=qi}",
284
283
  "",
@@ -297,15 +296,15 @@ functions = {
297
296
  "retval": {"already_cfretained": True},
298
297
  "arguments": {
299
298
  2: {
299
+ "null_accepted": True,
300
300
  "already_cfretained": True,
301
301
  "type_modifier": "o",
302
- "null_accepted": True,
303
302
  }
304
303
  },
305
304
  },
306
305
  ),
307
- "CFNetServiceCreateDictionaryWithTXTData": (
308
- b"^{__CFDictionary=}^{__CFAllocator=}^{__CFData=}",
306
+ "CFHTTPMessageCopySerializedMessage": (
307
+ b"^{__CFData=}^{__CFHTTPMessage=}",
309
308
  "",
310
309
  {"retval": {"already_cfretained": True}},
311
310
  ),
@@ -314,8 +313,8 @@ functions = {
314
313
  "",
315
314
  {"arguments": {1: {"type_modifier": "o"}}},
316
315
  ),
317
- "CFHTTPMessageCopySerializedMessage": (
318
- b"^{__CFData=}^{__CFHTTPMessage=}",
316
+ "CFNetServiceCreateDictionaryWithTXTData": (
317
+ b"^{__CFDictionary=}^{__CFAllocator=}^{__CFData=}",
319
318
  "",
320
319
  {"retval": {"already_cfretained": True}},
321
320
  ),
@@ -413,7 +412,6 @@ functions = {
413
412
  "",
414
413
  {"retval": {"already_cfretained": True}},
415
414
  ),
416
- "CFNetServiceSetProtocolSpecificInformation": (b"v^{__CFNetService=}@",),
417
415
  "CFSocketStreamSOCKSGetErrorSubdomain": (b"i^{CFStreamError=qi}",),
418
416
  "CFStreamCreatePairWithSocketToCFHost": (
419
417
  b"v^{__CFAllocator=}^{__CFHost=}i^^{__CFReadStream=}^^{__CFWriteStream=}",
@@ -1,38 +1,51 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: pyobjc-framework-CFNetwork
3
- Version: 10.3.2
3
+ Version: 12.2.1
4
4
  Summary: Wrappers for the framework CFNetwork on macOS
5
5
  Home-page: https://github.com/ronaldoussoren/pyobjc
6
6
  Author: Ronald Oussoren
7
7
  Author-email: pyobjc-dev@lists.sourceforge.net
8
- License: MIT License
8
+ License: MIT
9
9
  Keywords: PyObjC,CFNetwork
10
10
  Platform: MacOS X
11
11
  Classifier: Development Status :: 5 - Production/Stable
12
12
  Classifier: Environment :: Console
13
13
  Classifier: Environment :: MacOS X :: Cocoa
14
14
  Classifier: Intended Audience :: Developers
15
- Classifier: License :: OSI Approved :: MIT License
16
15
  Classifier: Natural Language :: English
17
16
  Classifier: Operating System :: MacOS :: MacOS X
18
17
  Classifier: Programming Language :: Python
19
18
  Classifier: Programming Language :: Python :: 3
20
19
  Classifier: Programming Language :: Python :: 3 :: Only
21
- Classifier: Programming Language :: Python :: 3.8
22
- Classifier: Programming Language :: Python :: 3.9
23
20
  Classifier: Programming Language :: Python :: 3.10
24
21
  Classifier: Programming Language :: Python :: 3.11
25
22
  Classifier: Programming Language :: Python :: 3.12
26
23
  Classifier: Programming Language :: Python :: 3.13
24
+ Classifier: Programming Language :: Python :: 3.14
25
+ Classifier: Programming Language :: Python :: 3.15
27
26
  Classifier: Programming Language :: Python :: Implementation :: CPython
27
+ Classifier: Programming Language :: Python :: Free Threading :: 3 - Stable
28
28
  Classifier: Programming Language :: Objective C
29
29
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
30
30
  Classifier: Topic :: Software Development :: User Interfaces
31
- Requires-Python: >=3.8
31
+ Requires-Python: >=3.10
32
32
  Description-Content-Type: text/x-rst; charset=UTF-8
33
33
  License-File: LICENSE.txt
34
- Requires-Dist: pyobjc-core>=10.3.2
35
- Requires-Dist: pyobjc-framework-Cocoa>=10.3.2
34
+ Requires-Dist: pyobjc-core>=12.2.1
35
+ Requires-Dist: pyobjc-framework-Cocoa>=12.2.1
36
+ Dynamic: author
37
+ Dynamic: author-email
38
+ Dynamic: classifier
39
+ Dynamic: description
40
+ Dynamic: description-content-type
41
+ Dynamic: home-page
42
+ Dynamic: keywords
43
+ Dynamic: license
44
+ Dynamic: license-file
45
+ Dynamic: platform
46
+ Dynamic: requires-dist
47
+ Dynamic: requires-python
48
+ Dynamic: summary
36
49
  Project-URL: Documentation, https://pyobjc.readthedocs.io/en/latest/
37
50
  Project-URL: Issue tracker, https://github.com/ronaldoussoren/pyobjc/issues
38
51
  Project-URL: Repository, https://github.com/ronaldoussoren/pyobjc
@@ -10,6 +10,7 @@ Lib/pyobjc_framework_CFNetwork.egg-info/PKG-INFO
10
10
  Lib/pyobjc_framework_CFNetwork.egg-info/SOURCES.txt
11
11
  Lib/pyobjc_framework_CFNetwork.egg-info/dependency_links.txt
12
12
  Lib/pyobjc_framework_CFNetwork.egg-info/not-zip-safe
13
+ Lib/pyobjc_framework_CFNetwork.egg-info/pyobjc-build-info.txt
13
14
  Lib/pyobjc_framework_CFNetwork.egg-info/requires.txt
14
15
  Lib/pyobjc_framework_CFNetwork.egg-info/top_level.txt
15
16
  Modules/_manual.m
@@ -30,10 +31,5 @@ PyObjCTest/test_cfproxysupport.py
30
31
  PyObjCTest/test_cfsocketstream.py
31
32
  metadata/CFNetwork.fwinfo
32
33
  metadata/metadata.ini
33
- metadata/raw/arm64-12.3.fwinfo
34
- metadata/raw/arm64-14.5.fwinfo
35
- metadata/raw/x86_64-10.10.fwinfo
36
- metadata/raw/x86_64-10.15.fwinfo
37
- metadata/raw/x86_64-10.16.fwinfo
38
- metadata/raw/x86_64-12.3.fwinfo
39
- metadata/raw/x86_64-14.5.fwinfo
34
+ metadata/raw/arm64-26.5.fwinfo
35
+ metadata/raw/x86_64-26.5.fwinfo
@@ -0,0 +1,3 @@
1
+ macOS 26.5 (25F71)
2
+ Apple clang version 21.0.0 (clang-2100.1.1.101)
3
+ SDK: macOS 26.5
@@ -0,0 +1,2 @@
1
+ pyobjc-core>=12.2.1
2
+ pyobjc-framework-Cocoa>=12.2.1
@@ -1,6 +1,3 @@
1
- #ifndef PyObjC_GIL_DISABLED
2
- #define Py_LIMITED_API 0x03060000
3
- #endif
4
1
  #define PY_SSIZE_T_CLEAN
5
2
  #include "Python.h"
6
3
  #include "pyobjc-api.h"
@@ -25,8 +22,29 @@ mod_release(const void* info)
25
22
  PyGILState_Release(state);
26
23
  }
27
24
 
25
+ static CFStringRef
26
+ mod_copyDescription(const void* info)
27
+ {
28
+ PyObject* repr;
29
+ PyGILState_STATE state = PyGILState_Ensure();
30
+
31
+ repr = PyObject_Repr((PyObject*)info);
32
+ if (repr == NULL) {
33
+ PyErr_Clear();
34
+ PyGILState_Release(state);
35
+ return (CFStringRef)CFRetain([NSString stringWithFormat:@"<pyinfo at %p>", info]);
36
+ } else {
37
+ NSString* result =
38
+ [NSString stringWithFormat:@"<pyinfo %s>", PyUnicode_AsUTF8(repr)];
39
+ Py_CLEAR(repr);
40
+ PyGILState_Release(state);
41
+ return (CFStringRef)CFRetain(result);
42
+ }
43
+ }
44
+
28
45
  static CFStreamClientContext mod_CFStreamClientContext = {
29
- 0, NULL, (void* (*)(void*))mod_retain, (void (*)(void*))mod_release, NULL};
46
+ 0, (CFStringRef (*)(void*))mod_copyDescription, (void* (*)(void*))mod_retain,
47
+ (void (*)(void*))mod_release, NULL};
30
48
 
31
49
  static CFHostClientContext mod_CFHostClientContext = {0, NULL, mod_retain, mod_release,
32
50
  0};
@@ -597,23 +615,50 @@ static PyMethodDef mod_methods[] = {
597
615
  0,
598
616
  }};
599
617
 
618
+ static int
619
+ mod_exec_module(PyObject* m)
620
+ {
621
+ if (PyObjC_ImportAPI(m) < 0) {
622
+ return -1;
623
+ }
624
+ return 0;
625
+ }
626
+
627
+ static struct PyModuleDef_Slot mod_slots[] = {
628
+ {.slot = Py_mod_exec, .value = (void*)mod_exec_module},
629
+ #if PY_VERSION_HEX >= 0x030c0000
630
+ {
631
+ .slot = Py_mod_multiple_interpreters,
632
+ .value = Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED,
633
+ },
634
+ #endif
635
+ #if PY_VERSION_HEX >= 0x030d0000
636
+ {
637
+ /* The code in this extension should be safe to use without the GIL */
638
+ .slot = Py_mod_gil,
639
+ .value = Py_MOD_GIL_NOT_USED,
640
+ },
641
+ #endif
642
+ {/* Sentinel */
643
+ .slot = 0,
644
+ .value = 0}};
645
+
600
646
  static struct PyModuleDef mod_module = {
601
- PyModuleDef_HEAD_INIT, "_manual", NULL, 0, mod_methods, NULL, NULL, NULL, NULL};
647
+ .m_base = PyModuleDef_HEAD_INIT,
648
+ .m_name = "_manual",
649
+ .m_doc = NULL,
650
+ .m_size = 0,
651
+ .m_methods = mod_methods,
652
+ .m_slots = mod_slots,
653
+ .m_traverse = NULL,
654
+ .m_clear = NULL,
655
+ .m_free = NULL,
656
+ };
602
657
 
603
658
  PyObject* PyInit__manual(void);
604
659
 
605
- PyObject* __attribute__((__visibility__("default"))) PyInit__manual(void)
660
+ PyObject* __attribute__((__visibility__("default")))
661
+ PyInit__manual(void)
606
662
  {
607
- PyObject* m;
608
-
609
- m = PyModule_Create(&mod_module);
610
- if (!m) {
611
- return NULL;
612
- }
613
-
614
- if (PyObjC_ImportAPI(m) < 0) {
615
- return NULL;
616
- }
617
-
618
- return m;
663
+ return PyModuleDef_Init(&mod_module);
619
664
  }
@@ -53,8 +53,9 @@ NS_ASSUME_NONNULL_BEGIN
53
53
  /*
54
54
  * Only add items to the end of this list!
55
55
  */
56
+
56
57
  typedef int(RegisterMethodMappingFunctionType)(
57
- Class, SEL,
58
+ Class _Nullable, SEL,
58
59
  PyObject* _Nullable (*_Nonnull)(PyObject* _Nonnull, PyObject* _Nonnull,
59
60
  PyObject* _Nonnull const* _Nonnull, size_t),
60
61
  IMP _Nullable (*_Nonnull)(PyObject* _Nonnull, PyObject* _Nonnull));
@@ -83,7 +84,8 @@ struct pyobjc_api {
83
84
  PyObject* _Nullable (*_Nonnull unsupported_method_caller)(
84
85
  PyObject* _Nonnull, PyObject* _Nonnull, PyObject* _Nonnull const* _Nonnull,
85
86
  size_t);
86
- void (*_Nonnull err_python_to_objc_gil)(PyGILState_STATE* _Nonnull state);
87
+ void (*_Nonnull err_python_to_objc_gil)(PyGILState_STATE* _Nonnull state)
88
+ __attribute__((__noreturn__));
87
89
  int (*_Nonnull simplify_sig)(const char* signature, char* buf, size_t buflen);
88
90
  void (*_Nonnull free_c_array)(int, Py_buffer*);
89
91
  int (*_Nonnull py_to_c_array)(BOOL, BOOL, const char* _Nonnull, PyObject* _Nonnull,
@@ -113,7 +115,8 @@ struct pyobjc_api {
113
115
  int (*_Nonnull checknokwnames)(PyObject* _Nonnull callable,
114
116
  PyObject* _Nullable kwnames);
115
117
 
116
- PyObject* _Nullable (*_Nonnull createopaquepointertype)(const char*, const char*, const char*);
118
+ PyObject* _Nullable (*_Nonnull createopaquepointertype)(const char*, const char*,
119
+ const char*);
117
120
  };
118
121
 
119
122
  #ifndef PYOBJC_BUILD
@@ -0,0 +1,371 @@
1
+ #ifndef PyObjC_COMPAT_H
2
+ #define PyObjC_COMPAT_H
3
+
4
+ #ifndef NS_ASSUME_NONNULL_BEGIN
5
+ /* Old compiler without the Nullability attributes */
6
+ #define NS_ASSUME_NONNULL_BEGIN
7
+ #define NS_ASSUME_NONNULL_END
8
+ #define _Nullable
9
+ #define _Nonnull
10
+ #endif
11
+
12
+ NS_ASSUME_NONNULL_BEGIN
13
+
14
+ #ifdef USE_STATIC_ANALYZER
15
+ #define CLANG_SUPPRESS [[clang::suppress]]
16
+ #else
17
+ #define CLANG_SUPPRESS
18
+ #endif
19
+
20
+ /*
21
+ *
22
+ * Start of compiler definitions
23
+ *
24
+ */
25
+ #if 0
26
+ #ifndef __has_feature
27
+ #define __has_feature(x) 0
28
+ #endif
29
+ #ifndef __has_extension
30
+ #define __has_extension(x) __has_feature(x)
31
+ #endif
32
+ #endif
33
+
34
+ #if __has_extension(c_static_assert)
35
+ #define STATIC_ASSERT(test, message) _Static_assert(test, message)
36
+ #else
37
+ #define STATIC_ASSERT(test, message) \
38
+ switch (0) { \
39
+ case 0: \
40
+ case test:; \
41
+ }
42
+ #endif
43
+
44
+ #if !__has_feature(objc_instancetype)
45
+ #define instancetype id
46
+ #endif
47
+
48
+ #ifdef __has_attribute
49
+ #if __has_attribute(objc_subclassing_restricted)
50
+ #define PyObjC_FINAL_CLASS __attribute__((__objc_subclassing_restricted__))
51
+ #endif
52
+ #endif
53
+ #ifndef PyObjC_FINAL_CLASS
54
+ #define PyObjC_FINAL_CLASS
55
+ #endif
56
+
57
+ /*
58
+ *
59
+ * Start of compiler support helpers
60
+ */
61
+
62
+ #define unlikely(x) __builtin_expect(!!(x), 0)
63
+ #define likely(x) __builtin_expect(!!(x), 1)
64
+
65
+ /*
66
+ *
67
+ * Python version compatibility
68
+ *
69
+ */
70
+
71
+ #ifndef Py_SET_TYPE
72
+ #define Py_SET_TYPE(obj, type) \
73
+ do { \
74
+ Py_TYPE((obj)) = (type); \
75
+ } while (0)
76
+ #endif
77
+
78
+ #ifndef Py_SET_SIZE
79
+ #define Py_SET_SIZE(obj, size) \
80
+ do { \
81
+ Py_SIZE((obj)) = (size); \
82
+ } while (0)
83
+ #endif
84
+
85
+ #ifndef Py_SET_REFCNT
86
+ #define Py_SET_REFCNT(obj, count) \
87
+ do { \
88
+ Py_REFCNT((obj)) = (count); \
89
+ } while (0)
90
+ #endif
91
+
92
+ /* Use CLINIC_SEP between the prototype and
93
+ * description in doc strings, to get clean
94
+ * docstrings.
95
+ */
96
+ #define CLINIC_SEP "--\n"
97
+
98
+ extern int PyObjC_Cmp(PyObject* o1, PyObject* o2, int* result);
99
+
100
+ #ifdef __clang__
101
+
102
+ #ifndef Py_LIMITED_API
103
+
104
+ static inline PyObject* _Nullable* _Nonnull PyTuple_ITEMS(PyObject* tuple)
105
+ {
106
+ return &PyTuple_GET_ITEM(tuple, 0); // LCOV_BR_EXCL_LINE
107
+ }
108
+
109
+ /* This is a crude hack to disable a otherwise useful warning in the context of
110
+ * PyTuple_SET_ITEM, without disabling it everywhere
111
+ */
112
+ #pragma clang diagnostic push
113
+ #pragma clang diagnostic ignored "-Warray-bounds"
114
+ static inline void
115
+ _PyObjCTuple_SetItem(PyObject* tuple, Py_ssize_t idx, PyObject* _Nullable value)
116
+ {
117
+ PyTuple_SET_ITEM(tuple, idx, value);
118
+ }
119
+ #undef PyTuple_SET_ITEM
120
+ #define PyTuple_SET_ITEM(a, b, c) _PyObjCTuple_SetItem(a, b, c)
121
+
122
+ static inline PyObject*
123
+ _PyObjCTuple_GetItem(PyObject* tuple, Py_ssize_t idx)
124
+ {
125
+ /* The protocol for tuples is that they are full initialized
126
+ * before handing them over to other code.
127
+ */
128
+ return (PyObject* _Nonnull)PyTuple_GET_ITEM(tuple, idx); // LCOV_BR_EXCL_LINE
129
+ }
130
+ #undef PyTuple_GET_ITEM
131
+ #define PyTuple_GET_ITEM(a, b) _PyObjCTuple_GetItem(a, b)
132
+
133
+ #pragma clang diagnostic pop
134
+
135
+ #endif /* !Py_LIMITED_API */
136
+
137
+ #endif /* __clang__ */
138
+
139
+ #define PyObjC_BEGIN_WITH_GIL \
140
+ { \
141
+ PyGILState_STATE _GILState; \
142
+ _GILState = PyGILState_Ensure();
143
+
144
+ #define PyObjC_GIL_FORWARD_EXC() \
145
+ do { \
146
+ PyObjCErr_ToObjCWithGILState(&_GILState); \
147
+ } while (0)
148
+
149
+ #define PyObjC_GIL_RETURN(val) \
150
+ do { \
151
+ PyGILState_Release(_GILState); \
152
+ return (val); \
153
+ } while (0)
154
+
155
+ #define PyObjC_GIL_RETURNVOID \
156
+ do { \
157
+ PyGILState_Release(_GILState); \
158
+ return; \
159
+ } while (0)
160
+
161
+ #define PyObjC_END_WITH_GIL \
162
+ PyGILState_Release(_GILState); \
163
+ }
164
+
165
+ #define PyObjC_LEAVE_GIL \
166
+ do { \
167
+ PyGILState_Release(_GILState); \
168
+ } while (0)
169
+
170
+ #if PY_VERSION_HEX < 0x030a0000
171
+
172
+ static inline PyObject*
173
+ Py_NewRef(PyObject* o)
174
+ {
175
+ Py_INCREF(o);
176
+ return o;
177
+ }
178
+
179
+ static inline PyObject*
180
+ Py_XNewRef(PyObject* o)
181
+ {
182
+ Py_XINCREF(o);
183
+ return o;
184
+ }
185
+
186
+ #endif /* PY_VERSION_HEX < 0x030a0000 */
187
+
188
+ #if PY_VERSION_HEX < 0x030d0000
189
+ #define Py_BEGIN_CRITICAL_SECTION(value) \
190
+ { \
191
+ (void)(value);
192
+ #define Py_END_CRITICAL_SECTION() }
193
+ #define Py_EXIT_CRITICAL_SECTION() ((void)0)
194
+
195
+ #define Py_BEGIN_CRITICAL_SECTION2(value1, value2) \
196
+ { \
197
+ (void)(value1); \
198
+ (void)(value2);
199
+ #define Py_END_CRITICAL_SECTION2() }
200
+ #define Py_EXIT_CRITICAL_SECTION2() ((void)0)
201
+
202
+ #define PyObjC_ATOMIC
203
+
204
+ #else
205
+
206
+ #ifdef Py_GIL_DISABLED
207
+ #define Py_EXIT_CRITICAL_SECTION() PyCriticalSection_End(&_py_cs)
208
+ #define Py_EXIT_CRITICAL_SECTION2() PyCriticalSection2_End(&_py_cs2)
209
+ #define PyObjC_ATOMIC _Atomic
210
+ #else
211
+ #define Py_EXIT_CRITICAL_SECTION() ((void)0)
212
+ #define Py_EXIT_CRITICAL_SECTION2() ((void)0)
213
+ #define PyObjC_ATOMIC
214
+ #endif
215
+
216
+ #endif
217
+
218
+ #if PY_VERSION_HEX < 0x030d0000
219
+ static inline int
220
+ PyDict_GetItemRef(PyObject* p, PyObject* key, PyObject* _Nonnull* _Nullable result)
221
+ {
222
+ *result = PyDict_GetItemWithError(p, key);
223
+ if (*result == NULL) {
224
+ if (PyErr_Occurred()) {
225
+ return -1;
226
+ } else {
227
+ return 0;
228
+ }
229
+ } else {
230
+ Py_INCREF(*result);
231
+ return 1;
232
+ }
233
+ }
234
+
235
+ static inline PyObject* _Nullable PyList_GetItemRef(PyObject* l, Py_ssize_t i)
236
+ {
237
+ PyObject* result = PyList_GetItem(l, i);
238
+ Py_XINCREF(result);
239
+ return result;
240
+ }
241
+
242
+ static inline int
243
+ PyDict_SetDefaultRef(PyObject* p, PyObject* key, PyObject* default_value,
244
+ PyObject* _Nonnull* _Nullable result)
245
+ {
246
+ *result = PyDict_SetDefault(p, key, default_value);
247
+ if (*result == NULL) {
248
+ return -1;
249
+ }
250
+ Py_INCREF(*result);
251
+
252
+ /* This does not follow the spec, should return 1 when the key was already
253
+ * in the dict. That part of the API is not used in PyObjC though.
254
+ */
255
+ return 0;
256
+ }
257
+
258
+ #endif
259
+
260
+ #if PY_VERSION_HEX < 0x030c0000
261
+ static inline PyObject*
262
+ PyType_GetDict(PyTypeObject* type)
263
+ {
264
+ PyObject* result = type->tp_dict;
265
+ Py_INCREF(result);
266
+ return result;
267
+ }
268
+ #endif
269
+
270
+ #if PY_VERSION_HEX >= 0x030c0000 && PY_VERSION_HEX < 0x030e0000
271
+ /*
272
+ * These are available in 3.14 and above, the definitions below
273
+ * mirror the private implementation in 3.13.
274
+ */
275
+ static inline int
276
+ PyUnstable_Object_IsUniquelyReferenced(PyObject* ob)
277
+ {
278
+ #ifdef Py_GIL_DISABLED
279
+ return (_Py_IsOwnedByCurrentThread(ob)
280
+ && _Py_atomic_load_uint32_relaxed(&ob->ob_ref_local) == 1
281
+ && _Py_atomic_load_ssize_relaxed(&ob->ob_ref_shared) == 0);
282
+ #else
283
+ return Py_REFCNT(ob) == 1;
284
+ #endif
285
+ }
286
+
287
+ static inline void
288
+ PyUnstable_EnableTryIncRef(PyObject* op __attribute__((__unused__)))
289
+ {
290
+ #ifdef Py_GIL_DISABLED
291
+ for (;;) {
292
+ Py_ssize_t shared = _Py_atomic_load_ssize_relaxed(&op->ob_ref_shared);
293
+ if ((shared & _Py_REF_SHARED_FLAG_MASK) != 0) {
294
+ // Nothing to do if it's in WEAKREFS, QUEUED, or MERGED states.
295
+ return;
296
+ }
297
+ if (_Py_atomic_compare_exchange_ssize(&op->ob_ref_shared, &shared,
298
+ shared | _Py_REF_MAYBE_WEAKREF)) {
299
+ return;
300
+ }
301
+ }
302
+ #endif
303
+ }
304
+
305
+ #ifdef Py_GIL_DISABLED
306
+ static inline int
307
+ _Py_TryIncrefFast(PyObject* op)
308
+ {
309
+ uint32_t local = _Py_atomic_load_uint32_relaxed(&op->ob_ref_local);
310
+ local += 1;
311
+ if (local == 0) {
312
+ // immortal
313
+ return 1;
314
+ }
315
+ if (_Py_IsOwnedByCurrentThread(op)) {
316
+ _Py_INCREF_STAT_INC();
317
+ _Py_atomic_store_uint32_relaxed(&op->ob_ref_local, local);
318
+ #ifdef Py_REF_DEBUG
319
+ _Py_IncRefTotal(_PyThreadState_GET());
320
+ #endif
321
+ return 1;
322
+ }
323
+ return 0;
324
+ }
325
+
326
+ static inline int
327
+ _Py_TryIncRefShared(PyObject* op)
328
+ {
329
+ Py_ssize_t shared = _Py_atomic_load_ssize_relaxed(&op->ob_ref_shared);
330
+ for (;;) {
331
+ // If the shared refcount is zero and the object is either merged
332
+ // or may not have weak references, then we cannot incref it.
333
+ if (shared == 0 || shared == _Py_REF_MERGED) {
334
+ return 0;
335
+ }
336
+
337
+ if (_Py_atomic_compare_exchange_ssize(&op->ob_ref_shared, &shared,
338
+ shared + (1 << _Py_REF_SHARED_SHIFT))) {
339
+ #ifdef Py_REF_DEBUG
340
+ _Py_IncRefTotal(_PyThreadState_GET());
341
+ #endif
342
+ _Py_INCREF_STAT_INC();
343
+ return 1;
344
+ }
345
+ }
346
+ }
347
+ #endif
348
+
349
+ static inline int
350
+ PyUnstable_TryIncRef(PyObject* op __attribute__((__unused__)))
351
+ {
352
+ #ifdef Py_GIL_DISABLED
353
+ return _Py_TryIncrefFast(op) || _Py_TryIncRefShared(op);
354
+ #else
355
+ if (Py_REFCNT(op) > 0) {
356
+ Py_INCREF(op);
357
+ return 1;
358
+ }
359
+ return 0;
360
+ #endif
361
+ }
362
+ #endif
363
+
364
+ #if PY_VERSION_HEX < 0x030f00a7
365
+ #define PyAnyDict_CheckExact PyDict_CheckExact
366
+ #define PyAnyDict_Check PyDict_Check
367
+ #endif
368
+
369
+ NS_ASSUME_NONNULL_END
370
+
371
+ #endif /* PyObjC_COMPAT_H */