| 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 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 ' }\n', | 406 ' }\n', |
| 407 EVENTS_CLASS=events_class) | 407 EVENTS_CLASS=events_class) |
| 408 | 408 |
| 409 def _ImplClassName(self, interface_name): | 409 def _ImplClassName(self, interface_name): |
| 410 return '_%sImpl' % interface_name | 410 return '_%sImpl' % interface_name |
| 411 | 411 |
| 412 def _DartType(self, idl_type): | 412 def _DartType(self, idl_type): |
| 413 return self._html_system.DartType(idl_type) | 413 return self._html_system.DartType(idl_type) |
| 414 | 414 |
| 415 def _BaseClassName(self): | 415 def _BaseClassName(self): |
| 416 root_class = 'NativeFieldWrapperClass1' |
| 417 |
| 416 if not self._interface.parents: | 418 if not self._interface.parents: |
| 417 return '_DOMWrapperBase' | 419 return root_class |
| 418 | 420 |
| 419 supertype = self._interface.parents[0].type.id | 421 supertype = self._interface.parents[0].type.id |
| 420 | 422 |
| 421 if IsPureInterface(supertype): # The class is a root. | 423 if IsPureInterface(supertype): # The class is a root. |
| 422 return '_DOMWrapperBase' | 424 return root_class |
| 423 | 425 |
| 424 # FIXME: We're currently injecting List<..> and EventTarget as | 426 # FIXME: We're currently injecting List<..> and EventTarget as |
| 425 # supertypes in dart.idl. We should annotate/preserve as | 427 # supertypes in dart.idl. We should annotate/preserve as |
| 426 # attributes instead. For now, this hack lets the self._interfaces | 428 # attributes instead. For now, this hack lets the self._interfaces |
| 427 # inherit, but not the classes. | 429 # inherit, but not the classes. |
| 428 # List methods are injected in AddIndexer. | 430 # List methods are injected in AddIndexer. |
| 429 if IsDartListType(supertype) or IsDartCollectionType(supertype): | 431 if IsDartListType(supertype) or IsDartCollectionType(supertype): |
| 430 return '_DOMWrapperBase' | 432 return root_class |
| 431 | 433 |
| 432 if supertype == 'EventTarget': | 434 if supertype == 'EventTarget': |
| 433 # Most implementors of EventTarget specify the EventListener operations | 435 # Most implementors of EventTarget specify the EventListener operations |
| 434 # again. If the operations are not specified, try to inherit from the | 436 # again. If the operations are not specified, try to inherit from the |
| 435 # EventTarget implementation. | 437 # EventTarget implementation. |
| 436 # | 438 # |
| 437 # Applies to MessagePort. | 439 # Applies to MessagePort. |
| 438 if not [op for op in self._interface.operations if op.id == 'addEventListe
ner']: | 440 if not [op for op in self._interface.operations if op.id == 'addEventListe
ner']: |
| 439 return self._ImplClassName(supertype) | 441 return self._ImplClassName(supertype) |
| 440 return '_DOMWrapperBase' | 442 return root_class |
| 441 | 443 |
| 442 return self._ImplClassName(supertype) | 444 return self._ImplClassName(supertype) |
| 443 | 445 |
| 444 def _HTMLInterfaceName(self, interface_name): | 446 def _HTMLInterfaceName(self, interface_name): |
| 445 return self._html_renames.get(interface_name, interface_name) | 447 return self._html_renames.get(interface_name, interface_name) |
| 446 | 448 |
| 447 def _IsConstructable(self): | 449 def _IsConstructable(self): |
| 448 # FIXME: support ConstructorTemplate. | 450 # FIXME: support ConstructorTemplate. |
| 449 return set(['CustomConstructor', 'V8CustomConstructor', 'Constructor', 'Name
dConstructor']) & set(self._interface.ext_attrs) | 451 return set(['CustomConstructor', 'V8CustomConstructor', 'Constructor', 'Name
dConstructor']) & set(self._interface.ext_attrs) |
| 450 | 452 |
| (...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1089 | 1091 |
| 1090 def _IsArgumentOptionalInWebCore(argument): | 1092 def _IsArgumentOptionalInWebCore(argument): |
| 1091 return IsOptional(argument) and not 'Callback' in argument.ext_attrs | 1093 return IsOptional(argument) and not 'Callback' in argument.ext_attrs |
| 1092 | 1094 |
| 1093 def _ToWebKitName(name): | 1095 def _ToWebKitName(name): |
| 1094 name = name[0].lower() + name[1:] | 1096 name = name[0].lower() + name[1:] |
| 1095 name = re.sub(r'^(hTML|uRL|jS|xML|xSLT)', lambda s: s.group(1).lower(), | 1097 name = re.sub(r'^(hTML|uRL|jS|xML|xSLT)', lambda s: s.group(1).lower(), |
| 1096 name) | 1098 name) |
| 1097 return re.sub(r'^(create|exclusive)', lambda s: 'is' + s.group(1).capitalize()
, | 1099 return re.sub(r'^(create|exclusive)', lambda s: 'is' + s.group(1).capitalize()
, |
| 1098 name) | 1100 name) |
| OLD | NEW |