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

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

Issue 11365019: Merging dart:html interfaces and implementations (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Adding generated files. Created 8 years, 1 month 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
(Empty)
1 #!/usr/bin/python
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
4 # BSD-style license that can be found in the LICENSE file.
5
6 """This module provides shared functionality for the system to generate
7 Dart:html APIs from the IDL database."""
8
9 from generator import *
Anton Muhin 2012/11/02 12:55:47 maybe use names instead of globbing?
blois 2012/11/02 19:25:28 Done.
10
11 class HtmlDartGenerator(object):
12 def __init__(self, interface, options):
13 self._interface = interface
14
15 def EmitAttributeDocumentation(self, attribute):
16 dom_name = DartDomNameOfAttribute(attribute)
17 self._members_emitter.Emit('\n /** @domName $DOMINTERFACE.$DOMNAME */',
18 DOMINTERFACE=attribute.doc_js_interface_name,
19 DOMNAME=dom_name)
20
21 def AdditionalImplementedInterfaces(self):
22 # TODO: Include all implemented interfaces, including other Lists.
23 implements = []
24 if self._interface_type_info.is_typed_array():
25 element_type = self._interface_type_info.list_item_type()
26 implements.append('List<%s>' % self._DartType(element_type))
27 if self._interface_type_info.list_item_type():
28 item_type_info = self._type_registry.TypeInfo(
29 self._interface_type_info.list_item_type())
30 implements.append('List<%s>' % item_type_info.dart_type())
31 return implements
32
33 def AddConstructors(self, constructors, factory_provider, class_name,
34 base_class):
35 for constructor_info in constructors:
36 self._AddConstructor(constructor_info, factory_provider)
37
38 typed_array_type = None
39 for interface in self._database.Hierarchy(self._interface):
40 type_info = self._type_registry.TypeInfo(interface.id)
41 if type_info.is_typed_array():
42 typed_array_type = type_info.list_item_type()
43 break
44 if typed_array_type:
45 self._members_emitter.Emit(
46 '\n'
47 ' factory $CTOR(int length) =>\n'
48 ' $FACTORY.create$(CTOR)(length);\n'
49 '\n'
50 ' factory $CTOR.fromList(List<$TYPE> list) =>\n'
51 ' $FACTORY.create$(CTOR)_fromList(list);\n'
52 '\n'
53 ' factory $CTOR.fromBuffer(ArrayBuffer buffer, [int byteOffset, int l ength]) => \n'
54 ' $FACTORY.create$(CTOR)_fromBuffer(buffer, byteOffset, length);\n' ,
55 CTOR=self._interface.id,
56 TYPE=self._DartType(typed_array_type),
57 FACTORY=factory_provider)
58
59 def _AddConstructor(self, constructor_info, factory_provider):
60 constructor_info.GenerateFactoryInvocation(
61 self._DartType, self._members_emitter, factory_provider)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698