|
1 | 1 | // REQUIRES: swift_feature_SafeInteropWrappers |
2 | 2 |
|
3 | | -// RUN: rm -rf %t |
| 3 | +// RUN: %empty-directory(%t) |
4 | 4 | // RUN: split-file %s %t |
5 | | -// RUN: %target-swift-ide-test -plugin-path %swift-plugin-dir -I %t/Inputs -cxx-interoperability-mode=upcoming-swift -enable-experimental-feature SafeInteropWrappers -print-module -module-to-print=Namespace -source-filename=x | %FileCheck %s |
6 | | -// RUN: %target-swift-frontend -plugin-path %swift-plugin-dir -I %t/Inputs -cxx-interoperability-mode=default -enable-experimental-feature SafeInteropWrappers %t/namespace.swift -dump-macro-expansions -typecheck -verify |
| 5 | +// RUN: %target-swift-frontend -plugin-path %swift-plugin-dir -I %t/Inputs -cxx-interoperability-mode=default -enable-experimental-feature SafeInteropWrappers %t/namespace.swift -emit-module -verify |
| 6 | +// RUN: %target-swift-ide-test -plugin-path %swift-plugin-dir -I %t/Inputs -cxx-interoperability-mode=upcoming-swift -enable-experimental-feature SafeInteropWrappers -print-module -module-to-print=Namespace -source-filename=x > %t/interface.txt |
| 7 | +// RUN: diff %t/interface.txt %t/interface.txt.expected |
7 | 8 |
|
8 | | -// CHECK: enum foo { |
9 | | -// CHECK: static func bar(_ p: UnsafeMutableBufferPointer<Float>) |
| 9 | +//--- interface.txt.expected |
| 10 | +@_exported import Namespace.Baz |
10 | 11 |
|
| 12 | +enum foo { |
| 13 | + static func foo_func(_ p: UnsafeMutablePointer<Float>!, _ len: Int32) |
| 14 | + /// This is an auto-generated wrapper for safer interop |
| 15 | + @_alwaysEmitIntoClient @_disfavoredOverload public static func foo_func(_ p: UnsafeMutableBufferPointer<Float>) |
| 16 | + static func foo_func2(_ p: UnsafePointer<baz_t>!, _ len: baz_t) |
| 17 | + /// This is an auto-generated wrapper for safer interop |
| 18 | + @available(visionOS 1.0, tvOS 12.2, watchOS 5.2, iOS 12.2, macOS 10.14.4, *) |
| 19 | + @_alwaysEmitIntoClient @_disfavoredOverload public static func foo_func2(_ p: Span<baz_t>) |
| 20 | + enum bar { |
| 21 | + static func bar_func(_ p: UnsafePointer<baz_t>!, _ len: baz_t) |
| 22 | + /// This is an auto-generated wrapper for safer interop |
| 23 | + @available(visionOS 1.0, tvOS 12.2, watchOS 5.2, iOS 12.2, macOS 10.14.4, *) |
| 24 | + @_alwaysEmitIntoClient @_disfavoredOverload public static func bar_func(_ p: Span<baz_t>) |
| 25 | + } |
| 26 | +} |
11 | 27 | //--- Inputs/module.modulemap |
12 | 28 | module Namespace { |
13 | 29 | header "namespace.h" |
14 | 30 | requires cplusplus |
| 31 | + module Baz { |
| 32 | + header "baz.h" |
| 33 | + } |
15 | 34 | } |
16 | 35 |
|
17 | 36 | //--- Inputs/namespace.h |
| 37 | +#include "baz.h" |
| 38 | + |
| 39 | +#define __counted_by(x) __attribute__((__counted_by__(x))) |
| 40 | +#define __noescape __attribute__((noescape)) |
18 | 41 |
|
19 | 42 | namespace foo { |
20 | | - __attribute__((swift_attr("@_SwiftifyImport(.countedBy(pointer: .param(1), count: \"len\"))"))) void bar(float *p, int len); |
| 43 | + __attribute__((swift_attr("@_SwiftifyImport(.countedBy(pointer: .param(1), count: \"len\"))"))) void foo_func(float *p, int len); |
| 44 | + void foo_func2(const baz_t * __counted_by(len) p __noescape, baz_t len); |
| 45 | + namespace bar { |
| 46 | + void bar_func(const baz_t * __counted_by(len) p __noescape, baz_t len); |
| 47 | + } |
21 | 48 | } |
22 | 49 |
|
| 50 | +//--- Inputs/baz.h |
| 51 | +typedef int baz_t; |
| 52 | + |
23 | 53 | //--- namespace.swift |
24 | 54 | import Namespace |
25 | | - |
| 55 | + |
26 | 56 | func test(s: UnsafeMutableBufferPointer<Float>) { |
27 | | - foo.bar(s) |
28 | | -} |
| 57 | + foo.foo_func(s) |
| 58 | +} |
| 59 | + |
| 60 | +func test2(s: Span<CInt>) { |
| 61 | + foo.foo_func2(s) |
| 62 | +} |
| 63 | + |
| 64 | +func test3(s: Span<CInt>) { |
| 65 | + foo.bar.bar_func(s) |
| 66 | +} |
0 commit comments