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

Side by Side Diff: lib/dom/scripts/systeminterface.py

Issue 10388084: Better support for the case of typed arrays inheriting from other typed arrays. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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 providesfunctionality for systems to generate 6 """This module providesfunctionality for systems to generate
7 Dart interfaces from the IDL database.""" 7 Dart interfaces from the IDL database."""
8 8
9 import os 9 import os
10 import systembase 10 import systembase
(...skipping 19 matching lines...) Expand all
30 self._dart_interface_file_paths.append(dart_interface_file_path) 30 self._dart_interface_file_paths.append(dart_interface_file_path)
31 31
32 dart_interface_code = self._emitters.FileEmitter(dart_interface_file_path) 32 dart_interface_code = self._emitters.FileEmitter(dart_interface_file_path)
33 33
34 template_file = 'interface_%s.darttemplate' % interface_name 34 template_file = 'interface_%s.darttemplate' % interface_name
35 template = self._templates.TryLoad(template_file) 35 template = self._templates.TryLoad(template_file)
36 if not template: 36 if not template:
37 template = self._templates.Load('interface.darttemplate') 37 template = self._templates.Load('interface.darttemplate')
38 38
39 return DartInterfaceGenerator( 39 return DartInterfaceGenerator(
40 interface, dart_interface_code, 40 self, interface, dart_interface_code,
41 template, 41 template,
42 common_prefix, super_interface_name, 42 common_prefix, super_interface_name,
43 source_filter) 43 source_filter)
44 44
45 def ProcessCallback(self, interface, info): 45 def ProcessCallback(self, interface, info):
46 """Generates a typedef for the callback interface.""" 46 """Generates a typedef for the callback interface."""
47 interface_name = interface.id 47 interface_name = interface.id
48 file_path = self._FilePathForDartInterface(interface_name) 48 file_path = self._FilePathForDartInterface(interface_name)
49 self._ProcessCallback(interface, info, file_path) 49 self._ProcessCallback(interface, info, file_path)
50 50
51 def GenerateLibraries(self, lib_dir): 51 def GenerateLibraries(self, lib_dir):
52 pass 52 pass
53 53
54 54
55 def _FilePathForDartInterface(self, interface_name): 55 def _FilePathForDartInterface(self, interface_name):
56 """Returns the file path of the Dart interface definition.""" 56 """Returns the file path of the Dart interface definition."""
57 return os.path.join(self._output_dir, 'src', 'interface', 57 return os.path.join(self._output_dir, 'src', 'interface',
58 '%s.dart' % interface_name) 58 '%s.dart' % interface_name)
59 59
60 # ------------------------------------------------------------------------------ 60 # ------------------------------------------------------------------------------
61 61
62 class DartInterfaceGenerator(object): 62 class DartInterfaceGenerator(object):
63 """Generates Dart Interface definition for one DOM IDL interface.""" 63 """Generates Dart Interface definition for one DOM IDL interface."""
64 64
65 def __init__(self, interface, emitter, template, 65 def __init__(self, system, interface, emitter, template,
66 common_prefix, super_interface, source_filter): 66 common_prefix, super_interface, source_filter):
67 """Generates Dart code for the given interface. 67 """Generates Dart code for the given interface.
68 68
69 Args: 69 Args:
70 interface -- an IDLInterface instance. It is assumed that all types have 70 interface -- an IDLInterface instance. It is assumed that all types have
71 been converted to Dart types (e.g. int, String), unless they are in the 71 been converted to Dart types (e.g. int, String), unless they are in the
72 same package as the interface. 72 same package as the interface.
73 common_prefix -- the prefix for the common library, if any. 73 common_prefix -- the prefix for the common library, if any.
74 super_interface -- the name of the common interface that this interface 74 super_interface -- the name of the common interface that this interface
75 implements, if any. 75 implements, if any.
76 source_filter -- if specified, rewrites the names of any superinterfaces 76 source_filter -- if specified, rewrites the names of any superinterfaces
77 that are not from these sources to use the common prefix. 77 that are not from these sources to use the common prefix.
78 """ 78 """
79 self._system = system
79 self._interface = interface 80 self._interface = interface
80 self._emitter = emitter 81 self._emitter = emitter
81 self._template = template 82 self._template = template
82 self._common_prefix = common_prefix 83 self._common_prefix = common_prefix
83 self._super_interface = super_interface 84 self._super_interface = super_interface
84 self._source_filter = source_filter 85 self._source_filter = source_filter
85 86
86 87
87 def StartInterface(self): 88 def StartInterface(self):
88 if self._super_interface: 89 if self._super_interface:
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 ID=typename, 134 ID=typename,
134 EXTENDS=extends_str) 135 EXTENDS=extends_str)
135 136
136 if constructor_info: 137 if constructor_info:
137 self._members_emitter.Emit( 138 self._members_emitter.Emit(
138 '\n' 139 '\n'
139 ' $CTOR($PARAMS);\n', 140 ' $CTOR($PARAMS);\n',
140 CTOR=typename, 141 CTOR=typename,
141 PARAMS=constructor_info.ParametersInterfaceDeclaration()); 142 PARAMS=constructor_info.ParametersInterfaceDeclaration());
142 143
143 element_type = MaybeTypedArrayElementType(self._interface) 144 element_type = MaybeTypedArrayElementTypeInHierarchy(
145 self._interface, self._system._database)
144 if element_type: 146 if element_type:
145 self._members_emitter.Emit( 147 self._members_emitter.Emit(
146 '\n' 148 '\n'
147 ' $CTOR(int length);\n' 149 ' $CTOR(int length);\n'
148 '\n' 150 '\n'
149 ' $CTOR.fromList(List<$TYPE> list);\n' 151 ' $CTOR.fromList(List<$TYPE> list);\n'
150 '\n' 152 '\n'
151 ' $CTOR.fromBuffer(ArrayBuffer buffer,' 153 ' $CTOR.fromBuffer(ArrayBuffer buffer,'
152 ' [int byteOffset, int length]);\n', 154 ' [int byteOffset, int length]);\n',
153 CTOR=self._interface.id, 155 CTOR=self._interface.id,
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 217
216 def AddStaticOperation(self, info): 218 def AddStaticOperation(self, info):
217 pass 219 pass
218 220
219 # Interfaces get secondary members directly via the superinterfaces. 221 # Interfaces get secondary members directly via the superinterfaces.
220 def AddSecondaryAttribute(self, interface, getter, setter): 222 def AddSecondaryAttribute(self, interface, getter, setter):
221 pass 223 pass
222 224
223 def AddSecondaryOperation(self, interface, attr): 225 def AddSecondaryOperation(self, interface, attr):
224 pass 226 pass
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698