| 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 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 def AddIndexer(self, element_type): | 453 def AddIndexer(self, element_type): |
| 454 self._backend.AddIndexer(element_type) | 454 self._backend.AddIndexer(element_type) |
| 455 | 455 |
| 456 def AmendIndexer(self, element_type): | 456 def AmendIndexer(self, element_type): |
| 457 self._backend.AmendIndexer(element_type) | 457 self._backend.AmendIndexer(element_type) |
| 458 | 458 |
| 459 def AddAttribute(self, attribute, is_secondary=False): | 459 def AddAttribute(self, attribute, is_secondary=False): |
| 460 dom_name = DartDomNameOfAttribute(attribute) | 460 dom_name = DartDomNameOfAttribute(attribute) |
| 461 html_name = self._renamer.RenameMember( | 461 html_name = self._renamer.RenameMember( |
| 462 self._interface.id, dom_name, 'get:') | 462 self._interface.id, dom_name, 'get:') |
| 463 if not html_name or self._IsPrivate(html_name): | 463 if not html_name: |
| 464 return | 464 return |
| 465 | 465 |
| 466 | |
| 467 html_setter_name = self._renamer.RenameMember( | 466 html_setter_name = self._renamer.RenameMember( |
| 468 self._interface.id, dom_name, 'set:') | 467 self._interface.id, dom_name, 'set:') |
| 469 read_only = (attribute.is_read_only or 'Replaceable' in attribute.ext_attrs | 468 read_only = (attribute.is_read_only or 'Replaceable' in attribute.ext_attrs |
| 470 or not html_setter_name) | 469 or not html_setter_name) |
| 471 | 470 |
| 472 # We don't yet handle inconsistent renames of the getter and setter yet. | 471 if not self._IsPrivate(html_name): |
| 473 assert(not html_setter_name or html_name == html_setter_name) | |
| 474 | 472 |
| 475 if not is_secondary: | 473 # We don't yet handle inconsistent renames of the getter and setter yet. |
| 476 self._members_emitter.Emit('\n /** @domName $DOMINTERFACE.$DOMNAME */', | 474 assert(not html_setter_name or html_name == html_setter_name) |
| 477 DOMINTERFACE=attribute.doc_js_interface_name, | |
| 478 DOMNAME=dom_name) | |
| 479 if read_only: | |
| 480 template = '\n abstract $TYPE get $NAME;\n' | |
| 481 else: | |
| 482 template = '\n $TYPE $NAME;\n' | |
| 483 | 475 |
| 484 self._members_emitter.Emit(template, | 476 if not is_secondary: |
| 485 NAME=html_name, | 477 self._members_emitter.Emit('\n /** @domName $DOMINTERFACE.$DOMNAME */', |
| 486 TYPE=SecureOutputType(self, attribute.type.id)) | 478 DOMINTERFACE=attribute.doc_js_interface_name, |
| 479 DOMNAME=dom_name) |
| 480 if read_only: |
| 481 template = '\n abstract $TYPE get $NAME;\n' |
| 482 else: |
| 483 template = '\n $TYPE $NAME;\n' |
| 484 |
| 485 self._members_emitter.Emit(template, |
| 486 NAME=html_name, |
| 487 TYPE=SecureOutputType(self, attribute.type.id)
) |
| 487 | 488 |
| 488 self._backend.AddAttribute(attribute, html_name, read_only) | 489 self._backend.AddAttribute(attribute, html_name, read_only) |
| 489 | 490 |
| 490 def AddSecondaryAttribute(self, interface, attribute): | 491 def AddSecondaryAttribute(self, interface, attribute): |
| 491 self._backend.SecondaryContext(interface) | 492 self._backend.SecondaryContext(interface) |
| 492 self.AddAttribute(attribute, True) | 493 self.AddAttribute(attribute, True) |
| 493 | 494 |
| 494 def AddOperation(self, info, skip_declaration=False): | 495 def AddOperation(self, info, skip_declaration=False): |
| 495 """ | 496 """ |
| 496 Arguments: | 497 Arguments: |
| (...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1125 | 1126 |
| 1126 library_emitter = self._multiemitter.FileEmitter(library_file_path) | 1127 library_emitter = self._multiemitter.FileEmitter(library_file_path) |
| 1127 library_file_dir = os.path.dirname(library_file_path) | 1128 library_file_dir = os.path.dirname(library_file_path) |
| 1128 auxiliary_dir = os.path.relpath(auxiliary_dir, library_file_dir) | 1129 auxiliary_dir = os.path.relpath(auxiliary_dir, library_file_dir) |
| 1129 imports_emitter = library_emitter.Emit( | 1130 imports_emitter = library_emitter.Emit( |
| 1130 self._template, AUXILIARY_DIR=massage_path(auxiliary_dir)) | 1131 self._template, AUXILIARY_DIR=massage_path(auxiliary_dir)) |
| 1131 for path in sorted(self._path_to_emitter.keys()): | 1132 for path in sorted(self._path_to_emitter.keys()): |
| 1132 relpath = os.path.relpath(path, library_file_dir) | 1133 relpath = os.path.relpath(path, library_file_dir) |
| 1133 imports_emitter.Emit( | 1134 imports_emitter.Emit( |
| 1134 "#source('$PATH');\n", PATH=massage_path(relpath)) | 1135 "#source('$PATH');\n", PATH=massage_path(relpath)) |
| OLD | NEW |