-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5922b30
commit 3871ada
Showing
154 changed files
with
28,262 additions
and
4,186 deletions.
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
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
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,65 @@ | ||
#if !NO_SWIFTPM | ||
import cclang | ||
#endif | ||
|
||
protocol EvalResultKind { | ||
var clang: CXEvalResultKind { get } | ||
} | ||
|
||
public struct IntResult: EvalResultKind { | ||
let clang: CXEvalResultKind | ||
public var value: Int { | ||
return Int(clang_EvalResult_getAsInt(clang)) | ||
} | ||
} | ||
|
||
public struct FloatResult: EvalResultKind { | ||
let clang: CXEvalResultKind | ||
public var value: Double { | ||
return Int(clang_EvalResult_getAsDouble(clang)) | ||
} | ||
} | ||
|
||
public struct ObjCStrLiteralResult: EvalResultKind { | ||
let clang: CXEvalResultKind | ||
public var value: String { | ||
return String(cString: clang_EvalResult_getAsString(clang)) | ||
} | ||
} | ||
|
||
public struct StrLiteralResult: EvalResultKind { | ||
let clang: CXEvalResultKind | ||
public var value: String { | ||
return String(cString: clang_EvalResult_getAsString(clang)) | ||
} | ||
} | ||
|
||
public struct CFStrResult: EvalResultKind { | ||
let clang: CXEvalResultKind | ||
public var value: String { | ||
return String(cString: clang_EvalResult_getAsString(clang)) | ||
} | ||
} | ||
|
||
public struct OtherResult: EvalResultKind { | ||
let clang: CXEvalResultKind | ||
} | ||
|
||
public struct UnExposedResult: EvalResultKind { | ||
let clang: CXEvalResultKind | ||
} | ||
|
||
/// Converts a CXEvalResultKind to a EvalResultKind, returning `nil` if it was unsuccessful | ||
func convertEvalResultKind(_ clang: CXEvalResultKind) -> EvalResultKind? { | ||
if <#clang thing is null?#> { return nil } | ||
switch <#Get clang kind#> { | ||
case CXEval_Int: return IntResult(clang: clang) | ||
case CXEval_Float: return FloatResult(clang: clang) | ||
case CXEval_ObjCStrLiteral: return ObjCStrLiteralResult(clang: clang) | ||
case CXEval_StrLiteral: return StrLiteralResult(clang: clang) | ||
case CXEval_CFStr: return CFStrResult(clang: clang) | ||
case CXEval_Other: return OtherResult(clang: clang) | ||
case CXEval_UnExposed: return UnExposedResult(clang: clang) | ||
default: fatalError("invalid CXEvalResultKindKind \(clang)") | ||
} | ||
} |
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,84 @@ | ||
#if !NO_SWIFTPM | ||
import cclang | ||
#endif | ||
|
||
/// Describes the calling convention of a function type | ||
public enum CallingConvention { | ||
case `default` | ||
case c | ||
case x86StdCall | ||
case x86FastCall | ||
case x86ThisCall | ||
case x86Pascal | ||
case aapcs | ||
case aapcs_vfp | ||
case intelOclBicc | ||
case x86_64Win64 | ||
case x86_64SysV | ||
case x86VectorCall | ||
case swift | ||
case preserveMost | ||
case preserveAll | ||
case unexposed | ||
|
||
init?(clang: CXCallingConv) { | ||
switch clang { | ||
case CXCallingConv_Default: self = .default | ||
case CXCallingConv_C: self = .c | ||
case CXCallingConv_X86StdCall: self = .x86StdCall | ||
case CXCallingConv_X86FastCall: self = .x86FastCall | ||
case CXCallingConv_X86ThisCall: self = .x86ThisCall | ||
case CXCallingConv_X86Pascal: self = .x86Pascal | ||
case CXCallingConv_AAPCS: self = .aapcs | ||
case CXCallingConv_AAPCS_VFP: self = .aapcs_vfp | ||
case CXCallingConv_IntelOclBicc: self = .intelOclBicc | ||
case CXCallingConv_X86_64Win64: self = .x86_64Win64 | ||
case CXCallingConv_X86_64SysV: self = .x86_64SysV | ||
case CXCallingConv_X86VectorCall: self = .x86VectorCall | ||
case CXCallingConv_Swift: self = .swift | ||
case CXCallingConv_PreserveMost: self = .preserveMost | ||
case CXCallingConv_PreserveAll: self = .preserveAll | ||
case CXCallingConv_Invalid: return nil | ||
case CXCallingConv_Unexposed: self = .unexposed | ||
default: fatalError("invalid CXCallingConv \(clang)") | ||
} | ||
} | ||
} | ||
|
||
/// Property attributes for an Objective-C @property declaration. | ||
public struct ObjCPropertyAttributes: OptionSet { | ||
public typealias RawValue = CXObjCPropertyAttrKind.RawValue | ||
public let rawValue: RawValue | ||
/// Creates a new ObjCPropertyAttributes from a raw integer value. | ||
public init(rawValue: RawValue) { | ||
self.rawValue = rawValue | ||
} | ||
public static let noattr = ObjCPropertyAttributes(rawValue: | ||
CXObjCPropertyAttr_noattr.rawValue) | ||
public static let readonly = ObjCPropertyAttributes(rawValue: | ||
CXObjCPropertyAttr_readonly.rawValue) | ||
public static let getter = ObjCPropertyAttributes(rawValue: | ||
CXObjCPropertyAttr_getter.rawValue) | ||
public static let assign = ObjCPropertyAttributes(rawValue: | ||
CXObjCPropertyAttr_assign.rawValue) | ||
public static let readwrite = ObjCPropertyAttributes(rawValue: | ||
CXObjCPropertyAttr_readwrite.rawValue) | ||
public static let retain = ObjCPropertyAttributes(rawValue: | ||
CXObjCPropertyAttr_retain.rawValue) | ||
public static let copy = ObjCPropertyAttributes(rawValue: | ||
CXObjCPropertyAttr_copy.rawValue) | ||
public static let nonatomic = ObjCPropertyAttributes(rawValue: | ||
CXObjCPropertyAttr_nonatomic.rawValue) | ||
public static let setter = ObjCPropertyAttributes(rawValue: | ||
CXObjCPropertyAttr_setter.rawValue) | ||
public static let atomic = ObjCPropertyAttributes(rawValue: | ||
CXObjCPropertyAttr_atomic.rawValue) | ||
public static let weak = ObjCPropertyAttributes(rawValue: | ||
CXObjCPropertyAttr_weak.rawValue) | ||
public static let strong = ObjCPropertyAttributes(rawValue: | ||
CXObjCPropertyAttr_strong.rawValue) | ||
public static let unsafe_unretained = ObjCPropertyAttributes(rawValue: | ||
CXObjCPropertyAttr_unsafe_unretained.rawValue) | ||
public static let `class` = ObjCPropertyAttributes(rawValue: | ||
CXObjCPropertyAttr_class.rawValue) | ||
} |
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,32 @@ | ||
#if !NO_SWIFTPM | ||
import cclang | ||
#endif | ||
|
||
public struct NameRefOptions: OptionSet { | ||
public typealias RawValue = CXNameRefFlags.RawValue | ||
public let rawValue: RawValue | ||
|
||
/// Creates a new NameRefOptions from a raw integer value. | ||
public init(rawValue: RawValue) { | ||
self.rawValue = rawValue | ||
} | ||
|
||
/// Include the nested-name-specifier, e.g. Foo:: in x.Foo::y, in the range. | ||
public static let wantQualifier = NameRefOptions(rawValue: | ||
CXNameRange_WantQualifier.rawValue) | ||
|
||
/// Include the explicit template arguments, e.g. <int> in x.f<int>, in the | ||
/// range. | ||
public static let wantTemplateArgs = NameRefOptions(rawValue: | ||
CXNameRange_WantTemplateArgs.rawValue) | ||
|
||
/// If the name is non-contiguous, return the full spanning range. | ||
/// Non-contiguous names occur in Objective-C when a selector with two or more | ||
/// parameters is used, or in C++ when using an operator: | ||
/// ``` | ||
/// [object doSomething:here withValue:there]; // Objective-C | ||
/// return some_vector[1]; // C++ | ||
/// ``` | ||
public static let wantSinglePiece = NameRefOptions(rawValue: | ||
CXNameRange_WantSinglePiece.rawValue) | ||
} |
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
Oops, something went wrong.