Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 77e54616 authored by Adam Lesinski's avatar Adam Lesinski Committed by Android (Google) Code Review
Browse files

Merge "Use Google3 style guide with .clang-format"

parents bb3d2e97 cacb28f2
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
BasedOnStyle: Google
ColumnLimit: 100
+685 −670
Original line number Diff line number Diff line
@@ -98,19 +98,22 @@ static bool parseMnc(const char* name, ResTable_config* out) {

static bool parseLayoutDirection(const char* name, ResTable_config* out) {
  if (strcmp(name, kWildcardName) == 0) {
        if (out) out->screenLayout =
                (out->screenLayout&~ResTable_config::MASK_LAYOUTDIR)
                | ResTable_config::LAYOUTDIR_ANY;
    if (out)
      out->screenLayout =
          (out->screenLayout & ~ResTable_config::MASK_LAYOUTDIR) |
          ResTable_config::LAYOUTDIR_ANY;
    return true;
  } else if (strcmp(name, "ldltr") == 0) {
        if (out) out->screenLayout =
                (out->screenLayout&~ResTable_config::MASK_LAYOUTDIR)
                | ResTable_config::LAYOUTDIR_LTR;
    if (out)
      out->screenLayout =
          (out->screenLayout & ~ResTable_config::MASK_LAYOUTDIR) |
          ResTable_config::LAYOUTDIR_LTR;
    return true;
  } else if (strcmp(name, "ldrtl") == 0) {
        if (out) out->screenLayout =
                (out->screenLayout&~ResTable_config::MASK_LAYOUTDIR)
                | ResTable_config::LAYOUTDIR_RTL;
    if (out)
      out->screenLayout =
          (out->screenLayout & ~ResTable_config::MASK_LAYOUTDIR) |
          ResTable_config::LAYOUTDIR_RTL;
    return true;
  }

@@ -119,29 +122,34 @@ static bool parseLayoutDirection(const char* name, ResTable_config* out) {

static bool parseScreenLayoutSize(const char* name, ResTable_config* out) {
  if (strcmp(name, kWildcardName) == 0) {
        if (out) out->screenLayout =
                (out->screenLayout&~ResTable_config::MASK_SCREENSIZE)
                | ResTable_config::SCREENSIZE_ANY;
    if (out)
      out->screenLayout =
          (out->screenLayout & ~ResTable_config::MASK_SCREENSIZE) |
          ResTable_config::SCREENSIZE_ANY;
    return true;
  } else if (strcmp(name, "small") == 0) {
        if (out) out->screenLayout =
                (out->screenLayout&~ResTable_config::MASK_SCREENSIZE)
                | ResTable_config::SCREENSIZE_SMALL;
    if (out)
      out->screenLayout =
          (out->screenLayout & ~ResTable_config::MASK_SCREENSIZE) |
          ResTable_config::SCREENSIZE_SMALL;
    return true;
  } else if (strcmp(name, "normal") == 0) {
        if (out) out->screenLayout =
                (out->screenLayout&~ResTable_config::MASK_SCREENSIZE)
                | ResTable_config::SCREENSIZE_NORMAL;
    if (out)
      out->screenLayout =
          (out->screenLayout & ~ResTable_config::MASK_SCREENSIZE) |
          ResTable_config::SCREENSIZE_NORMAL;
    return true;
  } else if (strcmp(name, "large") == 0) {
        if (out) out->screenLayout =
                (out->screenLayout&~ResTable_config::MASK_SCREENSIZE)
                | ResTable_config::SCREENSIZE_LARGE;
    if (out)
      out->screenLayout =
          (out->screenLayout & ~ResTable_config::MASK_SCREENSIZE) |
          ResTable_config::SCREENSIZE_LARGE;
    return true;
  } else if (strcmp(name, "xlarge") == 0) {
        if (out) out->screenLayout =
                (out->screenLayout&~ResTable_config::MASK_SCREENSIZE)
                | ResTable_config::SCREENSIZE_XLARGE;
    if (out)
      out->screenLayout =
          (out->screenLayout & ~ResTable_config::MASK_SCREENSIZE) |
          ResTable_config::SCREENSIZE_XLARGE;
    return true;
  }

@@ -150,19 +158,22 @@ static bool parseScreenLayoutSize(const char* name, ResTable_config* out) {

static bool parseScreenLayoutLong(const char* name, ResTable_config* out) {
  if (strcmp(name, kWildcardName) == 0) {
        if (out) out->screenLayout =
                (out->screenLayout&~ResTable_config::MASK_SCREENLONG)
                | ResTable_config::SCREENLONG_ANY;
    if (out)
      out->screenLayout =
          (out->screenLayout & ~ResTable_config::MASK_SCREENLONG) |
          ResTable_config::SCREENLONG_ANY;
    return true;
  } else if (strcmp(name, "long") == 0) {
        if (out) out->screenLayout =
                (out->screenLayout&~ResTable_config::MASK_SCREENLONG)
                | ResTable_config::SCREENLONG_YES;
    if (out)
      out->screenLayout =
          (out->screenLayout & ~ResTable_config::MASK_SCREENLONG) |
          ResTable_config::SCREENLONG_YES;
    return true;
  } else if (strcmp(name, "notlong") == 0) {
        if (out) out->screenLayout =
                (out->screenLayout&~ResTable_config::MASK_SCREENLONG)
                | ResTable_config::SCREENLONG_NO;
    if (out)
      out->screenLayout =
          (out->screenLayout & ~ResTable_config::MASK_SCREENLONG) |
          ResTable_config::SCREENLONG_NO;
    return true;
  }

@@ -171,19 +182,22 @@ static bool parseScreenLayoutLong(const char* name, ResTable_config* out) {

static bool parseScreenRound(const char* name, ResTable_config* out) {
  if (strcmp(name, kWildcardName) == 0) {
        if (out) out->screenLayout2 =
                (out->screenLayout2&~ResTable_config::MASK_SCREENROUND)
                | ResTable_config::SCREENROUND_ANY;
    if (out)
      out->screenLayout2 =
          (out->screenLayout2 & ~ResTable_config::MASK_SCREENROUND) |
          ResTable_config::SCREENROUND_ANY;
    return true;
  } else if (strcmp(name, "round") == 0) {
        if (out) out->screenLayout2 =
                (out->screenLayout2&~ResTable_config::MASK_SCREENROUND)
                | ResTable_config::SCREENROUND_YES;
    if (out)
      out->screenLayout2 =
          (out->screenLayout2 & ~ResTable_config::MASK_SCREENROUND) |
          ResTable_config::SCREENROUND_YES;
    return true;
  } else if (strcmp(name, "notround") == 0) {
        if (out) out->screenLayout2 =
                (out->screenLayout2&~ResTable_config::MASK_SCREENROUND)
                | ResTable_config::SCREENROUND_NO;
    if (out)
      out->screenLayout2 =
          (out->screenLayout2 & ~ResTable_config::MASK_SCREENROUND) |
          ResTable_config::SCREENROUND_NO;
    return true;
  }
  return false;
@@ -209,34 +223,34 @@ static bool parseOrientation(const char* name, ResTable_config* out) {

static bool parseUiModeType(const char* name, ResTable_config* out) {
  if (strcmp(name, kWildcardName) == 0) {
        if (out) out->uiMode =
                (out->uiMode&~ResTable_config::MASK_UI_MODE_TYPE)
                | ResTable_config::UI_MODE_TYPE_ANY;
    if (out)
      out->uiMode = (out->uiMode & ~ResTable_config::MASK_UI_MODE_TYPE) |
                    ResTable_config::UI_MODE_TYPE_ANY;
    return true;
  } else if (strcmp(name, "desk") == 0) {
      if (out) out->uiMode =
              (out->uiMode&~ResTable_config::MASK_UI_MODE_TYPE)
              | ResTable_config::UI_MODE_TYPE_DESK;
    if (out)
      out->uiMode = (out->uiMode & ~ResTable_config::MASK_UI_MODE_TYPE) |
                    ResTable_config::UI_MODE_TYPE_DESK;
    return true;
  } else if (strcmp(name, "car") == 0) {
      if (out) out->uiMode =
              (out->uiMode&~ResTable_config::MASK_UI_MODE_TYPE)
              | ResTable_config::UI_MODE_TYPE_CAR;
    if (out)
      out->uiMode = (out->uiMode & ~ResTable_config::MASK_UI_MODE_TYPE) |
                    ResTable_config::UI_MODE_TYPE_CAR;
    return true;
  } else if (strcmp(name, "television") == 0) {
      if (out) out->uiMode =
              (out->uiMode&~ResTable_config::MASK_UI_MODE_TYPE)
              | ResTable_config::UI_MODE_TYPE_TELEVISION;
    if (out)
      out->uiMode = (out->uiMode & ~ResTable_config::MASK_UI_MODE_TYPE) |
                    ResTable_config::UI_MODE_TYPE_TELEVISION;
    return true;
  } else if (strcmp(name, "appliance") == 0) {
      if (out) out->uiMode =
              (out->uiMode&~ResTable_config::MASK_UI_MODE_TYPE)
              | ResTable_config::UI_MODE_TYPE_APPLIANCE;
    if (out)
      out->uiMode = (out->uiMode & ~ResTable_config::MASK_UI_MODE_TYPE) |
                    ResTable_config::UI_MODE_TYPE_APPLIANCE;
    return true;
  } else if (strcmp(name, "watch") == 0) {
      if (out) out->uiMode =
              (out->uiMode&~ResTable_config::MASK_UI_MODE_TYPE)
              | ResTable_config::UI_MODE_TYPE_WATCH;
    if (out)
      out->uiMode = (out->uiMode & ~ResTable_config::MASK_UI_MODE_TYPE) |
                    ResTable_config::UI_MODE_TYPE_WATCH;
    return true;
  }

@@ -245,19 +259,19 @@ static bool parseUiModeType(const char* name, ResTable_config* out) {

static bool parseUiModeNight(const char* name, ResTable_config* out) {
  if (strcmp(name, kWildcardName) == 0) {
        if (out) out->uiMode =
                (out->uiMode&~ResTable_config::MASK_UI_MODE_NIGHT)
                | ResTable_config::UI_MODE_NIGHT_ANY;
    if (out)
      out->uiMode = (out->uiMode & ~ResTable_config::MASK_UI_MODE_NIGHT) |
                    ResTable_config::UI_MODE_NIGHT_ANY;
    return true;
  } else if (strcmp(name, "night") == 0) {
        if (out) out->uiMode =
                (out->uiMode&~ResTable_config::MASK_UI_MODE_NIGHT)
                | ResTable_config::UI_MODE_NIGHT_YES;
    if (out)
      out->uiMode = (out->uiMode & ~ResTable_config::MASK_UI_MODE_NIGHT) |
                    ResTable_config::UI_MODE_NIGHT_YES;
    return true;
  } else if (strcmp(name, "notnight") == 0) {
      if (out) out->uiMode =
              (out->uiMode&~ResTable_config::MASK_UI_MODE_NIGHT)
              | ResTable_config::UI_MODE_NIGHT_NO;
    if (out)
      out->uiMode = (out->uiMode & ~ResTable_config::MASK_UI_MODE_NIGHT) |
                    ResTable_config::UI_MODE_NIGHT_NO;
    return true;
  }

@@ -321,9 +335,7 @@ static bool parseDensity(const char* name, ResTable_config* out) {
  }

  // check that we have 'dpi' after the last digit.
    if (toupper(c[0]) != 'D' ||
            toupper(c[1]) != 'P' ||
            toupper(c[2]) != 'I' ||
  if (toupper(c[0]) != 'D' || toupper(c[1]) != 'P' || toupper(c[2]) != 'I' ||
      c[3] != 0) {
    return false;
  }
@@ -755,26 +767,28 @@ success:
  return true;
}

void ConfigDescription::applyVersionForCompatibility(ConfigDescription* config) {
void ConfigDescription::applyVersionForCompatibility(
    ConfigDescription* config) {
  uint16_t minSdk = 0;
  if (config->screenLayout2 & ResTable_config::MASK_SCREENROUND) {
    minSdk = SDK_MARSHMALLOW;
  } else if (config->density == ResTable_config::DENSITY_ANY) {
    minSdk = SDK_LOLLIPOP;
    } else if (config->smallestScreenWidthDp != ResTable_config::SCREENWIDTH_ANY
            || config->screenWidthDp != ResTable_config::SCREENWIDTH_ANY
            || config->screenHeightDp != ResTable_config::SCREENHEIGHT_ANY) {
  } else if (config->smallestScreenWidthDp !=
                 ResTable_config::SCREENWIDTH_ANY ||
             config->screenWidthDp != ResTable_config::SCREENWIDTH_ANY ||
             config->screenHeightDp != ResTable_config::SCREENHEIGHT_ANY) {
    minSdk = SDK_HONEYCOMB_MR2;
    } else if ((config->uiMode & ResTable_config::MASK_UI_MODE_TYPE)
                != ResTable_config::UI_MODE_TYPE_ANY
            ||  (config->uiMode & ResTable_config::MASK_UI_MODE_NIGHT)
                != ResTable_config::UI_MODE_NIGHT_ANY) {
  } else if ((config->uiMode & ResTable_config::MASK_UI_MODE_TYPE) !=
                 ResTable_config::UI_MODE_TYPE_ANY ||
             (config->uiMode & ResTable_config::MASK_UI_MODE_NIGHT) !=
                 ResTable_config::UI_MODE_NIGHT_ANY) {
    minSdk = SDK_FROYO;
    } else if ((config->screenLayout & ResTable_config::MASK_SCREENSIZE)
                != ResTable_config::SCREENSIZE_ANY
            ||  (config->screenLayout & ResTable_config::MASK_SCREENLONG)
                != ResTable_config::SCREENLONG_ANY
            || config->density != ResTable_config::DENSITY_DEFAULT) {
  } else if ((config->screenLayout & ResTable_config::MASK_SCREENSIZE) !=
                 ResTable_config::SCREENSIZE_ANY ||
             (config->screenLayout & ResTable_config::MASK_SCREENLONG) !=
                 ResTable_config::SCREENLONG_ANY ||
             config->density != ResTable_config::DENSITY_DEFAULT) {
    minSdk = SDK_DONUT;
  }

@@ -793,13 +807,12 @@ bool ConfigDescription::dominates(const ConfigDescription& o) const {
  if (*this == defaultConfig() || *this == o) {
    return true;
  }
    return matchWithDensity(o)
            && !o.matchWithDensity(*this)
            && !isMoreSpecificThan(o)
            && !o.hasHigherPrecedenceThan(*this);
  return matchWithDensity(o) && !o.matchWithDensity(*this) &&
         !isMoreSpecificThan(o) && !o.hasHigherPrecedenceThan(*this);
}

bool ConfigDescription::hasHigherPrecedenceThan(const ConfigDescription& o) const {
bool ConfigDescription::hasHigherPrecedenceThan(
    const ConfigDescription& o) const {
  // The order of the following tests defines the importance of one
  // configuration parameter over another. Those tests first are more
  // important, trumping any values in those following them.
@@ -813,7 +826,8 @@ bool ConfigDescription::hasHigherPrecedenceThan(const ConfigDescription& o) cons
  if ((screenLayout | o.screenLayout) & MASK_LAYOUTDIR) {
    return !(o.screenLayout & MASK_LAYOUTDIR);
  }
    if (smallestScreenWidthDp || o.smallestScreenWidthDp) return (!o.smallestScreenWidthDp);
  if (smallestScreenWidthDp || o.smallestScreenWidthDp)
    return (!o.smallestScreenWidthDp);
  if (screenWidthDp || o.screenWidthDp) return (!o.screenWidthDp);
  if (screenHeightDp || o.screenHeightDp) return (!o.screenHeightDp);
  if ((screenLayout | o.screenLayout) & MASK_SCREENSIZE) {
@@ -860,21 +874,22 @@ bool ConfigDescription::conflictsWith(const ConfigDescription& o) const {
  };
  // The values here can be found in ResTable_config#match. Density and range
  // values can't lead to conflicts, and are ignored.
    return !pred(mcc, o.mcc)
            || !pred(mnc, o.mnc)
            || !pred(locale, o.locale)
            || !pred(screenLayout & MASK_LAYOUTDIR, o.screenLayout & MASK_LAYOUTDIR)
            || !pred(screenLayout & MASK_SCREENLONG, o.screenLayout & MASK_SCREENLONG)
            || !pred(screenLayout & MASK_UI_MODE_TYPE, o.screenLayout & MASK_UI_MODE_TYPE)
            || !pred(uiMode & MASK_UI_MODE_TYPE, o.uiMode & MASK_UI_MODE_TYPE)
            || !pred(uiMode & MASK_UI_MODE_NIGHT, o.uiMode & MASK_UI_MODE_NIGHT)
            || !pred(screenLayout2 & MASK_SCREENROUND, o.screenLayout2 & MASK_SCREENROUND)
            || !pred(orientation, o.orientation)
            || !pred(touchscreen, o.touchscreen)
            || !pred(inputFlags & MASK_KEYSHIDDEN, o.inputFlags & MASK_KEYSHIDDEN)
            || !pred(inputFlags & MASK_NAVHIDDEN, o.inputFlags & MASK_NAVHIDDEN)
            || !pred(keyboard, o.keyboard)
            || !pred(navigation, o.navigation);
  return !pred(mcc, o.mcc) || !pred(mnc, o.mnc) || !pred(locale, o.locale) ||
         !pred(screenLayout & MASK_LAYOUTDIR,
               o.screenLayout & MASK_LAYOUTDIR) ||
         !pred(screenLayout & MASK_SCREENLONG,
               o.screenLayout & MASK_SCREENLONG) ||
         !pred(screenLayout & MASK_UI_MODE_TYPE,
               o.screenLayout & MASK_UI_MODE_TYPE) ||
         !pred(uiMode & MASK_UI_MODE_TYPE, o.uiMode & MASK_UI_MODE_TYPE) ||
         !pred(uiMode & MASK_UI_MODE_NIGHT, o.uiMode & MASK_UI_MODE_NIGHT) ||
         !pred(screenLayout2 & MASK_SCREENROUND,
               o.screenLayout2 & MASK_SCREENROUND) ||
         !pred(orientation, o.orientation) ||
         !pred(touchscreen, o.touchscreen) ||
         !pred(inputFlags & MASK_KEYSHIDDEN, o.inputFlags & MASK_KEYSHIDDEN) ||
         !pred(inputFlags & MASK_NAVHIDDEN, o.inputFlags & MASK_NAVHIDDEN) ||
         !pred(keyboard, o.keyboard) || !pred(navigation, o.navigation);
}

bool ConfigDescription::isCompatibleWith(const ConfigDescription& o) const {
+105 −101
Original line number Diff line number Diff line
@@ -123,13 +123,15 @@ inline ConfigDescription::ConfigDescription(ConfigDescription&& o) {
  *this = o;
}

inline ConfigDescription& ConfigDescription::operator=(const android::ResTable_config& o) {
inline ConfigDescription& ConfigDescription::operator=(
    const android::ResTable_config& o) {
  *static_cast<android::ResTable_config*>(this) = o;
  size = sizeof(android::ResTable_config);
  return *this;
}

inline ConfigDescription& ConfigDescription::operator=(const ConfigDescription& o) {
inline ConfigDescription& ConfigDescription::operator=(
    const ConfigDescription& o) {
  *static_cast<android::ResTable_config*>(this) = o;
  return *this;
}
@@ -139,7 +141,8 @@ inline ConfigDescription& ConfigDescription::operator=(ConfigDescription&& o) {
  return *this;
}

inline bool ConfigDescription::matchWithDensity(const ConfigDescription& o) const {
inline bool ConfigDescription::matchWithDensity(
    const ConfigDescription& o) const {
  return match(o) && (density == 0 || density == o.density);
}

@@ -167,7 +170,8 @@ inline bool ConfigDescription::operator>(const ConfigDescription& o) const {
  return compare(o) > 0;
}

inline ::std::ostream& operator<<(::std::ostream& out, const ConfigDescription& o) {
inline ::std::ostream& operator<<(::std::ostream& out,
                                  const ConfigDescription& o) {
  return out << o.toString().string();
}

+49 −46
Original line number Diff line number Diff line
@@ -23,8 +23,8 @@

namespace aapt {

static ::testing::AssertionResult TestParse(const StringPiece& input,
                                            ConfigDescription* config = nullptr) {
static ::testing::AssertionResult TestParse(
    const StringPiece& input, ConfigDescription* config = nullptr) {
  if (ConfigDescription::parse(input, config)) {
    return ::testing::AssertionSuccess() << input << " was successfully parsed";
  }
@@ -53,10 +53,13 @@ TEST(ConfigDescriptionTest, ParseBasicQualifiers) {
  EXPECT_TRUE(TestParse("fr-land", &config));
  EXPECT_EQ(std::string("fr-land"), config.toString().string());

    EXPECT_TRUE(TestParse("mcc310-pl-sw720dp-normal-long-port-night-"
                "xhdpi-keyssoft-qwerty-navexposed-nonav", &config));
  EXPECT_TRUE(
      TestParse("mcc310-pl-sw720dp-normal-long-port-night-"
                "xhdpi-keyssoft-qwerty-navexposed-nonav",
                &config));
  EXPECT_EQ(std::string("mcc310-pl-sw720dp-normal-long-port-night-"
                "xhdpi-keyssoft-qwerty-navexposed-nonav-v13"), config.toString().string());
                        "xhdpi-keyssoft-qwerty-navexposed-nonav-v13"),
            config.toString().string());
}

TEST(ConfigDescriptionTest, ParseLocales) {
+229 −225
Original line number Diff line number Diff line
@@ -17,8 +17,8 @@
#include "Debug.h"
#include "ResourceTable.h"
#include "ResourceValues.h"
#include "util/Util.h"
#include "ValueVisitor.h"
#include "util/Util.h"

#include <algorithm>
#include <iostream>
@@ -37,8 +37,8 @@ public:
  void visit(Attribute* attr) override {
    std::cout << "(attr) type=";
    attr->printMask(&std::cout);
        static constexpr uint32_t kMask = android::ResTable_map::TYPE_ENUM |
            android::ResTable_map::TYPE_FLAGS;
    static constexpr uint32_t kMask =
        android::ResTable_map::TYPE_ENUM | android::ResTable_map::TYPE_FLAGS;
    if (attr->typeMask & kMask) {
      for (const auto& symbol : attr->symbols) {
        std::cout << "\n        " << symbol.symbol.name.value().entry;
@@ -85,13 +85,9 @@ public:
    }
  }

    void visit(Array* array) override {
        array->print(&std::cout);
    }
  void visit(Array* array) override { array->print(&std::cout); }

    void visit(Plural* plural) override {
        plural->print(&std::cout);
    }
  void visit(Plural* plural) override { plural->print(&std::cout); }

  void visit(Styleable* styleable) override {
    std::cout << "(styleable)";
@@ -111,12 +107,11 @@ public:
    }
  }

    void visitItem(Item* item) override {
        item->print(&std::cout);
    }
  void visitItem(Item* item) override { item->print(&std::cout); }
};

void Debug::printTable(ResourceTable* table, const DebugPrintTableOptions& options) {
void Debug::printTable(ResourceTable* table,
                       const DebugPrintTableOptions& options) {
  PrintVisitor visitor;

  for (auto& package : table->packages) {
@@ -135,7 +130,8 @@ void Debug::printTable(ResourceTable* table, const DebugPrintTableOptions& optio

      std::vector<const ResourceEntry*> sortedEntries;
      for (const auto& entry : type->entries) {
                auto iter = std::lower_bound(sortedEntries.begin(), sortedEntries.end(), entry.get(),
        auto iter = std::lower_bound(
            sortedEntries.begin(), sortedEntries.end(), entry.get(),
            [](const ResourceEntry* a, const ResourceEntry* b) -> bool {
              if (a->id && b->id) {
                return a->id.value() < b->id.value();
@@ -156,9 +152,14 @@ void Debug::printTable(ResourceTable* table, const DebugPrintTableOptions& optio

        std::cout << "    spec resource " << id << " " << name;
        switch (entry->symbolStatus.state) {
                case SymbolState::kPublic: std::cout << " PUBLIC"; break;
                case SymbolState::kPrivate: std::cout << " _PRIVATE_"; break;
                default: break;
          case SymbolState::kPublic:
            std::cout << " PUBLIC";
            break;
          case SymbolState::kPrivate:
            std::cout << " _PRIVATE_";
            break;
          default:
            break;
        }

        std::cout << std::endl;
@@ -176,13 +177,15 @@ void Debug::printTable(ResourceTable* table, const DebugPrintTableOptions& optio
  }
}

static size_t getNodeIndex(const std::vector<ResourceName>& names, const ResourceName& name) {
static size_t getNodeIndex(const std::vector<ResourceName>& names,
                           const ResourceName& name) {
  auto iter = std::lower_bound(names.begin(), names.end(), name);
  assert(iter != names.end() && *iter == name);
  return std::distance(names.begin(), iter);
}

void Debug::printStyleGraph(ResourceTable* table, const ResourceName& targetStyle) {
void Debug::printStyleGraph(ResourceTable* table,
                            const ResourceName& targetStyle) {
  std::map<ResourceName, std::set<ResourceName>> graph;

  std::queue<ResourceName> stylesToVisit;
@@ -216,8 +219,8 @@ void Debug::printStyleGraph(ResourceTable* table, const ResourceName& targetStyl

  std::cout << "digraph styles {\n";
  for (const auto& name : names) {
        std::cout << "  node_" << getNodeIndex(names, name)
                  << " [label=\"" << name << "\"];\n";
    std::cout << "  node_" << getNodeIndex(names, name) << " [label=\"" << name
              << "\"];\n";
  }

  for (const auto& entry : graph) {
@@ -236,7 +239,8 @@ void Debug::printStyleGraph(ResourceTable* table, const ResourceName& targetStyl
void Debug::dumpHex(const void* data, size_t len) {
  const uint8_t* d = (const uint8_t*)data;
  for (size_t i = 0; i < len; i++) {
        std::cerr << std::hex << std::setfill('0') << std::setw(2) << (uint32_t) d[i] << " ";
    std::cerr << std::hex << std::setfill('0') << std::setw(2) << (uint32_t)d[i]
              << " ";
    if (i % 8 == 7) {
      std::cerr << "\n";
    }
Loading