File tree Expand file tree Collapse file tree 3 files changed +59
-0
lines changed Expand file tree Collapse file tree 3 files changed +59
-0
lines changed Original file line number Diff line number Diff line change
1
+ __attribute__ ((objc_runtime_visible))
2
+ @interface OS_dispatch_queue
3
+ @end
4
+
5
+ __attribute__((objc_runtime_visible))
6
+ @interface OS_object
7
+ @end
8
+
9
+ __attribute__((objc_runtime_visible))
10
+ @interface OS_dispatch_source
11
+ @end
12
+
13
+ id dispatch_get_current_queue(void );
Original file line number Diff line number Diff line change
1
+ module DispatchObjects {
2
+ header "DispatchObjects.h"
3
+ }
Original file line number Diff line number Diff line change
1
+ // RUN: rm -rf %t
2
+ // RUN: mkdir -p %t
3
+ //
4
+ // RUN: cp %s %t/main.swift
5
+ // RUN: %target-build-swift %t/main.swift -I %S/Inputs/custom-modules/ -o %t/OS_objects -Xfrontend -disable-access-control
6
+ // RUN: %target-run %t/OS_objects 2>&1 | FileCheck %s
7
+
8
+ // REQUIRES: objc_interop
9
+
10
+ // Note: Test the use of the Clang objc_runtime_visible attribute via
11
+ // known OS objects on Darwin.
12
+
13
+ import ObjectiveC
14
+ import DispatchObjects
15
+
16
+ // CHECK: Get current queue
17
+ print ( " Get current queue " )
18
+ let obj = dispatch_get_current_queue ( ) ;
19
+
20
+ // CHECK-NEXT: Object is a dispatch queue
21
+ if let q = obj as? OS_dispatch_queue {
22
+ print ( " Object is a dispatch queue " )
23
+ }
24
+
25
+ // CHECK-NEXT: Object is an OS object
26
+ if let q = obj as? OS_object {
27
+ print ( " Object is an OS object " )
28
+ }
29
+
30
+ // CHECK-NEXT: Object is an NSObject
31
+ if let q = obj as? NSObject {
32
+ print ( " Object is an NSObject " )
33
+ }
34
+
35
+ // CHECK-NEXT: Object is not a dispatch source
36
+ if let q = obj as? OS_dispatch_source {
37
+ print ( " Object is a dispatch source!?!? " )
38
+ } else {
39
+ print ( " Object is not a dispatch source " )
40
+ }
41
+
42
+ // CHECK-NEXT: DONE
43
+ print ( " DONE " ) ;
You can’t perform that action at this time.
0 commit comments