|
1 | 1 | import cclang
|
2 | 2 |
|
| 3 | +/// Flags that control the creation of translation units. |
| 4 | +/// The enumerators in this enumeration type are meant to be bitwise ORed |
| 5 | +/// together to specify which options should be used when constructing the |
| 6 | +/// translation unit. |
3 | 7 | public struct TranslationUnitOptions: OptionSet {
|
4 |
| - public typealias RawValue = UInt32 |
5 |
| - public let rawValue: UInt32 |
6 |
| - |
7 |
| - public init(rawValue: UInt32) { self.rawValue = rawValue } |
8 |
| - |
9 |
| - public static let detailedPreprocessingRecord = |
10 |
| - TranslationUnitOptions(rawValue: CXTranslationUnit_DetailedPreprocessingRecord.rawValue) |
11 |
| - public static let incomplete = |
12 |
| - TranslationUnitOptions(rawValue: CXTranslationUnit_Incomplete.rawValue) |
13 |
| - public static let precompiledPreamble = |
14 |
| - TranslationUnitOptions(rawValue: CXTranslationUnit_PrecompiledPreamble.rawValue) |
15 |
| - public static let cacheCompletionResults = |
16 |
| - TranslationUnitOptions(rawValue: CXTranslationUnit_CacheCompletionResults.rawValue) |
17 |
| - public static let forSerialization = |
18 |
| - TranslationUnitOptions(rawValue: CXTranslationUnit_ForSerialization.rawValue) |
19 |
| - public static let cxxChainedPCH = |
20 |
| - TranslationUnitOptions(rawValue: CXTranslationUnit_CXXChainedPCH.rawValue) |
21 |
| - public static let skipFunctionBodies = |
22 |
| - TranslationUnitOptions(rawValue: CXTranslationUnit_SkipFunctionBodies.rawValue) |
23 |
| - public static let includeBriefCommentsInCodeCompletion = |
24 |
| - TranslationUnitOptions(rawValue: CXTranslationUnit_IncludeBriefCommentsInCodeCompletion.rawValue) |
25 |
| - public static let createPreambleOnFirstParse = |
26 |
| - TranslationUnitOptions(rawValue: CXTranslationUnit_CreatePreambleOnFirstParse.rawValue) |
27 |
| - public static let keepGoing = |
28 |
| - TranslationUnitOptions(rawValue: CXTranslationUnit_KeepGoing.rawValue) |
| 8 | + public typealias RawValue = CXTranslationUnit_Flags.RawValue |
| 9 | + public let rawValue: RawValue |
| 10 | + |
| 11 | + /// Creates a new TranslationUnitOptions from a raw integer value. |
| 12 | + public init(rawValue: RawValue) { |
| 13 | + self.rawValue = rawValue |
| 14 | + } |
| 15 | + |
| 16 | + /// Used to indicate that no special translation-unit options are needed. |
| 17 | + public static let none = TranslationUnitOptions(rawValue: |
| 18 | + CXTranslationUnit_None.rawValue) |
| 19 | + |
| 20 | + /// Used to indicate that the parser should construct a "detailed" |
| 21 | + /// preprocessing record, including all macro definitions and instantiations. |
| 22 | + /// Constructing a detailed preprocessing record requires more memory and time |
| 23 | + /// to parse, since the information contained in the record is usually not |
| 24 | + /// retained. However, it can be useful for applications that require more |
| 25 | + /// detailed information about the behavior of the preprocessor. |
| 26 | + public static let detailedPreprocessingRecord = TranslationUnitOptions(rawValue: |
| 27 | + CXTranslationUnit_DetailedPreprocessingRecord.rawValue) |
| 28 | + |
| 29 | + /// Used to indicate that the translation unit is incomplete. |
| 30 | + /// When a translation unit is considered "incomplete", semantic analysis that |
| 31 | + /// is typically performed at the end of the translation unit will be |
| 32 | + /// suppressed. For example, this suppresses the completion of tentative |
| 33 | + /// declarations in C and of instantiation of implicitly-instantiation |
| 34 | + /// function templates in C++. This option is typically used when parsing a |
| 35 | + /// header with the intent of producing a precompiled header. |
| 36 | + public static let incomplete = TranslationUnitOptions(rawValue: |
| 37 | + CXTranslationUnit_Incomplete.rawValue) |
| 38 | + |
| 39 | + /// Used to indicate that the translation unit should be built with an |
| 40 | + /// implicit precompiled header for the preamble. |
| 41 | + /// An implicit precompiled header is used as an optimization when a |
| 42 | + /// particular translation unit is likely to be reparsed many times |
| 43 | + /// when the sources aren't changing that often. In this case, an |
| 44 | + /// implicit precompiled header will be built containing all of the |
| 45 | + /// initial includes at the top of the main file (what we refer to as |
| 46 | + /// the "preamble" of the file). In subsequent parses, if the |
| 47 | + /// preamble or the files in it have not changed, |
| 48 | + /// `clang_reparseTranslationUnit()` |
| 49 | + /// will re-use the implicit |
| 50 | + /// precompiled header to improve parsing performance. |
| 51 | + public static let precompiledPreamble = TranslationUnitOptions(rawValue: |
| 52 | + CXTranslationUnit_PrecompiledPreamble.rawValue) |
| 53 | + |
| 54 | + /// Used to indicate that the translation unit should cache some |
| 55 | + /// code-completion results with each reparse of the source file. |
| 56 | + /// Caching of code-completion results is a performance optimization that |
| 57 | + /// introduces some overhead to reparsing but improves the performance of |
| 58 | + /// code-completion operations. |
| 59 | + public static let cacheCompletionResults = TranslationUnitOptions(rawValue: |
| 60 | + CXTranslationUnit_CacheCompletionResults.rawValue) |
| 61 | + |
| 62 | + /// This option is typically used when parsing a header with the intent of |
| 63 | + /// producing a precompiled header. |
| 64 | + /// Used to indicate that the translation unit will be serialized with |
| 65 | + /// `clang_saveTranslationUnit.` |
| 66 | + public static let forSerialization = TranslationUnitOptions(rawValue: |
| 67 | + CXTranslationUnit_ForSerialization.rawValue) |
| 68 | + |
| 69 | + /// DEPRECATED: Enabled chained precompiled preambles in C++. |
| 70 | + /// Note: this is a *temporary* option that is available only while we are |
| 71 | + /// testing C++ precompiled preamble support. It is deprecated. |
| 72 | + public static let cxxChainedPCH = TranslationUnitOptions(rawValue: |
| 73 | + CXTranslationUnit_CXXChainedPCH.rawValue) |
| 74 | + |
| 75 | + /// Used to indicate that function/method bodies should be skipped while |
| 76 | + /// parsing. |
| 77 | + /// This option can be used to search for declarations/definitions while |
| 78 | + /// ignoring the usages. |
| 79 | + public static let skipFunctionBodies = TranslationUnitOptions(rawValue: |
| 80 | + CXTranslationUnit_SkipFunctionBodies.rawValue) |
| 81 | + |
| 82 | + /// Used to indicate that brief documentation comments should be included into |
| 83 | + /// the set of code completions returned from this translation unit. |
| 84 | + public static let includeBriefCommentsInCodeCompletion = TranslationUnitOptions(rawValue: |
| 85 | + CXTranslationUnit_IncludeBriefCommentsInCodeCompletion.rawValue) |
| 86 | + |
| 87 | + /// Used to indicate that the precompiled preamble should be created on the |
| 88 | + /// first parse. Otherwise it will be created on the first reparse. This |
| 89 | + /// trades runtime on the first parse (serializing the preamble takes time) |
| 90 | + /// for reduced runtime on the second parse (can now reuse the preamble). |
| 91 | + public static let createPreambleOnFirstParse = TranslationUnitOptions(rawValue: |
| 92 | + CXTranslationUnit_CreatePreambleOnFirstParse.rawValue) |
| 93 | + |
| 94 | + /// Do not stop processing when fatal errors are encountered. |
| 95 | + /// When fatal errors are encountered while parsing a translation unit, |
| 96 | + /// semantic analysis is typically stopped early when compiling code. A common |
| 97 | + /// source for fatal errors are unresolvable include files. For the purposes |
| 98 | + /// of an IDE, this is undesirable behavior and as much information as |
| 99 | + /// possible should be reported. Use this flag to enable this behavior. |
| 100 | + public static let keepGoing = TranslationUnitOptions(rawValue: |
| 101 | + CXTranslationUnit_KeepGoing.rawValue) |
29 | 102 | }
|
30 | 103 |
|
31 | 104 | public class TranslationUnit {
|
|
0 commit comments