xref: /llvm-project/llvm/lib/TextAPI/TextStubCommon.h (revision b2b50980de240b3d89e0f9340b51d6d6079fd19d)
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/StringRef.h"
17 #include "llvm/Support/YAMLTraits.h"
18 #include "llvm/TextAPI/Architecture.h"
19 #include "llvm/TextAPI/InterfaceFile.h"
20 #include "llvm/TextAPI/Platform.h"
21 #include "llvm/TextAPI/Target.h"
22 
23 using UUID = std::pair<llvm::MachO::Target, std::string>;
24 
25 // clang-format off
26 enum TBDFlags : unsigned {
27   None                         = 0U,
28   FlatNamespace                = 1U << 0,
29   NotApplicationExtensionSafe  = 1U << 1,
30   InstallAPI                   = 1U << 2,
31   LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/InstallAPI),
32 };
33 // clang-format on
34 
35 LLVM_YAML_STRONG_TYPEDEF(llvm::StringRef, FlowStringRef)
36 LLVM_YAML_STRONG_TYPEDEF(uint8_t, SwiftVersion)
37 LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(UUID)
38 LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(FlowStringRef)
39 
40 namespace llvm {
41 
42 namespace MachO {
43 class ArchitectureSet;
44 class PackedVersion;
45 
46 Expected<std::unique_ptr<InterfaceFile>>
47 getInterfaceFileFromJSON(StringRef JSON);
48 } // namespace MachO
49 
50 namespace yaml {
51 
52 template <> struct ScalarTraits<FlowStringRef> {
53   static void output(const FlowStringRef &, void *, raw_ostream &);
54   static StringRef input(StringRef, void *, FlowStringRef &);
55   static QuotingType mustQuote(StringRef);
56 };
57 
58 template <> struct ScalarEnumerationTraits<MachO::ObjCConstraintType> {
59   static void enumeration(IO &, MachO::ObjCConstraintType &);
60 };
61 
62 template <> struct ScalarTraits<MachO::PlatformSet> {
63   static void output(const MachO::PlatformSet &, void *, raw_ostream &);
64   static StringRef input(StringRef, void *, MachO::PlatformSet &);
65   static QuotingType mustQuote(StringRef);
66 };
67 
68 template <> struct ScalarBitSetTraits<MachO::ArchitectureSet> {
69   static void bitset(IO &, MachO::ArchitectureSet &);
70 };
71 
72 template <> struct ScalarTraits<MachO::Architecture> {
73   static void output(const MachO::Architecture &, void *, raw_ostream &);
74   static StringRef input(StringRef, void *, MachO::Architecture &);
75   static QuotingType mustQuote(StringRef);
76 };
77 
78 template <> struct ScalarTraits<MachO::PackedVersion> {
79   static void output(const MachO::PackedVersion &, void *, raw_ostream &);
80   static StringRef input(StringRef, void *, MachO::PackedVersion &);
81   static QuotingType mustQuote(StringRef);
82 };
83 
84 template <> struct ScalarTraits<SwiftVersion> {
85   static void output(const SwiftVersion &, void *, raw_ostream &);
86   static StringRef input(StringRef, void *, SwiftVersion &);
87   static QuotingType mustQuote(StringRef);
88 };
89 
90 template <> struct ScalarTraits<UUID> {
91   static void output(const UUID &, void *, raw_ostream &);
92   static StringRef input(StringRef, void *, UUID &);
93   static QuotingType mustQuote(StringRef);
94 };
95 
96 } // end namespace yaml.
97 } // end namespace llvm.
98 
99 #endif // LLVM_TEXTAPI_TEXT_STUB_COMMON_H
100