| 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 |
| 11 from generator import * | 11 from generator import * |
| 12 from htmldartgenerator import * | 12 from htmldartgenerator import * |
| 13 from systemhtml import js_support_checks, GetCallbackInfo | 13 from systemhtml import js_support_checks, GetCallbackInfo, HTML_LIBRARY_NAMES |
| 14 | 14 |
| 15 class DartiumBackend(HtmlDartGenerator): | 15 class DartiumBackend(HtmlDartGenerator): |
| 16 """Generates Dart implementation for one DOM IDL interface.""" | 16 """Generates Dart implementation for one DOM IDL interface.""" |
| 17 | 17 |
| 18 def __init__(self, interface, cpp_library_emitter, options): | 18 def __init__(self, interface, cpp_library_emitter, options): |
| 19 super(DartiumBackend, self).__init__(interface, options) | 19 super(DartiumBackend, self).__init__(interface, options) |
| 20 | 20 |
| 21 self._interface = interface | 21 self._interface = interface |
| 22 self._cpp_library_emitter = cpp_library_emitter | 22 self._cpp_library_emitter = cpp_library_emitter |
| 23 self._database = options.database | 23 self._database = options.database |
| (...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 871 return self._type_registry.TypeInfo(type_name) | 871 return self._type_registry.TypeInfo(type_name) |
| 872 | 872 |
| 873 def _DartType(self, type_name): | 873 def _DartType(self, type_name): |
| 874 return self._type_registry.DartType(type_name) | 874 return self._type_registry.DartType(type_name) |
| 875 | 875 |
| 876 | 876 |
| 877 class CPPLibraryEmitter(): | 877 class CPPLibraryEmitter(): |
| 878 def __init__(self, emitters, cpp_sources_dir): | 878 def __init__(self, emitters, cpp_sources_dir): |
| 879 self._emitters = emitters | 879 self._emitters = emitters |
| 880 self._cpp_sources_dir = cpp_sources_dir | 880 self._cpp_sources_dir = cpp_sources_dir |
| 881 self._library_headers = {} | 881 self._library_headers = dict((lib, []) for lib in HTML_LIBRARY_NAMES) |
| 882 self._sources_list = [] | 882 self._sources_list = [] |
| 883 | 883 |
| 884 def CreateHeaderEmitter(self, interface_name, library_name, is_callback=False)
: | 884 def CreateHeaderEmitter(self, interface_name, library_name, is_callback=False)
: |
| 885 path = os.path.join(self._cpp_sources_dir, 'Dart%s.h' % interface_name) | 885 path = os.path.join(self._cpp_sources_dir, 'Dart%s.h' % interface_name) |
| 886 if not is_callback: | 886 if not is_callback: |
| 887 if not library_name in self._library_headers: | |
| 888 self._library_headers[library_name] = [] | |
| 889 self._library_headers[library_name].append(path) | 887 self._library_headers[library_name].append(path) |
| 890 return self._emitters.FileEmitter(path) | 888 return self._emitters.FileEmitter(path) |
| 891 | 889 |
| 892 def CreateSourceEmitter(self, interface_name): | 890 def CreateSourceEmitter(self, interface_name): |
| 893 path = os.path.join(self._cpp_sources_dir, 'Dart%s.cpp' % interface_name) | 891 path = os.path.join(self._cpp_sources_dir, 'Dart%s.cpp' % interface_name) |
| 894 self._sources_list.append(path) | 892 self._sources_list.append(path) |
| 895 return self._emitters.FileEmitter(path) | 893 return self._emitters.FileEmitter(path) |
| 896 | 894 |
| 897 def EmitDerivedSources(self, template, output_dir): | 895 def EmitDerivedSources(self, template, output_dir): |
| 898 partitions = 20 # FIXME: this should be configurable. | 896 partitions = 20 # FIXME: this should be configurable. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 919 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argu
mentCount))\n' | 917 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argu
mentCount))\n' |
| 920 ' return func;\n', | 918 ' return func;\n', |
| 921 CLASS_NAME=os.path.splitext(os.path.basename(path))[0]) | 919 CLASS_NAME=os.path.splitext(os.path.basename(path))[0]) |
| 922 | 920 |
| 923 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): | 921 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): |
| 924 return ( | 922 return ( |
| 925 interface.id.endswith('Event') and | 923 interface.id.endswith('Event') and |
| 926 operation.id.startswith('init') and | 924 operation.id.startswith('init') and |
| 927 argument.ext_attrs.get('Optional') == 'DefaultIsUndefined' and | 925 argument.ext_attrs.get('Optional') == 'DefaultIsUndefined' and |
| 928 argument.type.id == 'DOMString') | 926 argument.type.id == 'DOMString') |
| OLD | NEW |