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 |