|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// RUN: split-file %s %t --leading-lines |
| 3 | + |
| 4 | +/// Generate cdecl.h for an app |
| 5 | +// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) \ |
| 6 | +// RUN: %t/Lib.swift -emit-module -verify -o %t -emit-module-doc \ |
| 7 | +// RUN: -emit-clang-header-path %t/cdecl.h -package-name pkg \ |
| 8 | +// RUN: -enable-experimental-feature CDecl |
| 9 | +// RUN: %FileCheck %s --input-file %t/cdecl.h --check-prefixes PUBLIC-AND-INTERNAL,INTERNAL-ONLY |
| 10 | +// RUN: %check-in-clang-c %t/cdecl.h |
| 11 | + |
| 12 | +/// Generate cdecl.h for a library |
| 13 | +// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -parse-as-library \ |
| 14 | +// RUN: %t/Lib.swift -emit-module -verify -o %t -emit-module-doc \ |
| 15 | +// RUN: -emit-clang-header-path %t/cdecl.h -package-name pkg \ |
| 16 | +// RUN: -enable-experimental-feature CDecl |
| 17 | +// RUN: %FileCheck %s --input-file %t/cdecl.h --check-prefixes PUBLIC-AND-INTERNAL |
| 18 | +// RUN: %FileCheck %s --input-file %t/cdecl.h --implicit-check-not INTERNAL-ONLY |
| 19 | +// RUN: %check-in-clang-c %t/cdecl.h |
| 20 | + |
| 21 | +// REQUIRES: swift_feature_CDecl |
| 22 | + |
| 23 | +//--- Lib.swift |
| 24 | + |
| 25 | +@cdecl private enum PrivateEnum: CInt { case A, B } |
| 26 | +// PUBLIC-AND-INTERNAL-NOT: PrivateEnum |
| 27 | + |
| 28 | +@cdecl internal enum InternalEnum: CInt { case A, B } |
| 29 | +// INTERNAL-ONLY: typedef SWIFT_ENUM(int, InternalEnum, closed) { |
| 30 | +// INTERNAL-ONLY: InternalEnumA = 0, |
| 31 | +// INTERNAL-ONLY: InternalEnumB = 1, |
| 32 | +// INTERNAL-ONLY: }; |
| 33 | + |
| 34 | +@cdecl package enum PackageEnum: CInt { case A, B } |
| 35 | +// INTERNAL-ONLY: typedef SWIFT_ENUM(int, PackageEnum, closed) { |
| 36 | +// INTERNAL-ONLY: PackageEnumA = 0, |
| 37 | +// INTERNAL-ONLY: PackageEnumB = 1, |
| 38 | +// INTERNAL-ONLY: }; |
| 39 | + |
| 40 | +@cdecl public enum PublicEnum: CInt { case A, B } |
| 41 | +// PUBLIC-AND-INTERNAL: typedef SWIFT_ENUM(int, PublicEnum, closed) { |
| 42 | +// PUBLIC-AND-INTERNAL: PublicEnumA = 0, |
| 43 | +// PUBLIC-AND-INTERNAL: PublicEnumB = 1, |
| 44 | +// PUBLIC-AND-INTERNAL: }; |
| 45 | + |
| 46 | +/// Private documentation |
| 47 | +@cdecl private func a_private() {} |
| 48 | +// PUBLIC-AND-INTERNAL-NOT: // Private documentation |
| 49 | +// PUBLIC-AND-INTERNAL-NOT: a_private |
| 50 | + |
| 51 | +/// Internal documentation |
| 52 | +@cdecl internal func b_internal() {} |
| 53 | +// INTERNAL-ONLY: // Internal documentation |
| 54 | +// INTERNAL-ONLY: b_internal |
| 55 | + |
| 56 | +/// Package documentation |
| 57 | +@cdecl package func c_package() {} |
| 58 | +// INTERNAL-ONLY: // Package documentation |
| 59 | +// INTERNAL-ONLY: c_package |
| 60 | + |
| 61 | +/// Public documentation |
| 62 | +@cdecl public func d_public() {} |
| 63 | +// PUBLIC-AND-INTERNAL: // Public documentation |
| 64 | +// PUBLIC-AND-INTERNAL: d_public |
0 commit comments