Commit ff458d8a authored by Dave Tapuska's avatar Dave Tapuska Committed by Commit Bot

Fix extensions generation code causing shadowed variables.

value is usually defined as a variable on the json class so it
causes a shadowed variable. Rename the variable on the stack to
to_value_result this name is unique enough it doesn't cause shadowed
variables.

BUG=794619

Change-Id: I43bb753d1fdec6871386881641a3d59ab010d475
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1786582Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Cr-Commit-Position: refs/heads/master@{#693891}
parent 3da8ec10
......@@ -444,7 +444,7 @@ class _Generator(object):
c = Code()
(c.Sblock('std::unique_ptr<base::DictionaryValue> %s::ToValue() const {' %
cpp_namespace)
.Append('std::unique_ptr<base::DictionaryValue> value('
.Append('std::unique_ptr<base::DictionaryValue> to_value_result('
'new base::DictionaryValue());')
.Append()
)
......@@ -470,7 +470,7 @@ class _Generator(object):
# it will always be a pointer.
is_ptr = prop.optional or prop.type_.property_type == PropertyType.ANY
c.Cblock(self._CreateValueFromType(
'value->SetWithoutPathExpansion("%s", %%s);' % prop.name,
'to_value_result->SetWithoutPathExpansion("%s", %%s);' % prop.name,
prop.name,
prop.type_,
prop_var,
......@@ -481,11 +481,11 @@ class _Generator(object):
if type_.additional_properties is not None:
if type_.additional_properties.property_type == PropertyType.ANY:
c.Append('value->MergeDictionary(&additional_properties);')
c.Append('to_value_result->MergeDictionary(&additional_properties);')
else:
(c.Sblock('for (const auto& it : additional_properties) {')
.Cblock(self._CreateValueFromType(
'value->SetWithoutPathExpansion(it.first, %s);',
'to_value_result->SetWithoutPathExpansion(it.first, %s);',
type_.additional_properties.name,
type_.additional_properties,
'it.second'))
......@@ -493,7 +493,7 @@ class _Generator(object):
)
return (c.Append()
.Append('return value;')
.Append('return to_value_result;')
.Eblock('}'))
def _GenerateChoiceTypeToValue(self, cpp_namespace, type_):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment