Chromium Code Reviews| 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). |