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

Side by Side Diff: tools/dom/scripts/systemhtml.py

Issue 284863002: Add type maps from blink name to html name (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Use implementation name Created 6 years, 7 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 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 logging 10 import logging
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 self._interface) 479 self._interface)
480 480
481 code.Emit('$(ANNOTATIONS)typedef void $NAME($PARAMS);\n', 481 code.Emit('$(ANNOTATIONS)typedef void $NAME($PARAMS);\n',
482 ANNOTATIONS=annotations, 482 ANNOTATIONS=annotations,
483 NAME=typedef_name, 483 NAME=typedef_name,
484 PARAMS=info.ParametersAsDeclaration(self._DartType)) 484 PARAMS=info.ParametersAsDeclaration(self._DartType))
485 self._backend.GenerateCallback(info) 485 self._backend.GenerateCallback(info)
486 486
487 def GenerateInterface(self): 487 def GenerateInterface(self):
488 interface_name = self._interface_type_info.interface_name() 488 interface_name = self._interface_type_info.interface_name()
489 implementation_name = self._interface_type_info.implementation_name()
490 self._library_emitter.AddTypeEntry(self._library_name,
491 self._interface.id, implementation_name)
489 492
490 factory_provider = None 493 factory_provider = None
491 if interface_name in interface_factories: 494 if interface_name in interface_factories:
492 factory_provider = interface_factories[interface_name] 495 factory_provider = interface_factories[interface_name]
493 factory_constructor_name = None 496 factory_constructor_name = None
494 497
495 constructors = [] 498 constructors = []
496 if interface_name in _static_classes: 499 if interface_name in _static_classes:
497 constructor_info = None 500 constructor_info = None
498 else: 501 else:
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
1197 path = os.path.join(aux_dir, '%s.dart' % basename) 1200 path = os.path.join(aux_dir, '%s.dart' % basename)
1198 if not path in self._path_to_emitter: 1201 if not path in self._path_to_emitter:
1199 emitter = self._multiemitter.FileEmitter(path) 1202 emitter = self._multiemitter.FileEmitter(path)
1200 if not template is None: 1203 if not template is None:
1201 emitter = emitter.Emit(template) 1204 emitter = emitter.Emit(template)
1202 self._path_to_emitter[path] = emitter 1205 self._path_to_emitter[path] = emitter
1203 1206
1204 self._dart_libraries.AddFile(basename, library_name, path) 1207 self._dart_libraries.AddFile(basename, library_name, path)
1205 return self._path_to_emitter[path] 1208 return self._path_to_emitter[path]
1206 1209
1210 def AddTypeEntry(self, basename, idl_name, dart_name):
1211 self._dart_libraries.AddTypeEntry(basename, idl_name, dart_name)
1212
1207 def EmitLibraries(self, auxiliary_dir): 1213 def EmitLibraries(self, auxiliary_dir):
1208 self._dart_libraries.Emit(self._multiemitter, auxiliary_dir) 1214 self._dart_libraries.Emit(self._multiemitter, auxiliary_dir)
1209 1215
1210 # ------------------------------------------------------------------------------ 1216 # ------------------------------------------------------------------------------
1211 class DartLibrary(): 1217 class DartLibrary():
1212 def __init__(self, name, template_loader, library_type, output_dir): 1218 def __init__(self, name, template_loader, library_type, output_dir):
1213 self._template = template_loader.Load( 1219 self._template = template_loader.Load(
1214 '%s_%s.darttemplate' % (name, library_type)) 1220 '%s_%s.darttemplate' % (name, library_type))
1215 self._dart_path = os.path.join( 1221 self._dart_path = os.path.join(
1216 output_dir, '%s_%s.dart' % (name, library_type)) 1222 output_dir, '%s_%s.dart' % (name, library_type))
1217 self._paths = [] 1223 self._paths = []
1224 self._typeMap = {}
1218 1225
1219 def AddFile(self, path): 1226 def AddFile(self, path):
1220 self._paths.append(path) 1227 self._paths.append(path)
1221 1228
1229 def AddTypeEntry(self, idl_name, dart_name):
1230 self._typeMap[idl_name] = dart_name
1231
1222 def Emit(self, emitter, auxiliary_dir): 1232 def Emit(self, emitter, auxiliary_dir):
1223 def massage_path(path): 1233 def massage_path(path):
1224 # The most robust way to emit path separators is to use / always. 1234 # The most robust way to emit path separators is to use / always.
1225 return path.replace('\\', '/') 1235 return path.replace('\\', '/')
1226 1236
1227 library_emitter = emitter.FileEmitter(self._dart_path) 1237 library_emitter = emitter.FileEmitter(self._dart_path)
1228 library_file_dir = os.path.dirname(self._dart_path) 1238 library_file_dir = os.path.dirname(self._dart_path)
1229 auxiliary_dir = os.path.relpath(auxiliary_dir, library_file_dir) 1239 auxiliary_dir = os.path.relpath(auxiliary_dir, library_file_dir)
1230 imports_emitter = library_emitter.Emit( 1240 emitters = library_emitter.Emit(
1231 self._template, AUXILIARY_DIR=massage_path(auxiliary_dir)) 1241 self._template, AUXILIARY_DIR=massage_path(auxiliary_dir))
1242 if isinstance(emitters, tuple):
1243 imports_emitter, map_emitter = emitters
1244 else:
1245 imports_emitter, map_emitter = emitters, None
1246
1232 1247
1233 for path in sorted(self._paths): 1248 for path in sorted(self._paths):
1234 relpath = os.path.relpath(path, library_file_dir) 1249 relpath = os.path.relpath(path, library_file_dir)
1235 imports_emitter.Emit( 1250 imports_emitter.Emit(
1236 "part '$PATH';\n", PATH=massage_path(relpath)) 1251 "part '$PATH';\n", PATH=massage_path(relpath))
1237 1252
1253 if map_emitter:
1254 items = self._typeMap.items()
1255 items.sort()
1256 for (idl_name, dart_name) in items:
1257 map_emitter.Emit(
1258 " '$IDL_NAME': $DART_NAME,\n",
1259 IDL_NAME=idl_name,
1260 DART_NAME=dart_name)
1261
1262
1238 # ------------------------------------------------------------------------------ 1263 # ------------------------------------------------------------------------------
1239 1264
1240 class DartLibraries(): 1265 class DartLibraries():
1241 def __init__(self, libraries, template_loader, library_type, output_dir): 1266 def __init__(self, libraries, template_loader, library_type, output_dir):
1242 self._libraries = {} 1267 self._libraries = {}
1243 for library_name in libraries: 1268 for library_name in libraries:
1244 self._libraries[library_name] = DartLibrary( 1269 self._libraries[library_name] = DartLibrary(
1245 library_name, template_loader, library_type, output_dir) 1270 library_name, template_loader, library_type, output_dir)
1246 1271
1247 def AddFile(self, basename, library_name, path): 1272 def AddFile(self, basename, library_name, path):
1248 self._libraries[library_name].AddFile(path) 1273 self._libraries[library_name].AddFile(path)
1249 1274
1275 def AddTypeEntry(self, library_name, idl_name, dart_name):
1276 self._libraries[library_name].AddTypeEntry(idl_name, dart_name)
1277
1250 def Emit(self, emitter, auxiliary_dir): 1278 def Emit(self, emitter, auxiliary_dir):
1251 for lib in self._libraries.values(): 1279 for lib in self._libraries.values():
1252 lib.Emit(emitter, auxiliary_dir) 1280 lib.Emit(emitter, auxiliary_dir)
OLDNEW
« no previous file with comments | « sdk/lib/web_sql/dartium/web_sql_dartium.dart ('k') | tools/dom/templates/html/dartium/_blink_dartium.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698