5"""This module provides shared functionality for the system to generate
6Dart:html APIs from the IDL database."""
13from collections
import OrderedDict
14from generator
import *
15from htmldartgenerator
import *
16from htmlrenamer
import generateCallbackInterface
18_logger = logging.getLogger(
'systemhtml')
24 static_extension_interfaces = []
25 return interface
in static_extension_interfaces
29 'html',
'indexed_db',
'svg',
'web_audio',
'web_gl',
'web_sql'
33 'systemhtml._safe_to_ignore_shadowing_members', [
34 'SVGElement.tabIndex',
35 'SVGStyleElement.title',
39 'systemhtml._js_custom_members',
41 'AudioContext.createGain',
42 'AudioContext.createScriptProcessor',
43 'CanvasRenderingContext2D.drawImage',
44 'CanvasRenderingContext2D.fillText',
45 'CanvasRenderingContext2D.lineDashOffset',
46 'CanvasRenderingContext2D.setLineDash',
48 'ConsoleBase.assertCondition',
51 'ConsoleBase.countReset',
57 'ConsoleBase.groupCollapsed',
58 'ConsoleBase.groupEnd',
61 'ConsoleBase.markTimeline',
62 'ConsoleBase.profile',
63 'ConsoleBase.profileEnd',
66 'ConsoleBase.timeEnd',
67 'ConsoleBase.timeStamp',
70 'WebKitCSSKeyframesRule.insertRule',
71 'CSSStyleDeclaration.setProperty',
72 'CSSStyleDeclaration.__propertyQuery__',
73 'Document.createNodeIterator',
74 'Document.createTreeWalker',
76 'DOMException.toString',
80 'DOMStringList.contains',
82 'Element.createShadowRoot',
83 'Element.insertAdjacentElement',
84 'Element.insertAdjacentHTML',
85 'Element.insertAdjacentText',
89 'ElementEvents.mouseWheel',
90 'ElementEvents.transitionEnd',
92 'HTMLAnchorElement.toString',
93 'HTMLAreaElement.toString',
94 'HTMLTableElement.createTBody',
96 'IDBDatabase.transaction',
97 'IDBDatabase.transactionList',
98 'IDBDatabase.transactionStore',
99 'IDBDatabase.transactionStores',
100 'KeyboardEvent.initKeyboardEvent',
103 'MouseEvent.offsetX',
104 'MouseEvent.offsetY',
105 'Navigator.language',
106 'Navigator.webkitGetUserMedia',
107 'ScriptProcessorNode._setEventListener',
108 'URL.createObjectURL',
109 'URL.createObjectUrlFromSource',
110 'URL.createObjectUrlFromStream',
111 'URL.createObjectUrlFromBlob',
112 'URL.revokeObjectURL',
114 'WheelEvent.deltaMode',
115 'Window.cancelAnimationFrame',
121 'Window.requestAnimationFrame',
129 'systemhtml._js_custom_constructors', [
137 'RTCSessionDescription',
144_static_classes =
set([
'Url'])
148 'systemhtml._callback_list_generics_mapping', [
150 'List<IntersectionObserverEntry>',
151 'List<MutationRecord>',
153 'List<ResizeObserverEntry>',
171 factory_provider_name='document'):
179 info = OperationInfo()
180 info.overloads =
None
181 info.declared_name = interface_name
182 info.name = interface_name
183 info.constructor_name = self.
name
185 info.type_name = interface_name
188 ParamInfo(name=tXn[1],
193 default_value_is_null=
False)
for tXn
in self.
opt_params
195 info.requires_named_arguments =
True
196 info.factory_parameters = [
'"%s"' % self.
tag]
197 info.pure_dart_constructor =
True
202 'systemhtml._html_element_constructors',
220 tag=
'canvas', opt_params=[(
'int',
'width'), (
'int',
'height')]),
221 'HTMLContentElement':
223 'HTMLDataListElement':
227 'HTMLDetailsElement':
233 'HTMLFieldSetElement':
241 'HTMLHeadingElement': [
256 opt_params=[(
'DOMString',
'src'), (
'int',
'width'),
280 'HTMLOptGroupElement':
284 'HTMLParagraphElement':
290 'HTMLProgressElement':
306 'HTMLTableCaptionElement':
308 'HTMLTableCellElement':
310 'HTMLTableColElement':
314 'HTMLTableRowElement':
317 'HTMLTemplateElement':
319 'HTMLTextAreaElement':
332 'systemhtml._svg_element_constructors', {
334 'SVGAltGlyphElement':
'altGlyph',
335 'SVGAnimateElement':
'animate',
336 'SVGAnimateMotionElement':
'animateMotion',
337 'SVGAnimateTransformElement':
'animateTransform',
338 'SVGAnimationElement':
'animation',
339 'SVGCircleElement':
'circle',
340 'SVGClipPathElement':
'clipPath',
341 'SVGCursorElement':
'cursor',
342 'SVGDefsElement':
'defs',
343 'SVGDescElement':
'desc',
344 'SVGEllipseElement':
'ellipse',
345 'SVGFEBlendElement':
'feBlend',
346 'SVGFEColorMatrixElement':
'feColorMatrix',
347 'SVGFEComponentTransferElement':
'feComponentTransfer',
348 'SVGFEConvolveMatrixElement':
'feConvolveMatrix',
349 'SVGFEDiffuseLightingElement':
'feDiffuseLighting',
350 'SVGFEDisplacementMapElement':
'feDisplacementMap',
351 'SVGFEDistantLightElement':
'feDistantLight',
352 'SVGFEFloodElement':
'feFlood',
353 'SVGFEFuncAElement':
'feFuncA',
354 'SVGFEFuncBElement':
'feFuncB',
355 'SVGFEFuncGElement':
'feFuncG',
356 'SVGFEFuncRElement':
'feFuncR',
357 'SVGFEGaussianBlurElement':
'feGaussianBlur',
358 'SVGFEImageElement':
'feImage',
359 'SVGFEMergeElement':
'feMerge',
360 'SVGFEMergeNodeElement':
'feMergeNode',
361 'SVGFEMorphology':
'feMorphology',
362 'SVGFEOffsetElement':
'feOffset',
363 'SVGFEPointLightElement':
'fePointLight',
364 'SVGFESpecularLightingElement':
'feSpecularLighting',
365 'SVGFESpotLightElement':
'feSpotLight',
366 'SVGFETileElement':
'feTile',
367 'SVGFETurbulenceElement':
'feTurbulence',
368 'SVGFilterElement':
'filter',
369 'SVGForeignObjectElement':
'foreignObject',
370 'SVGGlyphElement':
'glyph',
372 'SVGHKernElement':
'hkern',
373 'SVGImageElement':
'image',
374 'SVGLinearGradientElement':
'linearGradient',
375 'SVGLineElement':
'line',
376 'SVGMarkerElement':
'marker',
377 'SVGMaskElement':
'mask',
378 'SVGMPathElement':
'mpath',
379 'SVGPathElement':
'path',
380 'SVGPatternElement':
'pattern',
381 'SVGPolygonElement':
'polygon',
382 'SVGPolylineElement':
'polyline',
383 'SVGRadialGradientElement':
'radialGradient',
384 'SVGRectElement':
'rect',
385 'SVGScriptElement':
'script',
386 'SVGSetElement':
'set',
387 'SVGStopElement':
'stop',
388 'SVGStyleElement':
'style',
389 'SVGSwitchElement':
'switch',
390 'SVGSymbolElement':
'symbol',
391 'SVGTextElement':
'text',
392 'SVGTitleElement':
'title',
393 'SVGTRefElement':
'tref',
394 'SVGTSpanElement':
'tspan',
395 'SVGUseElement':
'use',
396 'SVGViewElement':
'view',
397 'SVGVKernElement':
'vkern',
400_element_constructors = {
401 'html': _html_element_constructors,
403 'svg': _svg_element_constructors,
410_factory_ctr_strings = {
412 'provider_name':
'document',
413 'constructor_name':
'createElement'
416 'provider_name':
'document',
417 'constructor_name':
'createElement'
420 'provider_name':
'_SvgElementFactoryProvider',
421 'constructor_name':
'createSvgElement_tag',
424 'provider_name':
'document',
425 'constructor_name':
'createElement'
428 'provider_name':
'document',
429 'constructor_name':
'createElement'
432 'provider_name':
'document',
433 'constructor_name':
'createElement'
436 'provider_name':
'document',
437 'constructor_name':
'createElement'
443 element_constructors,
444 factory_provider_name='_Elements'):
445 """Returns list of ElementConstructorInfos about the convenience constructors
446 for an Element
or SvgElement.
"""
448 if typename
not in element_constructors:
450 infos = element_constructors[typename]
451 if isinstance(infos, str):
453 tag=infos, factory_provider_name=factory_provider_name)
454 if not isinstance(infos, list):
465 return "Element.isTagSupported('%s')" % tagName
468_js_support_checks_basic_element_with_constructors = [
469 'HTMLContentElement',
470 'HTMLDataListElement',
471 'HTMLDetailsElement',
476 'HTMLProgressElement',
477 'HTMLTemplateElement',
481_js_support_checks_additional_element = [
484 'SVGAltGlyphElement',
486 'SVGAnimateMotionElement',
487 'SVGAnimateTransformElement',
490 'SVGFEColorMatrixElement',
491 'SVGFEComponentTransferElement',
492 'SVGFEConvolveMatrixElement',
493 'SVGFEDiffuseLightingElement',
494 'SVGFEDisplacementMapElement',
495 'SVGFEDistantLightElement',
501 'SVGFEGaussianBlurElement',
504 'SVGFEMergeNodeElement',
506 'SVGFEOffsetElement',
507 'SVGFEPointLightElement',
508 'SVGFESpecularLightingElement',
509 'SVGFESpotLightElement',
511 'SVGFETurbulenceElement',
513 'SVGForeignObjectElement',
517js_support_checks = dict(
520 "JS('bool', '!!(document.body.animate)')",
522 "JS('bool', '!!(window.AudioContext ||"
523 " window.webkitAudioContext)')",
525 "JS('bool', '!!(window.crypto && window.crypto.getRandomValues)')",
527 "JS('bool', '!!(window.openDatabase)')",
529 "JS('bool', '!!(window.DOMPoint) || !!(window.WebKitPoint)')",
531 "JS('bool', '!!(window.applicationCache)')",
533 "JS('bool', '!!(window.webkitRequestFileSystem)')",
535 "JS('bool', '!!(window.FormData)')",
537 "Device.isEventTypeSupported('HashChangeEvent')",
540 'HTMLTemplateElement':
543 "Device.isEventTypeSupported('MediaStreamEvent')",
544 'MediaStreamTrackEvent':
545 "Device.isEventTypeSupported('MediaStreamTrackEvent')",
547 "JS('bool', '!!(window.MediaSource)')",
549 "JS('bool', '!!(window.Notification)')",
551 "JS('bool', '!!(window.performance)')",
553 "JS('bool', '!!(window.SpeechRecognition || "
554 "window.webkitSpeechRecognition)')",
555 'SVGExternalResourcesRequired':
556 (
'supported(SvgElement element)',
557 "JS('bool', '#.externalResourcesRequired !== undefined && "
558 "#.externalResourcesRequired.animVal !== undefined', "
559 "element, element)"),
561 (
'supported(SvgElement element)',
562 "JS('bool', '#.xmlspace !== undefined && #.xmllang !== undefined', "
563 "element, element)"),
565 "JS('bool', '!!document.createTouchList')",
566 'WebGLRenderingContext':
567 "JS('bool', '!!(window.WebGLRenderingContext)')",
569 "JS('bool', 'typeof window.WebSocket != \"undefined\"')",
571 "JS('bool', '(typeof window.Worker != \"undefined\")')",
573 "JS('bool', '!!(window.XSLTProcessor)')",
576 SvgSupportStr(_svg_element_constructors[key])
if key.startswith(
578 for key
in _js_support_checks_basic_element_with_constructors +
579 _js_support_checks_additional_element).items()))
584_js_unreliable_element_factories =
set(
585 _js_support_checks_basic_element_with_constructors +
586 _js_support_checks_additional_element + [
590 'HTMLTemplateElement',
597 """Generates dart interface and implementation for the DOM IDL interface."""
599 def __init__(self, options, library_emitter, event_generator,
600 prototype_event_generator, interface, backend):
622 elif generateCallbackInterface(self.
_interface.id):
630 """Generates a typedef for the callback interface."""
640 annotations = self.
_metadata.GetFormattedMetadata(
643 params = info.ParametersAsDeclaration(self.
_DartType)
645 types = params.split()
647 mapType = types[0]
in _callback_list_generics_mapping
650 params =
" ".
join(types)
653 '$(ANNOTATIONS)typedef void $NAME($PARAMS);\n',
654 ANNOTATIONS=annotations,
666 factory_provider =
None
667 if interface_name
in interface_factories:
668 factory_provider = interface_factories[interface_name]
669 factory_constructor_name =
None
672 if interface_name
in _static_classes:
673 constructor_info =
None
675 constructor_info = AnalyzeConstructor(self.
_interface)
677 constructors.append(constructor_info)
679 factory_provider = interface_name
685 factory_provider_name=_factory_ctr_strings[self.
_library_name]
689 factory_constructor_name = _factory_ctr_strings[
693 constructors.append(info.ConstructorInfo(self.
_interface.id))
694 if factory_provider
and factory_provider != info.factory_provider_name:
695 _logger.warn(
'Conflicting factory provider names: %s != %s' %
696 (factory_provider, info.factory_provider_name))
697 factory_provider = info.factory_provider_name
701 base_type_info =
None
703 supertype = self.
_interface.parents[0].type.id
704 if not IsDartCollectionType(supertype)
and not IsPureInterface(
709 base_class = base_type_info.implementation_name()
711 base_class = self.
_backend.RootClassName()
713 implements = self.
_backend.AdditionalImplementedInterfaces()
716 if parent_type_info.interface_name() != base_class
and \
717 parent_type_info != base_type_info:
718 implements.append(parent_type_info.interface_name())
720 secure_base_name = self.
_backend.SecureBaseName(interface_name)
722 implements.append(secure_base_name)
727 implements = list(OrderedDict([(i,
None)
for i
in implements]))
728 implements_str =
' implements ' +
', '.
join(implements)
734 mixins_str =
' with ' +
', '.
join(mixins)
736 base_class =
'JavaScriptObject'
737 elif (base_class ==
'NativeFieldWrapperClass2' and
739 not (isinstance(self.
_backend, Dart2JSBackend))):
740 base_class =
'DartHtmlDomObject'
742 annotations = self.
_metadata.GetFormattedMetadata(
750 if (
not (isinstance(self.
_backend, Dart2JSBackend))
and
751 (self.
_interface.id ==
'XMLHttpRequestProgressEvent' or
760 not (isinstance(self.
_backend, Dart2JSBackend))
and
764 class_modifiers =
'abstract '
768 native_spec = self.
_backend.NativeSpec()
772 js_interop_wrapper =
'''
774 @Deprecated("Internal Use Only")
775 external static Type get instanceRuntimeType;
777 @Deprecated("Internal Use Only")
778 {0}.internal_() : super.internal_();
780'''.format(class_name)
781 if base_class ==
'NativeFieldWrapperClass2' or base_class ==
'DartHtmlDomObject':
782 js_interop_wrapper =
'''
784 @Deprecated("Internal Use Only")
785 external static Type get instanceRuntimeType;
787 @Deprecated("Internal Use Only")
788 {0}.internal_() {{ }}
789'''.format(class_name)
793 if (self.
_options.templates._conditions[
'DARTIUM']
and
796 self.
_interface.id ==
'CSSStyleDeclaration')):
797 base_class =
'DartHtmlDomObject'
800 maplikeValueType =
''
803 _TypeInfo(self.
_interface.maplike_key_value[0].id).dart_type()
804 maplikeValueType =
'dynamic'
805 mixins_str =
" with MapMixin<%s, %s>" % (maplikeKeyType,
808 implementation_members_emitter = implementation_emitter.Emit(
809 self.
_backend.ImplementationTemplate(),
811 ANNOTATIONS=annotations,
812 CLASS_MODIFIERS=class_modifiers,
813 CLASSNAME=class_name,
814 EXTENDS=
' extends %s' % base_class
if base_class
else '',
815 IMPLEMENTS=implements_str,
818 NATIVESPEC=native_spec,
819 KEYTYPE=maplikeKeyType,
820 VALUETYPE=maplikeValueType,
824 if self.
_interface.doc_js_name
is 'RadioNodeList':
826 print(implementation_members_emitter)
827 stream_getter_signatures_emitter =
None
828 element_stream_getters_emitter =
None
829 class_members_emitter =
None
830 if type(implementation_members_emitter) == tuple:
835 if (
len(implementation_members_emitter) == 3):
836 stream_getter_signatures_emitter = \
837 implementation_members_emitter[0]
838 element_stream_getters_emitter = implementation_members_emitter[
840 implementation_members_emitter = \
841 implementation_members_emitter[2]
844 elif (
len(implementation_members_emitter) == 2):
845 class_members_emitter = \
846 implementation_members_emitter[0]
847 implementation_members_emitter = \
848 implementation_members_emitter[1]
849 self.
_backend.StartInterface(implementation_members_emitter)
850 self.
_backend.EmitHelpers(base_class, class_members_emitter)
857 self.
_backend.AddConstructors(constructors, factory_provider,
858 factory_constructor_name,
859 class_members_emitter)
863 if parent.id ==
'Element':
867 if (implementation_members_emitter
and
868 self.
_options.templates._conditions[
'DARTIUM']
and
871 implementation_members_emitter.Emit(js_interop_wrapper)
873 if isElement
and self.
_interface.id !=
'Element':
874 implementation_members_emitter.Emit(
876 ' * Constructor instantiated by the DOM when a custom element has been created.\n'
878 ' * This can only be called by subclasses from their created constructor.\n'
880 ' $CLASSNAME.created() : super.created();\n',
888 self.
_database.GetInterface(merged_interface),
889 not self.
_backend.ImplementsMergedMembers())
895 self.
_interface, [], implementation_members_emitter,
897 element_stream_getters_emitter)
902 def _ImplementationEmitter(self):
905 self.
_backend.ImplementsMergedMembers()):
910 def _DartType(self, type_name):
915''' TODO(terry): Current idl_parser (Chrome) doesn't keep the Promise type e.g.,
916 Promise<T> in the AST so there
is no way to pull this out. Need
917 to investigate getting the Chrome folks to fix. However, they
918 don
't use this in the C++ code generation and don't have a need
919 for this feature. For now I have a table that maps to the
920 parameterized Promise type.
922promise_attributes = monitored.Dict(
923 'systemhtml.promise_attr_type', {
924 "Animation.finished": {
926 "creates":
"Animation"
930 "creates":
"Animation"
932 "BeforeInstallPromptEvent.userChoice": {
937 "creates":
"FontFace"
939 "FontFaceSet.ready": {
940 "type":
"FontFaceSet",
941 "creates":
"FontFaceSet"
943 "MediaKeySession.closed": {
946 "PresentationReceiver.connectionList": {
947 "type":
"PresentationConnectionList",
948 "creates":
"PresentationConnectionList"
950 "ServiceWorkerContainer.ready": {
951 "type":
"ServiceWorkerRegistration",
952 "creates":
"ServiceWorkerRegistration"
957 'systemhtml.promise_oper_type', {
959 "type":
"DataTransfer",
960 "creates":
"DataTransfer"
962 "Clipboard.readText": {
967 "creates":
"FontFace"
969 "FontFaceSet.load": {
970 "type":
"List<dynamic>"
972 "OffscreenCanvas.load": {
976 "BackgroundFetchManager.fetch": {
977 "type":
"BackgroundFetchRegistration",
978 "creates":
"BackgroundFetchRegistration"
980 "BackgroundFetchManager.get": {
981 "type":
"BackgroundFetchRegistration",
982 "creates":
"BackgroundFetchRegistration"
984 "BackgroundFetchManager.getIds": {
985 "type":
"List<dynamic>"
987 "BackgroundFetchRegistration.abort": {
990 "SyncManager.getTags": {
991 "type":
"List<dynamic>"
993 "BudgetService.getCost": {
996 "BudgetService.getBudget": {
997 "type":
"BudgetState",
998 "creates":
"BudgetState"
1000 "BudgetService.reserve": {
1009 "creates":
"FormData"
1014 "ImageCapture.getPhotoCapabilities": {
1015 "type":
"PhotoCapabilities",
1016 "creates":
"PhotoCapabilities"
1018 "ImageCapture.getPhotoSettings": {
1019 "type":
"dictionary"
1021 "ImageCapture.takePhoto": {
1025 "ImageCapture.grabFrame": {
1026 "type":
"ImageBitmap",
1027 "creates":
"ImageBitmap"
1029 "Navigator.getInstalledRelatedApps": {
1030 "type":
"RelatedApplication",
1031 "creates":
"RelatedApplication"
1033 "OffscreenCanvas.convertToBlob": {
1037 "MediaCapabilities.decodingInfo": {
1038 "type":
"MediaCapabilitiesInfo",
1039 "creates":
"MediaCapabilitiesInfo"
1041 "MediaCapabilities.encodingInfo": {
1042 "type":
"MediaCapabilitiesInfo",
1043 "creates":
"MediaCapabilitiesInfo"
1045 "MediaDevices.enumerateDevices": {
1046 "type":
"List<dynamic>"
1048 "MediaDevices.getUserMedia": {
1049 "type":
"MediaStream",
1050 "creates":
"MediaStream"
1052 "ServiceWorkerRegistration.getNotifications": {
1053 "type":
"List<dynamic>"
1055 "PaymentInstruments.delete": {
1058 "PaymentInstruments.get": {
1059 "type":
"dictionary"
1061 "PaymentInstruments.keys": {
1062 "type":
"List<dynamic>"
1064 "PaymentInstrumentshas.": {
1067 "PaymentRequest.show": {
1068 "type":
"PaymentResponse",
1069 "creates":
"PaymentResponse"
1071 "PaymentRequest.canMakePayment": {
1074 "PaymentRequestEvent.openWindow": {
1075 "type":
"WindowClient",
1076 "creates":
"WindowClient"
1078 "RTCPeerConnection.createOffer": {
1079 "type":
"RtcSessionDescription",
1080 "creates":
"RtcSessionDescription"
1082 "RTCPeerConnection.createAnswer": {
1083 "type":
"RtcSessionDescription",
1084 "creates":
"RtcSessionDescription"
1086 "RTCPeerConnection.getStats": {
1087 "type":
"RtcStatsReport",
1088 "maplike":
"RTCStatsReport",
1089 "creates":
"RtcStatsReport"
1091 "RTCPeerConnection.generateCertificate": {
1092 "type":
"RtcCertificate",
1093 "creates":
"RtcCertificate"
1095 "Permissions.query": {
1096 "type":
"PermissionStatus",
1097 "creates":
"PermissionStatus"
1099 "Permissions.request": {
1100 "type":
"PermissionStatus",
1101 "creates":
"PermissionStatus"
1103 "Permissions.revoke": {
1104 "type":
"PermissionStatus",
1105 "creates":
"PermissionStatus"
1107 "Permissions.requestAll": {
1108 "type":
"PermissionStatus",
1109 "creates":
"PermissionStatus"
1111 "PresentationRequest.start": {
1112 "type":
"PresentationConnection",
1113 "creates":
"PresentationConnection"
1115 "PresentationRequest.reconnect": {
1116 "type":
"PresentationConnection",
1117 "creates":
"PresentationConnection"
1119 "PresentationRequest.getAvailability": {
1120 "type":
"PresentationAvailability",
1121 "creates":
"PresentationAvailability"
1123 "PushManager.subscribe": {
1124 "type":
"PushSubscription",
1125 "creates":
"PushSubscription"
1127 "PushManager.getSubscription": {
1128 "type":
"PushSubscription",
1129 "creates":
"PushSubscription"
1131 "PushSubscription.unsubscribe": {
1134 "StorageManager.persisted": {
1137 "StorageManager.persist": {
1140 "StorageManager.estimate": {
1141 "type":
"dictionary"
1143 "RemotePlayback.watchAvailability": {
1146 "Clients.matchAll": {
1147 "type":
"List<dynamic>"
1149 "Clients.openWindow": {
1150 "type":
"WindowClient",
1151 "creates":
"WindowClient"
1153 "NavigationPreloadManager.getState": {
1154 "type":
"dictionary"
1156 "ServiceWorkerContainer.register": {
1157 "type":
"ServiceWorkerRegistration",
1158 "creates":
"ServiceWorkerRegistration"
1160 "ServiceWorkerContainer.getRegistration": {
1161 "type":
"ServiceWorkerRegistration",
1162 "creates":
"ServiceWorkerRegistration"
1164 "ServiceWorkerContainer.getRegistrations": {
1165 "type":
"List<dynamic>"
1167 "ServiceWorkerGlobalScope.fetch": {
1168 "creates":
"_Response"
1170 "ServiceWorkerRegistration.unregister": {
1173 "WindowClient.focus": {
1174 "type":
"WindowClient",
1175 "creates":
"WindowClient"
1177 "WindowClient.navigate": {
1178 "type":
"WindowClient",
1179 "creates":
"WindowClient"
1181 "BarcodeDetector.detect": {
1182 "type":
"List<dynamic>"
1184 "FaceDetector.detect": {
1185 "type":
"List<dynamic>"
1187 "TextDetector.detect": {
1188 "type":
"List<dynamic>"
1190 "BaseAudioContext.decodeAudioData": {
1191 "type":
"AudioBuffer",
1192 "creates":
"AudioBuffer"
1194 "OfflineAudioContext.startRendering": {
1195 "type":
"AudioBuffer",
1196 "creates":
"AudioBuffer"
1198 "CacheStorage.match": {
1199 "creates":
"_Response"
1201 "CacheStorage.open": {
1204 "CredentialsContainer.create": {
1205 "creates":
"Credential"
1207 "CredentialsContainer.get": {
1208 "creates":
"Credential"
1210 "CredentialsContainer.store": {
1211 "creates":
"Credential"
1213 "FetchEvent.preloadResponse": {
1214 "creates":
"_Response"
1216 "MediaKeySystemAccess.createMediaKeys": {
1217 "creates":
"MediaKeys"
1219 "Navigator.getVRDisplays": {
1220 "creates":
"VRDisplay"
1222 "Navigator.requestMediaKeySystemAccess": {
1223 "creates":
"MediaKeySystemAccess"
1225 "VRSession.requestFrameOfReference": {
1226 "creates":
"VRFrameOfReference"
1229 "creates":
"_Response"
1231 "WorkerGlobalScope.fetch": {
1232 "creates":
"_Response"
1237 "Navigator.requestKeyboardLock",
1241def _IsPromiseOperationGenerateCall(interface_operation):
1242 return interface_operation
in promise_generateCall
1245def _GetPromiseOperationType(interface_operation):
1246 if interface_operation
in promise_operations:
1247 return promise_operations[interface_operation]
1251def _GetPromiseAttributeType(interface_operation):
1252 if interface_operation
in promise_attributes:
1253 return promise_attributes[interface_operation]
1268 'DOMRectReadOnly': [
'bottom',
'height',
'left',
'right',
'top',
'width'],
1269 'DOMRect': [
'height',
'width'],
1274 """Generates a dart2js class for the dart:html library from a DOM IDL
1281 logging_level=logging.WARNING,
1282 generate_static_extensions=False):
1283 super(Dart2JSBackend, self).
__init__(interface, options,
False, _logger)
1298 _logger.setLevel(logging_level)
1307 implements = super(Dart2JSBackend,
1309 if self._interface_type_info.list_item_type()
and self.HasIndexedGetter(
1311 item_type = self._type_registry.TypeInfo(
1312 self._interface_type_info.list_item_type()).dart_type()
1313 if self._interface_type_info.list_item_type_nullable():
1315 implements.append(
'JavaScriptIndexingBehavior<%s>' % item_type)
1319 native_spec = MakeNativeSpec(self.
_interface.javascript_binding_name)
1320 return '@Native("%s")\n' % native_spec
1323 template_file = (
'impl_%s.darttemplate' % self.
_interface.doc_js_name)
1325 if not (template_file_content):
1329 'dart2js_maplike_impl.darttemplate')
1335 'dart2js_static_extension_impl.darttemplate')
1338 'dart2js_impl.darttemplate')
1339 return template_file_content
1348 return self._interface.doc_js_name
in js_support_checks
1351 """Return a tuple of the support check function signature and the support
1352 test itself. If no parameters are supplied, we assume the default."""
1353 if self.
_interface.doc_js_name
in _js_support_checks_additional_element:
1354 if self.
_interface.doc_js_name
in _svg_element_constructors:
1356 constructors = _svg_element_constructors
1359 constructors = _html_element_constructors
1360 return (js_support_checks.get(self.
_interface.doc_js_name) +
1361 " && (new %sElement.tag('%s') is %s)" %
1362 (lib_prefix, constructors[self.
_interface.doc_js_name],
1364 return js_support_checks.get(self.
_interface.doc_js_name)
1368 return self.
_interface.doc_js_name
in _js_custom_constructors
1371 if factory
is 'document' and method
is 'createElement' \
1372 and not ',' in arguments \
1374 return emitter.Format(
1376 "'returns:$INTERFACE_NAME;creates:$INTERFACE_NAME;new:true',"
1377 " '#.$METHOD(#)', $FACTORY, $ARGUMENTS)",
1382 ARGUMENTS=arguments)
1383 return emitter.Format(
'$FACTORY.$METHOD($ARGUMENTS)$CAST',
1386 ARGUMENTS=arguments,
1390 def _HasUnreliableFactoryConstructor(self):
1391 return self.
_interface.doc_js_name
in _js_unreliable_element_factories
1394 return argument.optional
1405 index =
len(arguments)
1406 arguments = constructor_info.ParametersAsArgumentList(index)
1408 arguments =
', ' + arguments
1410 " static $INTERFACE_NAME $NAME($PARAMETERS) => "
1411 "JS('$INTERFACE_NAME', 'new $CTOR_NAME($PLACEHOLDERS)'$ARGUMENTS);\n",
1412 INTERFACE_NAME=interface_name,
1415 PARAMETERS=constructor_info.ParametersAsArgumentList(index),
1416 CTOR_NAME=constructor_info.name
or self.
_interface.doc_js_name,
1417 PLACEHOLDERS=
','.
join([
'#'] * index),
1418 ARGUMENTS=arguments)
1424 '\n // From $WHERE\n', WHERE=interface.id)
1428 has_indexed_getter =
'CustomIndexedGetter' in ext_attrs
1430 if operation.id ==
'item' and 'getter' in operation.specials \
1432 has_indexed_getter =
True
1434 if operation.id ==
'__getter__' and 'getter' in operation.specials \
1436 has_indexed_getter =
True
1438 return has_indexed_getter
1441 """Adds all the methods required to complete implementation of List."""
1462 indexed_getter =
False
1463 indexed_getter_nullable = nullable
1464 if has_indexed_getter:
1465 indexed_getter = (
'JS("%s%s", "#[#]", this, index)' %
1467 "|Null" if nullable
else ""))
1470 if op.id ==
'getItem':
1471 indexed_getter =
'this.getItem(index)'
1472 indexed_getter_nullable = OperationTypeIsNullable(op)
1474 if not indexed_getter:
1477 indexed_getter =
'this.item(index)'
1478 indexed_getter_nullable = OperationTypeIsNullable(op)
1484 ' $TYPE operator[](int index) {\n'
1485 ' if (JS("bool", "# >>> 0 !== # || # >= #", index,\n'
1486 ' index, index, length))\n'
1487 ' throw new IndexError.withLength(index, length, indexable: this);\n'
1488 ' return $INDEXED_GETTER$NULLASSERT;\n'
1490 INDEXED_GETTER=indexed_getter,
1493 can_narrow_type=
True,
1497 NULLASSERT=
'!' if not nullable
and indexed_getter_nullable \
1500 if 'CustomIndexedSetter' in self.
_interface.ext_attrs:
1503 ' void operator[]=(int index, $TYPE$NULLABLE value) {'
1504 ' JS("void", "#[#] = #", this, index, value); }',
1506 NULLABLE=
'?' if nullable
else '')
1509 if theType ==
'DomRectList':
1514 ' void operator[]=(int index, $TYPE$NULLABLE value) {\n'
1515 ' throw new UnsupportedError("Cannot assign element of immutable List.");\n'
1518 NULLABLE=
'?' if nullable
else '')
1531 can_narrow_type=read_only,
1532 nullable=attribute.type.nullable)
1535 metadata = self.
_Metadata(attribute.type.id, attribute.id, output_type,
1536 attribute.type.nullable)
1552 if is_compat
is None:
1556 self.
_mdn_reader.set_compatible(attribute, is_compat)
1558 if attribute.type.id == super_attribute.type.id:
1563 nullable =
not is_compat
or attribute.type.nullable
1566 ' // Use implementation from $SUPER.\n'
1567 ' // $GET_TYPE get $NAME native;\n'
1568 ' // void set $NAME($SET_TYPE value) native;\n',
1569 SUPER=super_attribute_interface,
1572 can_narrow_type=read_only,
1575 can_narrow_type=read_only,
1576 nullable=nullable
or \
1577 'TreatNullAs' in attribute.ext_attrs))
1590 if (self.
_interface.id ==
'DOMMatrixReadOnly' or
1606 if attribute.type.nullable
or not is_compat:
1609 if attribute.type.id ==
'Promise':
1610 _logger.warn(
'R/W member is a Promise: %s.%s' %
1615 if attribute.type.id ==
'Promise':
1616 lookupOp =
"%s.%s" % (self.
_interface.id, html_name)
1617 promiseFound = _GetPromiseAttributeType(lookupOp)
1618 promiseType =
'Future'
1619 promiseCall =
'promiseToFuture'
1620 type_description =
''
1621 if promiseFound
is not (
None):
1622 paramType = promiseFound.get(
'type')
1623 if 'maplike' in promiseFound:
1624 promiseCall =
'promiseToFuture<dynamic>'
1625 promiseType =
'Future'
1626 elif paramType ==
'dictionary':
1628 promiseCall =
'promiseToFutureAsMap'
1631 nullability =
'?' if output_conversion.nullable_output \
1633 promiseType =
'Future<Map<String, dynamic>' + \
1636 promiseCall =
'promiseToFuture<%s>' % paramType
1637 promiseType =
'Future<%s>' % paramType
1639 if 'creates' in promiseFound:
1640 createsType = promiseFound[
'creates']
1641 type_description =
'creates:%s;' % createsType
1643 if attribute.type.nullable:
1646 template =
'\n $RENAME$(ANNOTATIONS)$TYPE get $NAME => '\
1647 '$PROMISE_CALL(JS("$TYPE_DESC", "#.$NAME", this));\n'
1652 ANNOTATIONS=metadata,
1654 PROMISE_CALL=promiseCall,
1655 TYPE_DESC=type_description,
1662 html_name ==
'length':
1664 '\n $RENAME$(ANNOTATIONS)$TYPE get $NAME => ' +
1665 'JS("$TYPE", "#.$NAME", this);\n')
1669 ANNOTATIONS=metadata,
1672 if output_type ==
'double' else output_type)
1678 read_only, rename, metadata)
1680 def _IsACompatibilityConflict(self, interface, attr):
1681 if interface
in compat_conflicts
and attr.id
in compat_conflicts[
1684 if is_compat
or attr.type.nullable:
1688 interface +
'.' + attr.id +
1689 ' has no conflict between compatibility and nullability.')
1694 def _AddAttributeUsingProperties(self, attribute, html_name, read_only,
1695 rename=None, metadata=None):
1701 def _AddRenamingGetter(self, attr, html_name, rename, metadata):
1708 nullable=(
not is_compat)
or
1715 rename =
'@JSName(\'%s\')' % html_name
1717 // The following getter is incompatible
with some browsers but
1718 // must be made non-nullable to match the overridden method.
1721 \n $STATIC $TYPE get _$HTML_NAME native;
1723 \n $STATIC $NONNULLTYPE get $HTML_NAME => _$HTML_NAME$NULLASSERT;
"""
1727 template =
"""\n $RENAME
1729 \n $STATIC $TYPE get $HTML_NAME => js_util.getProperty(this, '$JSNAME');
1732 template =
"""\n $RENAME
1734 \n $STATIC $TYPE get $HTML_NAME native;
1737 RENAME=rename if rename
else '',
1738 METADATA=metadata
if metadata
else '',
1739 HTML_NAME=html_name,
1740 STATIC=
'static' if attr.is_static
else '',
1743 NONNULLTYPE=non_null_return_type,
1744 JSNAME=rename
if rename
else html_name)
1746 def _AddRenamingSetter(self, attr, html_name, rename):
1750 nullable_type = attr.type.nullable
or 'TreatNullAs' in attr.ext_attrs
1757 if (conversion
and conversion.nullable_output)
or not is_compat:
1758 nullable_type =
True
1761 nullable_type =
False
1764 template =
"""\n $RENAME
1765 \n $STATIC set $HTML_NAME($TYPE value)
1766 => js_util.setProperty(this, '$JSNAME', value);
1769 template =
"""\n $RENAME
1770 \n $STATIC set $HTML_NAME($TYPE value) native;
1773 RENAME=rename if rename
else '',
1774 HTML_NAME=html_name,
1775 STATIC=
'static ' if attr.is_static
else '',
1777 attr.type.id, nullable=nullable_type),
1778 JSNAME=rename
if rename
else html_name)
1780 def _AddConvertingGetter(self, attr, html_name, conversion):
1782 nullable_out = conversion.nullable_output
and \
1783 not conversion.output_type ==
'dynamic'
1786 nullable_in = (
not is_compat
or attr.type.nullable)
and \
1787 not conversion.input_type ==
'dynamic'
1789 '\n $(METADATA)$RETURN_TYPE$NULLABLE_OUT get $HTML_NAME => '
1790 '$CONVERT(this._get_$(HTML_NAME)$NULLASSERT);'
1791 "\n @JSName('$NAME')"
1792 '\n $(JS_METADATA)$NATIVE_TYPE$NULLABLE_IN get _get_$HTML_NAME native;'
1796 JS_METADATA=self.
_Metadata(attr.type.id, html_name,
1797 conversion.input_type,
1798 conversion.nullable_output),
1799 CONVERT=conversion.function_name,
1800 HTML_NAME=html_name,
1802 RETURN_TYPE=conversion.output_type,
1803 NULLABLE_OUT=
'?' if nullable_out
else '',
1804 NATIVE_TYPE=conversion.input_type,
1805 NULLABLE_IN=
'?' if nullable_in
else '',
1806 NULLASSERT=
'!' if nullable_in
and \
1807 not conversion.nullable_input
else '')
1809 def _AddConvertingSetter(self, attr, html_name, conversion):
1813 nullable_in = ((attr.type.nullable
or 'TreatNullAs' in attr.ext_attrs) \
1814 and not conversion.input_type ==
'dynamic')
or not is_compat
1815 nullable_out = conversion.nullable_output
and \
1816 not conversion.output_type ==
'dynamic'
1819 '\n set $HTML_NAME($INPUT_TYPE$NULLABLE_IN value) {'
1820 '\n this._set_$HTML_NAME = $CONVERT(value$NULLASSERT);'
1822 '\n set _set_$HTML_NAME(/*$NATIVE_TYPE$NULLABLE_OUT*/ value) {'
1823 '\n JS("void", "#.$NAME = #", this, value);'
1826 CONVERT=conversion.function_name,
1827 HTML_NAME=html_name,
1829 INPUT_TYPE=conversion.input_type,
1830 NULLABLE_IN=
'?' if nullable_in
else '',
1831 NATIVE_TYPE=conversion.output_type,
1832 NULLABLE_OUT=
'?' if nullable_out
else '',
1833 NULLASSERT=
'!' if nullable_in
and \
1834 not conversion.nullable_input
else '')
1840 return 'JavaScriptObject'
1848 info: An OperationInfo object.
1855 elif info.callback_args:
1860 for op
in info.overloads):
1861 lookupOp =
"%s.%s" % (self.
_interface.id, html_name)
1862 if (_GetPromiseOperationType(lookupOp)
or info.type_name ==
'Promise')
and \
1863 not _IsPromiseOperationGenerateCall(lookupOp):
1871 def _computeResultType(self, checkType):
1877 resultType = checkType
1880 if 'Callback' in resultInterface.ext_attrs:
1881 resultType =
'Function'
1884 def _zeroArgs(self, argsNames):
1885 return 'JS("$TYPE_DESC", "#.$JSNAME()", this)'
1887 def _manyArgs(self, numberArgs, argsNames):
1888 argsPound =
"#" if numberArgs == 1
else (
"#, " * numberArgs)[:-2]
1889 template =
' JS("$TYPE_DESC", "#.$JSNAME(%s)", this, %s)'
1890 return template % (argsPound, argsNames)
1892 """ If argument conversionsMapToDictionary is a list first entry is argument
1893 name and second entry signals
if argument
is optional (
True).
"""
1895 def _promiseToFutureCode(self, argsNames, conversionsMapToDictionary=None):
1896 numberArgs = argsNames.count(
',') + 1
1897 jsCall = self.
_zeroArgs(argsNames)
if len(argsNames) == 0
else \
1901 if conversionsMapToDictionary
is None:
1904 ' $RENAME$METADATA$MODIFIERS $TYPE $NAME($PARAMS) => $PROMISE_CALL(',
1908 mapArg = conversionsMapToDictionary[0]
1909 tempVariable =
'%s_dict' % mapArg
1910 mapArgOptional = conversionsMapToDictionary[1]
1912 if argsNames.endswith(
'%s' % mapArg):
1913 argsNames =
'%s_dict' % argsNames
1914 jsCall = self.
_zeroArgs(argsNames)
if len(argsNames) == 0
else \
1920 ' $RENAME$METADATA$MODIFIERS $TYPE $NAME($PARAMS) {\n',
1929 ' = convertDartToNative_Dictionary(',
1933 ' return $PROMISE_CALL(',
1942 ' $RENAME$METADATA$MODIFIERS $TYPE $NAME($PARAMS) {\n',
1945 ' = convertDartToNative_Dictionary(',
1948 ' return $PROMISE_CALL(',
1954 return "".
join(futureTemplate)
1956 def _AddDirectNativeOperation(self, info, html_name):
1957 force_optional =
True if html_name.startswith(
'_')
else False
1960 if info.type_name ==
'Promise' and not (force_optional):
1961 lookupOp =
"%s.%s" % (self.
_interface.id, html_name)
1962 promiseFound = _GetPromiseOperationType(lookupOp)
1963 promiseType =
'Future'
1964 promiseCall =
'promiseToFuture'
1965 type_description =
''
1966 if promiseFound
is not (
None):
1967 paramType = promiseFound.get(
'type')
1968 if 'maplike' in promiseFound:
1969 if paramType ==
'dictionary':
1970 promiseCall =
'promiseToFuture<dynamic>'
1971 promiseType =
'Future'
1973 promiseCall =
'promiseToFuture<%s>' % paramType
1974 promiseType =
'Future<%s>' % paramType
1975 elif paramType ==
'dictionary':
1977 promiseCall =
'promiseToFutureAsMap'
1980 nullability =
'?' if output_conversion.nullable_output \
1982 promiseType =
'Future<Map<String, dynamic>' + \
1985 promiseCall =
'promiseToFuture<%s>' % paramType
1986 promiseType =
'Future<%s>' % paramType
1988 if 'creates' in promiseFound:
1989 createsType = promiseFound[
'creates']
1990 type_description =
'creates:%s;' % createsType
1992 argsNames = info.ParametersAsArgumentList()
1993 dictionary_argument = info.dictionaryArgumentName()
1995 dictionary_argument)
1996 if info.type_nullable:
2001 METADATA=self.
_Metadata(info.type_name, info.declared_name,
2003 nullable=info.type_nullable),
2004 info.type_nullable),
2005 MODIFIERS=
'static ' if info.IsStatic()
else '',
2007 PROMISE_CALL=promiseCall,
2009 TYPE_DESC=type_description,
2010 JSNAME=info.declared_name,
2016 ' $RENAME$METADATA$MODIFIERS$TYPE $NAME($PARAMS) => '\
2017 'js_util.callMethod(this, \'$JSNAME\', [$ARGS]);\n'
2019 '\n $RENAME$METADATA$MODIFIERS$TYPE $NAME($PARAMS) native;\n',
2022 info.type_name, info.declared_name,
2024 nullable=info.type_nullable),
2025 info.type_nullable),
2026 MODIFIERS=
'static ' if info.IsStatic()
else '',
2028 can_narrow_type=
True,
2029 nullable=info.type_nullable),
2033 ARGS=info.ParametersAsArgumentList(),
2034 JSNAME=info.declared_name
if info.declared_name != html_name
else html_name)
2036 def _AddOperationWithConversions(self, info, html_name):
2038 assert len(
set([op.type.id
for op
in info.operations])) == 1
2044 if output_conversion:
2045 return_type = output_conversion.output_type
2046 native_return_type = output_conversion.input_type
2048 return_type = resultType
if resultType ==
'Function' else self.
_NarrowInputType(
2050 native_return_type = return_type
2052 parameter_names = [param_info.name
for param_info
in info.param_infos]
2055 for param_info
in info.param_infos
2057 operations = info.operations
2059 def InputType(type_name):
2062 def GenerateCall(stmts_emitter, call_emitter, version, operation,
2064 target =
'_%s_%d' % (html_name[1:]
if html_name.startswith(
'_')
else
2067 (target_parameters, arguments,
2069 stmts_emitter, operation.arguments, argument_count, info)
2071 argument_list =
', '.
join(arguments)
2074 call =
'%s(%s)' % (target, argument_list)
2076 if output_conversion:
2077 call =
'%s(%s)' % (output_conversion.function_name, call)
2078 if output_conversion.nullable_output
and not info.type_nullable:
2083 call_emitter.Emit(call)
2085 if (native_return_type ==
'Future'):
2087 if argument_count > 0:
2088 if argument_count < 20:
2089 hashArgs =
'#,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#' [:
2097 "ERROR: Arguments exceede 20 - please fix Python code to handle more."
2100 ' $RENAME$METADATA$MODIFIERS$TYPE$TARGET($PARAMS) =>\n'
2101 ' promiseToFuture(JS("", "#.$JSNAME($HASH_STR)"'\
2102 ', this$CALLING_PARAMS));\n',
2104 METADATA=self.
_Metadata(info.type_name, info.declared_name,
2105 None, info.type_nullable),
2106 MODIFIERS=
'static ' if info.IsStatic()
else '',
2107 TYPE=TypeOrNothing(native_return_type,
2108 nullable=info.type_nullable),
2110 PARAMS=
', '.
join(target_parameters),
2111 JSNAME=operation.id,
2113 CALLING_PARAMS=calling_params)
2116 ' $RENAME$METADATA$MODIFIERS$TYPE$TARGET($PARAMS) native;\n',
2118 METADATA=self.
_Metadata(info.type_name, info.declared_name,
2119 None, info.type_nullable),
2120 MODIFIERS=
'static ' if info.IsStatic()
else '',
2121 TYPE=TypeOrNothing(native_return_type,
2122 nullable=info.type_nullable),
2124 PARAMS=
', '.
join(target_parameters))
2127 full_name =
'%s.%s' % (self.
_interface.id, info.declared_name)
2128 force_optional =
False if hasNamedFormals(full_name)
and not (
2129 html_name.startswith(
'_'))
else True
2131 nullsafe_return_type = return_type;
2132 if info.type_nullable:
2133 nullsafe_return_type +=
'?'
2135 declaration =
'%s%s%s %s(%s)' % (
2136 self.
_Metadata(info.type_name, info.declared_name, return_type,
2137 info.type_nullable),
2138 'static ' if info.IsStatic()
else '', nullsafe_return_type,
2139 html_name, info.ParametersAsDeclaration(InputType, force_optional))
2146 can_omit_type_check=
lambda type, pos: type == parameter_types[pos])
2148 def _AddInterfaceOperation(self, info, html_name):
2151 ' $TYPE $NAME($PARAMS);\n',
2153 nullable=info.type_nullable),
2157 def _OperationRequiresConversions(self, operation):
2161 def _OperationRequiresOutputConversion(self, operation):
2164 def _OperationRequiresInputConversions(self, operation):
2167 for arg
in operation.arguments)
2169 def _OutputConversion(self, idl_type, member):
2170 return FindConversion(idl_type,
'get', self.
_interface.id, member)
2172 def _InputConversion(self, idl_type, member):
2173 return FindConversion(idl_type,
'set', self.
_interface.id, member)
2175 def _HasCustomImplementation(self, member_name):
2176 member_name =
'%s.%s' % (self.
_interface.doc_js_name, member_name)
2177 return member_name
in _js_custom_members
2179 def _SafeToIgnoreShadowingMember(self, member_name):
2180 member_name =
'%s.%s' % (self.
_interface.doc_js_name, member_name)
2181 return member_name
in _safe_to_ignore_shadowing_members
2183 def _RenamingAnnotation(self, idl_name, member_name):
2184 if member_name != idl_name:
2185 return "@JSName('%s')\n " % idl_name
2188 def _Metadata(self, idl_type, idl_member_name, dart_type, nullable,
2194 idl_type, self.
_interface.id, idl_member_name):
2198 null_union =
'' if not nullable
else '|Null'
2199 if native_type != return_type:
2201 "@Returns('%s%s')" % (native_type, null_union),
2202 "@Creates('%s')" % native_type,
2204 if dart_type ==
'dynamic' or dart_type ==
'Object?':
2208 def js_type_annotation(ann):
2209 return re.search(
'^@.*Returns', ann)
or re.search(
2212 if not list(filter(js_type_annotation, anns)):
2213 _logger.warn(
'Member with wildcard native type: %s.%s' %
2219 return _js_custom_members
2221 def _FindShadowedAttribute(self, attr):
2222 """Returns (attribute, superinterface) or (None, None)."""
2224 def FindInParent(interface):
2225 """Returns matching attribute in parent, or None."""
2226 if interface.parents:
2227 parent = interface.parents[0]
2228 if IsDartCollectionType(parent.type.id):
2233 interfaces_to_search_in = []
2234 parent_interface_name = parent.type.id
2235 interfaces_to_search_in.append(parent_interface_name)
2237 parent_interface_name)
2238 if parent_type_info.merged_into():
2241 parent_interface_name = parent_type_info.merged_into()
2242 interfaces_to_search_in.append(parent_interface_name)
2243 elif parent_type_info.merged_interface():
2245 interfaces_to_search_in.append(
2246 parent_type_info.merged_interface())
2248 for interface_name
in interfaces_to_search_in:
2250 attr2 = FindMatchingAttribute(interface, attr)
2252 return (attr2, parent_interface_name)
2254 return FindInParent(
2258 return FindInParent(self.
_interface)
if attr
else (
None,
None)
2266 def __init__(self, multiemitter, dart_sources_dir, dart_libraries):
2274 path = os.path.join(aux_dir,
'%s.dart' % basename)
2277 if not template
is None:
2278 emitter = emitter.Emit(template)
2294 def __init__(self, name, template_loader, library_type, output_dir,
2297 '%s_%s.darttemplate' % (name, library_type))
2299 '%s_%s.dart' % (name, library_type))
2308 self.
_typeMap[idl_name] = dart_name
2310 def Emit(self, emitter, auxiliary_dir):
2312 def massage_path(path):
2314 return path.replace(
'\\',
'/')
2316 library_emitter = emitter.FileEmitter(self.
_dart_path)
2317 library_file_dir = os.path.dirname(self.
_dart_path)
2318 auxiliary_dir = os.path.relpath(auxiliary_dir, library_file_dir)
2319 emitters = library_emitter.Emit(
2321 AUXILIARY_DIR=massage_path(auxiliary_dir),
2323 if isinstance(emitters, tuple):
2324 imports_emitter, map_emitter = emitters
2326 imports_emitter, map_emitter = emitters,
None
2328 for path
in sorted(self.
_paths):
2329 relpath = os.path.relpath(path, library_file_dir)
2330 imports_emitter.Emit(
"part '$PATH';\n", PATH=massage_path(relpath))
2334 items = list(self.
_typeMap.items())
2336 for (idl_name, dart_name)
in items:
2338 " '$IDL_NAME': () => $DART_NAME.instanceRuntimeType,\n",
2340 DART_NAME=dart_name)
2348 def __init__(self, libraries, template_loader, library_type, output_dir,
2351 for library_name
in libraries:
2353 library_name, template_loader, library_type, output_dir,
2362 def Emit(self, emitter, auxiliary_dir):
2364 lib.Emit(emitter, auxiliary_dir)
static bool is_compatible(const GrSurfaceCharacterization &gsc, const GrBackendTexture &backendTex)
def _NarrowToImplementationType(self, type_name)
def SecureOutputType(self, type_name, is_dart_type=False, can_narrow_type=False, nullable=False)
def _GenerateDispatcherBody(self, info, operations, declaration, generate_call, is_optional, can_omit_type_check=lambda type, False pos)
def _DartType(self, type_name)
def EmitListMixin(self, element_name, nullable)
def _ConvertArgumentTypes(self, stmts_emitter, arguments, argument_count, info)
def _AddFutureifiedOperation(self, info, html_name)
def _NarrowInputType(self, type_name)
def _InputType(self, type_name, info)
def GenerateCallback(self, info)
def _OperationRequiresConversions(self, operation)
def SecondaryContext(self, interface)
def _OperationRequiresInputConversions(self, operation)
def __init__(self, interface, options, logging_level=logging.WARNING, generate_static_extensions=False)
def _HasUnreliableFactoryConstructor(self)
_generate_static_extensions
def GenerateCustomFactory(self, constructor_info)
def AmendIndexer(self, element_type)
def _HasCustomImplementation(self, member_name)
def AddIndexer(self, element_type, nullable)
def _FindShadowedAttribute(self, attr)
def EmitAttribute(self, attribute, html_name, read_only)
def CustomJSMembers(self)
def _computeResultType(self, checkType)
def _AddOperationWithConversions(self, info, html_name)
def _AddRenamingGetter(self, attr, html_name, rename, metadata)
def GetSupportCheck(self)
def ImplementsMergedMembers(self)
def _OperationRequiresOutputConversion(self, operation)
def FinishInterface(self)
def _AddConvertingGetter(self, attr, html_name, conversion)
def _Metadata(self, idl_type, idl_member_name, dart_type, nullable, indent=' ')
def _AddRenamingSetter(self, attr, html_name, rename)
def HasIndexedGetter(self)
def _IsACompatibilityConflict(self, interface, attr)
def _RenamingAnnotation(self, idl_name, member_name)
def MakeFactoryCall(self, factory, method, arguments, constructor_info)
def _AddDirectNativeOperation(self, info, html_name)
def ImplementationTemplate(self)
def IsConstructorArgumentOptional(self, argument)
def EmitOperation(self, info, html_name, dart_js_interop=False)
def _AddAttributeUsingProperties(self, attribute, html_name, read_only, rename=None, metadata=None)
def StartInterface(self, members_emitter)
def HasSupportCheck(self)
def _zeroArgs(self, argsNames)
def _SafeToIgnoreShadowingMember(self, member_name)
def AdditionalImplementedInterfaces(self)
_current_secondary_parent
def _OutputConversion(self, idl_type, member)
def _InputConversion(self, idl_type, member)
def _AddConvertingSetter(self, attr, html_name, conversion)
def OmitOperationOverrides(self)
def EmitStaticFactoryOverload(self, constructor_info, name, arguments, emitter)
def _AddInterfaceOperation(self, info, html_name)
def _promiseToFutureCode(self, argsNames, conversionsMapToDictionary=None)
def _manyArgs(self, numberArgs, argsNames)
def Emit(self, emitter, auxiliary_dir)
def __init__(self, libraries, template_loader, library_type, output_dir, dart_js_interop)
def AddTypeEntry(self, library_name, idl_name, dart_name)
def AddFile(self, basename, library_name, path)
def FileEmitter(self, basename, library_name, template=None)
def EmitLibraries(self, auxiliary_dir, dart_js_interop)
def AddTypeEntry(self, basename, idl_name, dart_name)
def __init__(self, multiemitter, dart_sources_dir, dart_libraries)
def __init__(self, name, template_loader, library_type, output_dir, dart_js_interop)
def AddTypeEntry(self, idl_name, dart_name)
def Emit(self, emitter, auxiliary_dir)
def __init__(self, name=None, tag=None, params=[], opt_params=[], factory_provider_name='document')
def ConstructorInfo(self, interface_name)
def _ImplementationEmitter(self)
def GenerateInterface(self)
def GenerateCallback(self)
def __init__(self, options, library_emitter, event_generator, prototype_event_generator, interface, backend)
def _DartType(self, type_name)
_prototype_event_generator
static void append(char **dst, size_t *count, const char *src, size_t n)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not set
def print(*args, **kwargs)
def ElemSupportStr(tagName)
def SvgSupportStr(tagName)
def ElementConstructorInfos(typename, element_constructors, factory_provider_name='_Elements')
def CanUseStaticExtensions(interface, should)
SIT bool any(const Vec< 1, T > &x)
static SkString join(const CommandLineFlags::StringArray &)