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/proto/TableProtoDeserializer.cpp b/tools/aapt2/proto/TableProtoDeserializer.cpp
index 0dfb01c..d93d495 100644
--- a/tools/aapt2/proto/TableProtoDeserializer.cpp
+++ b/tools/aapt2/proto/TableProtoDeserializer.cpp
@@ -14,13 +14,15 @@
* limitations under the License.
*/
+#include "proto/ProtoSerialize.h"
+
+#include "android-base/logging.h"
+#include "androidfw/ResourceTypes.h"
+
#include "ResourceTable.h"
#include "ResourceUtils.h"
#include "ValueVisitor.h"
#include "proto/ProtoHelpers.h"
-#include "proto/ProtoSerialize.h"
-
-#include <androidfw/ResourceTypes.h>
namespace aapt {
@@ -28,28 +30,28 @@
class ReferenceIdToNameVisitor : public ValueVisitor {
public:
- using ValueVisitor::visit;
+ using ValueVisitor::Visit;
explicit ReferenceIdToNameVisitor(
const std::map<ResourceId, ResourceNameRef>* mapping)
- : mMapping(mapping) {
- assert(mMapping);
+ : mapping_(mapping) {
+ CHECK(mapping_ != nullptr);
}
- void visit(Reference* reference) override {
- if (!reference->id || !reference->id.value().isValid()) {
+ void Visit(Reference* reference) override {
+ if (!reference->id || !reference->id.value().is_valid()) {
return;
}
ResourceId id = reference->id.value();
- auto cacheIter = mMapping->find(id);
- if (cacheIter != mMapping->end()) {
- reference->name = cacheIter->second.toResourceName();
+ auto cache_iter = mapping_->find(id);
+ if (cache_iter != mapping_->end()) {
+ reference->name = cache_iter->second.ToResourceName();
}
}
private:
- const std::map<ResourceId, ResourceNameRef>* mMapping;
+ const std::map<ResourceId, ResourceNameRef>* mapping_;
};
class PackagePbDeserializer {
@@ -58,14 +60,14 @@
const android::ResStringPool* sourcePool,
const android::ResStringPool* symbolPool,
const Source& source, IDiagnostics* diag)
- : mValuePool(valuePool),
- mSourcePool(sourcePool),
- mSymbolPool(symbolPool),
- mSource(source),
- mDiag(diag) {}
+ : value_pool_(valuePool),
+ source_pool_(sourcePool),
+ symbol_pool_(symbolPool),
+ source_(source),
+ diag_(diag) {}
public:
- bool deserializeFromPb(const pb::Package& pbPackage, ResourceTable* table) {
+ bool DeserializeFromPb(const pb::Package& pbPackage, ResourceTable* table) {
Maybe<uint8_t> id;
if (pbPackage.has_package_id()) {
id = static_cast<uint8_t>(pbPackage.package_id());
@@ -74,36 +76,36 @@
std::map<ResourceId, ResourceNameRef> idIndex;
ResourceTablePackage* pkg =
- table->createPackage(pbPackage.package_name(), id);
+ table->CreatePackage(pbPackage.package_name(), id);
for (const pb::Type& pbType : pbPackage.types()) {
- const ResourceType* resType = parseResourceType(pbType.name());
+ const ResourceType* resType = ParseResourceType(pbType.name());
if (!resType) {
- mDiag->error(DiagMessage(mSource) << "unknown type '" << pbType.name()
+ diag_->Error(DiagMessage(source_) << "unknown type '" << pbType.name()
<< "'");
return {};
}
- ResourceTableType* type = pkg->findOrCreateType(*resType);
+ ResourceTableType* type = pkg->FindOrCreateType(*resType);
for (const pb::Entry& pbEntry : pbType.entries()) {
- ResourceEntry* entry = type->findOrCreateEntry(pbEntry.name());
+ ResourceEntry* entry = type->FindOrCreateEntry(pbEntry.name());
// Deserialize the symbol status (public/private with source and
// comments).
if (pbEntry.has_symbol_status()) {
const pb::SymbolStatus& pbStatus = pbEntry.symbol_status();
if (pbStatus.has_source()) {
- deserializeSourceFromPb(pbStatus.source(), *mSourcePool,
- &entry->symbolStatus.source);
+ DeserializeSourceFromPb(pbStatus.source(), *source_pool_,
+ &entry->symbol_status.source);
}
if (pbStatus.has_comment()) {
- entry->symbolStatus.comment = pbStatus.comment();
+ entry->symbol_status.comment = pbStatus.comment();
}
SymbolState visibility =
- deserializeVisibilityFromPb(pbStatus.visibility());
- entry->symbolStatus.state = visibility;
+ DeserializeVisibilityFromPb(pbStatus.visibility());
+ entry->symbol_status.state = visibility;
if (visibility == SymbolState::kPublic) {
// This is a public symbol, we must encode the ID now if there is
@@ -112,22 +114,22 @@
entry->id = static_cast<uint16_t>(pbEntry.id());
}
- if (type->symbolStatus.state != SymbolState::kPublic) {
+ if (type->symbol_status.state != SymbolState::kPublic) {
// If the type has not been made public, do so now.
- type->symbolStatus.state = SymbolState::kPublic;
+ type->symbol_status.state = SymbolState::kPublic;
if (pbType.has_id()) {
type->id = static_cast<uint8_t>(pbType.id());
}
}
} else if (visibility == SymbolState::kPrivate) {
- if (type->symbolStatus.state == SymbolState::kUndefined) {
- type->symbolStatus.state = SymbolState::kPrivate;
+ if (type->symbol_status.state == SymbolState::kUndefined) {
+ type->symbol_status.state = SymbolState::kPrivate;
}
}
}
ResourceId resId(pbPackage.package_id(), pbType.id(), pbEntry.id());
- if (resId.isValid()) {
+ if (resId.is_valid()) {
idIndex[resId] = ResourceNameRef(pkg->name, type->type, entry->name);
}
@@ -135,21 +137,21 @@
const pb::ConfigDescription& pbConfig = pbConfigValue.config();
ConfigDescription config;
- if (!deserializeConfigDescriptionFromPb(pbConfig, &config)) {
- mDiag->error(DiagMessage(mSource) << "invalid configuration");
+ if (!DeserializeConfigDescriptionFromPb(pbConfig, &config)) {
+ diag_->Error(DiagMessage(source_) << "invalid configuration");
return {};
}
ResourceConfigValue* configValue =
- entry->findOrCreateValue(config, pbConfig.product());
+ entry->FindOrCreateValue(config, pbConfig.product());
if (configValue->value) {
// Duplicate config.
- mDiag->error(DiagMessage(mSource) << "duplicate configuration");
+ diag_->Error(DiagMessage(source_) << "duplicate configuration");
return {};
}
- configValue->value = deserializeValueFromPb(
- pbConfigValue.value(), config, &table->stringPool);
+ configValue->value = DeserializeValueFromPb(
+ pbConfigValue.value(), config, &table->string_pool);
if (!configValue->value) {
return {};
}
@@ -158,247 +160,247 @@
}
ReferenceIdToNameVisitor visitor(&idIndex);
- visitAllValuesInPackage(pkg, &visitor);
+ VisitAllValuesInPackage(pkg, &visitor);
return true;
}
private:
- std::unique_ptr<Item> deserializeItemFromPb(const pb::Item& pbItem,
+ std::unique_ptr<Item> DeserializeItemFromPb(const pb::Item& pb_item,
const ConfigDescription& config,
StringPool* pool) {
- if (pbItem.has_ref()) {
- const pb::Reference& pbRef = pbItem.ref();
+ if (pb_item.has_ref()) {
+ const pb::Reference& pb_ref = pb_item.ref();
std::unique_ptr<Reference> ref = util::make_unique<Reference>();
- if (!deserializeReferenceFromPb(pbRef, ref.get())) {
+ if (!DeserializeReferenceFromPb(pb_ref, ref.get())) {
return {};
}
return std::move(ref);
- } else if (pbItem.has_prim()) {
- const pb::Primitive& pbPrim = pbItem.prim();
+ } else if (pb_item.has_prim()) {
+ const pb::Primitive& pb_prim = pb_item.prim();
android::Res_value prim = {};
- prim.dataType = static_cast<uint8_t>(pbPrim.type());
- prim.data = pbPrim.data();
+ prim.dataType = static_cast<uint8_t>(pb_prim.type());
+ prim.data = pb_prim.data();
return util::make_unique<BinaryPrimitive>(prim);
- } else if (pbItem.has_id()) {
+ } else if (pb_item.has_id()) {
return util::make_unique<Id>();
- } else if (pbItem.has_str()) {
- const uint32_t idx = pbItem.str().idx();
- const std::string str = util::getString(*mValuePool, idx);
+ } else if (pb_item.has_str()) {
+ const uint32_t idx = pb_item.str().idx();
+ const std::string str = util::GetString(*value_pool_, idx);
- const android::ResStringPool_span* spans = mValuePool->styleAt(idx);
+ const android::ResStringPool_span* spans = value_pool_->styleAt(idx);
if (spans && spans->name.index != android::ResStringPool_span::END) {
- StyleString styleStr = {str};
+ StyleString style_str = {str};
while (spans->name.index != android::ResStringPool_span::END) {
- styleStr.spans.push_back(
- Span{util::getString(*mValuePool, spans->name.index),
+ style_str.spans.push_back(
+ Span{util::GetString(*value_pool_, spans->name.index),
spans->firstChar, spans->lastChar});
spans++;
}
- return util::make_unique<StyledString>(pool->makeRef(
- styleStr,
+ return util::make_unique<StyledString>(pool->MakeRef(
+ style_str,
StringPool::Context(StringPool::Context::kStylePriority, config)));
}
return util::make_unique<String>(
- pool->makeRef(str, StringPool::Context(config)));
+ pool->MakeRef(str, StringPool::Context(config)));
- } else if (pbItem.has_raw_str()) {
- const uint32_t idx = pbItem.raw_str().idx();
- const std::string str = util::getString(*mValuePool, idx);
+ } else if (pb_item.has_raw_str()) {
+ const uint32_t idx = pb_item.raw_str().idx();
+ const std::string str = util::GetString(*value_pool_, idx);
return util::make_unique<RawString>(
- pool->makeRef(str, StringPool::Context(config)));
+ pool->MakeRef(str, StringPool::Context(config)));
- } else if (pbItem.has_file()) {
- const uint32_t idx = pbItem.file().path_idx();
- const std::string str = util::getString(*mValuePool, idx);
- return util::make_unique<FileReference>(pool->makeRef(
+ } else if (pb_item.has_file()) {
+ const uint32_t idx = pb_item.file().path_idx();
+ const std::string str = util::GetString(*value_pool_, idx);
+ return util::make_unique<FileReference>(pool->MakeRef(
str,
StringPool::Context(StringPool::Context::kHighPriority, config)));
} else {
- mDiag->error(DiagMessage(mSource) << "unknown item");
+ diag_->Error(DiagMessage(source_) << "unknown item");
}
return {};
}
- std::unique_ptr<Value> deserializeValueFromPb(const pb::Value& pbValue,
+ std::unique_ptr<Value> DeserializeValueFromPb(const pb::Value& pb_value,
const ConfigDescription& config,
StringPool* pool) {
- const bool isWeak = pbValue.has_weak() ? pbValue.weak() : false;
+ const bool is_weak = pb_value.has_weak() ? pb_value.weak() : false;
std::unique_ptr<Value> value;
- if (pbValue.has_item()) {
- value = deserializeItemFromPb(pbValue.item(), config, pool);
+ if (pb_value.has_item()) {
+ value = DeserializeItemFromPb(pb_value.item(), config, pool);
if (!value) {
return {};
}
- } else if (pbValue.has_compound_value()) {
- const pb::CompoundValue& pbCompoundValue = pbValue.compound_value();
- if (pbCompoundValue.has_attr()) {
- const pb::Attribute& pbAttr = pbCompoundValue.attr();
- std::unique_ptr<Attribute> attr = util::make_unique<Attribute>(isWeak);
- attr->typeMask = pbAttr.format_flags();
- attr->minInt = pbAttr.min_int();
- attr->maxInt = pbAttr.max_int();
- for (const pb::Attribute_Symbol& pbSymbol : pbAttr.symbols()) {
+ } else if (pb_value.has_compound_value()) {
+ const pb::CompoundValue& pb_compound_value = pb_value.compound_value();
+ if (pb_compound_value.has_attr()) {
+ const pb::Attribute& pb_attr = pb_compound_value.attr();
+ std::unique_ptr<Attribute> attr = util::make_unique<Attribute>(is_weak);
+ attr->type_mask = pb_attr.format_flags();
+ attr->min_int = pb_attr.min_int();
+ attr->max_int = pb_attr.max_int();
+ for (const pb::Attribute_Symbol& pb_symbol : pb_attr.symbols()) {
Attribute::Symbol symbol;
- deserializeItemCommon(pbSymbol, &symbol.symbol);
- if (!deserializeReferenceFromPb(pbSymbol.name(), &symbol.symbol)) {
+ DeserializeItemCommon(pb_symbol, &symbol.symbol);
+ if (!DeserializeReferenceFromPb(pb_symbol.name(), &symbol.symbol)) {
return {};
}
- symbol.value = pbSymbol.value();
+ symbol.value = pb_symbol.value();
attr->symbols.push_back(std::move(symbol));
}
value = std::move(attr);
- } else if (pbCompoundValue.has_style()) {
- const pb::Style& pbStyle = pbCompoundValue.style();
+ } else if (pb_compound_value.has_style()) {
+ const pb::Style& pb_style = pb_compound_value.style();
std::unique_ptr<Style> style = util::make_unique<Style>();
- if (pbStyle.has_parent()) {
+ if (pb_style.has_parent()) {
style->parent = Reference();
- if (!deserializeReferenceFromPb(pbStyle.parent(),
+ if (!DeserializeReferenceFromPb(pb_style.parent(),
&style->parent.value())) {
return {};
}
- if (pbStyle.has_parent_source()) {
- Source parentSource;
- deserializeSourceFromPb(pbStyle.parent_source(), *mSourcePool,
- &parentSource);
- style->parent.value().setSource(std::move(parentSource));
+ if (pb_style.has_parent_source()) {
+ Source parent_source;
+ DeserializeSourceFromPb(pb_style.parent_source(), *source_pool_,
+ &parent_source);
+ style->parent.value().SetSource(std::move(parent_source));
}
}
- for (const pb::Style_Entry& pbEntry : pbStyle.entries()) {
+ for (const pb::Style_Entry& pb_entry : pb_style.entries()) {
Style::Entry entry;
- deserializeItemCommon(pbEntry, &entry.key);
- if (!deserializeReferenceFromPb(pbEntry.key(), &entry.key)) {
+ DeserializeItemCommon(pb_entry, &entry.key);
+ if (!DeserializeReferenceFromPb(pb_entry.key(), &entry.key)) {
return {};
}
- entry.value = deserializeItemFromPb(pbEntry.item(), config, pool);
+ entry.value = DeserializeItemFromPb(pb_entry.item(), config, pool);
if (!entry.value) {
return {};
}
- deserializeItemCommon(pbEntry, entry.value.get());
+ DeserializeItemCommon(pb_entry, entry.value.get());
style->entries.push_back(std::move(entry));
}
value = std::move(style);
- } else if (pbCompoundValue.has_styleable()) {
- const pb::Styleable& pbStyleable = pbCompoundValue.styleable();
+ } else if (pb_compound_value.has_styleable()) {
+ const pb::Styleable& pb_styleable = pb_compound_value.styleable();
std::unique_ptr<Styleable> styleable = util::make_unique<Styleable>();
- for (const pb::Styleable_Entry& pbEntry : pbStyleable.entries()) {
- Reference attrRef;
- deserializeItemCommon(pbEntry, &attrRef);
- deserializeReferenceFromPb(pbEntry.attr(), &attrRef);
- styleable->entries.push_back(std::move(attrRef));
+ for (const pb::Styleable_Entry& pb_entry : pb_styleable.entries()) {
+ Reference attr_ref;
+ DeserializeItemCommon(pb_entry, &attr_ref);
+ DeserializeReferenceFromPb(pb_entry.attr(), &attr_ref);
+ styleable->entries.push_back(std::move(attr_ref));
}
value = std::move(styleable);
- } else if (pbCompoundValue.has_array()) {
- const pb::Array& pbArray = pbCompoundValue.array();
+ } else if (pb_compound_value.has_array()) {
+ const pb::Array& pb_array = pb_compound_value.array();
std::unique_ptr<Array> array = util::make_unique<Array>();
- for (const pb::Array_Entry& pbEntry : pbArray.entries()) {
+ for (const pb::Array_Entry& pb_entry : pb_array.entries()) {
std::unique_ptr<Item> item =
- deserializeItemFromPb(pbEntry.item(), config, pool);
+ DeserializeItemFromPb(pb_entry.item(), config, pool);
if (!item) {
return {};
}
- deserializeItemCommon(pbEntry, item.get());
+ DeserializeItemCommon(pb_entry, item.get());
array->items.push_back(std::move(item));
}
value = std::move(array);
- } else if (pbCompoundValue.has_plural()) {
- const pb::Plural& pbPlural = pbCompoundValue.plural();
+ } else if (pb_compound_value.has_plural()) {
+ const pb::Plural& pb_plural = pb_compound_value.plural();
std::unique_ptr<Plural> plural = util::make_unique<Plural>();
- for (const pb::Plural_Entry& pbEntry : pbPlural.entries()) {
- size_t pluralIdx = deserializePluralEnumFromPb(pbEntry.arity());
+ for (const pb::Plural_Entry& pb_entry : pb_plural.entries()) {
+ size_t pluralIdx = DeserializePluralEnumFromPb(pb_entry.arity());
plural->values[pluralIdx] =
- deserializeItemFromPb(pbEntry.item(), config, pool);
+ DeserializeItemFromPb(pb_entry.item(), config, pool);
if (!plural->values[pluralIdx]) {
return {};
}
- deserializeItemCommon(pbEntry, plural->values[pluralIdx].get());
+ DeserializeItemCommon(pb_entry, plural->values[pluralIdx].get());
}
value = std::move(plural);
} else {
- mDiag->error(DiagMessage(mSource) << "unknown compound value");
+ diag_->Error(DiagMessage(source_) << "unknown compound value");
return {};
}
} else {
- mDiag->error(DiagMessage(mSource) << "unknown value");
+ diag_->Error(DiagMessage(source_) << "unknown value");
return {};
}
- assert(value && "forgot to set value");
+ CHECK(value) << "forgot to set value";
- value->setWeak(isWeak);
- deserializeItemCommon(pbValue, value.get());
+ value->SetWeak(is_weak);
+ DeserializeItemCommon(pb_value, value.get());
return value;
}
- bool deserializeReferenceFromPb(const pb::Reference& pbRef,
- Reference* outRef) {
- outRef->referenceType = deserializeReferenceTypeFromPb(pbRef.type());
- outRef->privateReference = pbRef.private_();
+ bool DeserializeReferenceFromPb(const pb::Reference& pb_ref,
+ Reference* out_ref) {
+ out_ref->reference_type = DeserializeReferenceTypeFromPb(pb_ref.type());
+ out_ref->private_reference = pb_ref.private_();
- if (!pbRef.has_id() && !pbRef.has_symbol_idx()) {
+ if (!pb_ref.has_id() && !pb_ref.has_symbol_idx()) {
return false;
}
- if (pbRef.has_id()) {
- outRef->id = ResourceId(pbRef.id());
+ if (pb_ref.has_id()) {
+ out_ref->id = ResourceId(pb_ref.id());
}
- if (pbRef.has_symbol_idx()) {
- const std::string strSymbol =
- util::getString(*mSymbolPool, pbRef.symbol_idx());
- ResourceNameRef nameRef;
- if (!ResourceUtils::parseResourceName(strSymbol, &nameRef, nullptr)) {
- mDiag->error(DiagMessage(mSource) << "invalid reference name '"
- << strSymbol << "'");
+ if (pb_ref.has_symbol_idx()) {
+ const std::string str_symbol =
+ util::GetString(*symbol_pool_, pb_ref.symbol_idx());
+ ResourceNameRef name_ref;
+ if (!ResourceUtils::ParseResourceName(str_symbol, &name_ref, nullptr)) {
+ diag_->Error(DiagMessage(source_) << "invalid reference name '"
+ << str_symbol << "'");
return false;
}
- outRef->name = nameRef.toResourceName();
+ out_ref->name = name_ref.ToResourceName();
}
return true;
}
template <typename T>
- void deserializeItemCommon(const T& pbItem, Value* outValue) {
- if (pbItem.has_source()) {
+ void DeserializeItemCommon(const T& pb_item, Value* out_value) {
+ if (pb_item.has_source()) {
Source source;
- deserializeSourceFromPb(pbItem.source(), *mSourcePool, &source);
- outValue->setSource(std::move(source));
+ DeserializeSourceFromPb(pb_item.source(), *source_pool_, &source);
+ out_value->SetSource(std::move(source));
}
- if (pbItem.has_comment()) {
- outValue->setComment(pbItem.comment());
+ if (pb_item.has_comment()) {
+ out_value->SetComment(pb_item.comment());
}
}
private:
- const android::ResStringPool* mValuePool;
- const android::ResStringPool* mSourcePool;
- const android::ResStringPool* mSymbolPool;
- const Source mSource;
- IDiagnostics* mDiag;
+ const android::ResStringPool* value_pool_;
+ const android::ResStringPool* source_pool_;
+ const android::ResStringPool* symbol_pool_;
+ const Source source_;
+ IDiagnostics* diag_;
};
} // namespace
-std::unique_ptr<ResourceTable> deserializeTableFromPb(
- const pb::ResourceTable& pbTable, const Source& source,
+std::unique_ptr<ResourceTable> DeserializeTableFromPb(
+ const pb::ResourceTable& pb_table, const Source& source,
IDiagnostics* diag) {
// We import the android namespace because on Windows NO_ERROR is a macro, not
// an enum, which
@@ -407,78 +409,79 @@
std::unique_ptr<ResourceTable> table = util::make_unique<ResourceTable>();
- if (!pbTable.has_string_pool()) {
- diag->error(DiagMessage(source) << "no string pool found");
+ if (!pb_table.has_string_pool()) {
+ diag->Error(DiagMessage(source) << "no string pool found");
return {};
}
- ResStringPool valuePool;
- status_t result = valuePool.setTo(pbTable.string_pool().data().data(),
- pbTable.string_pool().data().size());
+ ResStringPool value_pool;
+ status_t result = value_pool.setTo(pb_table.string_pool().data().data(),
+ pb_table.string_pool().data().size());
if (result != NO_ERROR) {
- diag->error(DiagMessage(source) << "invalid string pool");
+ diag->Error(DiagMessage(source) << "invalid string pool");
return {};
}
- ResStringPool sourcePool;
- if (pbTable.has_source_pool()) {
- result = sourcePool.setTo(pbTable.source_pool().data().data(),
- pbTable.source_pool().data().size());
+ ResStringPool source_pool;
+ if (pb_table.has_source_pool()) {
+ result = source_pool.setTo(pb_table.source_pool().data().data(),
+ pb_table.source_pool().data().size());
if (result != NO_ERROR) {
- diag->error(DiagMessage(source) << "invalid source pool");
+ diag->Error(DiagMessage(source) << "invalid source pool");
return {};
}
}
- ResStringPool symbolPool;
- if (pbTable.has_symbol_pool()) {
- result = symbolPool.setTo(pbTable.symbol_pool().data().data(),
- pbTable.symbol_pool().data().size());
+ ResStringPool symbol_pool;
+ if (pb_table.has_symbol_pool()) {
+ result = symbol_pool.setTo(pb_table.symbol_pool().data().data(),
+ pb_table.symbol_pool().data().size());
if (result != NO_ERROR) {
- diag->error(DiagMessage(source) << "invalid symbol pool");
+ diag->Error(DiagMessage(source) << "invalid symbol pool");
return {};
}
}
- PackagePbDeserializer packagePbDeserializer(&valuePool, &sourcePool,
- &symbolPool, source, diag);
- for (const pb::Package& pbPackage : pbTable.packages()) {
- if (!packagePbDeserializer.deserializeFromPb(pbPackage, table.get())) {
+ PackagePbDeserializer package_pb_deserializer(&value_pool, &source_pool,
+ &symbol_pool, source, diag);
+ for (const pb::Package& pb_package : pb_table.packages()) {
+ if (!package_pb_deserializer.DeserializeFromPb(pb_package, table.get())) {
return {};
}
}
return table;
}
-std::unique_ptr<ResourceFile> deserializeCompiledFileFromPb(
- const pb::CompiledFile& pbFile, const Source& source, IDiagnostics* diag) {
+std::unique_ptr<ResourceFile> DeserializeCompiledFileFromPb(
+ const pb::CompiledFile& pb_file, const Source& source, IDiagnostics* diag) {
std::unique_ptr<ResourceFile> file = util::make_unique<ResourceFile>();
- ResourceNameRef nameRef;
+ ResourceNameRef name_ref;
// Need to create an lvalue here so that nameRef can point to something real.
- if (!ResourceUtils::parseResourceName(pbFile.resource_name(), &nameRef)) {
- diag->error(DiagMessage(source)
+ if (!ResourceUtils::ParseResourceName(pb_file.resource_name(), &name_ref)) {
+ diag->Error(DiagMessage(source)
<< "invalid resource name in compiled file header: "
- << pbFile.resource_name());
+ << pb_file.resource_name());
return {};
}
- file->name = nameRef.toResourceName();
- file->source.path = pbFile.source_path();
- deserializeConfigDescriptionFromPb(pbFile.config(), &file->config);
+ file->name = name_ref.ToResourceName();
+ file->source.path = pb_file.source_path();
+ DeserializeConfigDescriptionFromPb(pb_file.config(), &file->config);
- for (const pb::CompiledFile_Symbol& pbSymbol : pbFile.exported_symbols()) {
+ for (const pb::CompiledFile_Symbol& pb_symbol : pb_file.exported_symbols()) {
// Need to create an lvalue here so that nameRef can point to something
// real.
- if (!ResourceUtils::parseResourceName(pbSymbol.resource_name(), &nameRef)) {
- diag->error(DiagMessage(source)
+ if (!ResourceUtils::ParseResourceName(pb_symbol.resource_name(),
+ &name_ref)) {
+ diag->Error(DiagMessage(source)
<< "invalid resource name for exported symbol in "
"compiled file header: "
- << pbFile.resource_name());
+ << pb_file.resource_name());
return {};
}
- file->exportedSymbols.push_back(
- SourcedResourceName{nameRef.toResourceName(), pbSymbol.line_no()});
+ file->exported_symbols.push_back(
+ SourcedResourceName{name_ref.ToResourceName(), pb_symbol.line_no()});
}
return file;
}