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

Unified Diff: tools/json_schema_compiler/feature_compiler.py

Issue 2201653003: Revert of Further reduction of feature_compiler.py generated code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@test-with-leiz
Patch Set: 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
« no previous file with comments | « extensions/common/features/simple_feature_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 e408d24cf42d587a26a6b45cc98a6a8b28ceaf84..6afe9eac23af11f3d67187ea917be46a586c36ea 100644
--- a/tools/json_schema_compiler/feature_compiler.py
+++ b/tools/json_schema_compiler/feature_compiler.py
@@ -357,7 +357,8 @@
def GetCode(self, feature_class):
"""Returns the Code object for generating this feature."""
c = Code()
- c.Append('%s* feature = new %s();' % (feature_class, feature_class))
+ c.Append('std::unique_ptr<%s> feature(new %s());' %
+ (feature_class, feature_class))
c.Append('feature->set_name("%s");' % self.name)
for key in sorted(self.feature_values.keys()):
if key in IGNORED_KEYS:
@@ -485,17 +486,19 @@
c.Sblock('{')
feature = self._features[k]
if type(feature) is list:
- c.Append('std::vector<Feature*> features;')
+ c.Append('std::unique_ptr<ComplexFeature::FeatureList> features(')
+ c.Append(' new ComplexFeature::FeatureList());')
for f in feature:
c.Sblock('{')
c.Concat(f.GetCode(self._feature_class))
- c.Append('features.push_back(feature);')
+ c.Append('features->push_back(std::move(feature));')
c.Eblock('}')
- c.Append('ComplexFeature* feature(new ComplexFeature(&features));')
+ c.Append('std::unique_ptr<ComplexFeature> feature(')
+ c.Append(' new ComplexFeature(std::move(features)));')
c.Append('feature->set_name("%s");' % k)
else:
c.Concat(feature.GetCode(self._feature_class))
- c.Append('AddFeature("%s", feature);' % k)
+ c.Append('AddFeature("%s", std::move(feature));' % k)
c.Eblock('}')
c.Eblock('}')
return c
« no previous file with comments | « extensions/common/features/simple_feature_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698