OLD | NEW |
1 # Copyright (C) 2013 Google Inc. All rights reserved. | 1 # Copyright (C) 2013 Google Inc. All rights reserved. |
2 # | 2 # |
3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
5 # met: | 5 # met: |
6 # | 6 # |
7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 try: | 298 try: |
299 return next(attribute | 299 return next(attribute |
300 for attribute in target_interface.attributes | 300 for attribute in target_interface.attributes |
301 if attribute.name == target_attribute_name) | 301 if attribute.name == target_attribute_name) |
302 except StopIteration: | 302 except StopIteration: |
303 raise Exception('[PutForward] target not found:\n' | 303 raise Exception('[PutForward] target not found:\n' |
304 'Attribute "%s" is not present in interface "%s"' % | 304 'Attribute "%s" is not present in interface "%s"' % |
305 (target_attribute_name, target_interface_name)) | 305 (target_attribute_name, target_interface_name)) |
306 | 306 |
307 extended_attributes = attribute.extended_attributes | 307 extended_attributes = attribute.extended_attributes |
| 308 interface_extended_attributes = interface.extended_attributes |
308 | 309 |
309 if 'PutForwards' in extended_attributes: | 310 if 'PutForwards' in extended_attributes: |
310 # Use target attribute in place of original attribute | 311 # Use target attribute in place of original attribute |
311 attribute = target_attribute() | 312 attribute = target_attribute() |
312 this_cpp_type = 'DartStringAdapter' | 313 this_cpp_type = 'DartStringAdapter' |
313 else: | 314 else: |
314 this_cpp_type = contents['cpp_type'] | 315 this_cpp_type = contents['cpp_type'] |
315 | 316 |
316 idl_type = attribute.idl_type | 317 idl_type = attribute.idl_type |
317 | 318 |
318 # TODO(terry): Should be able to eliminate suppress_setter as we move from | 319 # TODO(terry): Should be able to eliminate suppress_setter as we move from |
319 # IGNORE_MEMBERS to DartSuppress in the IDL. | 320 # IGNORE_MEMBERS to DartSuppress in the IDL. |
320 suppress = (suppress_setter(interface.name, attribute.name) or | 321 suppress = (suppress_setter(interface.name, attribute.name) or |
321 DartUtilities.has_extended_attribute_value(attribute, 'DartSuppr
ess', 'Setter')) | 322 DartUtilities.has_extended_attribute_value(attribute, 'DartSuppr
ess', 'Setter')) |
322 contents.update({ | 323 contents.update({ |
323 'is_setter_suppressed': suppress, | 324 'is_setter_suppressed': suppress, |
324 'setter_lvalue': dart_types.check_reserved_name(attribute.name), | 325 'setter_lvalue': dart_types.check_reserved_name(attribute.name), |
325 'cpp_type': this_cpp_type, | 326 'cpp_type': this_cpp_type, |
326 'local_cpp_type': idl_type.cpp_type_args(attribute.extended_attributes,
used_as_argument=True), | 327 'local_cpp_type': idl_type.cpp_type_args(attribute.extended_attributes,
used_as_argument=True), |
327 'cpp_setter': setter_expression(interface, attribute, contents), | 328 'cpp_setter': setter_expression(interface, attribute, contents), |
328 'dart_value_to_local_cpp_value': | 329 'dart_value_to_local_cpp_value': |
329 attribute.idl_type.dart_value_to_local_cpp_value( | 330 attribute.idl_type.dart_value_to_local_cpp_value( |
330 extended_attributes, attribute.name, False, 1, | 331 interface_extended_attributes, extended_attributes, attribute.na
me, False, 1, |
331 contents['is_auto_scope']), | 332 contents['is_auto_scope']), |
332 }) | 333 }) |
333 | 334 |
334 | 335 |
335 def setter_expression(interface, attribute, contents): | 336 def setter_expression(interface, attribute, contents): |
336 extended_attributes = attribute.extended_attributes | 337 extended_attributes = attribute.extended_attributes |
337 arguments = DartUtilities.call_with_arguments(attribute, extended_attributes
.get('SetterCallWith')) | 338 arguments = DartUtilities.call_with_arguments(attribute, extended_attributes
.get('SetterCallWith')) |
338 | 339 |
339 this_setter_base_name = setter_base_name(interface, attribute, arguments) | 340 this_setter_base_name = setter_base_name(interface, attribute, arguments) |
340 setter_name = DartUtilities.scoped_name(interface, attribute, this_setter_ba
se_name) | 341 setter_name = DartUtilities.scoped_name(interface, attribute, this_setter_ba
se_name) |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 lambda self: DartUtilities.strip_suffix(self.base_type, 'Constructor')) | 450 lambda self: DartUtilities.strip_suffix(self.base_type, 'Constructor')) |
450 | 451 |
451 | 452 |
452 def is_constructor_attribute(attribute): | 453 def is_constructor_attribute(attribute): |
453 # FIXME: replace this with [ConstructorAttribute] extended attribute | 454 # FIXME: replace this with [ConstructorAttribute] extended attribute |
454 return attribute.idl_type.base_type.endswith('Constructor') | 455 return attribute.idl_type.base_type.endswith('Constructor') |
455 | 456 |
456 | 457 |
457 def generate_constructor_getter(interface, attribute, contents): | 458 def generate_constructor_getter(interface, attribute, contents): |
458 contents['needs_constructor_getter_callback'] = contents['measure_as'] or co
ntents['deprecate_as'] | 459 contents['needs_constructor_getter_callback'] = contents['measure_as'] or co
ntents['deprecate_as'] |
OLD | NEW |