Chromium Code Reviews| 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 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 348 '\n' | 348 '\n' |
| 349 ' $EVENTS_CLASS get on() {\n' | 349 ' $EVENTS_CLASS get on() {\n' |
| 350 ' if (_on === null) _on = new $EVENTS_CLASS(this);\n' | 350 ' if (_on === null) _on = new $EVENTS_CLASS(this);\n' |
| 351 ' return _on;\n' | 351 ' return _on;\n' |
| 352 ' }\n', | 352 ' }\n', |
| 353 EVENTS_CLASS=events_class) | 353 EVENTS_CLASS=events_class) |
| 354 | 354 |
| 355 def _ImplClassName(self, interface_name): | 355 def _ImplClassName(self, interface_name): |
| 356 return '_%sDOMImpl' % interface_name | 356 return '_%sDOMImpl' % interface_name |
| 357 | 357 |
| 358 def _DartType(self, idl_type): | 358 def _DartType(self, idl_type): |
|
Anton Muhin
2012/05/30 00:10:46
do we need this method at all?
| |
| 359 # FIXME: Make dart:html wrapperless and cleanup this method. | |
| 360 if idl_type in ['EventListener', 'TimeoutHandler']: | |
| 361 return idl_type | |
| 362 if idl_type in ['EventTarget', 'IDBAny', 'IDBKey']: | |
| 363 return 'Dynamic' | |
| 364 if idl_type == 'DOMStringList': | |
| 365 return 'List<String>' | |
| 366 | |
| 367 type_info = GetIDLTypeInfo(idl_type) | 359 type_info = GetIDLTypeInfo(idl_type) |
| 368 if isinstance(type_info, PrimitiveIDLTypeInfo) or isinstance(type_info, Sequ enceIDLTypeInfo): | 360 return self._HTMLInterfaceName(type_info.dart_type()) |
|
Anton Muhin
2012/05/30 00:10:46
nit: make a one-liner?
| |
| 369 return type_info.dart_type() | |
| 370 | |
| 371 if self._system._database.HasInterface(idl_type): | |
| 372 interface = self._system._database.GetInterface(idl_type) | |
| 373 if 'Callback' in interface.ext_attrs: | |
| 374 return idl_type | |
| 375 return '_%s' % idl_type | |
| 376 return idl_type | |
| 377 | 361 |
| 378 def _BaseClassName(self): | 362 def _BaseClassName(self): |
| 379 if not self._interface.parents: | 363 if not self._interface.parents: |
| 380 return '_DOMWrapperBase' | 364 return '_DOMWrapperBase' |
| 381 | 365 |
| 382 supertype = self._interface.parents[0].type.id | 366 supertype = self._interface.parents[0].type.id |
| 383 | 367 |
| 384 # FIXME: We're currently injecting List<..> and EventTarget as | 368 # FIXME: We're currently injecting List<..> and EventTarget as |
| 385 # supertypes in dart.idl. We should annotate/preserve as | 369 # supertypes in dart.idl. We should annotate/preserve as |
| 386 # attributes instead. For now, this hack lets the self._interfaces | 370 # attributes instead. For now, this hack lets the self._interfaces |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 429 IMPL_CLASS=implementation_class, | 413 IMPL_CLASS=implementation_class, |
| 430 TYPE=self._ImplClassName(interface_name), | 414 TYPE=self._ImplClassName(interface_name), |
| 431 IMPL_FUNCTION=implementation_function, | 415 IMPL_FUNCTION=implementation_function, |
| 432 NATIVE_NAME=native_implementation_function) | 416 NATIVE_NAME=native_implementation_function) |
| 433 | 417 |
| 434 def FinishInterface(self): | 418 def FinishInterface(self): |
| 435 class_name = self._ImplClassName(self._interface.id) | 419 class_name = self._ImplClassName(self._interface.id) |
| 436 base = self._BaseClassName() | 420 base = self._BaseClassName() |
| 437 self._dart_impl_emitter.Emit( | 421 self._dart_impl_emitter.Emit( |
| 438 self._templates.Load('dart_implementation.darttemplate'), | 422 self._templates.Load('dart_implementation.darttemplate'), |
| 439 CLASS=class_name, BASE=base, INTERFACE=self._interface.id, | 423 CLASS=class_name, |
| 424 BASE=base, | |
| 425 INTERFACE=self._interface.id, | |
| 426 HTML_INTERFACE=self._HTMLInterfaceName(self._interface.id), | |
| 440 MEMBERS=self._members_emitter.Fragments()) | 427 MEMBERS=self._members_emitter.Fragments()) |
| 441 | 428 |
| 442 self._GenerateCppHeader() | 429 self._GenerateCppHeader() |
| 443 | 430 |
| 444 self._cpp_impl_emitter.Emit( | 431 self._cpp_impl_emitter.Emit( |
| 445 self._templates.Load('cpp_implementation.template'), | 432 self._templates.Load('cpp_implementation.template'), |
| 446 INTERFACE=self._interface.id, | 433 INTERFACE=self._interface.id, |
| 447 INCLUDES=_GenerateCPPIncludes(self._cpp_impl_includes), | 434 INCLUDES=_GenerateCPPIncludes(self._cpp_impl_includes), |
| 448 CALLBACKS=self._cpp_definitions_emitter.Fragments(), | 435 CALLBACKS=self._cpp_definitions_emitter.Fragments(), |
| 449 RESOLVER=self._cpp_resolver_emitter.Fragments(), | 436 RESOLVER=self._cpp_resolver_emitter.Fragments(), |
| (...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1246 for parent in interface.parents: | 1233 for parent in interface.parents: |
| 1247 parent_name = parent.type.id | 1234 parent_name = parent.type.id |
| 1248 if not database.HasInterface(parent.type.id): | 1235 if not database.HasInterface(parent.type.id): |
| 1249 continue | 1236 continue |
| 1250 parent_interface = database.GetInterface(parent.type.id) | 1237 parent_interface = database.GetInterface(parent.type.id) |
| 1251 if callback(parent_interface): | 1238 if callback(parent_interface): |
| 1252 return parent_interface | 1239 return parent_interface |
| 1253 parent_interface = _FindParent(parent_interface, database, callback) | 1240 parent_interface = _FindParent(parent_interface, database, callback) |
| 1254 if parent_interface: | 1241 if parent_interface: |
| 1255 return parent_interface | 1242 return parent_interface |
| OLD | NEW |