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 generates Dart APIs from the IDL database.""" | 6 """This module generates Dart APIs from the IDL database.""" |
7 | 7 |
8 import emitter | 8 import emitter |
9 import idlnode | 9 import idlnode |
10 import logging | 10 import logging |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 | 622 |
623 class DummyImplementationSystem(System): | 623 class DummyImplementationSystem(System): |
624 """Generates a dummy implementation for use by the editor analysis. | 624 """Generates a dummy implementation for use by the editor analysis. |
625 | 625 |
626 All the code comes from hand-written library files. | 626 All the code comes from hand-written library files. |
627 """ | 627 """ |
628 | 628 |
629 def __init__(self, templates, database, emitters, output_dir): | 629 def __init__(self, templates, database, emitters, output_dir): |
630 super(DummyImplementationSystem, self).__init__( | 630 super(DummyImplementationSystem, self).__init__( |
631 templates, database, emitters, output_dir) | 631 templates, database, emitters, output_dir) |
| 632 factory_providers_file = os.path.join(self._output_dir, 'src', 'dummy', |
| 633 'RegularFactoryProviders.dart') |
| 634 self._factory_providers_emitter = self._emitters.FileEmitter( |
| 635 factory_providers_file) |
| 636 self._impl_file_paths = [factory_providers_file] |
632 | 637 |
633 def InterfaceGenerator(self, | 638 def InterfaceGenerator(self, |
634 interface, | 639 interface, |
635 common_prefix, | 640 common_prefix, |
636 super_interface_name, | 641 super_interface_name, |
637 source_filter): | 642 source_filter): |
638 return DummyInterfaceGenerator(self, interface) | 643 return DummyInterfaceGenerator(self, interface) |
639 | 644 |
640 def ProcessCallback(self, interface, info): | 645 def ProcessCallback(self, interface, info): |
641 pass | 646 pass |
642 | 647 |
643 def GenerateLibraries(self, lib_dir): | 648 def GenerateLibraries(self, lib_dir): |
644 # Library generated for implementation. | 649 # Library generated for implementation. |
645 self._GenerateLibFile( | 650 self._GenerateLibFile( |
646 'dom_dummy.darttemplate', | 651 'dom_dummy.darttemplate', |
647 os.path.join(lib_dir, 'dom_dummy.dart'), | 652 os.path.join(lib_dir, 'dom_dummy.dart'), |
648 (self._interface_system._dart_interface_file_paths + | 653 (self._interface_system._dart_interface_file_paths + |
649 self._interface_system._dart_callback_file_paths + | 654 self._interface_system._dart_callback_file_paths + |
650 [] | 655 self._impl_file_paths)) |
651 # FIXME: Move the implementation to a separate library. | 656 |
652 # self._dart_wrapping_file_paths | |
653 )) | |
654 | 657 |
655 # ------------------------------------------------------------------------------ | 658 # ------------------------------------------------------------------------------ |
656 | 659 |
657 class DummyInterfaceGenerator(object): | 660 class DummyInterfaceGenerator(object): |
658 """Generates nothing.""" | 661 """Generates dummy implementation.""" |
659 | 662 |
660 def __init__(self, system, interface): | 663 def __init__(self, system, interface): |
661 pass | 664 self._system = system |
| 665 self._interface = interface |
662 | 666 |
663 def StartInterface(self): | 667 def StartInterface(self): |
664 pass | 668 # There is no implementation to match the interface, but there might be a |
| 669 # factory constructor for the Dart interface. |
| 670 constructor_info = AnalyzeConstructor(self._interface) |
| 671 if constructor_info: |
| 672 dart_interface_name = self._interface.id |
| 673 self._EmitFactoryProvider(dart_interface_name, constructor_info) |
| 674 |
| 675 def _EmitFactoryProvider(self, interface_name, constructor_info): |
| 676 factory_provider = '_' + interface_name + 'FactoryProvider' |
| 677 self._system._factory_providers_emitter.Emit( |
| 678 self._system._templates.Load('factoryprovider.darttemplate'), |
| 679 FACTORYPROVIDER=factory_provider, |
| 680 CONSTRUCTOR=interface_name, |
| 681 PARAMETERS=constructor_info.ParametersImplementationDeclaration()) |
665 | 682 |
666 def FinishInterface(self): | 683 def FinishInterface(self): |
667 pass | 684 pass |
668 | 685 |
669 def AddConstant(self, constant): | 686 def AddConstant(self, constant): |
670 pass | 687 pass |
671 | 688 |
672 def AddAttribute(self, getter, setter): | 689 def AddAttribute(self, getter, setter): |
673 pass | 690 pass |
674 | 691 |
675 def AddSecondaryAttribute(self, interface, getter, setter): | 692 def AddSecondaryAttribute(self, interface, getter, setter): |
676 pass | 693 pass |
677 | 694 |
678 def AddSecondaryOperation(self, interface, info): | 695 def AddSecondaryOperation(self, interface, info): |
679 pass | 696 pass |
680 | 697 |
681 def AddIndexer(self, element_type): | 698 def AddIndexer(self, element_type): |
682 pass | 699 pass |
683 | 700 |
684 def AddTypedArrayConstructors(self, element_type): | 701 def AddTypedArrayConstructors(self, element_type): |
685 pass | 702 pass |
686 | 703 |
687 def AddOperation(self, info): | 704 def AddOperation(self, info): |
688 pass | 705 pass |
689 | 706 |
690 def AddEventAttributes(self, event_attrs): | 707 def AddEventAttributes(self, event_attrs): |
691 pass | 708 pass |
OLD | NEW |