Chromium Code Reviews| Index: lib/dom/scripts/systemnative.py |
| diff --git a/lib/dom/scripts/systemnative.py b/lib/dom/scripts/systemnative.py |
| index 913c1c0a9387eabd76fb33f911601c2ada31bf09..7704f576410a92f42c124046e3bd7e4f5a4e5ae1 100644 |
| --- a/lib/dom/scripts/systemnative.py |
| +++ b/lib/dom/scripts/systemnative.py |
| @@ -387,7 +387,7 @@ class NativeImplementationGenerator(systemwrapping.WrappingInterfaceGenerator): |
| ' static PassRefPtr<NativeType> toNative(Dart_Handle handle, Dart_Handle& exception);\n') |
| else: |
| to_native_emitter.Emit( |
| - ' static PassRefPtr<NativeType> toNative(Dart_Handle handle, Dart_Handle& exception)\n' |
| + ' static NativeType* toNative(Dart_Handle handle, Dart_Handle& exception)\n' |
| ' {\n' |
| ' return DartDOMWrapper::unwrapDartWrapper<Dart$INTERFACE>(handle, exception);\n' |
| ' }\n', |
| @@ -538,7 +538,7 @@ class NativeImplementationGenerator(systemwrapping.WrappingInterfaceGenerator): |
| webcore_function_name += 'Animated' |
| argument_expression = self._GenerateParameterAdapter( |
| - parameter_definitions_emitter, attr, 0, adapter_name='value') |
| + parameter_definitions_emitter, attr, 0, argument_name='value') |
| arguments.append(argument_expression) |
| parameter_definitions = parameter_definitions_emitter.Fragments() |
| @@ -703,7 +703,7 @@ class NativeImplementationGenerator(systemwrapping.WrappingInterfaceGenerator): |
| if raises_exceptions: |
| body = emitter.Format( |
| - ' Dart_Handle exception;\n' |
| + ' Dart_Handle exception = 0;\n' |
| '$BODY' |
| '\n' |
| 'fail:\n' |
| @@ -722,35 +722,55 @@ class NativeImplementationGenerator(systemwrapping.WrappingInterfaceGenerator): |
| BODY=body) |
| def _GenerateParameterAdapter(self, emitter, idl_node, index, |
| - adapter_name=None): |
| + argument_name=None): |
| """idl_node is IDLArgument or IDLAttribute.""" |
| type_info = GetIDLTypeInfo(idl_node.type.id) |
| (adapter_type, include_name) = type_info.parameter_adapter_info() |
| if include_name: |
| self._cpp_impl_includes.add(include_name) |
| - adapter_name = adapter_name or idl_node.id |
| + argument_name = argument_name or idl_node.id |
| flags = '' |
| if (idl_node.ext_attrs.get('Optional') == 'DefaultIsNullString' or |
| 'RequiredCppParameter' in idl_node.ext_attrs): |
| flags = ', DartUtilities::ConvertNullToDefaultValue' |
| + |
| + if isinstance(type_info, PrimitiveIDLTypeInfo): |
| + emitter.Emit( |
|
Anton Muhin
2012/05/03 18:27:50
shouldn't it be a polymorphic method or something?
podivilov
2012/05/03 18:44:19
Probably not, because it uses too much of a contex
|
| + '\n' |
| + ' const $ADAPTER_TYPE $NAME(Dart_GetNativeArgument(args, $INDEX)$FLAGS);\n' |
| + ' if (!$NAME.conversionSuccessful()) {\n' |
| + ' exception = $NAME.exception();\n' |
| + ' goto fail;\n' |
| + ' }\n', |
| + ADAPTER_TYPE=adapter_type, |
| + NAME=argument_name, |
| + INDEX=index + 1, |
| + FLAGS=flags) |
| + return argument_name |
| + |
| + if 'Callback' in idl_node.ext_attrs: |
| + type = 'RefPtr<%s>' % type_info.native_type() |
| + conversion = '%s' |
| + elif type_info.custom_to_native(): |
| + type = 'RefPtr<%s>' % type_info.native_type() |
| + conversion = '%s.get()' |
| + else: |
| + type = '%s*' % type_info.native_type() |
| + if isinstance(type_info, SVGTearOffIDLTypeInfo) and not self._interface.id.endswith('List'): |
| + conversion = '%s->propertyReference()' |
| + else:#if type_info.idl_type() == 'SVGMatrix' and self._interface.id == 'SVGTransformList': |
| + conversion = '%s' |
| + |
| emitter.Emit( |
| '\n' |
| - ' const $ADAPTER_TYPE $NAME(Dart_GetNativeArgument(args, $INDEX)$FLAGS);\n' |
| - ' if (!$NAME.conversionSuccessful()) {\n' |
| - ' exception = $NAME.exception();\n' |
| - ' goto fail;\n' |
| - ' }\n', |
| - ADAPTER_TYPE=adapter_type, |
| - NAME=adapter_name, |
| - INDEX=index + 1, |
| - FLAGS=flags) |
| - |
| - conversion = '%s' |
| - if isinstance(type_info, SVGTearOffIDLTypeInfo) and not self._interface.id.endswith('List'): |
| - conversion = '%s.get()->propertyReference()' |
| - elif type_info.idl_type() == 'SVGMatrix' and self._interface.id == 'SVGTransformList': |
| - conversion = '%s.get()' |
| - return conversion % adapter_name |
| + ' $TYPE $NAME = Dart$IDL_TYPE::toNative(Dart_GetNativeArgument(args, $INDEX), exception);\n' |
| + ' if (exception)\n' |
| + ' goto fail;\n', |
| + TYPE=type, |
| + NAME=argument_name, |
| + IDL_TYPE=type_info.idl_type(), |
| + INDEX=index + 1) |
| + return conversion % argument_name |
| def _GenerateNativeBinding(self, idl_name, argument_count, dart_declaration, |
| native_suffix, is_custom): |