| 1 | //===- TextStubCommon.h ---------------------------------------------------===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // Defines common Text Stub YAML mappings. |
| 10 | // |
| 11 | //===----------------------------------------------------------------------===// |
| 12 | |
| 13 | #ifndef LLVM_TEXTAPI_TEXT_STUB_COMMON_H |
| 14 | #define LLVM_TEXTAPI_TEXT_STUB_COMMON_H |
| 15 | |
| 16 | #include "llvm/ADT/BitmaskEnum.h" |
| 17 | #include "llvm/ADT/StringRef.h" |
| 18 | #include "llvm/Support/YAMLTraits.h" |
| 19 | #include "llvm/TextAPI/Architecture.h" |
| 20 | #include "llvm/TextAPI/InterfaceFile.h" |
| 21 | #include "llvm/TextAPI/Platform.h" |
| 22 | #include "llvm/TextAPI/Target.h" |
| 23 | |
| 24 | using UUID = std::pair<llvm::MachO::Target, std::string>; |
| 25 | |
| 26 | // clang-format off |
| 27 | enum TBDFlags : unsigned { |
| 28 | None = 0U, |
| 29 | FlatNamespace = 1U << 0, |
| 30 | NotApplicationExtensionSafe = 1U << 1, |
| 31 | InstallAPI = 1U << 2, |
| 32 | SimulatorSupport = 1U << 3, |
| 33 | OSLibNotForSharedCache = 1U << 4, |
| 34 | LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/OSLibNotForSharedCache), |
| 35 | }; |
| 36 | // clang-format on |
| 37 | |
| 38 | LLVM_YAML_STRONG_TYPEDEF(llvm::StringRef, FlowStringRef) |
| 39 | LLVM_YAML_STRONG_TYPEDEF(uint8_t, SwiftVersion) |
| 40 | LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(UUID) |
| 41 | LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(FlowStringRef) |
| 42 | |
| 43 | namespace llvm { |
| 44 | |
| 45 | namespace MachO { |
| 46 | class ArchitectureSet; |
| 47 | class PackedVersion; |
| 48 | |
| 49 | Expected<std::unique_ptr<InterfaceFile>> |
| 50 | getInterfaceFileFromJSON(StringRef JSON); |
| 51 | |
| 52 | Error serializeInterfaceFileToJSON(raw_ostream &OS, const InterfaceFile &File, |
| 53 | const FileType FileKind, bool Compact); |
| 54 | } // namespace MachO |
| 55 | |
| 56 | namespace yaml { |
| 57 | |
| 58 | template <> struct ScalarTraits<FlowStringRef> { |
| 59 | static void output(const FlowStringRef &, void *, raw_ostream &); |
| 60 | static StringRef input(StringRef, void *, FlowStringRef &); |
| 61 | static QuotingType mustQuote(StringRef); |
| 62 | }; |
| 63 | |
| 64 | template <> struct ScalarEnumerationTraits<MachO::ObjCConstraintType> { |
| 65 | static void enumeration(IO &, MachO::ObjCConstraintType &); |
| 66 | }; |
| 67 | |
| 68 | template <> struct ScalarTraits<MachO::PlatformSet> { |
| 69 | static void output(const MachO::PlatformSet &, void *, raw_ostream &); |
| 70 | static StringRef input(StringRef, void *, MachO::PlatformSet &); |
| 71 | static QuotingType mustQuote(StringRef); |
| 72 | }; |
| 73 | |
| 74 | template <> struct ScalarBitSetTraits<MachO::ArchitectureSet> { |
| 75 | static void bitset(IO &, MachO::ArchitectureSet &); |
| 76 | }; |
| 77 | |
| 78 | template <> struct ScalarTraits<MachO::Architecture> { |
| 79 | static void output(const MachO::Architecture &, void *, raw_ostream &); |
| 80 | static StringRef input(StringRef, void *, MachO::Architecture &); |
| 81 | static QuotingType mustQuote(StringRef); |
| 82 | }; |
| 83 | |
| 84 | template <> struct ScalarTraits<MachO::PackedVersion> { |
| 85 | static void output(const MachO::PackedVersion &, void *, raw_ostream &); |
| 86 | static StringRef input(StringRef, void *, MachO::PackedVersion &); |
| 87 | static QuotingType mustQuote(StringRef); |
| 88 | }; |
| 89 | |
| 90 | template <> struct ScalarTraits<SwiftVersion> { |
| 91 | static void output(const SwiftVersion &, void *, raw_ostream &); |
| 92 | static StringRef input(StringRef, void *, SwiftVersion &); |
| 93 | static QuotingType mustQuote(StringRef); |
| 94 | }; |
| 95 | |
| 96 | // UUIDs are no longer respected but kept in the YAML parser |
| 97 | // to keep reading in older TBDs. |
| 98 | template <> struct ScalarTraits<UUID> { |
| 99 | static void output(const UUID &, void *, raw_ostream &); |
| 100 | static StringRef input(StringRef, void *, UUID &); |
| 101 | static QuotingType mustQuote(StringRef); |
| 102 | }; |
| 103 | |
| 104 | } // end namespace yaml. |
| 105 | } // end namespace llvm. |
| 106 | |
| 107 | #endif // LLVM_TEXTAPI_TEXT_STUB_COMMON_H |
| 108 | |