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

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

Issue 11053016: Remove constants declaration from dart2js implementation classes. (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
« no previous file with comments | « lib/html/dart2js/html_dart2js.dart ('k') | no next file » | 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 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 10
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 420
421 def FinishInterface(self): 421 def FinishInterface(self):
422 self._backend.FinishInterface() 422 self._backend.FinishInterface()
423 423
424 def AddConstant(self, constant): 424 def AddConstant(self, constant):
425 type = TypeOrNothing(self._DartType(constant.type.id), constant.type.id) 425 type = TypeOrNothing(self._DartType(constant.type.id), constant.type.id)
426 self._members_emitter.Emit('\n static const $TYPE$NAME = $VALUE;\n', 426 self._members_emitter.Emit('\n static const $TYPE$NAME = $VALUE;\n',
427 NAME=constant.id, 427 NAME=constant.id,
428 TYPE=type, 428 TYPE=type,
429 VALUE=constant.value) 429 VALUE=constant.value)
430 self._backend.AddConstant(constant)
431 430
432 def _EmitEventGetter(self, events_interface, events_class): 431 def _EmitEventGetter(self, events_interface, events_class):
433 self._members_emitter.Emit( 432 self._members_emitter.Emit(
434 '\n /**' 433 '\n /**'
435 '\n * @domName EventTarget.addEventListener, ' 434 '\n * @domName EventTarget.addEventListener, '
436 'EventTarget.removeEventListener, EventTarget.dispatchEvent' 435 'EventTarget.removeEventListener, EventTarget.dispatchEvent'
437 '\n */' 436 '\n */'
438 '\n $TYPE get on;\n', 437 '\n $TYPE get on;\n',
439 TYPE=events_interface) 438 TYPE=events_interface)
440 439
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 NATIVESPEC=' native "' + native_spec + '"') 531 NATIVESPEC=' native "' + native_spec + '"')
533 if self._members_emitter == None: 532 if self._members_emitter == None:
534 raise Exception("Class %s doesn't use the $!MEMBERS variable" % 533 raise Exception("Class %s doesn't use the $!MEMBERS variable" %
535 self._class_name) 534 self._class_name)
536 535
537 return self._members_emitter 536 return self._members_emitter
538 537
539 def FinishInterface(self): 538 def FinishInterface(self):
540 pass 539 pass
541 540
542 def AddConstant(self, constant):
543 # Since we are currently generating native classes without interfaces,
544 # generate the constants as part of the class. This will need to go away
545 # if we revert back to generating interfaces.
546 self._members_emitter.Emit('\n static const $TYPE $NAME = $VALUE;\n',
547 NAME=constant.id,
548 TYPE=self._DartType(constant.type.id),
549 VALUE=constant.value)
550
551 def EmitFactoryProvider(self, constructor_info, factory_provider, emitter): 541 def EmitFactoryProvider(self, constructor_info, factory_provider, emitter):
552 template_file = ('factoryprovider_%s.darttemplate' % 542 template_file = ('factoryprovider_%s.darttemplate' %
553 self._html_interface_name) 543 self._html_interface_name)
554 template = self._template_loader.TryLoad(template_file) 544 template = self._template_loader.TryLoad(template_file)
555 if not template: 545 if not template:
556 template = self._template_loader.Load('factoryprovider.darttemplate') 546 template = self._template_loader.Load('factoryprovider.darttemplate')
557 547
558 emitter.Emit( 548 emitter.Emit(
559 template, 549 template,
560 FACTORYPROVIDER=factory_provider, 550 FACTORYPROVIDER=factory_provider,
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 1015
1026 library_emitter = self._multiemitter.FileEmitter(library_file_path) 1016 library_emitter = self._multiemitter.FileEmitter(library_file_path)
1027 library_file_dir = os.path.dirname(library_file_path) 1017 library_file_dir = os.path.dirname(library_file_path)
1028 auxiliary_dir = os.path.relpath(auxiliary_dir, library_file_dir) 1018 auxiliary_dir = os.path.relpath(auxiliary_dir, library_file_dir)
1029 imports_emitter = library_emitter.Emit( 1019 imports_emitter = library_emitter.Emit(
1030 self._template, AUXILIARY_DIR=massage_path(auxiliary_dir)) 1020 self._template, AUXILIARY_DIR=massage_path(auxiliary_dir))
1031 for path in sorted(self._path_to_emitter.keys()): 1021 for path in sorted(self._path_to_emitter.keys()):
1032 relpath = os.path.relpath(path, library_file_dir) 1022 relpath = os.path.relpath(path, library_file_dir)
1033 imports_emitter.Emit( 1023 imports_emitter.Emit(
1034 "#source('$PATH');\n", PATH=massage_path(relpath)) 1024 "#source('$PATH');\n", PATH=massage_path(relpath))
OLDNEW
« no previous file with comments | « lib/html/dart2js/html_dart2js.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698