| OLD | NEW |
| 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 systems to generate | 6 """This module provides shared functionality for systems to generate |
| 7 Dart APIs from the IDL database.""" | 7 Dart APIs from the IDL database.""" |
| 8 | 8 |
| 9 import re | 9 import re |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 'SVGTransformable', | 23 'SVGTransformable', |
| 24 'SVGURIReference', | 24 'SVGURIReference', |
| 25 'SVGViewSpec', | 25 'SVGViewSpec', |
| 26 'SVGZoomAndPan', | 26 'SVGZoomAndPan', |
| 27 'TimeoutHandler']) | 27 'TimeoutHandler']) |
| 28 | 28 |
| 29 def IsPureInterface(interface_name): | 29 def IsPureInterface(interface_name): |
| 30 return interface_name in _pure_interfaces | 30 return interface_name in _pure_interfaces |
| 31 | 31 |
| 32 # | 32 # |
| 33 # Identifiers that are used in the IDL than need to be treated specially because | |
| 34 # *some* JavaScript processors forbid them as properties. | |
| 35 # | |
| 36 _javascript_keywords = ['delete', 'continue'] | |
| 37 | |
| 38 # | |
| 39 # Renames for attributes that have names that are not legal Dart names. | 33 # Renames for attributes that have names that are not legal Dart names. |
| 40 # | 34 # |
| 41 _dart_attribute_renames = { | 35 _dart_attribute_renames = { |
| 42 'default': 'defaultValue', | 36 'default': 'defaultValue', |
| 43 'final': 'finalValue', | 37 'final': 'finalValue', |
| 44 } | 38 } |
| 45 | 39 |
| 46 # | 40 # |
| 47 # Interface version of the DOM needs to delegate typed array constructors to a | 41 # Interface version of the DOM needs to delegate typed array constructors to a |
| 48 # factory provider. | 42 # factory provider. |
| 49 # | 43 # |
| 50 interface_factories = { | 44 interface_factories = { |
| 51 'Float32Array': '_TypedArrayFactoryProvider', | 45 'Float32Array': '_TypedArrayFactoryProvider', |
| 52 'Float64Array': '_TypedArrayFactoryProvider', | 46 'Float64Array': '_TypedArrayFactoryProvider', |
| 53 'Int8Array': '_TypedArrayFactoryProvider', | 47 'Int8Array': '_TypedArrayFactoryProvider', |
| 54 'Int16Array': '_TypedArrayFactoryProvider', | 48 'Int16Array': '_TypedArrayFactoryProvider', |
| 55 'Int32Array': '_TypedArrayFactoryProvider', | 49 'Int32Array': '_TypedArrayFactoryProvider', |
| 56 'Uint8Array': '_TypedArrayFactoryProvider', | 50 'Uint8Array': '_TypedArrayFactoryProvider', |
| 57 'Uint16Array': '_TypedArrayFactoryProvider', | 51 'Uint16Array': '_TypedArrayFactoryProvider', |
| 58 'Uint32Array': '_TypedArrayFactoryProvider', | 52 'Uint32Array': '_TypedArrayFactoryProvider', |
| 59 'Uint8ClampedArray': '_TypedArrayFactoryProvider', | 53 'Uint8ClampedArray': '_TypedArrayFactoryProvider', |
| 60 } | 54 } |
| 61 | 55 |
| 62 # | 56 # |
| 63 # Custom methods that must be implemented by hand. | |
| 64 # | |
| 65 _custom_methods = set([ | |
| 66 ('DOMWindow', 'setInterval'), | |
| 67 ('DOMWindow', 'setTimeout'), | |
| 68 ('WorkerContext', 'setInterval'), | |
| 69 ('WorkerContext', 'setTimeout'), | |
| 70 ('CanvasRenderingContext2D', 'setFillStyle'), | |
| 71 ('CanvasRenderingContext2D', 'setStrokeStyle'), | |
| 72 ('CanvasRenderingContext2D', 'setFillStyle'), | |
| 73 ]) | |
| 74 | |
| 75 # | |
| 76 # Custom getters that must be implemented by hand. | |
| 77 # | |
| 78 _custom_getters = set([ | |
| 79 ('DOMWindow', 'localStorage'), | |
| 80 ]) | |
| 81 | |
| 82 # | |
| 83 # Custom native specs for the Frog dom. | 57 # Custom native specs for the Frog dom. |
| 84 # | 58 # |
| 85 _frog_dom_custom_native_specs = { | 59 _frog_dom_custom_native_specs = { |
| 86 # Decorate the singleton Console object, if present (workers do not have a | 60 # Decorate the singleton Console object, if present (workers do not have a |
| 87 # console). | 61 # console). |
| 88 'Console': "=(typeof console == 'undefined' ? {} : console)", | 62 'Console': "=(typeof console == 'undefined' ? {} : console)", |
| 89 | 63 |
| 90 # DOMWindow aliased with global scope. | 64 # DOMWindow aliased with global scope. |
| 91 'DOMWindow': '@*DOMWindow', | 65 'DOMWindow': '@*DOMWindow', |
| 92 } | 66 } |
| 93 | 67 |
| 94 # | 68 # |
| 95 # Simple method substitution when one method had different names on different | |
| 96 # browsers, but are otherwise identical. The alternates are tried in order and | |
| 97 # the first one defined is used. | |
| 98 # | |
| 99 # This can be probably be removed when Chrome renames initWebKitWheelEvent to | |
| 100 # initWheelEvent. | |
| 101 # | |
| 102 _alternate_methods = { | |
| 103 ('WheelEvent', 'initWheelEvent'): ['initWebKitWheelEvent', 'initWheelEvent'] | |
| 104 } | |
| 105 | |
| 106 # | |
| 107 # Custom native bodies for frog implementations of dom operations that appear in | 69 # Custom native bodies for frog implementations of dom operations that appear in |
| 108 # dart:dom and dart:html. This is used to work-around the lack of a 'rename' | 70 # dart:dom and dart:html. This is used to work-around the lack of a 'rename' |
| 109 # feature in the 'native' string - the correct name is available on the DartName | 71 # feature in the 'native' string - the correct name is available on the DartName |
| 110 # extended attribute. See Issue 1814 | 72 # extended attribute. See Issue 1814 |
| 111 # | 73 # |
| 112 dom_frog_native_bodies = { | 74 dom_frog_native_bodies = { |
| 113 # Some JavaScript processors, especially tools like yuicompress and | 75 # Some JavaScript processors, especially tools like yuicompress and |
| 114 # JSCompiler, choke on 'this.continue' | 76 # JSCompiler, choke on 'this.continue' |
| 115 'IDBCursor.continueFunction': | 77 'IDBCursor.continueFunction': |
| 116 """ | 78 """ |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 '"SVGAnimatedPropertyTearOff.h"', | 597 '"SVGAnimatedPropertyTearOff.h"', |
| 636 '"SVGAnimatedListPropertyTearOff.h"', | 598 '"SVGAnimatedListPropertyTearOff.h"', |
| 637 '"SVGStaticListPropertyTearOff.h"', | 599 '"SVGStaticListPropertyTearOff.h"', |
| 638 '"SVGAnimatedListPropertyTearOff.h"', | 600 '"SVGAnimatedListPropertyTearOff.h"', |
| 639 '"SVGTransformListPropertyTearOff.h"', | 601 '"SVGTransformListPropertyTearOff.h"', |
| 640 '"SVGPathSegListPropertyTearOff.h"', | 602 '"SVGPathSegListPropertyTearOff.h"', |
| 641 ] | 603 ] |
| 642 | 604 |
| 643 def GetIDLTypeInfo(idl_type_name): | 605 def GetIDLTypeInfo(idl_type_name): |
| 644 return _idl_type_registry.get(idl_type_name, IDLTypeInfo(idl_type_name)) | 606 return _idl_type_registry.get(idl_type_name, IDLTypeInfo(idl_type_name)) |
| OLD | NEW |