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

Unified Diff: lib/html/scripts/generator.py

Issue 11065003: Convert between Dart and JavaScript SerializedScriptValues on postMessage. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/html/dart2js/html_dart2js.dart ('k') | lib/html/src/dart2js_Conversions.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/html/scripts/generator.py
diff --git a/lib/html/scripts/generator.py b/lib/html/scripts/generator.py
index 99f2190270186e02cc09daeacd17bd5e806cce4e..0603e01ddae2f97b487e5cc42aa94df1fc042525 100644
--- a/lib/html/scripts/generator.py
+++ b/lib/html/scripts/generator.py
@@ -522,81 +522,81 @@ class Conversion(object):
self.input_type = input_type
self.output_type = output_type
-# TYPE -> "DIRECTION INTERFACE.MEMBER" -> conversion
-# TYPE -> "DIRECTION INTERFACE.*" -> conversion
-# TYPE -> "DIRECTION" -> conversion
+# "TYPE DIRECTION INTERFACE.MEMBER" -> conversion
+# Specific member of interface
+# "TYPE DIRECTION INTERFACE.*" -> conversion
+# All members of interface getting (setting) with type.
+# "TYPE DIRECTION" -> conversion
+# All getters (setters) of type.
#
# where DIRECTION is 'get' for getters and operation return values, 'set' for
# setters and operation arguments. INTERFACE and MEMBER are the idl names.
#
+
+_serialize_SSV = Conversion('_convertDartToNative_SerializedScriptValue',
+ 'Dynamic', 'Dynamic')
+
dart2js_conversions = {
- 'IDBKey': {
- 'get':
- Conversion('_convertNativeToDart_IDBKey', 'Dynamic', 'Dynamic'),
- 'set':
- Conversion('_convertDartToNative_IDBKey', 'Dynamic', 'Dynamic'),
- },
- 'ImageData': {
- 'get':
- Conversion('_convertNativeToDart_ImageData', 'Dynamic', 'ImageData'),
- 'set':
- Conversion('_convertDartToNative_ImageData', 'ImageData', 'Dynamic')
- },
- 'Dictionary': {
- 'get':
- Conversion('_convertNativeToDart_Dictionary', 'Dynamic', 'Map'),
- 'set':
- Conversion('_convertDartToNative_Dictionary', 'Map', 'Dynamic'),
- },
-
- 'DOMString[]': {
- 'set':
- Conversion(
- '_convertDartToNative_StringArray', 'List<String>', 'List'),
- },
-
- 'any': {
- 'set IDBObjectStore.add':
- Conversion('_convertDartToNative_SerializedScriptValue',
- 'Dynamic', 'Dynamic'),
- 'set IDBObjectStore.put':
- Conversion('_convertDartToNative_SerializedScriptValue',
- 'Dynamic', 'Dynamic'),
- 'set IDBCursor.update':
- Conversion('_convertDartToNative_SerializedScriptValue',
- 'Dynamic', 'Dynamic'),
- },
+ 'IDBKey get':
+ Conversion('_convertNativeToDart_IDBKey', 'Dynamic', 'Dynamic'),
+ 'IDBKey set':
+ Conversion('_convertDartToNative_IDBKey', 'Dynamic', 'Dynamic'),
+
+ 'ImageData get':
+ Conversion('_convertNativeToDart_ImageData', 'Dynamic', 'ImageData'),
+ 'ImageData set':
+ Conversion('_convertDartToNative_ImageData', 'ImageData', 'Dynamic'),
+
+ 'Dictionary get':
+ Conversion('_convertNativeToDart_Dictionary', 'Dynamic', 'Map'),
+ 'Dictionary set':
+ Conversion('_convertDartToNative_Dictionary', 'Map', 'Dynamic'),
+
+ 'DOMString[] set':
+ Conversion('_convertDartToNative_StringArray', 'List<String>', 'List'),
+
+ 'any set IDBObjectStore.add': _serialize_SSV,
+ 'any set IDBObjectStore.put': _serialize_SSV,
+ 'any set IDBCursor.update': _serialize_SSV,
+
+ # postMessage
+ 'any set DedicatedWorkerContext.postMessage': _serialize_SSV,
+ 'any set MessagePort.postMessage': _serialize_SSV,
+ 'SerializedScriptValue set DOMWindow.postMessage': _serialize_SSV,
+ 'SerializedScriptValue set Worker.postMessage': _serialize_SSV,
+
+ # receiving message via MessageEvent
+ 'DOMObject get MessageEvent.data':
+ Conversion('_convertNativeToDart_SerializedScriptValue',
+ 'Dynamic', 'Dynamic'),
# IDBAny is problematic. Some uses are just a union of other IDB types,
# which need no conversion.. Others include data values which require
# serialized script value processing.
- 'IDBAny': {
- 'get IDBCursorWithValue.value':
- Conversion('_convertNativeToDart_IDBAny', 'Dynamic', 'Dynamic'),
-
- # This is problematic. The result property of IDBRequest is used for
- # all requests. Read requests like IDBDataStore.getObject need
- # conversion, but other requests like opening a database return
- # something that does not need conversion.
- 'get IDBRequest.result':
- Conversion('_convertNativeToDart_IDBAny', 'Dynamic', 'Dynamic'),
-
- # "source: On getting, returns the IDBObjectStore or IDBIndex that the
- # cursor is iterating. ...". So we should not try to convert it.
- 'get IDBCursor.source': None,
-
- # Should be either a DOMString, an Array of DOMStrings or null.
- 'get IDBObjectStore.keyPath': None
- },
+ 'IDBAny get IDBCursorWithValue.value':
+ Conversion('_convertNativeToDart_IDBAny', 'Dynamic', 'Dynamic'),
+
+ # This is problematic. The result property of IDBRequest is used for
+ # all requests. Read requests like IDBDataStore.getObject need
+ # conversion, but other requests like opening a database return
+ # something that does not need conversion.
+ 'IDBAny get IDBRequest.result':
+ Conversion('_convertNativeToDart_IDBAny', 'Dynamic', 'Dynamic'),
+
+ # "source: On getting, returns the IDBObjectStore or IDBIndex that the
+ # cursor is iterating. ...". So we should not try to convert it.
+ 'IDBAny get IDBCursor.source': None,
+
+ # Should be either a DOMString, an Array of DOMStrings or null.
+ 'IDBAny get IDBObjectStore.keyPath': None,
}
def FindConversion(idl_type, direction, interface, member):
- table = dart2js_conversions.get(idl_type)
- if table:
- return (table.get('%s %s.%s' % (direction, interface, member)) or
- table.get('%s %s.*' % (direction, interface)) or
- table.get(direction))
+ table = dart2js_conversions
+ return (table.get('%s %s %s.%s' % (idl_type, direction, interface, member)) or
+ table.get('%s %s %s.*' % (idl_type, direction, interface)) or
+ table.get('%s %s' % (idl_type, direction)))
return None
# ------------------------------------------------------------------------------
« no previous file with comments | « lib/html/dart2js/html_dart2js.dart ('k') | lib/html/src/dart2js_Conversions.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698