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

Unified Diff: tools/dom/scripts/generator.py

Issue 13811054: Update code generator for dartium dart:html with typeddata. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments Created 7 years, 8 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 | « tools/dom/idl/dart/dart.idl ('k') | tools/dom/scripts/htmldartgenerator.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/dom/scripts/generator.py
diff --git a/tools/dom/scripts/generator.py b/tools/dom/scripts/generator.py
index 74da08d91c14e7f11976856513fafac4e9ddba67..9d659101f8a820a82003350fc8065cae613a657c 100644
--- a/tools/dom/scripts/generator.py
+++ b/tools/dom/scripts/generator.py
@@ -1329,6 +1329,38 @@ class SVGTearOffIDLTypeInfo(InterfaceIDLTypeInfo):
return name if interface_name.endswith('List') else '%s->propertyReference()' % name
+class TypedListIDLTypeInfo(InterfaceIDLTypeInfo):
+ def __init__(self, idl_type, data, interface_name, type_registry):
+ super(TypedListIDLTypeInfo, self).__init__(
+ idl_type, data, interface_name, type_registry)
+
+ def conversion_includes(self):
+ return [ '"wtf/%s.h"' % self._idl_type ]
+
+ def to_dart_conversion(self, value, interface_name, attributes):
+ return 'DartUtilities::arrayBufferViewToDart(%s)' % value
+
+ def to_native_info(self, idl_node, interface_name):
+ return '%s.get()', 'RefPtr<%s>' % self._idl_type, 'DartUtilities', 'dartTo%s' % self._idl_type
+
+
+class BasicTypedListIDLTypeInfo(InterfaceIDLTypeInfo):
+ def __init__(self, idl_type, data, interface_name, type_registry):
+ super(BasicTypedListIDLTypeInfo, self).__init__(
+ idl_type, data, interface_name, type_registry)
+
+ def conversion_includes(self):
+ return []
+
+ def to_dart_conversion(self, value, interface_name, attributes):
+ function_name = 'DartUtilities::%sToDart' % self._idl_type
+ function_name = function_name[0].lower() + function_name[1:]
+ return '%s(%s)' % (function_name, value)
+
+ def to_native_info(self, idl_node, interface_name):
+ return '%s.get()', 'RefPtr<%s>' % self._idl_type, 'DartUtilities', 'dartTo%s' % self._idl_type
+
+
class TypeData(object):
def __init__(self, clazz, dart_type=None, native_type=None,
merged_interface=None, merged_into=None,
@@ -1352,13 +1384,11 @@ class TypeData(object):
self.is_typed_array = is_typed_array
-def TypedArrayTypeData(item_type):
+def TypedListTypeData(item_type):
return TypeData(
- clazz='Interface',
+ clazz='TypedList',
dart_type='List<%s>' % item_type, # TODO(antonm): proper typeddata interfaces.
item_type=item_type,
- # TODO(antonm): should be autogenerated. Let the dust settle down.
- custom_to_dart=True, custom_to_native=True,
is_typed_array=True)
@@ -1462,24 +1492,18 @@ _idl_type_registry = monitored.Dict('generator._idl_type_registry', {
'TextTrackList': TypeData(clazz='Interface', item_type='TextTrack'),
'TouchList': TypeData(clazz='Interface', item_type='Touch'),
- 'Float32Array': TypedArrayTypeData('double'),
- 'Float64Array': TypedArrayTypeData('double'),
- 'Int8Array': TypedArrayTypeData('int'),
- 'Int16Array': TypedArrayTypeData('int'),
- 'Int32Array': TypedArrayTypeData('int'),
- 'Uint8Array': TypedArrayTypeData('int'),
- 'Uint8ClampedArray': TypedArrayTypeData('int'),
- 'Uint16Array': TypedArrayTypeData('int'),
- 'Uint32Array': TypedArrayTypeData('int'),
- # TODO(antonm): temporary ugly hack.
- # While in transition phase we allow both DOM's ArrayBuffer
- # and dart:typeddata's ByteBuffer for IDLs' ArrayBuffers,
- # hence ArrayBuffer is mapped to dynamic in arguments and return
- # values.
- 'ArrayBufferView': TypeData(clazz='Interface', dart_type='dynamic',
- custom_to_native=True, custom_to_dart=True),
- 'ArrayBuffer': TypeData(clazz='Interface', dart_type='dynamic',
- custom_to_native=True, custom_to_dart=True),
+ 'Float32Array': TypedListTypeData('double'),
+ 'Float64Array': TypedListTypeData('double'),
+ 'Int8Array': TypedListTypeData('int'),
+ 'Int16Array': TypedListTypeData('int'),
+ 'Int32Array': TypedListTypeData('int'),
+ 'Uint8Array': TypedListTypeData('int'),
+ 'Uint8ClampedArray': TypedListTypeData('int'),
+ 'Uint16Array': TypedListTypeData('int'),
+ 'Uint32Array': TypedListTypeData('int'),
+
+ 'ArrayBufferView': TypeData(clazz='BasicTypedList'),
+ 'ArrayBuffer': TypeData(clazz='BasicTypedList'),
'SVGAngle': TypeData(clazz='SVGTearOff'),
'SVGLength': TypeData(clazz='SVGTearOff'),
@@ -1564,5 +1588,17 @@ class TypeRegistry(object):
return SVGTearOffIDLTypeInfo(
type_name, type_data, dart_interface_name, self)
+ if type_data.clazz == 'TypedList':
+ dart_interface_name = self._renamer.RenameInterface(
+ self._database.GetInterface(type_name))
+ return TypedListIDLTypeInfo(
+ type_name, type_data, dart_interface_name, self)
+
+ if type_data.clazz == 'BasicTypedList':
+ dart_interface_name = self._renamer.RenameInterface(
+ self._database.GetInterface(type_name))
+ return BasicTypedListIDLTypeInfo(
+ type_name, type_data, dart_interface_name, self)
+
class_name = '%sIDLTypeInfo' % type_data.clazz
return globals()[class_name](type_name, type_data)
« no previous file with comments | « tools/dom/idl/dart/dart.idl ('k') | tools/dom/scripts/htmldartgenerator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698