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

Unified Diff: tools/json_schema_compiler/js_externs_generator.py

Issue 1034553003: [Extension API Extern Generation] Fix array, choices specification (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
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 e0a09ff7f270bb4b836f248e33bb605bb91b95bb..beba10e04c5d9bee2dfb4f93bef9e3e296f273b3 100644
--- a/tools/json_schema_compiler/js_externs_generator.py
+++ b/tools/json_schema_compiler/js_externs_generator.py
@@ -180,7 +180,7 @@ class _Generator(object):
elif js_type.property_type is PropertyType.OBJECT:
return 'Object'
elif js_type.property_type is PropertyType.ARRAY:
- return 'Array'
+ return '!Array<%s>' % self._TypeToJsType(js_type.item_type)
elif js_type.property_type is PropertyType.REF:
ref_type = js_type.ref_type
# Enums are defined as chrome.fooAPI.MyEnum, but types are defined simply
@@ -188,6 +188,9 @@ class _Generator(object):
if self._namespace.types[ref_type].property_type is PropertyType.ENUM:
ref_type = 'chrome.%s.%s' % (self._namespace.name, ref_type)
return ref_type
+ elif js_type.property_type is PropertyType.CHOICES:
+ return '(%s)' % '|'.join(
+ [self._TypeToJsType(choice) for choice in js_type.choices])
elif js_type.property_type.is_fundamental:
return js_type.property_type.name
else:

Powered by Google App Engine
This is Rietveld 408576698