summaryrefslogtreecommitdiffstats
path: root/tools/json_schema_compiler/cc_generator.py
diff options
context:
space:
mode:
authorgdk@chromium.org <gdk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-27 15:59:32 +0000
committergdk@chromium.org <gdk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-27 15:59:32 +0000
commit6cab645ea7d36e82efcb92f82bd4b3f1c7d073e4 (patch)
tree0e8a5fb9ad8dffa7478932c52c07047ae8afb48e /tools/json_schema_compiler/cc_generator.py
parent179295d5ea45c22dc16182ec8ddea262d2bbda0d (diff)
downloadchromium_src-6cab645ea7d36e82efcb92f82bd4b3f1c7d073e4.zip
chromium_src-6cab645ea7d36e82efcb92f82bd4b3f1c7d073e4.tar.gz
chromium_src-6cab645ea7d36e82efcb92f82bd4b3f1c7d073e4.tar.bz2
Allow json_schema_compiler to handle dictionaries with no fields.
In addition, removes a dummy field from the CreateOptions dictionary the Socket API's IDL file. R=miket@chromium.org,asargent@chromium.org BUG=none TEST=none Review URL: http://codereview.chromium.org/10244008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@134277 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/json_schema_compiler/cc_generator.py')
-rw-r--r--tools/json_schema_compiler/cc_generator.py32
1 files changed, 17 insertions, 15 deletions
diff --git a/tools/json_schema_compiler/cc_generator.py b/tools/json_schema_compiler/cc_generator.py
index af81b5a..eaf6fb3 100644
--- a/tools/json_schema_compiler/cc_generator.py
+++ b/tools/json_schema_compiler/cc_generator.py
@@ -181,23 +181,25 @@ class CCGenerator(object):
'(const Value& value, %(name)s* out) {')
.Append('if (!value.IsType(Value::TYPE_DICTIONARY))')
.Append(' return false;')
- .Append('const DictionaryValue* dict = '
+ )
+ if type_.properties:
+ (c.Append('const DictionaryValue* dict = '
'static_cast<const DictionaryValue*>(&value);')
.Append()
- )
- for prop in type_.properties.values():
- c.Concat(self._InitializePropertyToDefault(prop, 'out'))
- for prop in type_.properties.values():
- if prop.type_ == PropertyType.ADDITIONAL_PROPERTIES:
- c.Append('out->additional_properties.MergeDictionary(dict);')
- # remove all keys that are actual properties
- for cur_prop in type_.properties.values():
- if prop != cur_prop:
- c.Append('out->additional_properties'
- '.RemoveWithoutPathExpansion("%s", NULL);' % cur_prop.name)
- c.Append()
- else:
- c.Concat(self._GenerateTypePopulateProperty(prop, 'dict', 'out'))
+ )
+ for prop in type_.properties.values():
+ c.Concat(self._InitializePropertyToDefault(prop, 'out'))
+ for prop in type_.properties.values():
+ if prop.type_ == PropertyType.ADDITIONAL_PROPERTIES:
+ c.Append('out->additional_properties.MergeDictionary(dict);')
+ # remove all keys that are actual properties
+ for cur_prop in type_.properties.values():
+ if prop != cur_prop:
+ c.Append('out->additional_properties'
+ '.RemoveWithoutPathExpansion("%s", NULL);' % cur_prop.name)
+ c.Append()
+ else:
+ c.Concat(self._GenerateTypePopulateProperty(prop, 'dict', 'out'))
(c.Append('return true;')
.Eblock('}')
)