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 system to generate | 6 """This module provides shared functionality for the system to generate |
7 Dart:html APIs from the IDL database.""" | 7 Dart:html APIs from the IDL database.""" |
8 | 8 |
9 import emitter | 9 import emitter |
10 import os | 10 import os |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 def ConstructorInfo(self, interface_name): | 77 def ConstructorInfo(self, interface_name): |
78 info = OperationInfo() | 78 info = OperationInfo() |
79 info.overloads = None | 79 info.overloads = None |
80 info.declared_name = interface_name | 80 info.declared_name = interface_name |
81 info.name = interface_name | 81 info.name = interface_name |
82 info.constructor_name = self.name | 82 info.constructor_name = self.name |
83 info.js_name = None | 83 info.js_name = None |
84 info.type_name = interface_name | 84 info.type_name = interface_name |
85 info.param_infos = map(lambda tXn: ParamInfo(tXn[1], tXn[0], True), | 85 info.param_infos = map(lambda tXn: ParamInfo(tXn[1], tXn[0], True), |
86 self.opt_params) | 86 self.opt_params) |
| 87 info.requires_named_arguments = True |
87 return info | 88 return info |
88 | 89 |
89 _html_element_constructors = { | 90 _html_element_constructors = { |
90 'AnchorElement' : | 91 'AnchorElement' : |
91 ElementConstructorInfo(tag='a', opt_params=[('DOMString', 'href')]), | 92 ElementConstructorInfo(tag='a', opt_params=[('DOMString', 'href')]), |
92 'AreaElement': 'area', | 93 'AreaElement': 'area', |
93 'ButtonElement': 'button', | 94 'ButtonElement': 'button', |
94 'BRElement': 'br', | 95 'BRElement': 'br', |
95 'BaseElement': 'base', | 96 'BaseElement': 'base', |
96 'BodyElement': 'body', | 97 'BodyElement': 'body', |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 '\n' | 179 '\n' |
179 ' static $RETURN_TYPE $CONSTRUCTOR($PARAMS) {\n' | 180 ' static $RETURN_TYPE $CONSTRUCTOR($PARAMS) {\n' |
180 ' $CLASS _e = _document.$dom_createElement("$TAG");\n' | 181 ' $CLASS _e = _document.$dom_createElement("$TAG");\n' |
181 '$!INITS' | 182 '$!INITS' |
182 ' return _e;\n' | 183 ' return _e;\n' |
183 ' }\n', | 184 ' }\n', |
184 RETURN_TYPE=rename_type(constructor_info.type_name), | 185 RETURN_TYPE=rename_type(constructor_info.type_name), |
185 CONSTRUCTOR=constructor_info.ConstructorFactoryName(rename_type), | 186 CONSTRUCTOR=constructor_info.ConstructorFactoryName(rename_type), |
186 CLASS=class_name, | 187 CLASS=class_name, |
187 TAG=info.tag, | 188 TAG=info.tag, |
188 PARAMS=constructor_info.ParametersInterfaceDeclaration(rename_type)) | 189 PARAMS=constructor_info.ParametersInterfaceDeclaration( |
| 190 rename_type, force_optional=True)) |
189 for param in constructor_info.param_infos: | 191 for param in constructor_info.param_infos: |
190 inits.Emit(' if ($E != null) _e.$E = $E;\n', E=param.name) | 192 inits.Emit(' if ($E != null) _e.$E = $E;\n', E=param.name) |
191 | 193 |
192 # ------------------------------------------------------------------------------ | 194 # ------------------------------------------------------------------------------ |
193 | 195 |
194 class HtmlDartInterfaceGenerator(object): | 196 class HtmlDartInterfaceGenerator(object): |
195 """Generates dart interface and implementation for the DOM IDL interface.""" | 197 """Generates dart interface and implementation for the DOM IDL interface.""" |
196 | 198 |
197 def __init__(self, options, library_emitter, event_generator, interface, | 199 def __init__(self, options, library_emitter, event_generator, interface, |
198 backend): | 200 backend): |
(...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1122 | 1124 |
1123 library_emitter = self._multiemitter.FileEmitter(library_file_path) | 1125 library_emitter = self._multiemitter.FileEmitter(library_file_path) |
1124 library_file_dir = os.path.dirname(library_file_path) | 1126 library_file_dir = os.path.dirname(library_file_path) |
1125 auxiliary_dir = os.path.relpath(auxiliary_dir, library_file_dir) | 1127 auxiliary_dir = os.path.relpath(auxiliary_dir, library_file_dir) |
1126 imports_emitter = library_emitter.Emit( | 1128 imports_emitter = library_emitter.Emit( |
1127 self._template, AUXILIARY_DIR=massage_path(auxiliary_dir)) | 1129 self._template, AUXILIARY_DIR=massage_path(auxiliary_dir)) |
1128 for path in sorted(self._path_to_emitter.keys()): | 1130 for path in sorted(self._path_to_emitter.keys()): |
1129 relpath = os.path.relpath(path, library_file_dir) | 1131 relpath = os.path.relpath(path, library_file_dir) |
1130 imports_emitter.Emit( | 1132 imports_emitter.Emit( |
1131 "#source('$PATH');\n", PATH=massage_path(relpath)) | 1133 "#source('$PATH');\n", PATH=massage_path(relpath)) |
OLD | NEW |