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

Side by Side Diff: client/dom/scripts/dartgenerator.py

Issue 9350030: Generate dummy dom to replace wrapping dom for dartc. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: x Created 8 years, 10 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
« no previous file with comments | « client/dom/scripts/dartdomgenerator.py ('k') | client/dom/src/dummy_FactoryProviders.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 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 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 self._ComputeInheritanceClosure() 375 self._ComputeInheritanceClosure()
376 376
377 self._systems = [] 377 self._systems = []
378 378
379 interface_system = InterfacesSystem( 379 interface_system = InterfacesSystem(
380 TemplateLoader(self._template_dir, ['dom/interface', 'dom', '']), 380 TemplateLoader(self._template_dir, ['dom/interface', 'dom', '']),
381 self._database, self._emitters, self._output_dir) 381 self._database, self._emitters, self._output_dir)
382 self._systems.append(interface_system) 382 self._systems.append(interface_system)
383 383
384 if 'native' in systems: 384 if 'native' in systems:
385 native_system = NativeImplementationSystem( 385 native_system = NativeImplementationSystem(
386 TemplateLoader(self._template_dir, ['dom/native', 'dom', '']), 386 TemplateLoader(self._template_dir, ['dom/native', 'dom', '']),
387 self._database, self._emitters, self._auxiliary_dir, 387 self._database, self._emitters, self._auxiliary_dir,
388 self._output_dir) 388 self._output_dir)
389 389
390 self._systems.append(native_system) 390 self._systems.append(native_system)
391 391
392 if 'wrapping' in systems: 392 if 'wrapping' in systems:
393 wrapping_system = WrappingImplementationSystem( 393 wrapping_system = WrappingImplementationSystem(
394 TemplateLoader(self._template_dir, ['dom/wrapping', 'dom', '']), 394 TemplateLoader(self._template_dir, ['dom/wrapping', 'dom', '']),
395 self._database, self._emitters, self._output_dir) 395 self._database, self._emitters, self._output_dir)
396 396
397 # Makes interface files available for listing in the library for the 397 # Makes interface files available for listing in the library for the
398 # wrapping implementation. 398 # wrapping implementation.
399 wrapping_system._interface_system = interface_system 399 wrapping_system._interface_system = interface_system
400 self._systems.append(wrapping_system) 400 self._systems.append(wrapping_system)
401 401
402 if 'dummy' in systems:
403 dummy_system = DummyImplementationSystem(
404 TemplateLoader(self._template_dir, ['dom/dummy', 'dom', '']),
405 self._database, self._emitters, self._output_dir)
406
407 # Makes interface files available for listing in the library for the
408 # dummy implementation.
409 dummy_system._interface_system = interface_system
410 self._systems.append(dummy_system)
411
402 if 'frog' in systems: 412 if 'frog' in systems:
403 frog_system = FrogSystem( 413 frog_system = FrogSystem(
404 TemplateLoader(self._template_dir, ['dom/frog', 'dom', '']), 414 TemplateLoader(self._template_dir, ['dom/frog', 'dom', '']),
405 self._database, self._emitters, self._output_dir) 415 self._database, self._emitters, self._output_dir)
406 416
407 frog_system._interface_system = interface_system 417 frog_system._interface_system = interface_system
408 self._systems.append(frog_system) 418 self._systems.append(frog_system)
409 419
410 420
411 # Render all interfaces into Dart and save them in files. 421 # Render all interfaces into Dart and save them in files.
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
965 975
966 976
967 def _FilePathForDartInterface(self, interface_name): 977 def _FilePathForDartInterface(self, interface_name):
968 """Returns the file path of the Dart interface definition.""" 978 """Returns the file path of the Dart interface definition."""
969 return os.path.join(self._output_dir, 'src', 'interface', 979 return os.path.join(self._output_dir, 'src', 'interface',
970 '%s.dart' % interface_name) 980 '%s.dart' % interface_name)
971 981
972 982
973 # ------------------------------------------------------------------------------ 983 # ------------------------------------------------------------------------------
974 984
985 class DummyImplementationSystem(System):
986 """Generates a dummy implementation for use by the editor analysis.
987
988 All the code comes from hand-written library files.
989 """
990
991 def __init__(self, templates, database, emitters, output_dir):
992 super(DummyImplementationSystem, self).__init__(
993 templates, database, emitters, output_dir)
994
995 def InterfaceGenerator(self,
996 interface,
997 common_prefix,
998 super_interface_name,
999 source_filter):
1000 return DummyInterfaceGenerator(self, interface)
1001
1002 def ProcessCallback(self, interface, info):
1003 pass
1004
1005 def GenerateLibraries(self, lib_dir):
1006 # Library generated for implementation.
1007 self._GenerateLibFile(
1008 'dom_dummy.darttemplate',
1009 os.path.join(lib_dir, 'dom_dummy.dart'),
1010 (self._interface_system._dart_interface_file_paths +
1011 self._interface_system._dart_callback_file_paths +
1012 []
1013 # FIXME: Move the implementation to a separate library.
1014 # self._dart_wrapping_file_paths
1015 ))
1016
1017 # ------------------------------------------------------------------------------
1018
975 class WrappingImplementationSystem(System): 1019 class WrappingImplementationSystem(System):
976 1020
977 def __init__(self, templates, database, emitters, output_dir): 1021 def __init__(self, templates, database, emitters, output_dir):
978 """Prepared for generating wrapping implementation. 1022 """Prepared for generating wrapping implementation.
979 1023
980 - Creates emitter for JS code. 1024 - Creates emitter for JS code.
981 - Creates emitter for Dart code. 1025 - Creates emitter for Dart code.
982 """ 1026 """
983 super(WrappingImplementationSystem, self).__init__( 1027 super(WrappingImplementationSystem, self).__init__(
984 templates, database, emitters, output_dir) 1028 templates, database, emitters, output_dir)
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
1273 1317
1274 # Given a sorted sequence of type identifiers, return an appropriate type 1318 # Given a sorted sequence of type identifiers, return an appropriate type
1275 # name 1319 # name
1276 def TypeName(typeIds, interface): 1320 def TypeName(typeIds, interface):
1277 # Dynamically type this field for now. 1321 # Dynamically type this field for now.
1278 return 'var' 1322 return 'var'
1279 1323
1280 1324
1281 # ------------------------------------------------------------------------------ 1325 # ------------------------------------------------------------------------------
1282 1326
1327 class DummyInterfaceGenerator(object):
1328 """Generates nothing."""
1329
1330 def __init__(self, system, interface):
1331 pass
1332
1333 def StartInterface(self):
1334 pass
1335
1336 def FinishInterface(self):
1337 pass
1338
1339 def AddConstant(self, constant):
1340 pass
1341
1342 def AddAttribute(self, getter, setter):
1343 pass
1344
1345 def AddSecondaryAttribute(self, interface, getter, setter):
1346 pass
1347
1348 def AddSecondaryOperation(self, interface, info):
1349 pass
1350
1351 def AddIndexer(self, element_type):
1352 pass
1353
1354 def AddTypedArrayConstructors(self, element_type):
1355 pass
1356
1357 def AddOperation(self, info):
1358 pass
1359
1360 # ------------------------------------------------------------------------------
1361
1283 class WrappingInterfaceGenerator(object): 1362 class WrappingInterfaceGenerator(object):
1284 """Generates Dart and JS implementation for one DOM IDL interface.""" 1363 """Generates Dart and JS implementation for one DOM IDL interface."""
1285 1364
1286 def __init__(self, interface, super_interface, dart_code, js_code, type_map, 1365 def __init__(self, interface, super_interface, dart_code, js_code, type_map,
1287 externs, base_members): 1366 externs, base_members):
1288 """Generates Dart and JS code for the given interface. 1367 """Generates Dart and JS code for the given interface.
1289 1368
1290 Args: 1369 Args:
1291 1370
1292 interface: an IDLInterface instance. It is assumed that all types have 1371 interface: an IDLInterface instance. It is assumed that all types have
(...skipping 989 matching lines...) Expand 10 before | Expand all | Expand 10 after
2282 INDENT=indent, 2361 INDENT=indent,
2283 NATIVENAME=native_name, 2362 NATIVENAME=native_name,
2284 ARGS=argument_expressions) 2363 ARGS=argument_expressions)
2285 2364
2286 self._members_emitter.Emit(' $TYPE $NATIVE_NAME($PARAMS) native ' 2365 self._members_emitter.Emit(' $TYPE $NATIVE_NAME($PARAMS) native '
2287 '"$(INTERFACE)$(NATIVE_NAME)_Callback";\n', 2366 '"$(INTERFACE)$(NATIVE_NAME)_Callback";\n',
2288 NATIVE_NAME=native_name, 2367 NATIVE_NAME=native_name,
2289 TYPE=info.type_name, 2368 TYPE=info.type_name,
2290 PARAMS=', '.join(arg_names), 2369 PARAMS=', '.join(arg_names),
2291 INTERFACE=self._interface.id) 2370 INTERFACE=self._interface.id)
OLDNEW
« no previous file with comments | « client/dom/scripts/dartdomgenerator.py ('k') | client/dom/src/dummy_FactoryProviders.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698