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

Unified Diff: tools/json_schema_compiler/feature_compiler.py

Issue 2193693003: Further reduction of feature_compiler.py generated code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@test-with-leiz
Patch Set: tests Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: tools/json_schema_compiler/feature_compiler.py
diff --git a/tools/json_schema_compiler/feature_compiler.py b/tools/json_schema_compiler/feature_compiler.py
index 6afe9eac23af11f3d67187ea917be46a586c36ea..099fdc43d3ca805100768f2ec8732139b2f9fbbb 100644
--- a/tools/json_schema_compiler/feature_compiler.py
+++ b/tools/json_schema_compiler/feature_compiler.py
@@ -357,8 +357,7 @@ class Feature(object):
def GetCode(self, feature_class):
"""Returns the Code object for generating this feature."""
c = Code()
- c.Append('std::unique_ptr<%s> feature(new %s());' %
- (feature_class, feature_class))
+ c.Append('%s* feature(new %s());' % (feature_class, feature_class))
Devlin 2016/07/29 21:15:02 optional nit: Usually we use assignment rather tha
scottmg 2016/07/29 21:28:45 Done.
c.Append('feature->set_name("%s");' % self.name)
for key in sorted(self.feature_values.keys()):
if key in IGNORED_KEYS:
@@ -486,19 +485,17 @@ class FeatureCompiler(object):
c.Sblock('{')
feature = self._features[k]
if type(feature) is list:
- c.Append('std::unique_ptr<ComplexFeature::FeatureList> features(')
- c.Append(' new ComplexFeature::FeatureList());')
+ c.Append('std::vector<Feature*> features;')
for f in feature:
c.Sblock('{')
c.Concat(f.GetCode(self._feature_class))
- c.Append('features->push_back(std::move(feature));')
+ c.Append('features.push_back(feature);')
c.Eblock('}')
- c.Append('std::unique_ptr<ComplexFeature> feature(')
- c.Append(' new ComplexFeature(std::move(features)));')
+ c.Append('ComplexFeature* feature(new ComplexFeature(features));')
c.Append('feature->set_name("%s");' % k)
else:
c.Concat(feature.GetCode(self._feature_class))
- c.Append('AddFeature("%s", std::move(feature));' % k)
+ c.Append('AddFeature("%s", feature);' % k)
c.Eblock('}')
c.Eblock('}')
return c

Powered by Google App Engine
This is Rietveld 408576698