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

Unified Diff: lib/dom/scripts/systemnative.py

Issue 10119009: Move custom to dart conversion logic to IDLTypeInfo implementations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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 | « lib/dom/scripts/generator.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/dom/scripts/systemnative.py
diff --git a/lib/dom/scripts/systemnative.py b/lib/dom/scripts/systemnative.py
index fe3bdfa99d8987e0e16477fb4cbf251043f07325..df58bbc4da7327d622a27daa64f0b81ee3961966 100644
--- a/lib/dom/scripts/systemnative.py
+++ b/lib/dom/scripts/systemnative.py
@@ -783,35 +783,13 @@ class NativeImplementationGenerator(systemwrapping.WrappingInterfaceGenerator):
return_type_info = GetIDLTypeInfo(idl_return_type)
self._cpp_impl_includes |= set(return_type_info.to_dart_includes())
- # Generate C++ cast based on idl return type.
- conversion_cast = return_type_info.conversion_cast('$FUNCTION_CALL')
- if isinstance(return_type_info, SVGTearOffIDLTypeInfo):
- svg_primitive_types = ['SVGAngle', 'SVGLength', 'SVGMatrix',
- 'SVGNumber', 'SVGPoint', 'SVGRect', 'SVGTransform']
- conversion_cast = '%s::create($FUNCTION_CALL)'
- if self._interface.id.startswith('SVGAnimated'):
- conversion_cast = 'static_cast<%s*>($FUNCTION_CALL)'
- elif return_type_info.idl_type() == 'SVGStringList':
- conversion_cast = '%s::create(receiver, $FUNCTION_CALL)'
- elif self._interface.id.endswith('List'):
- conversion_cast = 'static_cast<%s*>($FUNCTION_CALL.get())'
- elif return_type_info.idl_type() in svg_primitive_types:
- conversion_cast = '%s::create($FUNCTION_CALL)'
- else:
- conversion_cast = 'static_cast<%s*>($FUNCTION_CALL)'
- conversion_cast = conversion_cast % return_type_info.native_type()
-
# Generate to Dart conversion of C++ value.
- conversion_arguments = [conversion_cast]
- if (return_type_info.idl_type() in ['DOMString', 'AtomicString'] and
- 'TreatReturnedNullStringAs' in attributes):
- conversion_arguments.append('ConvertDefaultToNull')
-
+ to_dart_conversion = return_type_info.to_dart_conversion('$FUNCTION_CALL', self._interface.id, attributes)
invocation_template = emitter.Format(
- ' Dart_Handle returnValue = toDartValue($ARGUMENTS);\n'
+ ' Dart_Handle returnValue = $TO_DART_CONVERSION;\n'
' if (returnValue)\n'
' Dart_SetReturnValue(args, returnValue);\n',
- ARGUMENTS=', '.join(conversion_arguments))
+ TO_DART_CONVERSION=to_dart_conversion)
if raises_dom_exceptions:
# Add 'ec' argument to WebCore invocation and convert DOM exception to Dart exception.
« no previous file with comments | « lib/dom/scripts/generator.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698