| 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)
|
|
|