From ce5e56e243d262a9b65459c3bd0bb9eaadd40628 Mon Sep 17 00:00:00 2001 From: Adam Lesinski Date: Fri, 21 Oct 2016 17:56:45 -0700 Subject: [PATCH] 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 --- cmds/idmap/inspect.cpp | 1 + include/androidfw/Asset.h | 3 +- include/androidfw/ResourceTypes.h | 1 - include/androidfw/TypeWrappers.h | 1 + tools/aapt2/.clang-format | 1 - tools/aapt2/Android.mk | 2 +- tools/aapt2/AppInfo.h | 10 +- tools/aapt2/ConfigDescription.cpp | 190 +- tools/aapt2/ConfigDescription.h | 27 +- tools/aapt2/ConfigDescription_test.cpp | 7 +- tools/aapt2/Debug.cpp | 150 +- tools/aapt2/Debug.h | 18 +- tools/aapt2/Diagnostics.h | 77 +- tools/aapt2/DominatorTree.cpp | 63 +- tools/aapt2/DominatorTree.h | 48 +- tools/aapt2/DominatorTree_test.cpp | 121 +- tools/aapt2/Flags.cpp | 97 +- tools/aapt2/Flags.h | 30 +- tools/aapt2/Locale.cpp | 134 +- tools/aapt2/Locale.h | 23 +- tools/aapt2/Locale_test.cpp | 14 +- tools/aapt2/Main.cpp | 24 +- tools/aapt2/NameMangler.h | 46 +- tools/aapt2/NameMangler_test.cpp | 19 +- tools/aapt2/Resource.cpp | 5 +- tools/aapt2/Resource.h | 76 +- tools/aapt2/ResourceParser.cpp | 1139 +++++------ tools/aapt2/ResourceParser.h | 95 +- tools/aapt2/ResourceParser_test.cpp | 409 ++-- tools/aapt2/ResourceTable.cpp | 289 +-- tools/aapt2/ResourceTable.h | 78 +- tools/aapt2/ResourceTable_test.cpp | 118 +- tools/aapt2/ResourceUtils.cpp | 451 +++-- tools/aapt2/ResourceUtils.h | 106 +- tools/aapt2/ResourceUtils_test.cpp | 141 +- tools/aapt2/ResourceValues.cpp | 396 ++-- tools/aapt2/ResourceValues.h | 168 +- tools/aapt2/Resource_test.cpp | 47 +- tools/aapt2/SdkConstants.cpp | 12 +- tools/aapt2/SdkConstants.h | 10 +- tools/aapt2/SdkConstants_test.cpp | 16 +- tools/aapt2/Source.h | 12 +- tools/aapt2/StringPool.cpp | 361 ++-- tools/aapt2/StringPool.h | 72 +- tools/aapt2/StringPool_test.cpp | 151 +- tools/aapt2/ValueVisitor.h | 86 +- tools/aapt2/ValueVisitor_test.cpp | 51 +- tools/aapt2/compile/Compile.cpp | 596 +++--- tools/aapt2/compile/IdAssigner.cpp | 128 +- tools/aapt2/compile/IdAssigner.h | 12 +- tools/aapt2/compile/IdAssigner_test.cpp | 143 +- tools/aapt2/compile/Image.h | 33 +- tools/aapt2/compile/InlineXmlFormatParser.cpp | 147 +- tools/aapt2/compile/InlineXmlFormatParser.h | 15 +- .../compile/InlineXmlFormatParser_test.cpp | 87 +- tools/aapt2/compile/NinePatch.cpp | 590 +++--- tools/aapt2/compile/NinePatch_test.cpp | 174 +- tools/aapt2/compile/Png.cpp | 44 +- tools/aapt2/compile/Png.h | 34 +- tools/aapt2/compile/PngChunkFilter.cpp | 67 +- tools/aapt2/compile/PngCrunch.cpp | 557 ++--- tools/aapt2/compile/PseudolocaleGenerator.cpp | 167 +- tools/aapt2/compile/PseudolocaleGenerator.h | 4 +- .../compile/PseudolocaleGenerator_test.cpp | 119 +- tools/aapt2/compile/Pseudolocalizer.cpp | 166 +- tools/aapt2/compile/Pseudolocalizer.h | 27 +- tools/aapt2/compile/Pseudolocalizer_test.cpp | 83 +- tools/aapt2/compile/XmlIdCollector.cpp | 46 +- tools/aapt2/compile/XmlIdCollector.h | 2 +- tools/aapt2/compile/XmlIdCollector_test.cpp | 37 +- tools/aapt2/diff/Diff.cpp | 441 ++-- tools/aapt2/dump/Dump.cpp | 122 +- tools/aapt2/filter/ConfigFilter.cpp | 45 +- tools/aapt2/filter/ConfigFilter.h | 14 +- tools/aapt2/filter/ConfigFilter_test.cpp | 67 +- tools/aapt2/flatten/Archive.cpp | 124 +- tools/aapt2/flatten/Archive.h | 29 +- tools/aapt2/flatten/ChunkWriter.h | 64 +- tools/aapt2/flatten/ResourceTypeExtensions.h | 2 +- tools/aapt2/flatten/TableFlattener.cpp | 415 ++-- tools/aapt2/flatten/TableFlattener.h | 15 +- tools/aapt2/flatten/TableFlattener_test.cpp | 189 +- tools/aapt2/flatten/XmlFlattener.cpp | 376 ++-- tools/aapt2/flatten/XmlFlattener.h | 18 +- tools/aapt2/flatten/XmlFlattener_test.cpp | 131 +- tools/aapt2/io/Data.h | 35 +- tools/aapt2/io/File.cpp | 30 +- tools/aapt2/io/File.h | 39 +- tools/aapt2/io/FileSystem.cpp | 79 +- tools/aapt2/io/FileSystem.h | 24 +- tools/aapt2/io/Io.cpp | 34 +- tools/aapt2/io/Io.h | 9 +- tools/aapt2/io/ZipArchive.cpp | 209 +- tools/aapt2/io/ZipArchive.h | 33 +- tools/aapt2/java/AnnotationProcessor.cpp | 100 +- tools/aapt2/java/AnnotationProcessor.h | 18 +- tools/aapt2/java/AnnotationProcessor_test.cpp | 41 +- tools/aapt2/java/ClassDefinition.cpp | 72 +- tools/aapt2/java/ClassDefinition.h | 81 +- tools/aapt2/java/JavaClassGenerator.cpp | 972 ++++----- tools/aapt2/java/JavaClassGenerator.h | 30 +- tools/aapt2/java/JavaClassGenerator_test.cpp | 461 +++-- tools/aapt2/java/ManifestClassGenerator.cpp | 177 +- tools/aapt2/java/ManifestClassGenerator.h | 5 +- .../java/ManifestClassGenerator_test.cpp | 122 +- tools/aapt2/java/ProguardRules.cpp | 435 ++-- tools/aapt2/java/ProguardRules.h | 34 +- tools/aapt2/jni/aapt2_jni.cpp | 93 +- tools/aapt2/link/AutoVersioner.cpp | 87 +- tools/aapt2/link/AutoVersioner_test.cpp | 107 +- tools/aapt2/link/Link.cpp | 1801 +++++++++-------- tools/aapt2/link/Linkers.h | 110 +- tools/aapt2/link/ManifestFixer.cpp | 271 +-- tools/aapt2/link/ManifestFixer.h | 28 +- tools/aapt2/link/ManifestFixer_test.cpp | 170 +- tools/aapt2/link/PrivateAttributeMover.cpp | 50 +- .../aapt2/link/PrivateAttributeMover_test.cpp | 49 +- tools/aapt2/link/ProductFilter.cpp | 79 +- tools/aapt2/link/ProductFilter.h | 50 - tools/aapt2/link/ProductFilter_test.cpp | 141 +- tools/aapt2/link/ReferenceLinker.cpp | 269 +-- tools/aapt2/link/ReferenceLinker.h | 58 +- tools/aapt2/link/ReferenceLinker_test.cpp | 209 +- tools/aapt2/link/ResourceDeduper.cpp | 51 +- tools/aapt2/link/ResourceDeduper_test.cpp | 84 +- tools/aapt2/link/TableMerger.cpp | 322 +-- tools/aapt2/link/TableMerger.h | 58 +- tools/aapt2/link/TableMerger_test.cpp | 354 ++-- tools/aapt2/link/VersionCollapser.cpp | 81 +- tools/aapt2/link/VersionCollapser_test.cpp | 96 +- tools/aapt2/link/XmlNamespaceRemover.cpp | 29 +- tools/aapt2/link/XmlNamespaceRemover_test.cpp | 57 +- tools/aapt2/link/XmlReferenceLinker.cpp | 156 +- tools/aapt2/link/XmlReferenceLinker_test.cpp | 248 +-- tools/aapt2/process/IResourceTableConsumer.h | 26 +- tools/aapt2/process/SymbolTable.cpp | 162 +- tools/aapt2/process/SymbolTable.h | 82 +- tools/aapt2/process/SymbolTable_test.cpp | 29 +- tools/aapt2/proto/ProtoHelpers.cpp | 211 +- tools/aapt2/proto/ProtoHelpers.h | 45 +- tools/aapt2/proto/ProtoSerialize.h | 24 +- tools/aapt2/proto/TableProtoDeserializer.cpp | 371 ++-- tools/aapt2/proto/TableProtoSerializer.cpp | 635 +++--- .../aapt2/proto/TableProtoSerializer_test.cpp | 299 +-- tools/aapt2/split/TableSplitter.cpp | 441 ++-- tools/aapt2/split/TableSplitter.h | 33 +- tools/aapt2/split/TableSplitter_test.cpp | 279 +-- tools/aapt2/test/Builders.h | 209 +- tools/aapt2/test/Common.h | 68 +- tools/aapt2/test/Context.h | 122 +- tools/aapt2/test/Test.h | 8 +- .../aapt2/unflatten/BinaryResourceParser.cpp | 410 ++-- tools/aapt2/unflatten/BinaryResourceParser.h | 61 +- tools/aapt2/unflatten/ResChunkPullParser.cpp | 83 +- tools/aapt2/unflatten/ResChunkPullParser.h | 78 +- tools/aapt2/util/BigBuffer.cpp | 84 +- tools/aapt2/util/BigBuffer.h | 94 +- tools/aapt2/util/BigBuffer_test.cpp | 98 +- tools/aapt2/util/Files.cpp | 429 ++-- tools/aapt2/util/Files.h | 57 +- tools/aapt2/util/Files_test.cpp | 51 +- tools/aapt2/util/ImmutableMap.h | 40 +- tools/aapt2/util/Maybe.h | 105 +- tools/aapt2/util/Maybe_test.cpp | 160 +- tools/aapt2/util/StringPiece.h | 83 +- tools/aapt2/util/StringPiece_test.cpp | 107 +- tools/aapt2/util/Util.cpp | 921 +++++---- tools/aapt2/util/Util.h | 154 +- tools/aapt2/util/Util_test.cpp | 243 +-- tools/aapt2/xml/XmlActionExecutor.cpp | 141 +- tools/aapt2/xml/XmlActionExecutor.h | 34 +- tools/aapt2/xml/XmlActionExecutor_test.cpp | 62 +- tools/aapt2/xml/XmlDom.cpp | 771 +++---- tools/aapt2/xml/XmlDom.h | 103 +- tools/aapt2/xml/XmlDom_test.cpp | 28 +- tools/aapt2/xml/XmlPullParser.cpp | 500 ++--- tools/aapt2/xml/XmlPullParser.h | 140 +- tools/aapt2/xml/XmlPullParser_test.cpp | 49 +- tools/aapt2/xml/XmlUtil.cpp | 95 +- tools/aapt2/xml/XmlUtil.h | 27 +- tools/aapt2/xml/XmlUtil_test.cpp | 56 +- 181 files changed, 13853 insertions(+), 13329 deletions(-) delete mode 100644 tools/aapt2/link/ProductFilter.h diff --git a/cmds/idmap/inspect.cpp b/cmds/idmap/inspect.cpp index f6afc8594309a..154cb25a02a1f 100644 --- a/cmds/idmap/inspect.cpp +++ b/cmds/idmap/inspect.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include diff --git a/include/androidfw/Asset.h b/include/androidfw/Asset.h index 52c863774efb0..11709ce5f91b9 100644 --- a/include/androidfw/Asset.h +++ b/include/androidfw/Asset.h @@ -26,11 +26,12 @@ #include #include -#include #include namespace android { +class FileMap; + /* * Instances of this class provide read-only operations on a byte stream. * diff --git a/include/androidfw/ResourceTypes.h b/include/androidfw/ResourceTypes.h index 6349e86dae94e..08d6591e68868 100644 --- a/include/androidfw/ResourceTypes.h +++ b/include/androidfw/ResourceTypes.h @@ -22,7 +22,6 @@ #include #include -#include #include #include #include diff --git a/include/androidfw/TypeWrappers.h b/include/androidfw/TypeWrappers.h index 7bdf8af0ad4c7..4233b6bbee83b 100644 --- a/include/androidfw/TypeWrappers.h +++ b/include/androidfw/TypeWrappers.h @@ -18,6 +18,7 @@ #define __TYPE_WRAPPERS_H #include +#include namespace android { diff --git a/tools/aapt2/.clang-format b/tools/aapt2/.clang-format index 71c5ef2fcda08..545366a9b70b0 100644 --- a/tools/aapt2/.clang-format +++ b/tools/aapt2/.clang-format @@ -1,3 +1,2 @@ BasedOnStyle: Google -ColumnLimit: 100 diff --git a/tools/aapt2/Android.mk b/tools/aapt2/Android.mk index 284c7877d0546..197884dcf85ce 100644 --- a/tools/aapt2/Android.mk +++ b/tools/aapt2/Android.mk @@ -158,7 +158,7 @@ hostStaticLibs_windows := libz hostLdLibs_linux := -lz hostLdLibs_darwin := -lz -cFlags := -Wall -Werror -Wno-unused-parameter -UNDEBUG +cFlags := -Wall -Werror -Wno-unused-parameter cFlags_darwin := -D_DARWIN_UNLIMITED_STREAMS cFlags_windows := -Wno-maybe-uninitialized # Incorrectly marking use of Maybe.value() as error. cppFlags := -Wno-missing-field-initializers -fno-exceptions -fno-rtti diff --git a/tools/aapt2/AppInfo.h b/tools/aapt2/AppInfo.h index 2cbe117974406..1e488f70bd4d7 100644 --- a/tools/aapt2/AppInfo.h +++ b/tools/aapt2/AppInfo.h @@ -17,10 +17,10 @@ #ifndef AAPT_APP_INFO_H #define AAPT_APP_INFO_H -#include "util/Maybe.h" - #include +#include "util/Maybe.h" + namespace aapt { /** @@ -36,17 +36,17 @@ struct AppInfo { /** * The App's minimum SDK version. */ - Maybe minSdkVersion; + Maybe min_sdk_version; /** * The Version code of the app. */ - Maybe versionCode; + Maybe version_code; /** * The revision code of the app. */ - Maybe revisionCode; + Maybe revision_code; }; } // namespace aapt diff --git a/tools/aapt2/ConfigDescription.cpp b/tools/aapt2/ConfigDescription.cpp index 6598d63882001..289919a393739 100644 --- a/tools/aapt2/ConfigDescription.cpp +++ b/tools/aapt2/ConfigDescription.cpp @@ -15,22 +15,24 @@ */ #include "ConfigDescription.h" + +#include +#include + +#include "androidfw/ResourceTypes.h" + #include "Locale.h" #include "SdkConstants.h" #include "util/StringPiece.h" #include "util/Util.h" -#include -#include -#include - namespace aapt { using android::ResTable_config; static const char* kWildcardName = "any"; -const ConfigDescription& ConfigDescription::defaultConfig() { +const ConfigDescription& ConfigDescription::DefaultConfig() { static ConfigDescription config = {}; return config; } @@ -589,169 +591,169 @@ static bool parseVersion(const char* name, ResTable_config* out) { return true; } -bool ConfigDescription::parse(const StringPiece& str, ConfigDescription* out) { - std::vector parts = util::splitAndLowercase(str, '-'); +bool ConfigDescription::Parse(const StringPiece& str, ConfigDescription* out) { + std::vector parts = util::SplitAndLowercase(str, '-'); ConfigDescription config; - ssize_t partsConsumed = 0; + ssize_t parts_consumed = 0; LocaleValue locale; - const auto partsEnd = parts.end(); - auto partIter = parts.begin(); + const auto parts_end = parts.end(); + auto part_iter = parts.begin(); if (str.size() == 0) { goto success; } - if (parseMcc(partIter->c_str(), &config)) { - ++partIter; - if (partIter == partsEnd) { + if (parseMcc(part_iter->c_str(), &config)) { + ++part_iter; + if (part_iter == parts_end) { goto success; } } - if (parseMnc(partIter->c_str(), &config)) { - ++partIter; - if (partIter == partsEnd) { + if (parseMnc(part_iter->c_str(), &config)) { + ++part_iter; + if (part_iter == parts_end) { goto success; } } // Locale spans a few '-' separators, so we let it // control the index. - partsConsumed = locale.initFromParts(partIter, partsEnd); - if (partsConsumed < 0) { + parts_consumed = locale.InitFromParts(part_iter, parts_end); + if (parts_consumed < 0) { return false; } else { - locale.writeTo(&config); - partIter += partsConsumed; - if (partIter == partsEnd) { + locale.WriteTo(&config); + part_iter += parts_consumed; + if (part_iter == parts_end) { goto success; } } - if (parseLayoutDirection(partIter->c_str(), &config)) { - ++partIter; - if (partIter == partsEnd) { + if (parseLayoutDirection(part_iter->c_str(), &config)) { + ++part_iter; + if (part_iter == parts_end) { goto success; } } - if (parseSmallestScreenWidthDp(partIter->c_str(), &config)) { - ++partIter; - if (partIter == partsEnd) { + if (parseSmallestScreenWidthDp(part_iter->c_str(), &config)) { + ++part_iter; + if (part_iter == parts_end) { goto success; } } - if (parseScreenWidthDp(partIter->c_str(), &config)) { - ++partIter; - if (partIter == partsEnd) { + if (parseScreenWidthDp(part_iter->c_str(), &config)) { + ++part_iter; + if (part_iter == parts_end) { goto success; } } - if (parseScreenHeightDp(partIter->c_str(), &config)) { - ++partIter; - if (partIter == partsEnd) { + if (parseScreenHeightDp(part_iter->c_str(), &config)) { + ++part_iter; + if (part_iter == parts_end) { goto success; } } - if (parseScreenLayoutSize(partIter->c_str(), &config)) { - ++partIter; - if (partIter == partsEnd) { + if (parseScreenLayoutSize(part_iter->c_str(), &config)) { + ++part_iter; + if (part_iter == parts_end) { goto success; } } - if (parseScreenLayoutLong(partIter->c_str(), &config)) { - ++partIter; - if (partIter == partsEnd) { + if (parseScreenLayoutLong(part_iter->c_str(), &config)) { + ++part_iter; + if (part_iter == parts_end) { goto success; } } - if (parseScreenRound(partIter->c_str(), &config)) { - ++partIter; - if (partIter == partsEnd) { + if (parseScreenRound(part_iter->c_str(), &config)) { + ++part_iter; + if (part_iter == parts_end) { goto success; } } - if (parseOrientation(partIter->c_str(), &config)) { - ++partIter; - if (partIter == partsEnd) { + if (parseOrientation(part_iter->c_str(), &config)) { + ++part_iter; + if (part_iter == parts_end) { goto success; } } - if (parseUiModeType(partIter->c_str(), &config)) { - ++partIter; - if (partIter == partsEnd) { + if (parseUiModeType(part_iter->c_str(), &config)) { + ++part_iter; + if (part_iter == parts_end) { goto success; } } - if (parseUiModeNight(partIter->c_str(), &config)) { - ++partIter; - if (partIter == partsEnd) { + if (parseUiModeNight(part_iter->c_str(), &config)) { + ++part_iter; + if (part_iter == parts_end) { goto success; } } - if (parseDensity(partIter->c_str(), &config)) { - ++partIter; - if (partIter == partsEnd) { + if (parseDensity(part_iter->c_str(), &config)) { + ++part_iter; + if (part_iter == parts_end) { goto success; } } - if (parseTouchscreen(partIter->c_str(), &config)) { - ++partIter; - if (partIter == partsEnd) { + if (parseTouchscreen(part_iter->c_str(), &config)) { + ++part_iter; + if (part_iter == parts_end) { goto success; } } - if (parseKeysHidden(partIter->c_str(), &config)) { - ++partIter; - if (partIter == partsEnd) { + if (parseKeysHidden(part_iter->c_str(), &config)) { + ++part_iter; + if (part_iter == parts_end) { goto success; } } - if (parseKeyboard(partIter->c_str(), &config)) { - ++partIter; - if (partIter == partsEnd) { + if (parseKeyboard(part_iter->c_str(), &config)) { + ++part_iter; + if (part_iter == parts_end) { goto success; } } - if (parseNavHidden(partIter->c_str(), &config)) { - ++partIter; - if (partIter == partsEnd) { + if (parseNavHidden(part_iter->c_str(), &config)) { + ++part_iter; + if (part_iter == parts_end) { goto success; } } - if (parseNavigation(partIter->c_str(), &config)) { - ++partIter; - if (partIter == partsEnd) { + if (parseNavigation(part_iter->c_str(), &config)) { + ++part_iter; + if (part_iter == parts_end) { goto success; } } - if (parseScreenSize(partIter->c_str(), &config)) { - ++partIter; - if (partIter == partsEnd) { + if (parseScreenSize(part_iter->c_str(), &config)) { + ++part_iter; + if (part_iter == parts_end) { goto success; } } - if (parseVersion(partIter->c_str(), &config)) { - ++partIter; - if (partIter == partsEnd) { + if (parseVersion(part_iter->c_str(), &config)) { + ++part_iter; + if (part_iter == parts_end) { goto success; } } @@ -761,57 +763,57 @@ bool ConfigDescription::parse(const StringPiece& str, ConfigDescription* out) { success: if (out != NULL) { - applyVersionForCompatibility(&config); + ApplyVersionForCompatibility(&config); *out = config; } return true; } -void ConfigDescription::applyVersionForCompatibility( +void ConfigDescription::ApplyVersionForCompatibility( ConfigDescription* config) { - uint16_t minSdk = 0; + uint16_t min_sdk = 0; if (config->screenLayout2 & ResTable_config::MASK_SCREENROUND) { - minSdk = SDK_MARSHMALLOW; + min_sdk = SDK_MARSHMALLOW; } else if (config->density == ResTable_config::DENSITY_ANY) { - minSdk = SDK_LOLLIPOP; + min_sdk = SDK_LOLLIPOP; } else if (config->smallestScreenWidthDp != ResTable_config::SCREENWIDTH_ANY || config->screenWidthDp != ResTable_config::SCREENWIDTH_ANY || config->screenHeightDp != ResTable_config::SCREENHEIGHT_ANY) { - minSdk = SDK_HONEYCOMB_MR2; + min_sdk = 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) { - minSdk = SDK_FROYO; + min_sdk = 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) { - minSdk = SDK_DONUT; + min_sdk = SDK_DONUT; } - if (minSdk > config->sdkVersion) { - config->sdkVersion = minSdk; + if (min_sdk > config->sdkVersion) { + config->sdkVersion = min_sdk; } } -ConfigDescription ConfigDescription::copyWithoutSdkVersion() const { +ConfigDescription ConfigDescription::CopyWithoutSdkVersion() const { ConfigDescription copy = *this; copy.sdkVersion = 0; return copy; } -bool ConfigDescription::dominates(const ConfigDescription& o) const { - if (*this == defaultConfig() || *this == o) { +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( +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 @@ -866,7 +868,7 @@ bool ConfigDescription::hasHigherPrecedenceThan( return *this != o; } -bool ConfigDescription::conflictsWith(const ConfigDescription& o) const { +bool ConfigDescription::ConflictsWith(const ConfigDescription& o) const { // This method should be updated as new configuration parameters are // introduced (e.g. screenConfig2). auto pred = [](const uint32_t a, const uint32_t b) -> bool { @@ -892,8 +894,8 @@ bool ConfigDescription::conflictsWith(const ConfigDescription& o) const { !pred(keyboard, o.keyboard) || !pred(navigation, o.navigation); } -bool ConfigDescription::isCompatibleWith(const ConfigDescription& o) const { - return !conflictsWith(o) && !dominates(o) && !o.dominates(*this); +bool ConfigDescription::IsCompatibleWith(const ConfigDescription& o) const { + return !ConflictsWith(o) && !Dominates(o) && !o.Dominates(*this); } } // namespace aapt diff --git a/tools/aapt2/ConfigDescription.h b/tools/aapt2/ConfigDescription.h index bb54886739753..97d0f38a5af1e 100644 --- a/tools/aapt2/ConfigDescription.h +++ b/tools/aapt2/ConfigDescription.h @@ -17,11 +17,12 @@ #ifndef AAPT_CONFIG_DESCRIPTION_H #define AAPT_CONFIG_DESCRIPTION_H -#include "util/StringPiece.h" - -#include #include +#include "androidfw/ResourceTypes.h" + +#include "util/StringPiece.h" + namespace aapt { /* @@ -32,7 +33,7 @@ struct ConfigDescription : public android::ResTable_config { /** * Returns an immutable default config. */ - static const ConfigDescription& defaultConfig(); + static const ConfigDescription& DefaultConfig(); /* * Parse a string of the form 'fr-sw600dp-land' and fill in the @@ -41,14 +42,14 @@ struct ConfigDescription : public android::ResTable_config { * The resulting configuration has the appropriate sdkVersion defined * for backwards compatibility. */ - static bool parse(const StringPiece& str, ConfigDescription* out = nullptr); + static bool Parse(const StringPiece& str, ConfigDescription* out = nullptr); /** * If the configuration uses an axis that was added after * the original Android release, make sure the SDK version * is set accordingly. */ - static void applyVersionForCompatibility(ConfigDescription* config); + static void ApplyVersionForCompatibility(ConfigDescription* config); ConfigDescription(); ConfigDescription(const android::ResTable_config& o); // NOLINT(implicit) @@ -59,7 +60,7 @@ struct ConfigDescription : public android::ResTable_config { ConfigDescription& operator=(const ConfigDescription& o); ConfigDescription& operator=(ConfigDescription&& o); - ConfigDescription copyWithoutSdkVersion() const; + ConfigDescription CopyWithoutSdkVersion() const; /** * A configuration X dominates another configuration Y, if X has at least the @@ -70,14 +71,14 @@ struct ConfigDescription : public android::ResTable_config { * For example, the configuration 'en-w800dp' dominates 'en-rGB-w1024dp'. It * does not dominate 'fr', 'en-w720dp', or 'mcc001-en-w800dp'. */ - bool dominates(const ConfigDescription& o) const; + bool Dominates(const ConfigDescription& o) const; /** * Returns true if this configuration defines a more important configuration * parameter than o. For example, "en" has higher precedence than "v23", * whereas "en" has the same precedence as "en-v23". */ - bool hasHigherPrecedenceThan(const ConfigDescription& o) const; + bool HasHigherPrecedenceThan(const ConfigDescription& o) const; /** * A configuration conflicts with another configuration if both @@ -85,7 +86,7 @@ struct ConfigDescription : public android::ResTable_config { * incompatible configuration parameter is a non-range, non-density parameter * that is defined in both configurations as a different, non-default value. */ - bool conflictsWith(const ConfigDescription& o) const; + bool ConflictsWith(const ConfigDescription& o) const; /** * A configuration is compatible with another configuration if both @@ -93,9 +94,9 @@ struct ConfigDescription : public android::ResTable_config { * unrelated by domination. For example, land-v11 conflicts with port-v21 * but is compatible with v21 (both land-v11 and v21 would match en-land-v23). */ - bool isCompatibleWith(const ConfigDescription& o) const; + bool IsCompatibleWith(const ConfigDescription& o) const; - bool matchWithDensity(const ConfigDescription& o) const; + bool MatchWithDensity(const ConfigDescription& o) const; bool operator<(const ConfigDescription& o) const; bool operator<=(const ConfigDescription& o) const; @@ -141,7 +142,7 @@ inline ConfigDescription& ConfigDescription::operator=(ConfigDescription&& o) { return *this; } -inline bool ConfigDescription::matchWithDensity( +inline bool ConfigDescription::MatchWithDensity( const ConfigDescription& o) const { return match(o) && (density == 0 || density == o.density); } diff --git a/tools/aapt2/ConfigDescription_test.cpp b/tools/aapt2/ConfigDescription_test.cpp index 66b7d47761188..c331dc0f69098 100644 --- a/tools/aapt2/ConfigDescription_test.cpp +++ b/tools/aapt2/ConfigDescription_test.cpp @@ -15,17 +15,18 @@ */ #include "ConfigDescription.h" + +#include + #include "SdkConstants.h" #include "test/Test.h" #include "util/StringPiece.h" -#include - namespace aapt { static ::testing::AssertionResult TestParse( const StringPiece& input, ConfigDescription* config = nullptr) { - if (ConfigDescription::parse(input, config)) { + if (ConfigDescription::Parse(input, config)) { return ::testing::AssertionSuccess() << input << " was successfully parsed"; } return ::testing::AssertionFailure() << input << " could not be parsed"; diff --git a/tools/aapt2/Debug.cpp b/tools/aapt2/Debug.cpp index 965db9ebc9c85..60b01e372d7b1 100644 --- a/tools/aapt2/Debug.cpp +++ b/tools/aapt2/Debug.cpp @@ -15,10 +15,6 @@ */ #include "Debug.h" -#include "ResourceTable.h" -#include "ResourceValues.h" -#include "ValueVisitor.h" -#include "util/Util.h" #include #include @@ -28,18 +24,25 @@ #include #include +#include "android-base/logging.h" + +#include "ResourceTable.h" +#include "ResourceValues.h" +#include "ValueVisitor.h" +#include "util/Util.h" + namespace aapt { class PrintVisitor : public ValueVisitor { public: - using ValueVisitor::visit; + using ValueVisitor::Visit; - void visit(Attribute* attr) override { + void Visit(Attribute* attr) override { std::cout << "(attr) type="; - attr->printMask(&std::cout); + attr->PrintMask(&std::cout); static constexpr uint32_t kMask = android::ResTable_map::TYPE_ENUM | android::ResTable_map::TYPE_FLAGS; - if (attr->typeMask & kMask) { + if (attr->type_mask & kMask) { for (const auto& symbol : attr->symbols) { std::cout << "\n " << symbol.symbol.name.value().entry; if (symbol.symbol.id) { @@ -50,20 +53,20 @@ class PrintVisitor : public ValueVisitor { } } - void visit(Style* style) override { + void Visit(Style* style) override { std::cout << "(style)"; if (style->parent) { - const Reference& parentRef = style->parent.value(); + const Reference& parent_ref = style->parent.value(); std::cout << " parent="; - if (parentRef.name) { - if (parentRef.privateReference) { + if (parent_ref.name) { + if (parent_ref.private_reference) { std::cout << "*"; } - std::cout << parentRef.name.value() << " "; + std::cout << parent_ref.name.value() << " "; } - if (parentRef.id) { - std::cout << parentRef.id.value(); + if (parent_ref.id) { + std::cout << parent_ref.id.value(); } } @@ -85,11 +88,11 @@ class PrintVisitor : public ValueVisitor { } } - 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 { + void Visit(Styleable* styleable) override { std::cout << "(styleable)"; for (const auto& attr : styleable->entries) { std::cout << "\n "; @@ -107,10 +110,10 @@ class PrintVisitor : public ValueVisitor { } } - void visitItem(Item* item) override { item->print(&std::cout); } + void VisitItem(Item* item) override { item->Print(&std::cout); } }; -void Debug::printTable(ResourceTable* table, +void Debug::PrintTable(ResourceTable* table, const DebugPrintTableOptions& options) { PrintVisitor visitor; @@ -128,10 +131,10 @@ void Debug::printTable(ResourceTable* table, } std::cout << " entryCount=" << type->entries.size() << std::endl; - std::vector sortedEntries; + std::vector sorted_entries; for (const auto& entry : type->entries) { auto iter = std::lower_bound( - sortedEntries.begin(), sortedEntries.end(), entry.get(), + sorted_entries.begin(), sorted_entries.end(), entry.get(), [](const ResourceEntry* a, const ResourceEntry* b) -> bool { if (a->id && b->id) { return a->id.value() < b->id.value(); @@ -141,17 +144,17 @@ void Debug::printTable(ResourceTable* table, return false; } }); - sortedEntries.insert(iter, entry.get()); + sorted_entries.insert(iter, entry.get()); } - for (const ResourceEntry* entry : sortedEntries) { + for (const ResourceEntry* entry : sorted_entries) { ResourceId id(package->id ? package->id.value() : uint8_t(0), type->id ? type->id.value() : uint8_t(0), entry->id ? entry->id.value() : uint16_t(0)); ResourceName name(package->name, type->type, entry->name); std::cout << " spec resource " << id << " " << name; - switch (entry->symbolStatus.state) { + switch (entry->symbol_status.state) { case SymbolState::kPublic: std::cout << " PUBLIC"; break; @@ -166,9 +169,9 @@ void Debug::printTable(ResourceTable* table, for (const auto& value : entry->values) { std::cout << " (" << value->config << ") "; - value->value->accept(&visitor); - if (options.showSources && !value->value->getSource().path.empty()) { - std::cout << " src=" << value->value->getSource(); + value->value->Accept(&visitor); + if (options.show_sources && !value->value->GetSource().path.empty()) { + std::cout << " src=" << value->value->GetSource(); } std::cout << std::endl; } @@ -177,35 +180,36 @@ void Debug::printTable(ResourceTable* table, } } -static size_t getNodeIndex(const std::vector& names, +static size_t GetNodeIndex(const std::vector& names, const ResourceName& name) { auto iter = std::lower_bound(names.begin(), names.end(), name); - assert(iter != names.end() && *iter == name); + CHECK(iter != names.end()); + CHECK(*iter == name); return std::distance(names.begin(), iter); } -void Debug::printStyleGraph(ResourceTable* table, - const ResourceName& targetStyle) { +void Debug::PrintStyleGraph(ResourceTable* table, + const ResourceName& target_style) { std::map> graph; - std::queue stylesToVisit; - stylesToVisit.push(targetStyle); - for (; !stylesToVisit.empty(); stylesToVisit.pop()) { - const ResourceName& styleName = stylesToVisit.front(); - std::set& parents = graph[styleName]; + std::queue styles_to_visit; + styles_to_visit.push(target_style); + for (; !styles_to_visit.empty(); styles_to_visit.pop()) { + const ResourceName& style_name = styles_to_visit.front(); + std::set& parents = graph[style_name]; if (!parents.empty()) { // We've already visited this style. continue; } - Maybe result = table->findResource(styleName); + Maybe result = table->FindResource(style_name); if (result) { ResourceEntry* entry = result.value().entry; for (const auto& value : entry->values) { - if (Style* style = valueCast"; - ASSERT_TRUE(testParse(input)); + ASSERT_TRUE(TestParse(input)); - Style* style = test::getValue"; - ASSERT_TRUE(testParse(input)); + ASSERT_TRUE(TestParse(input)); - Style* style = test::getValue