108 lines · c
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-exception6//7//===----------------------------------------------------------------------===//8//9// Defines common Text Stub YAML mappings.10//11//===----------------------------------------------------------------------===//12 13#ifndef LLVM_TEXTAPI_TEXT_STUB_COMMON_H14#define LLVM_TEXTAPI_TEXT_STUB_COMMON_H15 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 24using UUID = std::pair<llvm::MachO::Target, std::string>;25 26// clang-format off27enum 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 on37 38LLVM_YAML_STRONG_TYPEDEF(llvm::StringRef, FlowStringRef)39LLVM_YAML_STRONG_TYPEDEF(uint8_t, SwiftVersion)40LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(UUID)41LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(FlowStringRef)42 43namespace llvm {44 45namespace MachO {46class ArchitectureSet;47class PackedVersion;48 49Expected<std::unique_ptr<InterfaceFile>>50getInterfaceFileFromJSON(StringRef JSON);51 52Error serializeInterfaceFileToJSON(raw_ostream &OS, const InterfaceFile &File,53 const FileType FileKind, bool Compact);54} // namespace MachO55 56namespace yaml {57 58template <> 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 64template <> struct ScalarEnumerationTraits<MachO::ObjCConstraintType> {65 static void enumeration(IO &, MachO::ObjCConstraintType &);66};67 68template <> 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 74template <> struct ScalarBitSetTraits<MachO::ArchitectureSet> {75 static void bitset(IO &, MachO::ArchitectureSet &);76};77 78template <> 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 84template <> 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 90template <> 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 parser97// to keep reading in older TBDs.98template <> 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_H108