From 7769a6d2bc258cf42ed348f89c451ce554e81221 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Tue, 19 Oct 2021 20:48:47 +0900 Subject: [PATCH] [Mach-O] wip --- macho/tapi.cc | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/macho/tapi.cc b/macho/tapi.cc index 3ff54358..c8cf2bdf 100644 --- a/macho/tapi.cc +++ b/macho/tapi.cc @@ -4,7 +4,7 @@ namespace mold::macho { -typedef std::vector YamlVector; +typedef std::vector Vector; static std::string_view get_line(std::string_view str, i64 pos) { i64 begin = str.substr(0, pos).rfind('\n'); @@ -28,7 +28,7 @@ static const T *lookup(const YamlNode &node, std::string_view key) { return nullptr; } -static bool contains(const YamlVector &vec, std::string_view key) { +static bool contains(const Vector &vec, std::string_view key) { for (const YamlNode &mem : vec) if (const std::string_view *s = std::get_if(&mem.data)) if (*s == key) @@ -37,13 +37,13 @@ static bool contains(const YamlVector &vec, std::string_view key) { } static std::optional to_tbd(const YamlNode &node) { - const YamlVector *targets = lookup(node, "targets"); + const Vector *targets = lookup(node, "targets"); if (!targets || !contains(*targets, "x86_64-macos")) return {}; TextBasedDylib tbd; - if (auto *vec = lookup(node, "uuids")) + if (auto *vec = lookup(node, "uuids")) for (const YamlNode &mem : *vec) if (auto *target = lookup(mem, "target")) if (*target == "x86_64-macos") @@ -56,27 +56,27 @@ static std::optional to_tbd(const YamlNode &node) { if (auto *val = lookup(node, "current-version")) tbd.current_version = *val; - if (auto *vec = lookup(node, "parent-umbrella")) + if (auto *vec = lookup(node, "parent-umbrella")) for (const YamlNode &mem : *vec) - if (auto *targets = lookup(mem, "targets")) + if (auto *targets = lookup(mem, "targets")) if (contains(*targets, "x86_64-macos")) if (auto *val = lookup(mem, "umbrella")) tbd.parent_umbrella = *val; - if (auto *vec = lookup(node, "reexported-libraries")) + if (auto *vec = lookup(node, "reexported-libraries")) for (const YamlNode &mem : *vec) - if (auto *targets = lookup(mem, "targets")) + if (auto *targets = lookup(mem, "targets")) if (contains(*targets, "x86_64-macos")) - if (auto *libs = lookup(mem, "libraries")) + if (auto *libs = lookup(mem, "libraries")) for (const YamlNode &mem : *libs) if (auto *lib = std::get_if(&mem.data)) tbd.reexported_libs.push_back(*lib); - if (auto *vec = lookup(node, "exports")) + if (auto *vec = lookup(node, "exports")) for (const YamlNode &mem : *vec) - if (auto *targets = lookup(mem, "targets")) + if (auto *targets = lookup(mem, "targets")) if (contains(*targets, "x86_64-macos")) - if (auto *syms = lookup(mem, "symbols")) + if (auto *syms = lookup(mem, "symbols")) for (const YamlNode &mem : *syms) if (auto *sym = std::get_if(&mem.data)) tbd.exports.push_back(*sym); @@ -86,7 +86,7 @@ static std::optional to_tbd(const YamlNode &node) { std::vector parse_tbd(Context &ctx, MappedFile *mf) { std::string_view contents = mf->get_contents(); - std::variant res = parse_yaml(contents); + std::variant res = parse_yaml(contents); if (YamlError *err = std::get_if(&res)) { std::string_view line = get_line(contents, err->pos); @@ -95,7 +95,7 @@ std::vector parse_tbd(Context &ctx, MappedFile *mf) { << ": YAML parse error: " << err->msg; } - YamlVector &nodes = std::get(res); + Vector &nodes = std::get(res); std::vector vec; vec.reserve(nodes.size());