| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 import argparse | 5 import argparse |
| 6 import copy | 6 import copy |
| 7 from datetime import datetime | 7 from datetime import datetime |
| 8 import os | 8 import os |
| 9 | 9 |
| 10 from code import Code | 10 from code import Code |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 for f in feature: | 491 for f in feature: |
| 492 c.Sblock('{') | 492 c.Sblock('{') |
| 493 c.Concat(f.GetCode(self._feature_class)) | 493 c.Concat(f.GetCode(self._feature_class)) |
| 494 c.Append('features->push_back(std::move(feature));') | 494 c.Append('features->push_back(std::move(feature));') |
| 495 c.Eblock('}') | 495 c.Eblock('}') |
| 496 c.Append('std::unique_ptr<ComplexFeature> feature(') | 496 c.Append('std::unique_ptr<ComplexFeature> feature(') |
| 497 c.Append(' new ComplexFeature(std::move(features)));') | 497 c.Append(' new ComplexFeature(std::move(features)));') |
| 498 c.Append('feature->set_name("%s");' % k) | 498 c.Append('feature->set_name("%s");' % k) |
| 499 else: | 499 else: |
| 500 c.Concat(feature.GetCode(self._feature_class)) | 500 c.Concat(feature.GetCode(self._feature_class)) |
| 501 c.Append('features_["%s"] = std::move(feature);' % k) | 501 c.Append('AddFeature("%s", std::move(feature));' % k) |
| 502 c.Eblock('}') | 502 c.Eblock('}') |
| 503 c.Eblock('}') | 503 c.Eblock('}') |
| 504 return c | 504 return c |
| 505 | 505 |
| 506 def Write(self): | 506 def Write(self): |
| 507 """Writes the output.""" | 507 """Writes the output.""" |
| 508 header_file_path = self._out_base_filename + '.h' | 508 header_file_path = self._out_base_filename + '.h' |
| 509 cc_file_path = self._out_base_filename + '.cc' | 509 cc_file_path = self._out_base_filename + '.cc' |
| 510 substitutions = ({ | 510 substitutions = ({ |
| 511 'header_file_path': header_file_path, | 511 'header_file_path': header_file_path, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 'out_base_filename', type=str, | 551 'out_base_filename', type=str, |
| 552 help='The base filename for the C++ files (.h and .cc will be appended)') | 552 help='The base filename for the C++ files (.h and .cc will be appended)') |
| 553 parser.add_argument('source_files', type=str, nargs='+', | 553 parser.add_argument('source_files', type=str, nargs='+', |
| 554 help='The source features.json files') | 554 help='The source features.json files') |
| 555 args = parser.parse_args() | 555 args = parser.parse_args() |
| 556 c = FeatureCompiler(args.chrome_root, args.source_files, args.feature_class, | 556 c = FeatureCompiler(args.chrome_root, args.source_files, args.feature_class, |
| 557 args.provider_class, args.out_root, | 557 args.provider_class, args.out_root, |
| 558 args.out_base_filename) | 558 args.out_base_filename) |
| 559 c.Compile() | 559 c.Compile() |
| 560 c.Write() | 560 c.Write() |
| OLD | NEW |