mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[cxx-interop] Support nested structs
It is really involved to change how methods and classes are emitted into the header so this patch introduces the impression of nested structs through using statements and still emits the structs themselves as top level structs. It emits them in their own namespace to avoid name collisions. This patch also had to change some names to be fully qualified to avoid some name lookup errors in case of nested structs. Moreover, nesting level of 3 and above requires C++17 because it relies on nested namespaces. Only nested structs are supported, not nested classes. Since this patch is already started to grow quite big, I decided to put it out for reviews and plan to address some of the shortcomings in a follow-up PR. rdar://118793469
This commit is contained in:
@@ -32,7 +32,7 @@ public func passIntReturnVoid(x: CInt) { print("passIntReturnVoid \(x)") }
|
||||
public func passTwoIntReturnInt(x: CInt, y: CInt) -> CInt { return x + y }
|
||||
|
||||
// CHECK: SWIFT_INLINE_THUNK int passTwoIntReturnInt(int x, int y) noexcept SWIFT_SYMBOL("s:9Functions016passTwoIntReturnD01x1ys5Int32VAF_AFtF") SWIFT_WARN_UNUSED_RESULT {
|
||||
// CHECK: return _impl::$s9Functions016passTwoIntReturnD01x1ys5Int32VAF_AFtF(x, y);
|
||||
// CHECK: return Functions::_impl::$s9Functions016passTwoIntReturnD01x1ys5Int32VAF_AFtF(x, y);
|
||||
// CHECK: }
|
||||
|
||||
public func passTwoIntReturnIntNoArgLabel(_: CInt, _: CInt) -> CInt {
|
||||
@@ -41,13 +41,13 @@ public func passTwoIntReturnIntNoArgLabel(_: CInt, _: CInt) -> CInt {
|
||||
}
|
||||
|
||||
// CHECK: SWIFT_INLINE_THUNK int passTwoIntReturnIntNoArgLabel(int _1, int _2) noexcept SWIFT_SYMBOL("s:9Functions016passTwoIntReturnD10NoArgLabelys5Int32VAD_ADtF") SWIFT_WARN_UNUSED_RESULT {
|
||||
// CHECK: return _impl::$s9Functions016passTwoIntReturnD10NoArgLabelys5Int32VAD_ADtF(_1, _2);
|
||||
// CHECK: return Functions::_impl::$s9Functions016passTwoIntReturnD10NoArgLabelys5Int32VAD_ADtF(_1, _2);
|
||||
// CHECK: }
|
||||
|
||||
public func passTwoIntReturnIntNoArgLabelParamName(_ x2: CInt, _ y2: CInt) -> CInt { return x2 + y2 }
|
||||
|
||||
// CHECK: SWIFT_INLINE_THUNK int passTwoIntReturnIntNoArgLabelParamName(int x2, int y2) noexcept SWIFT_SYMBOL("s:9Functions016passTwoIntReturnD19NoArgLabelParamNameys5Int32VAD_ADtF") SWIFT_WARN_UNUSED_RESULT {
|
||||
// CHECK: return _impl::$s9Functions016passTwoIntReturnD19NoArgLabelParamNameys5Int32VAD_ADtF(x2, y2);
|
||||
// CHECK: return Functions::_impl::$s9Functions016passTwoIntReturnD19NoArgLabelParamNameys5Int32VAD_ADtF(x2, y2);
|
||||
// CHECK: }
|
||||
|
||||
public func passVoidReturnNever() -> Never {
|
||||
|
||||
Reference in New Issue
Block a user