Chromium Code Reviews| Index: lib/html/scripts/generator.py |
| diff --git a/lib/html/scripts/generator.py b/lib/html/scripts/generator.py |
| index e501a0f7cf4a8ec5f31ed65f2c2ec60ba8854a2a..ffe54bb3de13f93795a6add66ef097216fa55ce7 100644 |
| --- a/lib/html/scripts/generator.py |
| +++ b/lib/html/scripts/generator.py |
| @@ -551,11 +551,17 @@ class IDLTypeInfo(object): |
| def native_type(self): |
| return self._data.native_type or self._idl_type |
| + def bindings_class(self): |
| + return 'Dart%s' % self.idl_type() |
| + |
| + def as_item_converter(self): |
| + return self.bindings_class() |
| + |
| def requires_v8_scope(self): |
| return self._data.requires_v8_scope |
| def to_native_info(self, idl_node, interface_name): |
| - cls = 'Dart%s' % self.idl_type() |
| + cls = self.bindings_class() |
| if 'Callback' in idl_node.ext_attrs: |
| return '%s', 'RefPtr<%s>' % self.native_type(), cls, 'create' |
| @@ -635,20 +641,17 @@ class SequenceIDLTypeInfo(IDLTypeInfo): |
| def dart_type(self): |
| return 'List<%s>' % self._item_info.dart_type() |
| - def to_native_info(self, idl_node, interface_name): |
| - item_info = self._item_info |
| - item_native_type = item_info.native_type() |
| - # Ugly hack. Usually IDLs floats are treated as C++ doubles, however |
| - # sequence<float> should map to Vector<float> |
| - if item_native_type == 'double' and item_info.idl_type() == 'float': |
| - item_native_type = 'float' |
| + def as_item_converter(self): |
|
podivilov
2012/09/14 15:15:04
I hope it's temporary anyway, so let's call it vec
Anton Muhin
2012/09/14 15:30:45
Thanks a lot!
|
| + raise Exception('sequences of sequences are not supported yet') |
| + def to_native_info(self, idl_node, interface_name): |
| + item_native_type = self._item_info.as_item_converter() |
| return '%s', 'Vector<%s>' % item_native_type, 'DartUtilities', 'toNativeVector<%s>' % item_native_type |
| def pass_native_by_ref(self): return True |
| def to_dart_conversion(self, value, interface_name=None, attributes=None): |
| - return 'DartDOMWrapper::vectorToDart<Dart%s>(%s)' % (self._item_info.native_type(), value) |
| + return 'DartDOMWrapper::vectorToDart<%s>(%s)' % (self._item_info.as_item_converter(), value) |
| def conversion_includes(self): |
| return self._item_info.conversion_includes() |
| @@ -668,6 +671,12 @@ class PrimitiveIDLTypeInfo(IDLTypeInfo): |
| def __init__(self, idl_type, data): |
| super(PrimitiveIDLTypeInfo, self).__init__(idl_type, data) |
| + def as_item_converter(self): |
|
podivilov
2012/09/14 13:24:46
Why do you return primitive types from a function
Anton Muhin
2012/09/14 13:26:12
The name is misleading, all I want is to return a
|
| + # Ugly hack. Usually IDLs floats are treated as C++ doubles, however |
| + # sequence<float> should map to Vector<float> |
| + if self.idl_type() == 'float': return 'float' |
|
podivilov
2012/09/14 13:24:46
I don't think it's the preferred style in generato
Anton Muhin
2012/09/14 13:26:12
Will do
On 2012/09/14 13:24:46, podivilov wrote:
|
| + return self.native_type() |
| + |
| def to_native_info(self, idl_node, interface_name): |
| type = self.native_type() |
| if type == 'SerializedScriptValue': |