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

Side by Side Diff: tools/dom/scripts/generator.py

Issue 1723703002: Fix generator to use SerializedScriptValue for all postMessages (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 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 copy 9 import copy
10 import json 10 import json
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 Conversion('convertDartToNative_Dictionary', 'Map', 'dynamic'), 715 Conversion('convertDartToNative_Dictionary', 'Map', 'dynamic'),
716 716
717 'sequence<DOMString> set': 717 'sequence<DOMString> set':
718 Conversion('convertDartToNative_StringArray', 'List<String>', 'List'), 718 Conversion('convertDartToNative_StringArray', 'List<String>', 'List'),
719 719
720 'any set IDBObjectStore.add': _serialize_SSV, 720 'any set IDBObjectStore.add': _serialize_SSV,
721 'any set IDBObjectStore.put': _serialize_SSV, 721 'any set IDBObjectStore.put': _serialize_SSV,
722 'any set IDBCursor.update': _serialize_SSV, 722 'any set IDBCursor.update': _serialize_SSV,
723 723
724 # postMessage 724 # postMessage
725 'SerializedScriptValue set': _serialize_SSV,
726 'any set CompositorWorkerGlobalScope.postMessage': _serialize_SSV,
727 'any set DedicatedWorkerGlobalScope.postMessage': _serialize_SSV,
725 'any set MessagePort.postMessage': _serialize_SSV, 728 'any set MessagePort.postMessage': _serialize_SSV,
726 'SerializedScriptValue set Window.postMessage': _serialize_SSV, 729 'any set Window.postMessage': _serialize_SSV,
727 'SerializedScriptValue set Worker.postMessage': _serialize_SSV, 730 'any set _DOMWindowCrossFrame.postMessage': _serialize_SSV,
terry 2016/02/23 14:19:04 I'm wondering how the tests ran on integration w/o
Alan Knight 2016/02/23 17:54:37 Good question. Maybe there's some interaction with
728 'any set DedicatedWorkerGlobalScope.postMessage' : _serialize_SSV,
729 'SerializedScriptValue set ServiceWorkerClient.postMessage': _serialize_SSV,
730 731
731 '* get CustomEvent.detail': 732 '* get CustomEvent.detail':
732 Conversion('convertNativeToDart_SerializedScriptValue', 733 Conversion('convertNativeToDart_SerializedScriptValue',
733 'dynamic', 'dynamic'), 734 'dynamic', 'dynamic'),
734 735
735 # receiving message via MessageEvent 736 # receiving message via MessageEvent
736 '* get MessageEvent.data': 737 '* get MessageEvent.data':
737 Conversion('convertNativeToDart_SerializedScriptValue', 738 Conversion('convertNativeToDart_SerializedScriptValue',
738 'dynamic', 'dynamic'), 739 'dynamic', 'dynamic'),
739 740
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after
1462 return BasicTypedListIDLTypeInfo( 1463 return BasicTypedListIDLTypeInfo(
1463 type_name, type_data, dart_interface_name, self) 1464 type_name, type_data, dart_interface_name, self)
1464 1465
1465 class_name = '%sIDLTypeInfo' % type_data.clazz 1466 class_name = '%sIDLTypeInfo' % type_data.clazz
1466 return globals()[class_name](type_name, type_data) 1467 return globals()[class_name](type_name, type_data)
1467 1468
1468 def isList(return_type): 1469 def isList(return_type):
1469 return return_type.startswith('List<') if return_type else False 1470 return return_type.startswith('List<') if return_type else False
1470 1471
1471 def get_list_type(return_type): 1472 def get_list_type(return_type):
1472 # Get the list type NNNN inside of List<NNNN> 1473 # Get the list type NNNN inside of List<NNNN>
1473 return return_type[5:-1] if isList(return_type) else return_type 1474 return return_type[5:-1] if isList(return_type) else return_type
1474 1475
1475 def wrap_unwrap_list_blink(return_type, type_registry): 1476 def wrap_unwrap_list_blink(return_type, type_registry):
1476 """Return True if the type is the list type is a blink know 1477 """Return True if the type is the list type is a blink know
1477 type e.g., List<Node>, List<FontFace>, etc.""" 1478 type e.g., List<Node>, List<FontFace>, etc."""
1478 if isList(return_type): 1479 if isList(return_type):
1479 list_type = get_list_type(return_type) 1480 list_type = get_list_type(return_type)
1480 if type_registry.HasInterface(list_type): 1481 if type_registry.HasInterface(list_type):
1481 return True; 1482 return True;
1482 1483
(...skipping 18 matching lines...) Expand all
1501 return_type == 'Rectangle') 1502 return_type == 'Rectangle')
1502 1503
1503 def wrap_return_type_blink(return_type, type_name, type_registry): 1504 def wrap_return_type_blink(return_type, type_name, type_registry):
1504 """Returns True if we should wrap the returned value. This checks 1505 """Returns True if we should wrap the returned value. This checks
1505 a number of different variations, calling the more basic functions 1506 a number of different variations, calling the more basic functions
1506 above.""" 1507 above."""
1507 return (wrap_unwrap_type_blink(return_type, type_registry) or 1508 return (wrap_unwrap_type_blink(return_type, type_registry) or
1508 wrap_unwrap_type_blink(type_name, type_registry) or 1509 wrap_unwrap_type_blink(type_name, type_registry) or
1509 wrap_type_blink(return_type, type_registry) or 1510 wrap_type_blink(return_type, type_registry) or
1510 wrap_unwrap_list_blink(return_type, type_registry)) 1511 wrap_unwrap_list_blink(return_type, type_registry))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698