OLD | NEW |
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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 if not attribute.is_read_only: | 119 if not attribute.is_read_only: |
120 setter_attr = copy.deepcopy(attribute) | 120 setter_attr = copy.deepcopy(attribute) |
121 setter_attr.is_fc_setter = True | 121 setter_attr.is_fc_setter = True |
122 new_attributes.append(setter_attr) | 122 new_attributes.append(setter_attr) |
123 interface.attributes = new_attributes | 123 interface.attributes = new_attributes |
124 | 124 |
125 # Remove optional annotations from legacy optional arguments. | 125 # Remove optional annotations from legacy optional arguments. |
126 for op in interface.operations: | 126 for op in interface.operations: |
127 for i in range(0, len(op.arguments)): | 127 for i in range(0, len(op.arguments)): |
128 argument = op.arguments[i] | 128 argument = op.arguments[i] |
| 129 |
| 130 in_optional_whitelist = (interface.id, op.id, argument.id) in optional_a
rgument_whitelist |
| 131 if in_optional_whitelist or set(['Optional', 'Callback']).issubset(argum
ent.ext_attrs.keys()): |
| 132 argument.is_optional = True |
| 133 argument.ext_attrs['RequiredCppParameter'] = None |
| 134 continue |
| 135 |
129 if argument.is_optional: | 136 if argument.is_optional: |
130 if 'Optional' in argument.ext_attrs: | 137 if 'Optional' in argument.ext_attrs: |
131 optional_value = argument.ext_attrs['Optional'] | 138 optional_value = argument.ext_attrs['Optional'] |
132 if optional_value: | 139 if optional_value: |
133 if (interface.id, op.id, argument.id) not in optional_argument_whi
telist: | 140 argument.is_optional = False |
134 argument.is_optional = False | 141 del argument.ext_attrs['Optional'] |
135 del argument.ext_attrs['Optional'] | |
136 | 142 |
137 # split operations with optional args into multiple operations | 143 # split operations with optional args into multiple operations |
138 new_ops = [] | 144 new_ops = [] |
139 for op in interface.operations: | 145 for op in interface.operations: |
140 for i in range(0, len(op.arguments)): | 146 for i in range(0, len(op.arguments)): |
141 if op.arguments[i].is_optional: | 147 if op.arguments[i].is_optional: |
142 op.arguments[i].is_optional = False | 148 op.arguments[i].is_optional = False |
143 new_op = copy.deepcopy(op) | 149 new_op = copy.deepcopy(op) |
144 new_op.arguments = new_op.arguments[:i] | 150 new_op.arguments = new_op.arguments[:i] |
145 new_ops.append(new_op) | 151 new_ops.append(new_op) |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 annotation = idl_node.annotations[source] | 606 annotation = idl_node.annotations[source] |
601 for name, value in annotation.items(): | 607 for name, value in annotation.items(): |
602 if (name in top_level_annotation | 608 if (name in top_level_annotation |
603 and value == top_level_annotation[name]): | 609 and value == top_level_annotation[name]): |
604 del annotation[name] | 610 del annotation[name] |
605 | 611 |
606 map(normalize, interface.parents) | 612 map(normalize, interface.parents) |
607 map(normalize, interface.constants) | 613 map(normalize, interface.constants) |
608 map(normalize, interface.attributes) | 614 map(normalize, interface.attributes) |
609 map(normalize, interface.operations) | 615 map(normalize, interface.operations) |
OLD | NEW |