File tree 2 files changed +0
-50
lines changed
2 files changed +0
-50
lines changed Original file line number Diff line number Diff line change 1
-
2
- # NOTE(compnerd) Today regardless of whether or not ObjC interop is enabled,
3
- # swift will use an autoreleased return value convention for certain CF
4
- # functions (including some that are used/related to dispatch). This means that
5
- # the swift compiler in callers to such functions will call the function, and
6
- # then pass the result of the function to objc_retainAutoreleasedReturnValue. In
7
- # a context where we have ObjC interop disabled, we do not have access to the
8
- # objc runtime so an implementation of objc_retainAutoreleasedReturnValue is not
9
- # available. To work around this, we provide a shim for
10
- # objc_retainAutoreleasedReturnValue in DispatchStubs.cc that just calls retain
11
- # on the object. Once we fix the swift compiler to switch to a different model
12
- # for handling these arguments with objc-interop disabled these shims can be
13
- # eliminated.
14
1
add_library (DispatchStubs STATIC
15
2
DispatchStubs.cc)
16
3
target_include_directories (DispatchStubs PRIVATE
Original file line number Diff line number Diff line change @@ -56,40 +56,3 @@ static void _dispatch_overlay_constructor() {
56
56
}
57
57
58
58
#endif /* USE_OBJC */
59
-
60
- #if !USE_OBJC
61
- DISPATCH_RUNTIME_STDLIB_INTERFACE
62
- extern " C" void * objc_retainAutoreleasedReturnValue (void *obj);
63
- #endif
64
-
65
- #if !USE_OBJC
66
-
67
- // For CF functions with 'Get' semantics, the compiler currently assumes that
68
- // the result is autoreleased and must be retained. It does so on all platforms
69
- // by emitting a call to objc_retainAutoreleasedReturnValue. On Darwin, this is
70
- // implemented by the ObjC runtime. On non-ObjC platforms, there is no runtime,
71
- // and therefore we have to stub it out here ourselves. The compiler will
72
- // eventually call swift_release to balance the retain below. This is a
73
- // workaround until the compiler no longer emits this callout on non-ObjC
74
- // platforms.
75
- extern " C"
76
- #if defined(_WIN32)
77
- __declspec (dllimport)
78
- #endif
79
- void swift_retain (void *);
80
-
81
- DISPATCH_RUNTIME_STDLIB_INTERFACE
82
- extern " C" void * objc_retainAutoreleasedReturnValue (void *obj) {
83
- if (obj) {
84
- swift_retain (obj);
85
- return obj;
86
- }
87
- else return NULL ;
88
- }
89
-
90
- #if defined(_WIN32)
91
- extern " C" void *(*__imp_objc_retainAutoreleasedReturnValue)(void *) =
92
- &objc_retainAutoreleasedReturnValue;
93
- #endif
94
-
95
- #endif // !USE_OBJC
You can’t perform that action at this time.
0 commit comments