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

Unified Diff: tools/json_schema_compiler/idl_schema.py

Issue 12315074: Fix problem with non void return types in extension API IDL. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: asargent's feedback Created 7 years, 10 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/dart_generator.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/json_schema_compiler/idl_schema.py
diff --git a/tools/json_schema_compiler/idl_schema.py b/tools/json_schema_compiler/idl_schema.py
index 8334e7ed8db9b62ca147dd08da568e449f3af3d0..62e0e565df2b00c8b0aace0e7c05c971e437d22c 100644
--- a/tools/json_schema_compiler/idl_schema.py
+++ b/tools/json_schema_compiler/idl_schema.py
@@ -88,7 +88,8 @@ def ProcessComment(comment):
class Callspec(object):
'''
Given a Callspec node representing an IDL function declaration, converts into
- a name/value pair where the value is a list of function parameters.
+ a tuple:
+ (name, list of function parameters, return type)
'''
def __init__(self, callspec_node, comment):
self.node = callspec_node
@@ -96,12 +97,22 @@ class Callspec(object):
def process(self, callbacks):
parameters = []
+ return_type = None
+ if self.node.GetProperty('TYPEREF') not in ('void', None):
+ return_type = Typeref(self.node.GetProperty('TYPEREF'),
+ self.node,
+ {'name': self.node.GetName()}).process(callbacks)
+ # The IDL parser doesn't allow specifying return types as optional.
+ # Instead we infer any object return values to be optional.
+ # TODO(asargent): fix the IDL parser to support optional return types.
+ if return_type.get('type') == 'object' or '$ref' in return_type:
+ return_type['optional'] = True;
for node in self.node.children:
parameter = Param(node).process(callbacks)
if parameter['name'] in self.comment:
parameter['description'] = self.comment[parameter['name']]
parameters.append(parameter)
- return self.node.GetName(), parameters
+ return (self.node.GetName(), parameters, return_type)
class Param(object):
'''
@@ -161,8 +172,11 @@ class Member(object):
properties['description'] = parent_comment
elif node.cls == 'Callspec':
is_function = True
- name, parameters = Callspec(node, parameter_comments).process(callbacks)
+ name, parameters, return_type = (Callspec(node, parameter_comments)
+ .process(callbacks))
properties['parameters'] = parameters
+ if return_type is not None:
+ properties['returns'] = return_type
properties['name'] = name
if is_function:
properties['type'] = 'function'
@@ -226,6 +240,12 @@ class Typeref(object):
elif self.typeref == 'ArrayBuffer':
properties['type'] = 'binary'
properties['isInstanceOf'] = 'ArrayBuffer'
+ elif self.typeref == 'FileEntry':
+ properties['type'] = 'object'
+ properties['isInstanceOf'] = 'FileEntry'
+ if 'additionalProperties' not in properties:
+ properties['additionalProperties'] = OrderedDict()
+ properties['additionalProperties']['type'] = 'any'
elif self.typeref is None:
properties['type'] = 'function'
else:
« no previous file with comments | « tools/json_schema_compiler/dart_generator.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698