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

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

Issue 9467007: Support ImplementedBy idl attribute. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 10 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/dom/scripts/systemnative.py
diff --git a/client/dom/scripts/systemnative.py b/client/dom/scripts/systemnative.py
index 95c1eef490b80315b58af9ea682195852d9703e5..37c606d4834423fb70de1763472888cdbd12d93f 100644
--- a/client/dom/scripts/systemnative.py
+++ b/client/dom/scripts/systemnative.py
@@ -304,17 +304,20 @@ class NativeImplementationGenerator(systemwrapping.WrappingInterfaceGenerator):
else:
raise Exception('Unsupported CallWith=%s attribute' % call_with)
+ if raises_dom_exceptions:
+ arguments.append('ec')
+
+ invocation = '%s::create(%s)' % (type_info.native_type(), ', '.join(arguments))
self._GenerateNativeCallback(
callback_name='constructorCallback',
idl_node=self._interface,
parameter_definitions=parameter_definitions,
- needs_receiver=False, function_name='%s::create' % type_info.native_type(),
- arguments=arguments,
+ needs_receiver=False,
+ invocation=invocation,
idl_return_type=self._interface,
raises_dart_exceptions=raises_dart_exceptions,
raises_dom_exceptions=raises_dom_exceptions)
-
def _ImplClassName(self, interface_name):
return interface_name + 'Implementation'
@@ -382,10 +385,6 @@ class NativeImplementationGenerator(systemwrapping.WrappingInterfaceGenerator):
if (getter or setter).type.id == 'EventListener':
return
- # FIXME: support 'ImplementedBy'.
- if 'ImplementedBy' in (getter or setter).ext_attrs:
- return
-
# FIXME: these should go away.
classes_with_unsupported_custom_getters = [
'Clipboard', 'Console', 'Coordinates', 'DeviceMotionEvent',
@@ -433,8 +432,10 @@ class NativeImplementationGenerator(systemwrapping.WrappingInterfaceGenerator):
if attr.type.id.startswith('SVGAnimated'):
webcore_function_name += 'Animated'
+ invocation = self._GenerateWebCoreInvocation(attr, webcore_function_name,
+ arguments, attr.get_raises)
self._GenerateNativeCallback(cpp_callback_name, attr, '',
- True, webcore_function_name, arguments, idl_return_type=attr.type,
+ True, invocation, idl_return_type=attr.type,
raises_dart_exceptions=attr.get_raises,
raises_dom_exceptions=attr.get_raises)
@@ -459,11 +460,14 @@ class NativeImplementationGenerator(systemwrapping.WrappingInterfaceGenerator):
webcore_function_name += 'Animated'
arguments.append(attr.id)
+
parameter_definitions_emitter = emitter.Emitter()
self._GenerateParameterAdapter(parameter_definitions_emitter, attr, 0)
parameter_definitions = parameter_definitions_emitter.Fragments()
+ invocation = self._GenerateWebCoreInvocation(attr, webcore_function_name,
+ arguments, attr.set_raises)
self._GenerateNativeCallback(cpp_callback_name, attr, parameter_definitions,
- True, webcore_function_name, arguments, idl_return_type=None,
+ True, invocation, idl_return_type=None,
raises_dart_exceptions=True,
raises_dom_exceptions=attr.set_raises)
@@ -523,10 +527,6 @@ class NativeImplementationGenerator(systemwrapping.WrappingInterfaceGenerator):
operation: the IDLOperation to call.
"""
- # FIXME: support ImplementedBy callbacks.
- if 'ImplementedBy' in operation.ext_attrs:
- return
-
for op in self._interface.operations:
if op.id != operation.id or len(op.arguments) <= len(operation.arguments):
continue
@@ -567,9 +567,7 @@ class NativeImplementationGenerator(systemwrapping.WrappingInterfaceGenerator):
return
# Generate callback.
- webcore_function_name = operation.id
- if 'ImplementedAs' in operation.ext_attrs:
- webcore_function_name = operation.ext_attrs['ImplementedAs']
+ webcore_function_name = operation.ext_attrs.get('ImplementedAs', operation.id)
parameter_definitions_emitter = emitter.Emitter()
raises_dart_exceptions = len(operation.arguments) > 0 or operation.raises
@@ -625,22 +623,22 @@ class NativeImplementationGenerator(systemwrapping.WrappingInterfaceGenerator):
arguments.append('String()')
if 'NeedsUserGestureCheck' in operation.ext_attrs:
- arguments.extend('DartUtilities::processingUserGesture')
-
- parameter_definitions = parameter_definitions_emitter.Fragments()
- self._GenerateNativeCallback(cpp_callback_name, operation, parameter_definitions,
- True, webcore_function_name, arguments, idl_return_type=operation.type,
+ arguments.append('DartUtilities::processingUserGesture')
+
+ invocation = self._GenerateWebCoreInvocation(operation,
+ webcore_function_name, arguments, operation.raises)
+ self._GenerateNativeCallback(cpp_callback_name, operation,
+ parameter_definitions=parameter_definitions_emitter.Fragments(),
+ needs_receiver=True, invocation=invocation,
+ idl_return_type=operation.type,
raises_dart_exceptions=raises_dart_exceptions,
raises_dom_exceptions=operation.raises)
def _GenerateNativeCallback(self, callback_name, idl_node,
- parameter_definitions, needs_receiver, function_name, arguments, idl_return_type,
+ parameter_definitions, needs_receiver, invocation, idl_return_type,
raises_dart_exceptions, raises_dom_exceptions):
- if raises_dom_exceptions:
- arguments.append('ec')
- prefix = ''
- if needs_receiver: prefix = self._interface_type_info.receiver()
- callback = '%s%s(%s)' % (prefix, function_name, ', '.join(arguments))
+
+ callback = invocation
nested_templates = []
if idl_return_type and idl_return_type.id != 'void':
@@ -781,3 +779,18 @@ class NativeImplementationGenerator(systemwrapping.WrappingInterfaceGenerator):
attribute_name = attr.ext_attrs['Reflect'] or attr.id.lower()
return 'WebCore::%s::%sAttr' % (namespace, attribute_name)
+
+ def _GenerateWebCoreInvocation(self, idl_node, function_name, arguments,
+ raises_dom_exceptions):
antonm 2012/02/24 19:01:40 I don't like how ec handling is now spread all ove
+ if 'ImplementedBy' in idl_node.ext_attrs:
+ implementedBy = idl_node.ext_attrs['ImplementedBy']
+ self._cpp_impl_includes[implementedBy] = 1
+ invocation = '%s::%s' % (implementedBy, function_name)
+ arguments.insert(0, 'receiver')
+ else:
+ invocation = '%s%s' % (self._interface_type_info.receiver(), function_name)
+
+ if raises_dom_exceptions:
+ arguments.append('ec')
+
+ return '%s(%s)' % (invocation, ', '.join(arguments))
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698