OLD | NEW |
| (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 systems to generate | |
7 Dart APIs from the IDL database.""" | |
8 | |
9 import re | |
10 | |
11 # IDL->Dart primitive types conversion. | |
12 _idl_to_dart_type_conversions = { | |
13 'any': 'Object', | |
14 'any[]': 'List', | |
15 'custom': 'Dynamic', | |
16 'boolean': 'bool', | |
17 'DOMObject': 'Object', | |
18 'DOMString': 'String', | |
19 'DOMStringList': 'List<String>', | |
20 'DOMTimeStamp': 'int', | |
21 'Date': 'Date', | |
22 # Map to num to enable callers to pass in Dart int, rational | |
23 # types. Our implementations will need to convert these to | |
24 # doubles or floats as needed. | |
25 'double': 'num', | |
26 'float': 'num', | |
27 'int': 'int', | |
28 # Map to extra precision - int is a bignum in Dart. | |
29 'long': 'int', | |
30 'long long': 'int', | |
31 'object': 'Object', | |
32 # Map to extra precision - int is a bignum in Dart. | |
33 'short': 'int', | |
34 'string': 'String', | |
35 'void': 'void', | |
36 'Array': 'List', | |
37 'sequence': 'List', | |
38 # TODO(sra): Come up with some meaningful name so that where this appears in | |
39 # the documentation, the user is made aware that only a limited subset of | |
40 # serializable types are actually permitted. | |
41 'SerializedScriptValue': 'Dynamic', | |
42 # TODO(vsm): Automatically recognize types defined in src. | |
43 'TimeoutHandler': 'TimeoutHandler', | |
44 'RequestAnimationFrameCallback': 'RequestAnimationFrameCallback', | |
45 | |
46 # TODO(sra): Flags is really a dictionary: {create:bool, exclusive:bool} | |
47 # http://dev.w3.org/2009/dap/file-system/file-dir-sys.html#the-flags-interfa
ce | |
48 'WebKitFlags': 'Object', | |
49 } | |
50 | |
51 _dart_to_idl_type_conversions = dict((v,k) for k, v in | |
52 _idl_to_dart_type_conversions.iteritems()) | |
53 | |
54 _pure_interfaces = set([ | |
55 'ElementTimeControl', | |
56 'ElementTraversal', | |
57 'MediaQueryListListener', | |
58 'NodeSelector', | |
59 'SVGExternalResourcesRequired', | |
60 'SVGFilterPrimitiveStandardAttributes', | |
61 'SVGFitToViewBox', | |
62 'SVGLangSpace', | |
63 'SVGLocatable', | |
64 'SVGStylable', | |
65 'SVGTests', | |
66 'SVGTransformable', | |
67 'SVGURIReference', | |
68 'SVGViewSpec', | |
69 'SVGZoomAndPan']) | |
70 | |
71 def IsPureInterface(interface_name): | |
72 return interface_name in _pure_interfaces | |
73 | |
74 # | |
75 # Identifiers that are used in the IDL than need to be treated specially because | |
76 # *some* JavaScript processors forbid them as properties. | |
77 # | |
78 _javascript_keywords = ['delete', 'continue'] | |
79 | |
80 # | |
81 # Renames for attributes that have names that are not legal Dart names. | |
82 # | |
83 _dart_attribute_renames = { | |
84 'default': 'defaultValue', | |
85 'final': 'finalValue', | |
86 } | |
87 | |
88 # | |
89 # Interface version of the DOM needs to delegate typed array constructors to a | |
90 # factory provider. | |
91 # | |
92 interface_factories = { | |
93 'Float32Array': '_TypedArrayFactoryProvider', | |
94 'Float64Array': '_TypedArrayFactoryProvider', | |
95 'Int8Array': '_TypedArrayFactoryProvider', | |
96 'Int16Array': '_TypedArrayFactoryProvider', | |
97 'Int32Array': '_TypedArrayFactoryProvider', | |
98 'Uint8Array': '_TypedArrayFactoryProvider', | |
99 'Uint16Array': '_TypedArrayFactoryProvider', | |
100 'Uint32Array': '_TypedArrayFactoryProvider', | |
101 'Uint8ClampedArray': '_TypedArrayFactoryProvider', | |
102 } | |
103 | |
104 # | |
105 # Custom methods that must be implemented by hand. | |
106 # | |
107 _custom_methods = set([ | |
108 ('DOMWindow', 'setInterval'), | |
109 ('DOMWindow', 'setTimeout'), | |
110 ('WorkerContext', 'setInterval'), | |
111 ('WorkerContext', 'setTimeout'), | |
112 ('CanvasRenderingContext2D', 'setFillStyle'), | |
113 ('CanvasRenderingContext2D', 'setStrokeStyle'), | |
114 ('CanvasRenderingContext2D', 'setFillStyle'), | |
115 ]) | |
116 | |
117 # | |
118 # Custom getters that must be implemented by hand. | |
119 # | |
120 _custom_getters = set([ | |
121 ('DOMWindow', 'localStorage'), | |
122 ]) | |
123 | |
124 # | |
125 # Custom native specs for the Frog dom. | |
126 # | |
127 _frog_dom_custom_native_specs = { | |
128 # Decorate the singleton Console object, if present (workers do not have a | |
129 # console). | |
130 'Console': "=(typeof console == 'undefined' ? {} : console)", | |
131 | |
132 # DOMWindow aliased with global scope. | |
133 'DOMWindow': '@*DOMWindow', | |
134 } | |
135 | |
136 # | |
137 # Simple method substitution when one method had different names on different | |
138 # browsers, but are otherwise identical. The alternates are tried in order and | |
139 # the first one defined is used. | |
140 # | |
141 # This can be probably be removed when Chrome renames initWebKitWheelEvent to | |
142 # initWheelEvent. | |
143 # | |
144 _alternate_methods = { | |
145 ('WheelEvent', 'initWheelEvent'): ['initWebKitWheelEvent', 'initWheelEvent'] | |
146 } | |
147 | |
148 # | |
149 # Custom native bodies for frog implementations of dom operations that appear in | |
150 # dart:dom and dart:html. This is used to work-around the lack of a 'rename' | |
151 # feature in the 'native' string - the correct name is available on the DartName | |
152 # extended attribute. See Issue 1814 | |
153 # | |
154 _dom_frog_native_typed_array_set_operation = """ | |
155 if (offset == null) return this.set(array); | |
156 return this.set(array, offset);""" | |
157 | |
158 dom_frog_native_bodies = { | |
159 'IDBCursor.continueFunction': | |
160 """ | |
161 if (key == null) return this['continue'](); | |
162 return this['continue'](key); | |
163 """, | |
164 'IDBIndex.getObject': """return this.get(key);""", | |
165 'IDBObjectStore.getObject': """return this.get(key);""", | |
166 'Float32Array.setElements': _dom_frog_native_typed_array_set_operation, | |
167 'Float64Array.setElements': _dom_frog_native_typed_array_set_operation, | |
168 'Int16Array.setElements': _dom_frog_native_typed_array_set_operation, | |
169 'Int32Array.setElements': _dom_frog_native_typed_array_set_operation, | |
170 'Int8Array.setElements': _dom_frog_native_typed_array_set_operation, | |
171 'Uint16Array.setElements': _dom_frog_native_typed_array_set_operation, | |
172 'Uint32Array.setElements': _dom_frog_native_typed_array_set_operation, | |
173 'Uint8Array.setElements': _dom_frog_native_typed_array_set_operation, | |
174 'Uint8ClampedArray.setElements': _dom_frog_native_typed_array_set_operation, | |
175 } | |
176 | |
177 | |
178 def ConvertPrimitiveType(type_name): | |
179 if type_name.startswith('unsigned '): | |
180 type_name = type_name[len('unsigned '):] | |
181 | |
182 if type_name in _idl_to_dart_type_conversions: | |
183 # Primitive type conversion | |
184 return _idl_to_dart_type_conversions[type_name] | |
185 return None | |
186 | |
187 def IsPrimitiveType(type_name): | |
188 return (ConvertPrimitiveType(type_name) is not None or | |
189 type_name in _dart_to_idl_type_conversions) | |
190 | |
191 def MaybeListElementTypeName(type_name): | |
192 """Returns the List element type T from string of form "List<T>", or None.""" | |
193 match = re.match(r'sequence<(\w*)>$', type_name) | |
194 if match: | |
195 return match.group(1) | |
196 return None | |
197 | |
198 def MaybeListElementType(interface): | |
199 """Returns the List element type T, or None in interface does not implement | |
200 List<T>. | |
201 """ | |
202 for parent in interface.parents: | |
203 element_type = MaybeListElementTypeName(parent.type.id) | |
204 if element_type: | |
205 return element_type | |
206 return None | |
207 | |
208 def MaybeTypedArrayElementType(interface): | |
209 """Returns the typed array element type, or None in interface is not a | |
210 TypedArray. | |
211 """ | |
212 # Typed arrays implement ArrayBufferView and List<T>. | |
213 for parent in interface.parents: | |
214 if parent.type.id == 'ArrayBufferView': | |
215 return MaybeListElementType(interface) | |
216 if parent.type.id == 'Uint8Array': | |
217 return 'int' | |
218 return None | |
219 | |
220 def MakeNativeSpec(javascript_binding_name): | |
221 if javascript_binding_name in _frog_dom_custom_native_specs: | |
222 return _frog_dom_custom_native_specs[javascript_binding_name] | |
223 else: | |
224 # Make the class 'hidden' so it is dynamically patched at runtime. This | |
225 # is useful not only for browser compat, but to allow code that links | |
226 # against dart:dom to load in a worker isolate. | |
227 return '*' + javascript_binding_name | |
228 | |
229 | |
230 def MatchSourceFilter(filter, thing): | |
231 if not filter: | |
232 return True | |
233 else: | |
234 return any(token in thing.annotations for token in filter) | |
235 | |
236 def DartType(idl_type_name): | |
237 match = re.match(r'sequence<(\w*)>$', idl_type_name) | |
238 if match: | |
239 return 'List<%s>' % GetIDLTypeInfo(match.group(1)).dart_type() | |
240 return GetIDLTypeInfo(idl_type_name).dart_type() | |
241 | |
242 # Given a list of overloaded arguments, render a dart argument. | |
243 def _DartArg(args, interface): | |
244 # Given a list of overloaded arguments, choose a suitable name. | |
245 def OverloadedName(args): | |
246 return '_OR_'.join(sorted(set(arg.id for arg in args))) | |
247 | |
248 # Given a list of overloaded arguments, choose a suitable type. | |
249 def OverloadedType(args): | |
250 typeIds = sorted(set(DartType(arg.type.id) for arg in args)) | |
251 if len(typeIds) == 1: | |
252 return typeIds[0] | |
253 else: | |
254 return TypeName(typeIds, interface) | |
255 | |
256 filtered = filter(None, args) | |
257 optional = any(not arg or arg.is_optional for arg in args) | |
258 type = OverloadedType(filtered) | |
259 name = OverloadedName(filtered) | |
260 if optional: | |
261 return (name, type, 'null') | |
262 else: | |
263 return (name, type, None) | |
264 | |
265 | |
266 def AnalyzeOperation(interface, operations): | |
267 """Makes operation calling convention decision for a set of overloads. | |
268 | |
269 Returns: An OperationInfo object. | |
270 """ | |
271 | |
272 # Zip together arguments from each overload by position, then convert | |
273 # to a dart argument. | |
274 args = map(lambda *args: _DartArg(args, interface), | |
275 *(op.arguments for op in operations)) | |
276 | |
277 info = OperationInfo() | |
278 info.overloads = operations | |
279 info.declared_name = operations[0].id | |
280 info.name = operations[0].ext_attrs.get('DartName', info.declared_name) | |
281 info.js_name = info.declared_name | |
282 info.type_name = DartType(operations[0].type.id) # TODO: widen. | |
283 info.arg_infos = args | |
284 return info | |
285 | |
286 | |
287 def AnalyzeConstructor(interface): | |
288 """Returns an OperationInfo object for the constructor. | |
289 | |
290 Returns None if the interface has no Constructor. | |
291 """ | |
292 def GetArgs(func_value): | |
293 return map(lambda arg: _DartArg([arg], interface), func_value.arguments) | |
294 | |
295 if 'Constructor' in interface.ext_attrs: | |
296 name = None | |
297 func_value = interface.ext_attrs.get('Constructor') | |
298 if func_value: | |
299 # [Constructor(param,...)] | |
300 args = GetArgs(func_value) | |
301 idl_args = func_value.arguments | |
302 else: # [Constructor] | |
303 args = [] | |
304 idl_args = [] | |
305 else: | |
306 func_value = interface.ext_attrs.get('NamedConstructor') | |
307 if func_value: | |
308 name = func_value.id | |
309 args = GetArgs(func_value) | |
310 idl_args = func_value.arguments | |
311 else: | |
312 return None | |
313 | |
314 info = OperationInfo() | |
315 info.overloads = None | |
316 info.idl_args = idl_args | |
317 info.declared_name = name | |
318 info.name = name | |
319 info.js_name = name | |
320 info.type_name = interface.id | |
321 info.arg_infos = args | |
322 return info | |
323 | |
324 | |
325 def RecognizeCallback(interface): | |
326 """Returns the info for the callback method if the interface smells like a | |
327 callback. | |
328 """ | |
329 if 'Callback' not in interface.ext_attrs: return None | |
330 handlers = [op for op in interface.operations if op.id == 'handleEvent'] | |
331 if not handlers: return None | |
332 if not (handlers == interface.operations): return None | |
333 return AnalyzeOperation(interface, handlers) | |
334 | |
335 def IsDartListType(type): | |
336 return type == 'List' or type.startswith('sequence<') | |
337 | |
338 def IsDartCollectionType(type): | |
339 return IsDartListType(type) | |
340 | |
341 def FindMatchingAttribute(interface, attr1): | |
342 matches = [attr2 for attr2 in interface.attributes | |
343 if attr1.id == attr2.id | |
344 and attr1.is_fc_getter == attr2.is_fc_getter | |
345 and attr1.is_fc_setter == attr2.is_fc_setter] | |
346 if matches: | |
347 assert len(matches) == 1 | |
348 return matches[0] | |
349 return None | |
350 | |
351 | |
352 def DartDomNameOfAttribute(attr): | |
353 """Returns the Dart name for an IDLAttribute. | |
354 | |
355 attr.id is the 'native' or JavaScript name. | |
356 | |
357 To ensure uniformity, work with the true IDL name until as late a possible, | |
358 e.g. translate to the Dart name when generating Dart code. | |
359 """ | |
360 name = attr.id | |
361 name = _dart_attribute_renames.get(name, name) | |
362 name = attr.ext_attrs.get('DartName', None) or name | |
363 return name | |
364 | |
365 class OperationInfo(object): | |
366 """Holder for various derived information from a set of overloaded operations. | |
367 | |
368 Attributes: | |
369 overloads: A list of IDL operation overloads with the same name. | |
370 name: A string, the simple name of the operation. | |
371 type_name: A string, the name of the return type of the operation. | |
372 arg_infos: A list of (name, type, default_value) tuples. | |
373 default_value is None for mandatory arguments. | |
374 """ | |
375 | |
376 def ParametersInterfaceDeclaration(self): | |
377 """Returns a formatted string declaring the parameters for the interface.""" | |
378 return self._FormatArgs(self.arg_infos, True) | |
379 | |
380 def ParametersImplementationDeclaration(self, rename_type=None): | |
381 """Returns a formatted string declaring the parameters for the | |
382 implementation. | |
383 | |
384 Args: | |
385 rename_type: A function that allows the types to be renamed. | |
386 """ | |
387 args = self.arg_infos | |
388 if rename_type: | |
389 args = [(name, rename_type(type), default) | |
390 for (name, type, default) in args] | |
391 return self._FormatArgs(args, False) | |
392 | |
393 def ParametersAsArgumentList(self): | |
394 """Returns a formatted string declaring the parameters names as an argument | |
395 list. | |
396 """ | |
397 return ', '.join(map(lambda arg_info: arg_info[0], self.arg_infos)) | |
398 | |
399 def _FormatArgs(self, args, is_interface): | |
400 def FormatArg(arg_info): | |
401 """Returns an argument declaration fragment for an argument info tuple.""" | |
402 (name, type, default) = arg_info | |
403 if default: | |
404 return '%s %s = %s' % (type, name, default) | |
405 else: | |
406 return '%s %s' % (type, name) | |
407 | |
408 required = [] | |
409 optional = [] | |
410 for (name, type, default) in args: | |
411 if default: | |
412 if is_interface: | |
413 optional.append((name, type, None)) # Default values illegal. | |
414 else: | |
415 optional.append((name, type, default)) | |
416 else: | |
417 if optional: | |
418 raise Exception('Optional arguments cannot precede required ones: ' | |
419 + str(args)) | |
420 required.append((name, type, None)) | |
421 argtexts = map(FormatArg, required) | |
422 if optional: | |
423 argtexts.append('[' + ', '.join(map(FormatArg, optional)) + ']') | |
424 return ', '.join(argtexts) | |
425 | |
426 | |
427 def AttributeOutputOrder(a, b): | |
428 """Canonical output ordering for attributes.""" | |
429 # Getters before setters: | |
430 if a.id < b.id: return -1 | |
431 if a.id > b.id: return 1 | |
432 if a.is_fc_setter < b.is_fc_setter: return -1 | |
433 if a.is_fc_setter > b.is_fc_setter: return 1 | |
434 return 0 | |
435 | |
436 def ConstantOutputOrder(a, b): | |
437 """Canonical output ordering for constants.""" | |
438 if a.id < b.id: return -1 | |
439 if a.id > b.id: return 1 | |
440 return 0 | |
441 | |
442 | |
443 def _FormatNameList(names): | |
444 """Returns JavaScript array literal expression with one name per line.""" | |
445 #names = sorted(names) | |
446 if len(names) <= 1: | |
447 expression_string = str(names) # e.g. ['length'] | |
448 else: | |
449 expression_string = ',\n '.join(str(names).split(',')) | |
450 expression_string = expression_string.replace('[', '[\n ') | |
451 return expression_string | |
452 | |
453 | |
454 def IndentText(text, indent): | |
455 """Format lines of text with indent.""" | |
456 def FormatLine(line): | |
457 if line.strip(): | |
458 return '%s%s\n' % (indent, line) | |
459 else: | |
460 return '\n' | |
461 return ''.join(FormatLine(line) for line in text.split('\n')) | |
462 | |
463 # Given a sorted sequence of type identifiers, return an appropriate type | |
464 # name | |
465 def TypeName(typeIds, interface): | |
466 # Dynamically type this field for now. | |
467 return 'var' | |
468 | |
469 # ------------------------------------------------------------------------------ | |
470 | |
471 class IDLTypeInfo(object): | |
472 def __init__(self, idl_type, dart_type=None, native_type=None, ref_counted=Tru
e, | |
473 has_dart_wrapper=True, conversion_template=None, | |
474 custom_to_dart=False, conversion_includes=[]): | |
475 self._idl_type = idl_type | |
476 self._dart_type = dart_type | |
477 self._native_type = native_type | |
478 self._ref_counted = ref_counted | |
479 self._has_dart_wrapper = has_dart_wrapper | |
480 self._conversion_template = conversion_template | |
481 self._custom_to_dart = custom_to_dart | |
482 self._conversion_includes = conversion_includes | |
483 | |
484 def idl_type(self): | |
485 return self._idl_type | |
486 | |
487 def dart_type(self): | |
488 if self._dart_type: | |
489 return self._dart_type | |
490 return self._idl_type | |
491 | |
492 def native_type(self): | |
493 if self._native_type: | |
494 return self._native_type | |
495 return self._idl_type | |
496 | |
497 def parameter_adapter_info(self): | |
498 native_type = self.native_type() | |
499 if self._ref_counted: | |
500 native_type = 'RefPtr< %s >' % native_type | |
501 if self._has_dart_wrapper: | |
502 wrapper_type = 'Dart%s' % self.idl_type() | |
503 adapter_type = 'ParameterAdapter<%s, %s>' % (native_type, wrapper_type) | |
504 return (adapter_type, '"%s.h"' % wrapper_type) | |
505 return ('ParameterAdapter< %s >' % native_type, '"%s.h"' % self._idl_type) | |
506 | |
507 def parameter_type(self): | |
508 return '%s*' % self.native_type() | |
509 | |
510 def webcore_includes(self): | |
511 WTF_INCLUDES = [ | |
512 'ArrayBuffer', | |
513 'ArrayBufferView', | |
514 'Float32Array', | |
515 'Float64Array', | |
516 'Int8Array', | |
517 'Int16Array', | |
518 'Int32Array', | |
519 'Uint8Array', | |
520 'Uint16Array', | |
521 'Uint32Array', | |
522 'Uint8ClampedArray', | |
523 ] | |
524 | |
525 if self._idl_type in WTF_INCLUDES: | |
526 return ['<wtf/%s.h>' % self._idl_type] | |
527 | |
528 if not self._idl_type.startswith('SVG'): | |
529 return ['"%s.h"' % self._idl_type] | |
530 | |
531 if self._idl_type in ['SVGNumber', 'SVGPoint']: | |
532 return [] | |
533 if self._idl_type.startswith('SVGPathSeg'): | |
534 include = self._idl_type.replace('Abs', '').replace('Rel', '') | |
535 else: | |
536 include = self._idl_type | |
537 return ['"%s.h"' % include] + _svg_supplemental_includes | |
538 | |
539 def receiver(self): | |
540 return 'receiver->' | |
541 | |
542 def conversion_includes(self): | |
543 return ['"Dart%s.h"' % include for include in [self.dart_type()] + self._con
version_includes] | |
544 | |
545 def conversion_cast(self, expression): | |
546 if self._conversion_template: | |
547 return self._conversion_template % expression | |
548 return expression | |
549 | |
550 def custom_to_dart(self): | |
551 return self._custom_to_dart | |
552 | |
553 class PrimitiveIDLTypeInfo(IDLTypeInfo): | |
554 def __init__(self, idl_type, dart_type, native_type=None, ref_counted=False, | |
555 conversion_template=None, | |
556 webcore_getter_name='getAttribute', | |
557 webcore_setter_name='setAttribute'): | |
558 super(PrimitiveIDLTypeInfo, self).__init__(idl_type, dart_type=dart_type, | |
559 native_type=native_type, ref_counted=ref_counted, | |
560 conversion_template=conversion_template) | |
561 self._webcore_getter_name = webcore_getter_name | |
562 self._webcore_setter_name = webcore_setter_name | |
563 | |
564 def parameter_adapter_info(self): | |
565 native_type = self.native_type() | |
566 if self._ref_counted: | |
567 native_type = 'RefPtr< %s >' % native_type | |
568 return ('ParameterAdapter< %s >' % native_type, None) | |
569 | |
570 def parameter_type(self): | |
571 if self.native_type() == 'String': | |
572 return 'const String&' | |
573 return self.native_type() | |
574 | |
575 def conversion_includes(self): | |
576 return [] | |
577 | |
578 def webcore_getter_name(self): | |
579 return self._webcore_getter_name | |
580 | |
581 def webcore_setter_name(self): | |
582 return self._webcore_setter_name | |
583 | |
584 class SVGTearOffIDLTypeInfo(IDLTypeInfo): | |
585 def __init__(self, idl_type, native_type='', ref_counted=True): | |
586 super(SVGTearOffIDLTypeInfo, self).__init__(idl_type, | |
587 native_type=native_type, | |
588 ref_counted=ref_counted) | |
589 | |
590 def native_type(self): | |
591 if self._native_type: | |
592 return self._native_type | |
593 tear_off_type = 'SVGPropertyTearOff' | |
594 if self._idl_type.endswith('List'): | |
595 tear_off_type = 'SVGListPropertyTearOff' | |
596 return '%s<%s>' % (tear_off_type, self._idl_type) | |
597 | |
598 def receiver(self): | |
599 if self._idl_type.endswith('List'): | |
600 return 'receiver->' | |
601 return 'receiver->propertyReference().' | |
602 | |
603 | |
604 _idl_type_registry = { | |
605 # There is GC3Dboolean which is not a bool, but unsigned char for OpenGL com
patibility. | |
606 'boolean': PrimitiveIDLTypeInfo('boolean', dart_type='bool', native_type='bo
ol', | |
607 conversion_template='static_cast<bool>(%s)', | |
608 webcore_getter_name='hasAttribute', | |
609 webcore_setter_name='setBooleanAttribute'), | |
610 # Some IDL's unsigned shorts/shorts are mapped to WebCore C++ enums, so we | |
611 # use a static_cast<int> here not to provide overloads for all enums. | |
612 'short': PrimitiveIDLTypeInfo('short', dart_type='int', native_type='int', | |
613 conversion_template='static_cast<int>(%s)'), | |
614 'unsigned short': PrimitiveIDLTypeInfo('unsigned short', dart_type='int', | |
615 native_type='int', conversion_template='static_cast<int>(%s)'), | |
616 'int': PrimitiveIDLTypeInfo('int', dart_type='int'), | |
617 'unsigned int': PrimitiveIDLTypeInfo('unsigned int', dart_type='int', | |
618 native_type='unsigned'), | |
619 'long': PrimitiveIDLTypeInfo('long', dart_type='int', native_type='int', | |
620 webcore_getter_name='getIntegralAttribute', | |
621 webcore_setter_name='setIntegralAttribute'), | |
622 'unsigned long': PrimitiveIDLTypeInfo('unsigned long', dart_type='int', | |
623 native_type='unsigned', | |
624 webcore_getter_name='getUnsignedIntegralAttribute', | |
625 webcore_setter_name='setUnsignedIntegralAttribute'), | |
626 'long long': PrimitiveIDLTypeInfo('long long', dart_type='int'), | |
627 'unsigned long long': PrimitiveIDLTypeInfo('unsigned long long', dart_type='
int'), | |
628 'double': PrimitiveIDLTypeInfo('double', dart_type='num'), | |
629 'float': PrimitiveIDLTypeInfo('float', dart_type='num'), | |
630 | |
631 'any': PrimitiveIDLTypeInfo('any', dart_type='Object'), | |
632 'any[]': PrimitiveIDLTypeInfo('any[]', dart_type='List'), | |
633 'Array': PrimitiveIDLTypeInfo('Array', dart_type='List'), | |
634 'custom': PrimitiveIDLTypeInfo('custom', dart_type='Dynamic'), | |
635 'Date': PrimitiveIDLTypeInfo('Date', dart_type='Date', native_type='double')
, | |
636 'DOMObject': PrimitiveIDLTypeInfo('DOMObject', dart_type='Object'), | |
637 'DOMString': PrimitiveIDLTypeInfo('DOMString', dart_type='String', native_ty
pe='String'), | |
638 # TODO(sra): Flags is really a dictionary: {create:bool, exclusive:bool} | |
639 # http://dev.w3.org/2009/dap/file-system/file-dir-sys.html#the-flags-interfa
ce | |
640 'Flags': PrimitiveIDLTypeInfo('Flags', dart_type='Object'), | |
641 'List<String>': PrimitiveIDLTypeInfo('DOMStringList', dart_type='List<String
>'), | |
642 'DOMTimeStamp': PrimitiveIDLTypeInfo('DOMTimeStamp', dart_type='int'), | |
643 'object': PrimitiveIDLTypeInfo('object', dart_type='Object', native_type='Sc
riptValue'), | |
644 'SerializedScriptValue': PrimitiveIDLTypeInfo('SerializedScriptValue', dart_
type='Dynamic', ref_counted=True), | |
645 'WebKitFlags': PrimitiveIDLTypeInfo('WebKitFlags', dart_type='Object'), | |
646 | |
647 'CSSRule': IDLTypeInfo('CSSRule', conversion_includes=['CSSImportRule']), | |
648 'DOMException': IDLTypeInfo('DOMCoreException', dart_type='DOMException'), | |
649 'DOMWindow': IDLTypeInfo('DOMWindow', custom_to_dart=True), | |
650 'Element': IDLTypeInfo('Element', custom_to_dart=True), | |
651 'EventListener': IDLTypeInfo('EventListener', has_dart_wrapper=False), | |
652 'EventTarget': IDLTypeInfo('EventTarget', has_dart_wrapper=False), | |
653 'HTMLElement': IDLTypeInfo('HTMLElement', custom_to_dart=True), | |
654 'MediaQueryListListener': IDLTypeInfo('MediaQueryListListener', has_dart_wra
pper=False), | |
655 'OptionsObject': IDLTypeInfo('OptionsObject', has_dart_wrapper=False), | |
656 'StyleSheet': IDLTypeInfo('StyleSheet', conversion_includes=['CSSStyleSheet'
]), | |
657 'SVGElement': IDLTypeInfo('SVGElement', custom_to_dart=True), | |
658 | |
659 'SVGAngle': SVGTearOffIDLTypeInfo('SVGAngle'), | |
660 'SVGLength': SVGTearOffIDLTypeInfo('SVGLength'), | |
661 'SVGLengthList': SVGTearOffIDLTypeInfo('SVGLengthList', ref_counted=False), | |
662 'SVGMatrix': SVGTearOffIDLTypeInfo('SVGMatrix'), | |
663 'SVGNumber': SVGTearOffIDLTypeInfo('SVGNumber', native_type='SVGPropertyTear
Off<float>'), | |
664 'SVGNumberList': SVGTearOffIDLTypeInfo('SVGNumberList', ref_counted=False), | |
665 'SVGPathSegList': SVGTearOffIDLTypeInfo('SVGPathSegList', native_type='SVGPa
thSegListPropertyTearOff', ref_counted=False), | |
666 'SVGPoint': SVGTearOffIDLTypeInfo('SVGPoint', native_type='SVGPropertyTearOf
f<FloatPoint>'), | |
667 'SVGPointList': SVGTearOffIDLTypeInfo('SVGPointList', ref_counted=False), | |
668 'SVGPreserveAspectRatio': SVGTearOffIDLTypeInfo('SVGPreserveAspectRatio'), | |
669 'SVGRect': SVGTearOffIDLTypeInfo('SVGRect', native_type='SVGPropertyTearOff<
FloatRect>'), | |
670 'SVGStringList': SVGTearOffIDLTypeInfo('SVGStringList', native_type='SVGStat
icListPropertyTearOff<SVGStringList>', ref_counted=False), | |
671 'SVGTransform': SVGTearOffIDLTypeInfo('SVGTransform'), | |
672 'SVGTransformList': SVGTearOffIDLTypeInfo('SVGTransformList', native_type='S
VGTransformListPropertyTearOff', ref_counted=False) | |
673 } | |
674 | |
675 _svg_supplemental_includes = [ | |
676 '"SVGAnimatedPropertyTearOff.h"', | |
677 '"SVGAnimatedListPropertyTearOff.h"', | |
678 '"SVGStaticListPropertyTearOff.h"', | |
679 '"SVGAnimatedListPropertyTearOff.h"', | |
680 '"SVGTransformListPropertyTearOff.h"', | |
681 '"SVGPathSegListPropertyTearOff.h"', | |
682 ] | |
683 | |
684 def GetIDLTypeInfo(idl_type_name): | |
685 return _idl_type_registry.get(idl_type_name, IDLTypeInfo(idl_type_name)) | |
OLD | NEW |