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 the systems to generate | 6 """This module provides shared functionality for the systems to generate |
7 native binding from the IDL database.""" | 7 native binding from the IDL database.""" |
8 | 8 |
9 import emitter | 9 import emitter |
10 import os | 10 import os |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 IS_EVENT_TARGET=TypeCheckHelper(is_event_target_test), | 273 IS_EVENT_TARGET=TypeCheckHelper(is_event_target_test), |
274 TO_NATIVE=to_native_emitter.Fragments(), | 274 TO_NATIVE=to_native_emitter.Fragments(), |
275 TO_DART=to_dart_emitter.Fragments()) | 275 TO_DART=to_dart_emitter.Fragments()) |
276 | 276 |
277 def EmitAttribute(self, attribute, html_name, read_only): | 277 def EmitAttribute(self, attribute, html_name, read_only): |
278 self._AddGetter(attribute, html_name) | 278 self._AddGetter(attribute, html_name) |
279 if not read_only: | 279 if not read_only: |
280 self._AddSetter(attribute, html_name) | 280 self._AddSetter(attribute, html_name) |
281 | 281 |
282 def _AddGetter(self, attr, html_name): | 282 def _AddGetter(self, attr, html_name): |
| 283 # Temporary hack to force dart:scalarlist clamped array for ImageData.data. |
| 284 # TODO(antonm): solve in principled way. |
| 285 if self._interface.id == 'ImageData' and html_name == 'data': |
| 286 html_name = '_data' |
283 type_info = self._TypeInfo(attr.type.id) | 287 type_info = self._TypeInfo(attr.type.id) |
284 dart_declaration = '%s get %s' % ( | 288 dart_declaration = '%s get %s' % ( |
285 self.SecureOutputType(attr.type.id), html_name) | 289 self.SecureOutputType(attr.type.id), html_name) |
286 is_custom = 'Custom' in attr.ext_attrs or 'CustomGetter' in attr.ext_attrs | 290 is_custom = 'Custom' in attr.ext_attrs or 'CustomGetter' in attr.ext_attrs |
287 cpp_callback_name = self._GenerateNativeBinding(attr.id, 1, | 291 cpp_callback_name = self._GenerateNativeBinding(attr.id, 1, |
288 dart_declaration, 'Getter', is_custom) | 292 dart_declaration, 'Getter', is_custom) |
289 if is_custom: | 293 if is_custom: |
290 return | 294 return |
291 | 295 |
292 if 'Reflect' in attr.ext_attrs: | 296 if 'Reflect' in attr.ext_attrs: |
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
868 LIBRARY_NAME=library_name) | 872 LIBRARY_NAME=library_name) |
869 | 873 |
870 headers = self._library_headers[library_name] | 874 headers = self._library_headers[library_name] |
871 for header_file in headers: | 875 for header_file in headers: |
872 path = os.path.relpath(header_file, output_dir) | 876 path = os.path.relpath(header_file, output_dir) |
873 includes_emitter.Emit('#include "$PATH"\n', PATH=path) | 877 includes_emitter.Emit('#include "$PATH"\n', PATH=path) |
874 body_emitter.Emit( | 878 body_emitter.Emit( |
875 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argu
mentCount))\n' | 879 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argu
mentCount))\n' |
876 ' return func;\n', | 880 ' return func;\n', |
877 CLASS_NAME=os.path.splitext(os.path.basename(path))[0]) | 881 CLASS_NAME=os.path.splitext(os.path.basename(path))[0]) |
OLD | NEW |