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

Side by Side Diff: lib/dom/scripts/databasebuilder.py

Issue 10521002: Use WebKit IDL syntax for declaring optional parameters in dart.idl. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « lib/dom/idl/dart/dart.idl ('k') | lib/dom/scripts/idlnode.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 2 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
3 # for details. All rights reserved. Use of this source code is governed by a 3 # for details. All rights reserved. Use of this source code is governed by a
4 # BSD-style license that can be found in the LICENSE file. 4 # BSD-style license that can be found in the LICENSE file.
5 5
6 import copy 6 import copy
7 import database 7 import database
8 import idlparser 8 import idlparser
9 import logging 9 import logging
10 import os 10 import os
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 interface.attributes = new_attributes 122 interface.attributes = new_attributes
123 123
124 # Remove optional annotations from legacy optional arguments. 124 # Remove optional annotations from legacy optional arguments.
125 for op in interface.operations: 125 for op in interface.operations:
126 for i in range(0, len(op.arguments)): 126 for i in range(0, len(op.arguments)):
127 argument = op.arguments[i] 127 argument = op.arguments[i]
128 128
129 in_optional_whitelist = (interface.id, op.id, argument.id) in optional_a rgument_whitelist 129 in_optional_whitelist = (interface.id, op.id, argument.id) in optional_a rgument_whitelist
130 if in_optional_whitelist or set(['Optional', 'Callback']).issubset(argum ent.ext_attrs.keys()): 130 if in_optional_whitelist or set(['Optional', 'Callback']).issubset(argum ent.ext_attrs.keys()):
131 argument.is_optional = True 131 argument.is_optional = True
132 argument.ext_attrs['Optional'] = None
132 argument.ext_attrs['RequiredCppParameter'] = None 133 argument.ext_attrs['RequiredCppParameter'] = None
133 continue 134 continue
134 135
135 if argument.is_optional: 136 if 'Optional' in argument.ext_attrs:
136 if 'Optional' in argument.ext_attrs: 137 optional_value = argument.ext_attrs['Optional']
137 optional_value = argument.ext_attrs['Optional'] 138 if optional_value:
138 if optional_value: 139 argument.is_optional = False
139 argument.is_optional = False 140 del argument.ext_attrs['Optional']
140 del argument.ext_attrs['Optional']
141 141
142 # split operations with optional args into multiple operations 142 # split operations with optional args into multiple operations
143 new_ops = [] 143 new_ops = []
144 for op in interface.operations: 144 for op in interface.operations:
145 for i in range(0, len(op.arguments)): 145 for i in range(0, len(op.arguments)):
146 if op.arguments[i].is_optional: 146 if op.arguments[i].is_optional:
147 op.arguments[i].is_optional = False 147 op.arguments[i].is_optional = False
148 new_op = copy.deepcopy(op) 148 new_op = copy.deepcopy(op)
149 new_op.arguments = new_op.arguments[:i] 149 new_op.arguments = new_op.arguments[:i]
150 new_ops.append(new_op) 150 new_ops.append(new_op)
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 annotation = idl_node.annotations[source] 577 annotation = idl_node.annotations[source]
578 for name, value in annotation.items(): 578 for name, value in annotation.items():
579 if (name in top_level_annotation 579 if (name in top_level_annotation
580 and value == top_level_annotation[name]): 580 and value == top_level_annotation[name]):
581 del annotation[name] 581 del annotation[name]
582 582
583 map(normalize, interface.parents) 583 map(normalize, interface.parents)
584 map(normalize, interface.constants) 584 map(normalize, interface.constants)
585 map(normalize, interface.attributes) 585 map(normalize, interface.attributes)
586 map(normalize, interface.operations) 586 map(normalize, interface.operations)
OLDNEW
« no previous file with comments | « lib/dom/idl/dart/dart.idl ('k') | lib/dom/scripts/idlnode.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698