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

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

Issue 10517004: Move splitting operations with optional arguments to generator. (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 | « no previous file | lib/dom/scripts/generator.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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 continue 114 continue
115 getter_attr = copy.deepcopy(attribute) 115 getter_attr = copy.deepcopy(attribute)
116 getter_attr.is_fc_getter = True 116 getter_attr.is_fc_getter = True
117 new_attributes.append(getter_attr) 117 new_attributes.append(getter_attr)
118 if not attribute.is_read_only: 118 if not attribute.is_read_only:
119 setter_attr = copy.deepcopy(attribute) 119 setter_attr = copy.deepcopy(attribute)
120 setter_attr.is_fc_setter = True 120 setter_attr.is_fc_setter = True
121 new_attributes.append(setter_attr) 121 new_attributes.append(setter_attr)
122 interface.attributes = new_attributes 122 interface.attributes = new_attributes
123 123
124 # Remove optional annotations from legacy optional arguments. 124 # Add 'Optional' attribute to whitelisted arguments.
125 for op in interface.operations: 125 for op in interface.operations:
126 for i in range(0, len(op.arguments)): 126 for argument in op.arguments:
127 argument = op.arguments[i]
128
129 in_optional_whitelist = (interface.id, op.id, argument.id) in optional_a rgument_whitelist 127 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()): 128 if in_optional_whitelist or set(['Optional', 'Callback']).issubset(argum ent.ext_attrs.keys()):
131 argument.is_optional = True
132 argument.ext_attrs['Optional'] = None 129 argument.ext_attrs['Optional'] = None
133 argument.ext_attrs['RequiredCppParameter'] = None 130 argument.ext_attrs['RequiredCppParameter'] = None
134 continue
135
136 if 'Optional' in argument.ext_attrs:
137 optional_value = argument.ext_attrs['Optional']
138 if optional_value:
139 argument.is_optional = False
140 del argument.ext_attrs['Optional']
141
142 # split operations with optional args into multiple operations
143 new_ops = []
144 for op in interface.operations:
145 for i in range(0, len(op.arguments)):
146 if op.arguments[i].is_optional:
147 op.arguments[i].is_optional = False
148 new_op = copy.deepcopy(op)
149 new_op.arguments = new_op.arguments[:i]
150 new_ops.append(new_op)
151 new_ops.append(op)
152 interface.operations = new_ops
153 131
154 def _rename_types(self, idl_file, import_options): 132 def _rename_types(self, idl_file, import_options):
155 """Rename interface and type names with names provided in the 133 """Rename interface and type names with names provided in the
156 options. Also clears scopes from scoped names""" 134 options. Also clears scopes from scoped names"""
157 135
158 def rename(name): 136 def rename(name):
159 name_parts = name.split('::') 137 name_parts = name.split('::')
160 name = name_parts[-1] 138 name = name_parts[-1]
161 if name in import_options.type_rename_map: 139 if name in import_options.type_rename_map:
162 name = import_options.type_rename_map[name] 140 name = import_options.type_rename_map[name]
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 annotation = idl_node.annotations[source] 555 annotation = idl_node.annotations[source]
578 for name, value in annotation.items(): 556 for name, value in annotation.items():
579 if (name in top_level_annotation 557 if (name in top_level_annotation
580 and value == top_level_annotation[name]): 558 and value == top_level_annotation[name]):
581 del annotation[name] 559 del annotation[name]
582 560
583 map(normalize, interface.parents) 561 map(normalize, interface.parents)
584 map(normalize, interface.constants) 562 map(normalize, interface.constants)
585 map(normalize, interface.attributes) 563 map(normalize, interface.attributes)
586 map(normalize, interface.operations) 564 map(normalize, interface.operations)
OLDNEW
« no previous file with comments | « no previous file | lib/dom/scripts/generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698