Chromium Code Reviews| Index: tools/dom/scripts/generator.py |
| diff --git a/tools/dom/scripts/generator.py b/tools/dom/scripts/generator.py |
| index 74da08d91c14e7f11976856513fafac4e9ddba67..dd7bbb920c98349cd30bb398a26791f1d70edd39 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): |
| + conversion_cast = 'static_cast<ArrayBufferView*>(%s)' % value |
|
Anton Muhin
2013/04/19 11:37:53
do you need this cast?
Mads Ager (google)
2013/04/19 12:05:41
Ehm, no. Thanks!
|
| + return 'DartUtilities::arrayBufferViewToDart(%s)' % conversion_cast |
| + |
| + 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 [] |
|
Anton Muhin
2013/04/19 11:37:53
why no includes?
Mads Ager (google)
2013/04/19 12:05:41
Because it only needs DartUtilities. Am I missing
Anton Muhin
2013/04/19 12:57:43
Adding includes might be more robust, but we are n
|
| + |
| + def to_dart_conversion(self, value, interface_name, attributes): |
| + conversion_cast = 'static_cast<%s*>(%s)' % (self.native_type(), value) |
|
Anton Muhin
2013/04/19 11:37:53
why you need a cast?
Mads Ager (google)
2013/04/19 12:05:41
Ehm, no. Thanks! :-)
|
| + return 'DartUtilities::%sToDart(%s)' % (self._idl_type, conversion_cast) |
| + |
| + 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) |