| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 2 # Copyright (c) 2012, 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 """This module provides shared functionality for systems to generate | 6 """This module provides shared functionality for systems to generate |
| 7 Dart APIs from the IDL database.""" | 7 Dart APIs from the IDL database.""" |
| 8 | 8 |
| 9 import re | 9 import re |
| 10 | 10 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 if element_type: | 101 if element_type: |
| 102 return element_type | 102 return element_type |
| 103 return None | 103 return None |
| 104 | 104 |
| 105 def MaybeTypedArrayElementType(interface): | 105 def MaybeTypedArrayElementType(interface): |
| 106 """Returns the typed array element type, or None in interface is not a | 106 """Returns the typed array element type, or None in interface is not a |
| 107 TypedArray. | 107 TypedArray. |
| 108 """ | 108 """ |
| 109 # Typed arrays implement ArrayBufferView and List<T>. | 109 # Typed arrays implement ArrayBufferView and List<T>. |
| 110 for parent in interface.parents: | 110 for parent in interface.parents: |
| 111 if parent.type.id == 'ArrayBufferView': | 111 if parent.type.id == 'ArrayBufferView': |
| 112 return MaybeListElementType(interface) | 112 return MaybeListElementType(interface) |
| 113 return None | 113 return None |
| 114 | 114 |
| 115 def MaybeTypedArrayElementTypeInHierarchy(interface, database): |
| 116 """Returns the typed array element type, or None in interface is not a |
| 117 TypedArray. Checks the whole parent hierarchy. |
| 118 """ |
| 119 element_type = MaybeTypedArrayElementType(interface) |
| 120 if element_type: |
| 121 return element_type |
| 122 for parent in interface.parents: |
| 123 if database.HasInterface(parent.type.id): |
| 124 parent_interface = database.GetInterface(parent.type.id) |
| 125 element_type = MaybeTypedArrayElementType(parent_interface) |
| 126 if element_type: |
| 127 return element_type |
| 128 |
| 129 return None |
| 130 |
| 115 def MakeNativeSpec(javascript_binding_name): | 131 def MakeNativeSpec(javascript_binding_name): |
| 116 if javascript_binding_name in _frog_dom_custom_native_specs: | 132 if javascript_binding_name in _frog_dom_custom_native_specs: |
| 117 return _frog_dom_custom_native_specs[javascript_binding_name] | 133 return _frog_dom_custom_native_specs[javascript_binding_name] |
| 118 else: | 134 else: |
| 119 # Make the class 'hidden' so it is dynamically patched at runtime. This | 135 # Make the class 'hidden' so it is dynamically patched at runtime. This |
| 120 # is useful not only for browser compat, but to allow code that links | 136 # is useful not only for browser compat, but to allow code that links |
| 121 # against dart:dom to load in a worker isolate. | 137 # against dart:dom to load in a worker isolate. |
| 122 return '*' + javascript_binding_name | 138 return '*' + javascript_binding_name |
| 123 | 139 |
| 124 | 140 |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 '"SVGAnimatedListPropertyTearOff.h"', | 730 '"SVGAnimatedListPropertyTearOff.h"', |
| 715 '"SVGTransformListPropertyTearOff.h"', | 731 '"SVGTransformListPropertyTearOff.h"', |
| 716 '"SVGPathSegListPropertyTearOff.h"', | 732 '"SVGPathSegListPropertyTearOff.h"', |
| 717 ] | 733 ] |
| 718 | 734 |
| 719 def GetIDLTypeInfo(idl_type_name): | 735 def GetIDLTypeInfo(idl_type_name): |
| 720 match = re.match(r'sequence<(\w+)>$', idl_type_name) | 736 match = re.match(r'sequence<(\w+)>$', idl_type_name) |
| 721 if match: | 737 if match: |
| 722 return SequenceIDLTypeInfo(idl_type_name, GetIDLTypeInfo(match.group(1))) | 738 return SequenceIDLTypeInfo(idl_type_name, GetIDLTypeInfo(match.group(1))) |
| 723 return _idl_type_registry.get(idl_type_name, IDLTypeInfo(idl_type_name)) | 739 return _idl_type_registry.get(idl_type_name, IDLTypeInfo(idl_type_name)) |
| OLD | NEW |