Chromium Code Reviews| 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..9e22edf7945b924179d5233d088814f3008bcdba 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,19 @@ 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) |
| + if return_type.get('type', '') == 'object' or '$ref' in return_type: |
|
not at google - send to devlin
2013/02/25 18:00:43
the second argument to .get is unnecessary, it's i
benwells
2013/02/26 04:19:07
Done.
|
| + return_type['optional'] = True; |
|
not at google - send to devlin
2013/02/25 18:00:43
Yes it would be much preferable to fix this by ann
benwells
2013/02/26 04:19:07
Yep, that would be nicer. The idl parser doesn't s
|
| 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 +169,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 +237,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' |
|
not at google - send to devlin
2013/02/25 18:00:43
I think we're going to want a way to actually anno
benwells
2013/02/26 04:19:07
Sounds good.
not at google - send to devlin
2013/02/26 05:31:58
which I suppose would just be adding support for [
not at google - send to devlin
2013/02/26 05:54:20
I haven't dealt with it much; my understanding was
|
| elif self.typeref is None: |
| properties['type'] = 'function' |
| else: |