summaryrefslogtreecommitdiff
path: root/tools/aapt2/cmd/Compile.cpp
diff options
context:
space:
mode:
authorAdam Lesinski <adamlesinski@google.com>2017-09-28 15:50:03 -0700
committerAdam Lesinski <adamlesinski@google.com>2017-09-28 20:43:22 -0700
commit8cdca1bd722049facf5bbec44ec3ca67cade5288 (patch)
treef5c1cbc7940d47b60cfdef1cd602e96ac1adefc7 /tools/aapt2/cmd/Compile.cpp
parentd3ffa844f5a07756009f019e13806e253d1bb119 (diff)
AAPT2: Cleanup proto classes/methods and add XML serialization
Test: make aapt2_tests Change-Id: I01ac2285af6771a683533c033a59ae6cfe875d93
Diffstat (limited to 'tools/aapt2/cmd/Compile.cpp')
-rw-r--r--tools/aapt2/cmd/Compile.cpp27
1 files changed, 15 insertions, 12 deletions
diff --git a/tools/aapt2/cmd/Compile.cpp b/tools/aapt2/cmd/Compile.cpp
index 7f5bbf042766..0690dc1b8ec6 100644
--- a/tools/aapt2/cmd/Compile.cpp
+++ b/tools/aapt2/cmd/Compile.cpp
@@ -248,8 +248,9 @@ static bool CompileTable(IAaptContext* context, const CompileOptions& options,
// ZeroCopyOutputStream interface.
CopyingOutputStreamAdaptor copying_adaptor(writer);
- std::unique_ptr<pb::ResourceTable> pb_table = SerializeTableToPb(&table);
- if (!pb_table->SerializeToZeroCopyStream(&copying_adaptor)) {
+ pb::ResourceTable pb_table;
+ SerializeTableToPb(table, &pb_table);
+ if (!pb_table.SerializeToZeroCopyStream(&copying_adaptor)) {
context->GetDiagnostics()->Error(DiagMessage(output_path) << "failed to write");
return false;
}
@@ -282,9 +283,10 @@ static bool WriteHeaderAndBufferToWriter(const StringPiece& output_path, const R
// Number of CompiledFiles.
output_stream.WriteLittleEndian32(1);
- std::unique_ptr<pb::internal::CompiledFile> compiled_file = SerializeCompiledFileToPb(file);
- output_stream.WriteCompiledFile(compiled_file.get());
- output_stream.WriteData(&buffer);
+ pb::internal::CompiledFile pb_compiled_file;
+ SerializeCompiledFileToPb(file, &pb_compiled_file);
+ output_stream.WriteCompiledFile(pb_compiled_file);
+ output_stream.WriteData(buffer);
if (output_stream.HadError()) {
diag->Error(DiagMessage(output_path) << "failed to write data");
@@ -319,8 +321,9 @@ static bool WriteHeaderAndMmapToWriter(const StringPiece& output_path, const Res
// Number of CompiledFiles.
output_stream.WriteLittleEndian32(1);
- std::unique_ptr<pb::internal::CompiledFile> compiled_file = SerializeCompiledFileToPb(file);
- output_stream.WriteCompiledFile(compiled_file.get());
+ pb::internal::CompiledFile pb_compiled_file;
+ SerializeCompiledFileToPb(file, &pb_compiled_file);
+ output_stream.WriteCompiledFile(pb_compiled_file);
output_stream.WriteData(map.getDataPtr(), map.getDataLength());
if (output_stream.HadError()) {
@@ -346,13 +349,13 @@ static bool FlattenXmlToOutStream(IAaptContext* context, const StringPiece& outp
return false;
}
- std::unique_ptr<pb::internal::CompiledFile> pb_compiled_file =
- SerializeCompiledFileToPb(xmlres->file);
- out->WriteCompiledFile(pb_compiled_file.get());
- out->WriteData(&buffer);
+ pb::internal::CompiledFile pb_compiled_file;
+ SerializeCompiledFileToPb(xmlres->file, &pb_compiled_file);
+ out->WriteCompiledFile(pb_compiled_file);
+ out->WriteData(buffer);
if (out->HadError()) {
- context->GetDiagnostics()->Error(DiagMessage(output_path) << "failed to write data");
+ context->GetDiagnostics()->Error(DiagMessage(output_path) << "failed to write XML data");
return false;
}
return true;