llvm/llvm/include/llvm/ObjectYAML/MachOYAML.h

//===- MachOYAML.h - Mach-O YAMLIO implementation ---------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
///
/// \file
/// This file declares classes for handling the YAML representation
/// of Mach-O.
///
//===----------------------------------------------------------------------===//

#ifndef LLVM_OBJECTYAML_MACHOYAML_H
#define LLVM_OBJECTYAML_MACHOYAML_H

#include "llvm/ADT/StringRef.h"
#include "llvm/BinaryFormat/MachO.h"
#include "llvm/ObjectYAML/DWARFYAML.h"
#include "llvm/ObjectYAML/YAML.h"
#include "llvm/Support/YAMLTraits.h"
#include <cstdint>
#include <optional>
#include <string>
#include <vector>

namespace llvm {
namespace MachOYAML {

struct Relocation {};

struct Section {};

struct FileHeader {};

struct LoadCommand {};

struct NListEntry {};

struct RebaseOpcode {};

struct BindOpcode {};

struct ExportEntry {};

struct DataInCodeEntry {};

struct LinkEditData {};

struct Object {};

struct FatHeader {};

struct FatArch {};

struct UniversalBinary {};

} // end namespace MachOYAML
} // end namespace llvm

LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::MachOYAML::LoadCommand)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::MachOYAML::Relocation)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::MachOYAML::Section)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::MachOYAML::RebaseOpcode)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::MachOYAML::BindOpcode)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::MachOYAML::ExportEntry)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::MachOYAML::NListEntry)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::MachOYAML::Object)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::MachOYAML::FatArch)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::MachOYAML::DataInCodeEntry)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::MachO::build_tool_version)

namespace llvm {

class raw_ostream;

namespace yaml {

template <> struct MappingTraits<MachOYAML::FileHeader> {};

template <> struct MappingTraits<MachOYAML::Object> {};

template <> struct MappingTraits<MachOYAML::FatHeader> {};

template <> struct MappingTraits<MachOYAML::FatArch> {};

template <> struct MappingTraits<MachOYAML::UniversalBinary> {};

template <> struct MappingTraits<MachOYAML::LoadCommand> {};

template <> struct MappingTraits<MachOYAML::LinkEditData> {};

template <> struct MappingTraits<MachOYAML::RebaseOpcode> {};

template <> struct MappingTraits<MachOYAML::BindOpcode> {};

template <> struct MappingTraits<MachOYAML::ExportEntry> {};

template <> struct MappingTraits<MachOYAML::Relocation> {};

template <> struct MappingTraits<MachOYAML::Section> {};

template <> struct MappingTraits<MachOYAML::NListEntry> {};

template <> struct MappingTraits<MachO::build_tool_version> {};

template <> struct MappingTraits<MachOYAML::DataInCodeEntry> {};

#define HANDLE_LOAD_COMMAND

template <> struct ScalarEnumerationTraits<MachO::LoadCommandType> {};

#define ENUM_CASE(Enum)

template <> struct ScalarEnumerationTraits<MachO::RebaseOpcode> {};

template <> struct ScalarEnumerationTraits<MachO::BindOpcode> {};

// This trait is used for 16-byte chars in Mach structures used for strings
char_16;

template <> struct ScalarTraits<char_16> {};

// This trait is used for UUIDs. It reads and writes them matching otool's
// formatting style.
uuid_t;

template <> struct ScalarTraits<uuid_t> {};

// Load Command struct mapping traits

#define LOAD_COMMAND_STRUCT

#include "llvm/BinaryFormat/MachO.def"

// Extra structures used by load commands
template <> struct MappingTraits<MachO::dylib> {};

template <> struct MappingTraits<MachO::fvmlib> {};

template <> struct MappingTraits<MachO::section> {};

template <> struct MappingTraits<MachO::section_64> {};

} // end namespace yaml

} // end namespace llvm

#endif // LLVM_OBJECTYAML_MACHOYAML_H