Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Side by Side Diff: lib/html/scripts/systemnative.py

Issue 11045020: Merge BaseGenerator into HtmlDartInterfaceGenerator. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
11 from generator import * 11 from generator import *
12 from systembase import BaseGenerator
13 12
14 13
15 class DartiumBackend(BaseGenerator): 14 class DartiumBackend(object):
16 """Generates Dart implementation for one DOM IDL interface.""" 15 """Generates Dart implementation for one DOM IDL interface."""
17 16
18 def __init__(self, interface, cpp_library_emitter, options): 17 def __init__(self, interface, cpp_library_emitter, options):
19 super(DartiumBackend, self).__init__( 18 self._interface = interface
20 options.database, options.type_registry, interface)
21 self._cpp_library_emitter = cpp_library_emitter 19 self._cpp_library_emitter = cpp_library_emitter
20 self._database = options.database
22 self._template_loader = options.templates 21 self._template_loader = options.templates
22 self._type_registry = options.type_registry
23 self._html_interface_name = options.renamer.RenameInterface(self._interface) 23 self._html_interface_name = options.renamer.RenameInterface(self._interface)
24 24
25 def HasImplementation(self): 25 def HasImplementation(self):
26 return not IsPureInterface(self._interface.id) 26 return not IsPureInterface(self._interface.id)
27 27
28 def ImplementationClassName(self): 28 def ImplementationClassName(self):
29 return self._ImplClassName(self._interface.id) 29 return self._ImplClassName(self._interface.id)
30 30
31 def SetImplementationEmitter(self, implementation_emitter): 31 def SetImplementationEmitter(self, implementation_emitter):
32 self._dart_impl_emitter = implementation_emitter 32 self._dart_impl_emitter = implementation_emitter
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 return ''.join(['#include %s\n' % include for include in sorted(includes)]) 846 return ''.join(['#include %s\n' % include for include in sorted(includes)])
847 847
848 def _ToWebKitName(self, name): 848 def _ToWebKitName(self, name):
849 name = name[0].lower() + name[1:] 849 name = name[0].lower() + name[1:]
850 name = re.sub(r'^(hTML|uRL|jS|xML|xSLT)', lambda s: s.group(1).lower(), 850 name = re.sub(r'^(hTML|uRL|jS|xML|xSLT)', lambda s: s.group(1).lower(),
851 name) 851 name)
852 return re.sub(r'^(create|exclusive)', 852 return re.sub(r'^(create|exclusive)',
853 lambda s: 'is' + s.group(1).capitalize(), 853 lambda s: 'is' + s.group(1).capitalize(),
854 name) 854 name)
855 855
856 def _TypeInfo(self, type_name):
857 return self._type_registry.TypeInfo(type_name)
858
859 def _DartType(self, type_name):
860 return self._type_registry.DartType(type_name)
861
856 862
857 class CPPLibraryEmitter(): 863 class CPPLibraryEmitter():
858 def __init__(self, emitters, cpp_sources_dir): 864 def __init__(self, emitters, cpp_sources_dir):
859 self._emitters = emitters 865 self._emitters = emitters
860 self._cpp_sources_dir = cpp_sources_dir 866 self._cpp_sources_dir = cpp_sources_dir
861 self._headers_list = [] 867 self._headers_list = []
862 self._sources_list = [] 868 self._sources_list = []
863 869
864 def CreateHeaderEmitter(self, interface_name, is_callback=False): 870 def CreateHeaderEmitter(self, interface_name, is_callback=False):
865 path = os.path.join(self._cpp_sources_dir, 'Dart%s.h' % interface_name) 871 path = os.path.join(self._cpp_sources_dir, 'Dart%s.h' % interface_name)
(...skipping 19 matching lines...) Expand all
885 def EmitResolver(self, template, output_dir): 891 def EmitResolver(self, template, output_dir):
886 file_path = os.path.join(output_dir, 'DartResolver.cpp') 892 file_path = os.path.join(output_dir, 'DartResolver.cpp')
887 includes_emitter, body_emitter = self._emitters.FileEmitter(file_path).Emit( template) 893 includes_emitter, body_emitter = self._emitters.FileEmitter(file_path).Emit( template)
888 for header_file in self._headers_list: 894 for header_file in self._headers_list:
889 path = os.path.relpath(header_file, output_dir) 895 path = os.path.relpath(header_file, output_dir)
890 includes_emitter.Emit('#include "$PATH"\n', PATH=path) 896 includes_emitter.Emit('#include "$PATH"\n', PATH=path)
891 body_emitter.Emit( 897 body_emitter.Emit(
892 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argume ntCount))\n' 898 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argume ntCount))\n'
893 ' return func;\n', 899 ' return func;\n',
894 CLASS_NAME=os.path.splitext(os.path.basename(path))[0]) 900 CLASS_NAME=os.path.splitext(os.path.basename(path))[0])
OLDNEW
« lib/html/scripts/systemhtml.py ('K') | « lib/html/scripts/systemhtml.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698