1
1
// RUN: %empty-directory(%t)
2
2
// RUN: split-file %s %t
3
3
4
- // RUN: %target-swift-frontend -typecheck %t/use-span.swift -typecheck -module-name UseSpan -emit-clang-header-path %t/UseSpan.h -I %t -enable-experimental-cxx-interop -Xcc -std=c++20 -clang-header-expose-decls=all-public
4
+ // RUN: %target-swift-frontend -typecheck %t/use-span.swift -typecheck -module-name UseSpan -emit-clang-header-path %t/UseSpan.h -I %t -enable-experimental-cxx-interop -Xcc -Xclang -Xcc -fmodule-format=raw -Xcc - std=c++20 -clang-header-expose-decls=all-public
5
5
6
6
// RUN: %target-interop-build-clangxx -std=c++20 -c %t/use-span.cpp -I %t -o %t/swift-cxx-execution.o
7
7
// RUN: %target-interop-build-swift %t/use-span.swift -o %t/swift-cxx-execution -Xlinker %t/swift-cxx-execution.o -module-name UseSpan -Xfrontend -entry-point-function-name -Xfrontend swiftMain -I %t -O -Xcc --std=c++20
21
21
using Span = std::span<int >;
22
22
using SpanOfString = std::span<std::string>;
23
23
24
+ namespace ns {
25
+ using SpanOfConstUInt8 = std::span<const uint8_t >;
26
+ }
27
+
24
28
static int staticArr[] = {1 , 2 , 3 };
25
29
static Span staticSpan = {staticArr};
26
30
@@ -34,49 +38,46 @@ module CxxTest {
34
38
// --- use-span.swift
35
39
import CxxTest
36
40
37
- @_expose(Cxx)
38
41
public func createEmptySpan () -> Span {
39
42
return Span ()
40
43
}
41
44
42
- @_expose(Cxx)
43
45
public func printSpan () {
44
46
print (" {\(staticSpan[0]), \(staticSpan[1]), \(staticSpan[2])}" )
45
47
}
46
48
47
- @_expose(Cxx)
48
49
public func printSpan (_ sp: Span) {
49
50
print (" {\(sp[0]), \(sp[1]), \(sp[2])}" )
50
51
}
51
52
52
- @_expose(Cxx)
53
53
public func printSpanOfString (_ sp: SpanOfString) {
54
54
print (" {\(sp[0]), \(sp[1]), \(sp[2])}" )
55
55
}
56
56
57
- @_expose(Cxx)
58
57
public func passthroughSpan (_ sp: Span) -> Span {
59
58
return sp;
60
59
}
61
60
62
- @_expose(Cxx)
63
61
public func changeSpan (_ sp: inout Span) {
64
62
sp[0 ] = 0 ;
65
63
}
66
64
67
- @_expose(Cxx)
68
65
public func mapSpan (_ sp: Span) {
69
66
let result = sp.map { $0 + 3 }
70
67
print (result)
71
68
}
72
69
73
- @_expose(Cxx)
74
70
public func receiveArr (_ arr: inout [Int32]) -> Span {
75
71
arr.withUnsafeMutableBufferPointer { ubpointer in
76
72
return Span (ubpointer);
77
73
}
78
74
}
79
75
76
+ public typealias SpanConstUInt8 = ns.SpanOfConstUInt8
77
+
78
+ public func receiveSpanAlias (_ sp1: SpanConstUInt8, _ sp2: SpanConstUInt8) {
79
+ }
80
+
80
81
// --- use-span.cpp
81
82
#include < cassert>
82
83
#include " header.h"
0 commit comments