-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #75202 from swiftlang/gaborh/export-static-properties
[cxx-interop] Export accessors of static properties to C++
- Loading branch information
Showing
3 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
test/Interop/SwiftToCxx/class/swift-class-static-variables-execution.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// RUN: %empty-directory(%t) | ||
|
||
// RUN: %target-swift-frontend %S/swift-class-static-variables.swift -typecheck -module-name Class -clang-header-expose-decls=all-public -emit-clang-header-path %t/class.h | ||
|
||
// RUN: %target-interop-build-clangxx -c %s -I %t -o %t/swift-class-execution.o | ||
// RUN: %target-interop-build-swift %S/swift-class-static-variables.swift -o %t/swift-class-execution -Xlinker %t/swift-class-execution.o -module-name Class -Xfrontend -entry-point-function-name -Xfrontend swiftMain | ||
|
||
// RUN: %target-codesign %t/swift-class-execution | ||
// RUN: %target-run %t/swift-class-execution | ||
|
||
// REQUIRES: executable_test | ||
|
||
|
||
#include "class.h" | ||
#include <assert.h> | ||
#include <cstdio> | ||
|
||
using namespace Class; | ||
|
||
int main() { | ||
auto x = FileUtilities::getShared(); | ||
assert(x.getField() == 42); | ||
} |
13 changes: 13 additions & 0 deletions
13
test/Interop/SwiftToCxx/class/swift-class-static-variables.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
// RUN: %empty-directory(%t) | ||
// RUN: %target-swift-frontend %s -typecheck -module-name Class -clang-header-expose-decls=all-public -emit-clang-header-path %t/class.h | ||
// RUN: %FileCheck %s < %t/class.h | ||
|
||
// RUN: %check-interop-cxx-header-in-clang(%t/class.h -DSWIFT_CXX_INTEROP_HIDE_STL_OVERLAY) | ||
|
||
public class FileUtilities { | ||
public static let shared = FileUtilities() | ||
public let field = 42; | ||
} | ||
|
||
// CHECK: SWIFT_INLINE_THUNK FileUtilities FileUtilities::getShared() { |