diff options
author | Adam Lesinski <adamlesinski@google.com> | 2015-10-30 16:31:42 -0700 |
---|---|---|
committer | Adam Lesinski <adamlesinski@google.com> | 2015-11-02 11:53:47 -0800 |
commit | 3b4cd94034ff3e5567a2ba6da35d640ff61db4b9 (patch) | |
tree | 83c604b9a3b0d1b25769a6afd16578fd97e6effe /tools/aapt2/unflatten/BinaryResourceParser.cpp | |
parent | 104e028c3a180a4a151160299ad2e1a4185d6c50 (diff) |
AAPT2: Add support for comments in R.java
Change-Id: Iaa5f3b75bf7de9dbf458fa5c452f7312989f4c4f
Diffstat (limited to 'tools/aapt2/unflatten/BinaryResourceParser.cpp')
-rw-r--r-- | tools/aapt2/unflatten/BinaryResourceParser.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/tools/aapt2/unflatten/BinaryResourceParser.cpp b/tools/aapt2/unflatten/BinaryResourceParser.cpp index 30c60918d4e8..0d17e8467d32 100644 --- a/tools/aapt2/unflatten/BinaryResourceParser.cpp +++ b/tools/aapt2/unflatten/BinaryResourceParser.cpp @@ -116,7 +116,7 @@ bool BinaryResourceParser::getSymbol(const void* data, ResourceNameRef* outSymbo if (util::deviceToHost32(mSymbolEntries[i].offset) == offset) { // This offset is a symbol! const StringPiece16 str = util::getString( - mSymbolPool, util::deviceToHost32(mSymbolEntries[i].stringIndex)); + mSymbolPool, util::deviceToHost32(mSymbolEntries[i].name.index)); StringPiece16 typeStr; ResourceUtils::extractResourceName(str, &outSymbol->package, &typeStr, @@ -425,8 +425,14 @@ bool BinaryResourceParser::parsePublic(const ResourceTablePackage* package, Symbol symbol; if (mSourcePool.getError() == NO_ERROR) { symbol.source.path = util::utf16ToUtf8(util::getString( - mSourcePool, util::deviceToHost32(entry->source.index))); - symbol.source.line = util::deviceToHost32(entry->sourceLine); + mSourcePool, util::deviceToHost32(entry->source.path.index))); + symbol.source.line = util::deviceToHost32(entry->source.line); + } + + StringPiece16 comment = util::getString(mSourcePool, + util::deviceToHost32(entry->source.comment.index)); + if (!comment.empty()) { + symbol.comment = comment.toString(); } switch (util::deviceToHost16(entry->state)) { @@ -560,7 +566,7 @@ bool BinaryResourceParser::parseType(const ResourceTablePackage* package, Source source = mSource; if (sourceBlock) { size_t len; - const char* str = mSourcePool.string8At(util::deviceToHost32(sourceBlock->pathIndex), + const char* str = mSourcePool.string8At(util::deviceToHost32(sourceBlock->path.index), &len); if (str) { source.path.assign(str, len); @@ -568,6 +574,12 @@ bool BinaryResourceParser::parseType(const ResourceTablePackage* package, source.line = util::deviceToHost32(sourceBlock->line); } + StringPiece16 comment = util::getString(mSourcePool, + util::deviceToHost32(sourceBlock->comment.index)); + if (!comment.empty()) { + resourceValue->setComment(comment); + } + resourceValue->setSource(source); if (!mTable->addResourceAllowMangled(name, config, std::move(resourceValue), mContext->getDiagnostics())) { |