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

Unified Diff: tools/dom/scripts/systemhtml.py

Issue 11896038: Some more refactorings of overload dispatcher generation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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
Index: tools/dom/scripts/systemhtml.py
diff --git a/tools/dom/scripts/systemhtml.py b/tools/dom/scripts/systemhtml.py
index 19c251e75c3fb2a0755cda878881e0c7f2d52fbe..f341dcc72e75c225f96e89e725d3ac325b926525 100644
--- a/tools/dom/scripts/systemhtml.py
+++ b/tools/dom/scripts/systemhtml.py
@@ -789,35 +789,15 @@ class Dart2JSBackend(HtmlDartGenerator):
else:
return self._NarrowInputType(type_name) if type_name else 'dynamic'
- body = self._members_emitter.Emit(
- '\n'
- ' $MODIFIERS$TYPE $(HTML_NAME)($PARAMS) {\n'
- '$!BODY'
- ' }\n',
- MODIFIERS='static ' if info.IsStatic() else '',
- TYPE=return_type,
- HTML_NAME=html_name,
- PARAMS=info.ParametersDeclaration(InputType))
-
parameter_names = [param_info.name for param_info in info.param_infos]
parameter_types = [InputType(param_info.type_id)
for param_info in info.param_infos]
operations = info.operations
- method_version = [0]
temp_version = [0]
- def GenerateCall(operation, argument_count, checks):
- if checks:
- (stmts_emitter, call_emitter) = body.Emit(
- ' if ($CHECKS) {\n$!STMTS$!CALL }\n',
- INDENT=' ',
- CHECKS=' &&\n '.join(checks))
- else:
- (stmts_emitter, call_emitter) = body.Emit('$!A$!B', INDENT=' ');
-
- method_version[0] += 1
- target = '_%s_%d' % (html_name, method_version[0]);
+ def GenerateCall(stmts_emitter, call_emitter, version, operation, argument_count):
+ target = '_%s_%d' % (html_name, version);
arguments = []
target_parameters = []
for position, arg in enumerate(operation.arguments[:argument_count]):
@@ -860,11 +840,7 @@ class Dart2JSBackend(HtmlDartGenerator):
if output_conversion:
call = '%s(%s)' % (output_conversion.function_name, call)
- if operation.type.id == 'void':
- call_emitter.Emit('$(INDENT)$CALL;\n$(INDENT)return;\n',
- CALL=call)
- else:
- call_emitter.Emit('$(INDENT)return $CALL;\n', CALL=call)
+ call_emitter.Emit(call)
self._members_emitter.Emit(
' $RENAME$ANNOTATIONS$MODIFIERS$TYPE$TARGET($PARAMS) native;\n',
@@ -875,10 +851,15 @@ class Dart2JSBackend(HtmlDartGenerator):
TARGET=target,
PARAMS=', '.join(target_parameters))
+ declaration = '%s%s %s(%s)' % (
+ 'static ' if info.IsStatic() else '',
+ return_type,
+ html_name,
+ info.ParametersDeclaration(InputType))
self._GenerateDispatcherBody(
- body,
operations,
parameter_names,
+ declaration,
GenerateCall,
self._IsOptional,
can_omit_type_check=lambda type, pos: type == parameter_types[pos])

Powered by Google App Engine
This is Rietveld 408576698