| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/env_var.h" |
| 12 #include "base/logging.h" | 13 #include "base/logging.h" |
| 13 #include "base/sys_info.h" | 14 #include "base/scoped_ptr.h" |
| 15 #include "base/string_util.h" |
| 14 | 16 |
| 15 #include "courgette/courgette.h" | 17 #include "courgette/courgette.h" |
| 16 #include "courgette/streams.h" | 18 #include "courgette/streams.h" |
| 17 | 19 |
| 18 namespace courgette { | 20 namespace courgette { |
| 19 | 21 |
| 20 // Stream indexes. | 22 // Stream indexes. |
| 21 const int kStreamMisc = 0; | 23 const int kStreamMisc = 0; |
| 22 const int kStreamOps = 1; | 24 const int kStreamOps = 1; |
| 23 const int kStreamBytes = 2; | 25 const int kStreamBytes = 2; |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 INCLUDE_REL32_INDEXES = 0x0020, | 259 INCLUDE_REL32_INDEXES = 0x0020, |
| 258 INCLUDE_OPS = 0x0100, | 260 INCLUDE_OPS = 0x0100, |
| 259 INCLUDE_BYTES = 0x0200, | 261 INCLUDE_BYTES = 0x0200, |
| 260 INCLUDE_COPY_COUNTS = 0x0400, | 262 INCLUDE_COPY_COUNTS = 0x0400, |
| 261 INCLUDE_MISC = 0x1000 | 263 INCLUDE_MISC = 0x1000 |
| 262 }; | 264 }; |
| 263 | 265 |
| 264 static FieldSelect GetFieldSelect() { | 266 static FieldSelect GetFieldSelect() { |
| 265 #if 1 | 267 #if 1 |
| 266 // TODO(sra): Use better configuration. | 268 // TODO(sra): Use better configuration. |
| 267 std::wstring s = base::SysInfo::GetEnvVar(L"A_FIELDS"); | 269 scoped_ptr<base::EnvVarGetter> env(base::EnvVarGetter::Create()); |
| 270 std::string s; |
| 271 env->GetEnv("A_FIELDS", &s); |
| 268 if (!s.empty()) { | 272 if (!s.empty()) { |
| 269 return static_cast<FieldSelect>(wcstoul(s.c_str(), 0, 0)); | 273 return static_cast<FieldSelect>(wcstoul(ASCIIToWide(s).c_str(), 0, 0)); |
| 270 } | 274 } |
| 271 #endif | 275 #endif |
| 272 return static_cast<FieldSelect>(~0); | 276 return static_cast<FieldSelect>(~0); |
| 273 } | 277 } |
| 274 | 278 |
| 275 void EncodedProgram::WriteTo(SinkStreamSet* streams) { | 279 void EncodedProgram::WriteTo(SinkStreamSet* streams) { |
| 276 FieldSelect select = GetFieldSelect(); | 280 FieldSelect select = GetFieldSelect(); |
| 277 | 281 |
| 278 // The order of fields must be consistent in WriteTo and ReadFrom, regardless | 282 // The order of fields must be consistent in WriteTo and ReadFrom, regardless |
| 279 // of the streams used. The code can be configured with all kStreamXXX | 283 // of the streams used. The code can be configured with all kStreamXXX |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 if (assembled) | 560 if (assembled) |
| 557 return C_OK; | 561 return C_OK; |
| 558 return C_ASSEMBLY_FAILED; | 562 return C_ASSEMBLY_FAILED; |
| 559 } | 563 } |
| 560 | 564 |
| 561 void DeleteEncodedProgram(EncodedProgram* encoded) { | 565 void DeleteEncodedProgram(EncodedProgram* encoded) { |
| 562 delete encoded; | 566 delete encoded; |
| 563 } | 567 } |
| 564 | 568 |
| 565 } // end namespace | 569 } // end namespace |
| OLD | NEW |