AAPT2: Rename to match new style

Use Google3 naming style to match new
projects' and open source google projects' style.

Preferred to do this in a massive CL so as to avoid
style inconsistencies that plague legacy code bases.
This is a relatively NEW code base, may as well keep
it up to date.

Test: name/style refactor - existing tests pass
Change-Id: Ie80ecb78d46ec53efdfca2336bb57d96cbb7fb87
diff --git a/tools/aapt2/flatten/TableFlattener.cpp b/tools/aapt2/flatten/TableFlattener.cpp
index d4ea6c0..19d030e 100644
--- a/tools/aapt2/flatten/TableFlattener.cpp
+++ b/tools/aapt2/flatten/TableFlattener.cpp
@@ -14,21 +14,23 @@
  * limitations under the License.
  */
 
-#include "ResourceTable.h"
-#include "ResourceValues.h"
-#include "ValueVisitor.h"
-
-#include "flatten/ChunkWriter.h"
-#include "flatten/ResourceTypeExtensions.h"
 #include "flatten/TableFlattener.h"
-#include "util/BigBuffer.h"
 
-#include <android-base/macros.h>
 #include <algorithm>
 #include <numeric>
 #include <sstream>
 #include <type_traits>
 
+#include "android-base/logging.h"
+#include "android-base/macros.h"
+
+#include "ResourceTable.h"
+#include "ResourceValues.h"
+#include "ValueVisitor.h"
+#include "flatten/ChunkWriter.h"
+#include "flatten/ResourceTypeExtensions.h"
+#include "util/BigBuffer.h"
+
 using namespace android;
 
 namespace aapt {
@@ -36,7 +38,7 @@
 namespace {
 
 template <typename T>
-static bool cmpIds(const T* a, const T* b) {
+static bool cmp_ids(const T* a, const T* b) {
   return a->id.value() < b->id.value();
 }
 
@@ -46,14 +48,14 @@
   }
 
   size_t i;
-  const char16_t* srcData = src.data();
+  const char16_t* src_data = src.data();
   for (i = 0; i < len - 1 && i < src.size(); i++) {
-    dst[i] = util::hostToDevice16((uint16_t)srcData[i]);
+    dst[i] = util::HostToDevice16((uint16_t)src_data[i]);
   }
   dst[i] = 0;
 }
 
-static bool cmpStyleEntries(const Style::Entry& a, const Style::Entry& b) {
+static bool cmp_style_entries(const Style::Entry& a, const Style::Entry& b) {
   if (a.key.id) {
     if (b.key.id) {
       return a.key.id.value() < b.key.id.value();
@@ -70,75 +72,75 @@
   Value* value;
 
   // The entry string pool index to the entry's name.
-  uint32_t entryKey;
+  uint32_t entry_key;
 };
 
 class MapFlattenVisitor : public RawValueVisitor {
  public:
-  using RawValueVisitor::visit;
+  using RawValueVisitor::Visit;
 
-  MapFlattenVisitor(ResTable_entry_ext* outEntry, BigBuffer* buffer)
-      : mOutEntry(outEntry), mBuffer(buffer) {}
+  MapFlattenVisitor(ResTable_entry_ext* out_entry, BigBuffer* buffer)
+      : out_entry_(out_entry), buffer_(buffer) {}
 
-  void visit(Attribute* attr) override {
+  void Visit(Attribute* attr) override {
     {
       Reference key = Reference(ResourceId(ResTable_map::ATTR_TYPE));
-      BinaryPrimitive val(Res_value::TYPE_INT_DEC, attr->typeMask);
-      flattenEntry(&key, &val);
+      BinaryPrimitive val(Res_value::TYPE_INT_DEC, attr->type_mask);
+      FlattenEntry(&key, &val);
     }
 
-    if (attr->minInt != std::numeric_limits<int32_t>::min()) {
+    if (attr->min_int != std::numeric_limits<int32_t>::min()) {
       Reference key = Reference(ResourceId(ResTable_map::ATTR_MIN));
       BinaryPrimitive val(Res_value::TYPE_INT_DEC,
-                          static_cast<uint32_t>(attr->minInt));
-      flattenEntry(&key, &val);
+                          static_cast<uint32_t>(attr->min_int));
+      FlattenEntry(&key, &val);
     }
 
-    if (attr->maxInt != std::numeric_limits<int32_t>::max()) {
+    if (attr->max_int != std::numeric_limits<int32_t>::max()) {
       Reference key = Reference(ResourceId(ResTable_map::ATTR_MAX));
       BinaryPrimitive val(Res_value::TYPE_INT_DEC,
-                          static_cast<uint32_t>(attr->maxInt));
-      flattenEntry(&key, &val);
+                          static_cast<uint32_t>(attr->max_int));
+      FlattenEntry(&key, &val);
     }
 
     for (Attribute::Symbol& s : attr->symbols) {
       BinaryPrimitive val(Res_value::TYPE_INT_DEC, s.value);
-      flattenEntry(&s.symbol, &val);
+      FlattenEntry(&s.symbol, &val);
     }
   }
 
-  void visit(Style* style) override {
+  void Visit(Style* style) override {
     if (style->parent) {
-      const Reference& parentRef = style->parent.value();
-      assert(parentRef.id && "parent has no ID");
-      mOutEntry->parent.ident = util::hostToDevice32(parentRef.id.value().id);
+      const Reference& parent_ref = style->parent.value();
+      CHECK(bool(parent_ref.id)) << "parent has no ID";
+      out_entry_->parent.ident = util::HostToDevice32(parent_ref.id.value().id);
     }
 
     // Sort the style.
-    std::sort(style->entries.begin(), style->entries.end(), cmpStyleEntries);
+    std::sort(style->entries.begin(), style->entries.end(), cmp_style_entries);
 
     for (Style::Entry& entry : style->entries) {
-      flattenEntry(&entry.key, entry.value.get());
+      FlattenEntry(&entry.key, entry.value.get());
     }
   }
 
-  void visit(Styleable* styleable) override {
-    for (auto& attrRef : styleable->entries) {
+  void Visit(Styleable* styleable) override {
+    for (auto& attr_ref : styleable->entries) {
       BinaryPrimitive val(Res_value{});
-      flattenEntry(&attrRef, &val);
+      FlattenEntry(&attr_ref, &val);
     }
   }
 
-  void visit(Array* array) override {
+  void Visit(Array* array) override {
     for (auto& item : array->items) {
-      ResTable_map* outEntry = mBuffer->nextBlock<ResTable_map>();
-      flattenValue(item.get(), outEntry);
-      outEntry->value.size = util::hostToDevice16(sizeof(outEntry->value));
-      mEntryCount++;
+      ResTable_map* out_entry = buffer_->NextBlock<ResTable_map>();
+      FlattenValue(item.get(), out_entry);
+      out_entry->value.size = util::HostToDevice16(sizeof(out_entry->value));
+      entry_count_++;
     }
   }
 
-  void visit(Plural* plural) override {
+  void Visit(Plural* plural) override {
     const size_t count = plural->values.size();
     for (size_t i = 0; i < count; i++) {
       if (!plural->values[i]) {
@@ -172,12 +174,12 @@
           break;
 
         default:
-          assert(false);
+          LOG(FATAL) << "unhandled plural type";
           break;
       }
 
       Reference key(q);
-      flattenEntry(&key, plural->values[i].get());
+      FlattenEntry(&key, plural->values[i].get());
     }
   }
 
@@ -185,267 +187,264 @@
    * Call this after visiting a Value. This will finish any work that
    * needs to be done to prepare the entry.
    */
-  void finish() { mOutEntry->count = util::hostToDevice32(mEntryCount); }
+  void Finish() { out_entry_->count = util::HostToDevice32(entry_count_); }
 
  private:
-  void flattenKey(Reference* key, ResTable_map* outEntry) {
-    assert(key->id && "key has no ID");
-    outEntry->name.ident = util::hostToDevice32(key->id.value().id);
+  DISALLOW_COPY_AND_ASSIGN(MapFlattenVisitor);
+
+  void FlattenKey(Reference* key, ResTable_map* out_entry) {
+    CHECK(bool(key->id)) << "key has no ID";
+    out_entry->name.ident = util::HostToDevice32(key->id.value().id);
   }
 
-  void flattenValue(Item* value, ResTable_map* outEntry) {
-    bool result = value->flatten(&outEntry->value);
-    assert(result && "flatten failed");
+  void FlattenValue(Item* value, ResTable_map* out_entry) {
+    CHECK(value->Flatten(&out_entry->value)) << "flatten failed";
   }
 
-  void flattenEntry(Reference* key, Item* value) {
-    ResTable_map* outEntry = mBuffer->nextBlock<ResTable_map>();
-    flattenKey(key, outEntry);
-    flattenValue(value, outEntry);
-    outEntry->value.size = util::hostToDevice16(sizeof(outEntry->value));
-    mEntryCount++;
+  void FlattenEntry(Reference* key, Item* value) {
+    ResTable_map* out_entry = buffer_->NextBlock<ResTable_map>();
+    FlattenKey(key, out_entry);
+    FlattenValue(value, out_entry);
+    out_entry->value.size = util::HostToDevice16(sizeof(out_entry->value));
+    entry_count_++;
   }
 
-  ResTable_entry_ext* mOutEntry;
-  BigBuffer* mBuffer;
-  size_t mEntryCount = 0;
+  ResTable_entry_ext* out_entry_;
+  BigBuffer* buffer_;
+  size_t entry_count_ = 0;
 };
 
 class PackageFlattener {
  public:
   PackageFlattener(IDiagnostics* diag, ResourceTablePackage* package)
-      : mDiag(diag), mPackage(package) {}
+      : diag_(diag), package_(package) {}
 
-  bool flattenPackage(BigBuffer* buffer) {
-    ChunkWriter pkgWriter(buffer);
-    ResTable_package* pkgHeader =
-        pkgWriter.startChunk<ResTable_package>(RES_TABLE_PACKAGE_TYPE);
-    pkgHeader->id = util::hostToDevice32(mPackage->id.value());
+  bool FlattenPackage(BigBuffer* buffer) {
+    ChunkWriter pkg_writer(buffer);
+    ResTable_package* pkg_header =
+        pkg_writer.StartChunk<ResTable_package>(RES_TABLE_PACKAGE_TYPE);
+    pkg_header->id = util::HostToDevice32(package_->id.value());
 
-    if (mPackage->name.size() >= arraysize(pkgHeader->name)) {
-      mDiag->error(DiagMessage() << "package name '" << mPackage->name
+    if (package_->name.size() >= arraysize(pkg_header->name)) {
+      diag_->Error(DiagMessage() << "package name '" << package_->name
                                  << "' is too long");
       return false;
     }
 
     // Copy the package name in device endianness.
-    strcpy16_htod(pkgHeader->name, arraysize(pkgHeader->name),
-                  util::utf8ToUtf16(mPackage->name));
+    strcpy16_htod(pkg_header->name, arraysize(pkg_header->name),
+                  util::Utf8ToUtf16(package_->name));
 
     // Serialize the types. We do this now so that our type and key strings
     // are populated. We write those first.
-    BigBuffer typeBuffer(1024);
-    flattenTypes(&typeBuffer);
+    BigBuffer type_buffer(1024);
+    FlattenTypes(&type_buffer);
 
-    pkgHeader->typeStrings = util::hostToDevice32(pkgWriter.size());
-    StringPool::flattenUtf16(pkgWriter.getBuffer(), mTypePool);
+    pkg_header->typeStrings = util::HostToDevice32(pkg_writer.size());
+    StringPool::FlattenUtf16(pkg_writer.buffer(), type_pool_);
 
-    pkgHeader->keyStrings = util::hostToDevice32(pkgWriter.size());
-    StringPool::flattenUtf8(pkgWriter.getBuffer(), mKeyPool);
+    pkg_header->keyStrings = util::HostToDevice32(pkg_writer.size());
+    StringPool::FlattenUtf8(pkg_writer.buffer(), key_pool_);
 
     // Append the types.
-    buffer->appendBuffer(std::move(typeBuffer));
+    buffer->AppendBuffer(std::move(type_buffer));
 
-    pkgWriter.finish();
+    pkg_writer.Finish();
     return true;
   }
 
  private:
-  IDiagnostics* mDiag;
-  ResourceTablePackage* mPackage;
-  StringPool mTypePool;
-  StringPool mKeyPool;
+  DISALLOW_COPY_AND_ASSIGN(PackageFlattener);
 
   template <typename T, bool IsItem>
-  T* writeEntry(FlatEntry* entry, BigBuffer* buffer) {
+  T* WriteEntry(FlatEntry* entry, BigBuffer* buffer) {
     static_assert(std::is_same<ResTable_entry, T>::value ||
                       std::is_same<ResTable_entry_ext, T>::value,
                   "T must be ResTable_entry or ResTable_entry_ext");
 
-    T* result = buffer->nextBlock<T>();
-    ResTable_entry* outEntry = (ResTable_entry*)(result);
-    if (entry->entry->symbolStatus.state == SymbolState::kPublic) {
-      outEntry->flags |= ResTable_entry::FLAG_PUBLIC;
+    T* result = buffer->NextBlock<T>();
+    ResTable_entry* out_entry = (ResTable_entry*)result;
+    if (entry->entry->symbol_status.state == SymbolState::kPublic) {
+      out_entry->flags |= ResTable_entry::FLAG_PUBLIC;
     }
 
-    if (entry->value->isWeak()) {
-      outEntry->flags |= ResTable_entry::FLAG_WEAK;
+    if (entry->value->IsWeak()) {
+      out_entry->flags |= ResTable_entry::FLAG_WEAK;
     }
 
     if (!IsItem) {
-      outEntry->flags |= ResTable_entry::FLAG_COMPLEX;
+      out_entry->flags |= ResTable_entry::FLAG_COMPLEX;
     }
 
-    outEntry->flags = util::hostToDevice16(outEntry->flags);
-    outEntry->key.index = util::hostToDevice32(entry->entryKey);
-    outEntry->size = util::hostToDevice16(sizeof(T));
+    out_entry->flags = util::HostToDevice16(out_entry->flags);
+    out_entry->key.index = util::HostToDevice32(entry->entry_key);
+    out_entry->size = util::HostToDevice16(sizeof(T));
     return result;
   }
 
-  bool flattenValue(FlatEntry* entry, BigBuffer* buffer) {
-    if (Item* item = valueCast<Item>(entry->value)) {
-      writeEntry<ResTable_entry, true>(entry, buffer);
-      Res_value* outValue = buffer->nextBlock<Res_value>();
-      bool result = item->flatten(outValue);
-      assert(result && "flatten failed");
-      outValue->size = util::hostToDevice16(sizeof(*outValue));
+  bool FlattenValue(FlatEntry* entry, BigBuffer* buffer) {
+    if (Item* item = ValueCast<Item>(entry->value)) {
+      WriteEntry<ResTable_entry, true>(entry, buffer);
+      Res_value* outValue = buffer->NextBlock<Res_value>();
+      CHECK(item->Flatten(outValue)) << "flatten failed";
+      outValue->size = util::HostToDevice16(sizeof(*outValue));
     } else {
-      ResTable_entry_ext* outEntry =
-          writeEntry<ResTable_entry_ext, false>(entry, buffer);
-      MapFlattenVisitor visitor(outEntry, buffer);
-      entry->value->accept(&visitor);
-      visitor.finish();
+      ResTable_entry_ext* out_entry =
+          WriteEntry<ResTable_entry_ext, false>(entry, buffer);
+      MapFlattenVisitor visitor(out_entry, buffer);
+      entry->value->Accept(&visitor);
+      visitor.Finish();
     }
     return true;
   }
 
-  bool flattenConfig(const ResourceTableType* type,
+  bool FlattenConfig(const ResourceTableType* type,
                      const ConfigDescription& config,
                      std::vector<FlatEntry>* entries, BigBuffer* buffer) {
-    ChunkWriter typeWriter(buffer);
-    ResTable_type* typeHeader =
-        typeWriter.startChunk<ResTable_type>(RES_TABLE_TYPE_TYPE);
-    typeHeader->id = type->id.value();
-    typeHeader->config = config;
-    typeHeader->config.swapHtoD();
+    ChunkWriter type_writer(buffer);
+    ResTable_type* type_header =
+        type_writer.StartChunk<ResTable_type>(RES_TABLE_TYPE_TYPE);
+    type_header->id = type->id.value();
+    type_header->config = config;
+    type_header->config.swapHtoD();
 
-    auto maxAccum = [](uint32_t max,
-                       const std::unique_ptr<ResourceEntry>& a) -> uint32_t {
+    auto max_accum = [](uint32_t max,
+                        const std::unique_ptr<ResourceEntry>& a) -> uint32_t {
       return std::max(max, (uint32_t)a->id.value());
     };
 
     // Find the largest entry ID. That is how many entries we will have.
-    const uint32_t entryCount =
+    const uint32_t entry_count =
         std::accumulate(type->entries.begin(), type->entries.end(), 0,
-                        maxAccum) +
+                        max_accum) +
         1;
 
-    typeHeader->entryCount = util::hostToDevice32(entryCount);
-    uint32_t* indices = typeWriter.nextBlock<uint32_t>(entryCount);
+    type_header->entryCount = util::HostToDevice32(entry_count);
+    uint32_t* indices = type_writer.NextBlock<uint32_t>(entry_count);
 
-    assert((size_t)entryCount <= std::numeric_limits<uint16_t>::max() + 1);
-    memset(indices, 0xff, entryCount * sizeof(uint32_t));
+    CHECK((size_t)entry_count <= std::numeric_limits<uint16_t>::max());
+    memset(indices, 0xff, entry_count * sizeof(uint32_t));
 
-    typeHeader->entriesStart = util::hostToDevice32(typeWriter.size());
+    type_header->entriesStart = util::HostToDevice32(type_writer.size());
 
-    const size_t entryStart = typeWriter.getBuffer()->size();
-    for (FlatEntry& flatEntry : *entries) {
-      assert(flatEntry.entry->id.value() < entryCount);
-      indices[flatEntry.entry->id.value()] =
-          util::hostToDevice32(typeWriter.getBuffer()->size() - entryStart);
-      if (!flattenValue(&flatEntry, typeWriter.getBuffer())) {
-        mDiag->error(DiagMessage()
+    const size_t entry_start = type_writer.buffer()->size();
+    for (FlatEntry& flat_entry : *entries) {
+      CHECK(flat_entry.entry->id.value() < entry_count);
+      indices[flat_entry.entry->id.value()] =
+          util::HostToDevice32(type_writer.buffer()->size() - entry_start);
+      if (!FlattenValue(&flat_entry, type_writer.buffer())) {
+        diag_->Error(DiagMessage()
                      << "failed to flatten resource '"
-                     << ResourceNameRef(mPackage->name, type->type,
-                                        flatEntry.entry->name)
+                     << ResourceNameRef(package_->name, type->type,
+                                        flat_entry.entry->name)
                      << "' for configuration '" << config << "'");
         return false;
       }
     }
-    typeWriter.finish();
+    type_writer.Finish();
     return true;
   }
 
-  std::vector<ResourceTableType*> collectAndSortTypes() {
-    std::vector<ResourceTableType*> sortedTypes;
-    for (auto& type : mPackage->types) {
+  std::vector<ResourceTableType*> CollectAndSortTypes() {
+    std::vector<ResourceTableType*> sorted_types;
+    for (auto& type : package_->types) {
       if (type->type == ResourceType::kStyleable) {
         // Styleables aren't real Resource Types, they are represented in the
-        // R.java
-        // file.
+        // R.java file.
         continue;
       }
 
-      assert(type->id && "type must have an ID set");
+      CHECK(bool(type->id)) << "type must have an ID set";
 
-      sortedTypes.push_back(type.get());
+      sorted_types.push_back(type.get());
     }
-    std::sort(sortedTypes.begin(), sortedTypes.end(),
-              cmpIds<ResourceTableType>);
-    return sortedTypes;
+    std::sort(sorted_types.begin(), sorted_types.end(),
+              cmp_ids<ResourceTableType>);
+    return sorted_types;
   }
 
-  std::vector<ResourceEntry*> collectAndSortEntries(ResourceTableType* type) {
+  std::vector<ResourceEntry*> CollectAndSortEntries(ResourceTableType* type) {
     // Sort the entries by entry ID.
-    std::vector<ResourceEntry*> sortedEntries;
+    std::vector<ResourceEntry*> sorted_entries;
     for (auto& entry : type->entries) {
-      assert(entry->id && "entry must have an ID set");
-      sortedEntries.push_back(entry.get());
+      CHECK(bool(entry->id)) << "entry must have an ID set";
+      sorted_entries.push_back(entry.get());
     }
-    std::sort(sortedEntries.begin(), sortedEntries.end(),
-              cmpIds<ResourceEntry>);
-    return sortedEntries;
+    std::sort(sorted_entries.begin(), sorted_entries.end(),
+              cmp_ids<ResourceEntry>);
+    return sorted_entries;
   }
 
-  bool flattenTypeSpec(ResourceTableType* type,
-                       std::vector<ResourceEntry*>* sortedEntries,
+  bool FlattenTypeSpec(ResourceTableType* type,
+                       std::vector<ResourceEntry*>* sorted_entries,
                        BigBuffer* buffer) {
-    ChunkWriter typeSpecWriter(buffer);
-    ResTable_typeSpec* specHeader =
-        typeSpecWriter.startChunk<ResTable_typeSpec>(RES_TABLE_TYPE_SPEC_TYPE);
-    specHeader->id = type->id.value();
+    ChunkWriter type_spec_writer(buffer);
+    ResTable_typeSpec* spec_header =
+        type_spec_writer.StartChunk<ResTable_typeSpec>(
+            RES_TABLE_TYPE_SPEC_TYPE);
+    spec_header->id = type->id.value();
 
-    if (sortedEntries->empty()) {
-      typeSpecWriter.finish();
+    if (sorted_entries->empty()) {
+      type_spec_writer.Finish();
       return true;
     }
 
     // We can't just take the size of the vector. There may be holes in the
     // entry ID space.
     // Since the entries are sorted by ID, the last one will be the biggest.
-    const size_t numEntries = sortedEntries->back()->id.value() + 1;
+    const size_t num_entries = sorted_entries->back()->id.value() + 1;
 
-    specHeader->entryCount = util::hostToDevice32(numEntries);
+    spec_header->entryCount = util::HostToDevice32(num_entries);
 
     // Reserve space for the masks of each resource in this type. These
     // show for which configuration axis the resource changes.
-    uint32_t* configMasks = typeSpecWriter.nextBlock<uint32_t>(numEntries);
+    uint32_t* config_masks = type_spec_writer.NextBlock<uint32_t>(num_entries);
 
-    const size_t actualNumEntries = sortedEntries->size();
-    for (size_t entryIndex = 0; entryIndex < actualNumEntries; entryIndex++) {
-      ResourceEntry* entry = sortedEntries->at(entryIndex);
+    const size_t actual_num_entries = sorted_entries->size();
+    for (size_t entryIndex = 0; entryIndex < actual_num_entries; entryIndex++) {
+      ResourceEntry* entry = sorted_entries->at(entryIndex);
 
       // Populate the config masks for this entry.
 
-      if (entry->symbolStatus.state == SymbolState::kPublic) {
-        configMasks[entry->id.value()] |=
-            util::hostToDevice32(ResTable_typeSpec::SPEC_PUBLIC);
+      if (entry->symbol_status.state == SymbolState::kPublic) {
+        config_masks[entry->id.value()] |=
+            util::HostToDevice32(ResTable_typeSpec::SPEC_PUBLIC);
       }
 
-      const size_t configCount = entry->values.size();
-      for (size_t i = 0; i < configCount; i++) {
+      const size_t config_count = entry->values.size();
+      for (size_t i = 0; i < config_count; i++) {
         const ConfigDescription& config = entry->values[i]->config;
-        for (size_t j = i + 1; j < configCount; j++) {
-          configMasks[entry->id.value()] |=
-              util::hostToDevice32(config.diff(entry->values[j]->config));
+        for (size_t j = i + 1; j < config_count; j++) {
+          config_masks[entry->id.value()] |=
+              util::HostToDevice32(config.diff(entry->values[j]->config));
         }
       }
     }
-    typeSpecWriter.finish();
+    type_spec_writer.Finish();
     return true;
   }
 
-  bool flattenTypes(BigBuffer* buffer) {
+  bool FlattenTypes(BigBuffer* buffer) {
     // Sort the types by their IDs. They will be inserted into the StringPool in
     // this order.
-    std::vector<ResourceTableType*> sortedTypes = collectAndSortTypes();
+    std::vector<ResourceTableType*> sorted_types = CollectAndSortTypes();
 
-    size_t expectedTypeId = 1;
-    for (ResourceTableType* type : sortedTypes) {
+    size_t expected_type_id = 1;
+    for (ResourceTableType* type : sorted_types) {
       // If there is a gap in the type IDs, fill in the StringPool
       // with empty values until we reach the ID we expect.
-      while (type->id.value() > expectedTypeId) {
-        std::stringstream typeName;
-        typeName << "?" << expectedTypeId;
-        mTypePool.makeRef(typeName.str());
-        expectedTypeId++;
+      while (type->id.value() > expected_type_id) {
+        std::stringstream type_name;
+        type_name << "?" << expected_type_id;
+        type_pool_.MakeRef(type_name.str());
+        expected_type_id++;
       }
-      expectedTypeId++;
-      mTypePool.makeRef(toString(type->type));
+      expected_type_id++;
+      type_pool_.MakeRef(ToString(type->type));
 
-      std::vector<ResourceEntry*> sortedEntries = collectAndSortEntries(type);
+      std::vector<ResourceEntry*> sorted_entries = CollectAndSortEntries(type);
 
-      if (!flattenTypeSpec(type, &sortedEntries, buffer)) {
+      if (!FlattenTypeSpec(type, &sorted_entries, buffer)) {
         return false;
       }
 
@@ -455,35 +454,41 @@
       // each
       // configuration available. Here we reverse this to match the binary
       // table.
-      std::map<ConfigDescription, std::vector<FlatEntry>> configToEntryListMap;
-      for (ResourceEntry* entry : sortedEntries) {
-        const uint32_t keyIndex =
-            (uint32_t)mKeyPool.makeRef(entry->name).getIndex();
+      std::map<ConfigDescription, std::vector<FlatEntry>>
+          config_to_entry_list_map;
+      for (ResourceEntry* entry : sorted_entries) {
+        const uint32_t key_index =
+            (uint32_t)key_pool_.MakeRef(entry->name).index();
 
         // Group values by configuration.
-        for (auto& configValue : entry->values) {
-          configToEntryListMap[configValue->config].push_back(
-              FlatEntry{entry, configValue->value.get(), keyIndex});
+        for (auto& config_value : entry->values) {
+          config_to_entry_list_map[config_value->config].push_back(
+              FlatEntry{entry, config_value->value.get(), key_index});
         }
       }
 
       // Flatten a configuration value.
-      for (auto& entry : configToEntryListMap) {
-        if (!flattenConfig(type, entry.first, &entry.second, buffer)) {
+      for (auto& entry : config_to_entry_list_map) {
+        if (!FlattenConfig(type, entry.first, &entry.second, buffer)) {
           return false;
         }
       }
     }
     return true;
   }
+
+  IDiagnostics* diag_;
+  ResourceTablePackage* package_;
+  StringPool type_pool_;
+  StringPool key_pool_;
 };
 
 }  // namespace
 
-bool TableFlattener::consume(IAaptContext* context, ResourceTable* table) {
+bool TableFlattener::Consume(IAaptContext* context, ResourceTable* table) {
   // We must do this before writing the resources, since the string pool IDs may
   // change.
-  table->stringPool.sort(
+  table->string_pool.Sort(
       [](const StringPool::Entry& a, const StringPool::Entry& b) -> bool {
         int diff = a.context.priority - b.context.priority;
         if (diff < 0) return true;
@@ -493,30 +498,30 @@
         if (diff > 0) return false;
         return a.value < b.value;
       });
-  table->stringPool.prune();
+  table->string_pool.Prune();
 
   // Write the ResTable header.
-  ChunkWriter tableWriter(mBuffer);
-  ResTable_header* tableHeader =
-      tableWriter.startChunk<ResTable_header>(RES_TABLE_TYPE);
-  tableHeader->packageCount = util::hostToDevice32(table->packages.size());
+  ChunkWriter table_writer(buffer_);
+  ResTable_header* table_header =
+      table_writer.StartChunk<ResTable_header>(RES_TABLE_TYPE);
+  table_header->packageCount = util::HostToDevice32(table->packages.size());
 
   // Flatten the values string pool.
-  StringPool::flattenUtf8(tableWriter.getBuffer(), table->stringPool);
+  StringPool::FlattenUtf8(table_writer.buffer(), table->string_pool);
 
-  BigBuffer packageBuffer(1024);
+  BigBuffer package_buffer(1024);
 
   // Flatten each package.
   for (auto& package : table->packages) {
-    PackageFlattener flattener(context->getDiagnostics(), package.get());
-    if (!flattener.flattenPackage(&packageBuffer)) {
+    PackageFlattener flattener(context->GetDiagnostics(), package.get());
+    if (!flattener.FlattenPackage(&package_buffer)) {
       return false;
     }
   }
 
   // Finally merge all the packages into the main buffer.
-  tableWriter.getBuffer()->appendBuffer(std::move(packageBuffer));
-  tableWriter.finish();
+  table_writer.buffer()->AppendBuffer(std::move(package_buffer));
+  table_writer.Finish();
   return true;
 }