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

Unified Diff: tools/json_schema_compiler/js_externs_generator.py

Issue 1062573004: [Extension API Extern Generation] Fix a few bugs in extern generation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 | « tools/json_schema_compiler/code_test.py ('k') | tools/json_schema_compiler/js_externs_generator_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/json_schema_compiler/js_externs_generator.py
diff --git a/tools/json_schema_compiler/js_externs_generator.py b/tools/json_schema_compiler/js_externs_generator.py
index 34552a7a888a10fa39c2fb49665c751cb56766ea..99a37a72739f84c2f8588baf587468712a47b3e9 100644
--- a/tools/json_schema_compiler/js_externs_generator.py
+++ b/tools/json_schema_compiler/js_externs_generator.py
@@ -126,7 +126,7 @@ class _Generator(object):
"""Given an OrderedDict of properties, returns a Code containing the
description of an object.
"""
- if not properties: return ''
+ if not properties: return Code()
c = Code()
c.Sblock('{')
@@ -216,7 +216,10 @@ class _Generator(object):
if js_type.property_type in (PropertyType.INTEGER, PropertyType.DOUBLE):
c.Append('number')
elif js_type.property_type is PropertyType.OBJECT:
- c = self._GenerateObjectDefinition(js_type.properties)
+ if js_type.properties:
+ c = self._GenerateObjectDefinition(js_type.properties)
Dan Beam 2015/04/07 01:54:46 this is OK i guess but it might be mildly better i
Devlin 2015/04/07 16:13:27 Yeah, I guess "return Code().Append('foo')" isn't
+ else:
+ c.Append('Object')
elif js_type.property_type is PropertyType.ARRAY:
(c.Append('!Array<').
Concat(self._TypeToJsType(js_type.item_type), new_line=False).
« no previous file with comments | « tools/json_schema_compiler/code_test.py ('k') | tools/json_schema_compiler/js_externs_generator_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698