Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(385)

Side by Side Diff: courgette/encoded_program.cc

Issue 1855133002: convert //courgette to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update comment in memory_allocator.h Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « courgette/encoded_program.h ('k') | courgette/encoded_program_fuzz_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "courgette/encoded_program.h" 5 #include "courgette/encoded_program.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 INCLUDE_ABS32_INDEXES = 0x0010, 272 INCLUDE_ABS32_INDEXES = 0x0010,
273 INCLUDE_REL32_INDEXES = 0x0020, 273 INCLUDE_REL32_INDEXES = 0x0020,
274 INCLUDE_OPS = 0x0100, 274 INCLUDE_OPS = 0x0100,
275 INCLUDE_BYTES = 0x0200, 275 INCLUDE_BYTES = 0x0200,
276 INCLUDE_COPY_COUNTS = 0x0400, 276 INCLUDE_COPY_COUNTS = 0x0400,
277 INCLUDE_MISC = 0x1000 277 INCLUDE_MISC = 0x1000
278 }; 278 };
279 279
280 static FieldSelect GetFieldSelect() { 280 static FieldSelect GetFieldSelect() {
281 // TODO(sra): Use better configuration. 281 // TODO(sra): Use better configuration.
282 scoped_ptr<base::Environment> env(base::Environment::Create()); 282 std::unique_ptr<base::Environment> env(base::Environment::Create());
283 std::string s; 283 std::string s;
284 env->GetVar("A_FIELDS", &s); 284 env->GetVar("A_FIELDS", &s);
285 uint64_t fields; 285 uint64_t fields;
286 if (!base::StringToUint64(s, &fields)) 286 if (!base::StringToUint64(s, &fields))
287 return static_cast<FieldSelect>(~0); 287 return static_cast<FieldSelect>(~0);
288 return static_cast<FieldSelect>(fields); 288 return static_cast<FieldSelect>(fields);
289 } 289 }
290 290
291 CheckBool EncodedProgram::WriteTo(SinkStreamSet* streams) { 291 CheckBool EncodedProgram::WriteTo(SinkStreamSet* streams) {
292 FieldSelect select = GetFieldSelect(); 292 FieldSelect select = GetFieldSelect();
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 } 774 }
775 //////////////////////////////////////////////////////////////////////////////// 775 ////////////////////////////////////////////////////////////////////////////////
776 776
777 Status WriteEncodedProgram(EncodedProgram* encoded, SinkStreamSet* sink) { 777 Status WriteEncodedProgram(EncodedProgram* encoded, SinkStreamSet* sink) {
778 if (!encoded->WriteTo(sink)) 778 if (!encoded->WriteTo(sink))
779 return C_STREAM_ERROR; 779 return C_STREAM_ERROR;
780 return C_OK; 780 return C_OK;
781 } 781 }
782 782
783 Status ReadEncodedProgram(SourceStreamSet* streams, 783 Status ReadEncodedProgram(SourceStreamSet* streams,
784 scoped_ptr<EncodedProgram>* output) { 784 std::unique_ptr<EncodedProgram>* output) {
785 output->reset(); 785 output->reset();
786 scoped_ptr<EncodedProgram> encoded(new EncodedProgram()); 786 std::unique_ptr<EncodedProgram> encoded(new EncodedProgram());
787 if (!encoded->ReadFrom(streams)) 787 if (!encoded->ReadFrom(streams))
788 return C_DESERIALIZATION_FAILED; 788 return C_DESERIALIZATION_FAILED;
789 789
790 *output = std::move(encoded); 790 *output = std::move(encoded);
791 return C_OK; 791 return C_OK;
792 } 792 }
793 793
794 Status Assemble(EncodedProgram* encoded, SinkStream* buffer) { 794 Status Assemble(EncodedProgram* encoded, SinkStream* buffer) {
795 bool assembled = encoded->AssembleTo(buffer); 795 bool assembled = encoded->AssembleTo(buffer);
796 if (assembled) 796 if (assembled)
797 return C_OK; 797 return C_OK;
798 return C_ASSEMBLY_FAILED; 798 return C_ASSEMBLY_FAILED;
799 } 799 }
800 800
801 } // namespace courgette 801 } // namespace courgette
OLDNEW
« no previous file with comments | « courgette/encoded_program.h ('k') | courgette/encoded_program_fuzz_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698