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

Unified Diff: sdk/lib/html/scripts/systemnative.py

Issue 11688005: Start unification of overload dispatcher generation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years 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: sdk/lib/html/scripts/systemnative.py
diff --git a/sdk/lib/html/scripts/systemnative.py b/sdk/lib/html/scripts/systemnative.py
index deb96205e123ec780b3e5b636dd292789f9bbdcf..bf461c0ab9c3644df1d2f8d9114ffea29e3de69b 100644
--- a/sdk/lib/html/scripts/systemnative.py
+++ b/sdk/lib/html/scripts/systemnative.py
@@ -442,7 +442,7 @@ class DartiumBackend(HtmlDartGenerator):
else:
self._GenerateDispatcher(info.operations, dart_declaration, [info.name for info in info.param_infos])
- def _GenerateDispatcher(self, operations, dart_declaration, argument_names):
+ def _GenerateDispatcher(self, operations, dart_declaration, parameter_names):
body = self._members_emitter.Emit(
'\n'
@@ -466,7 +466,7 @@ class DartiumBackend(HtmlDartGenerator):
overload_name = '%s_%s' % (operation.id, version[0])
version[0] += 1
- argument_list = ', '.join(argument_names[:argument_count])
+ argument_list = ', '.join(parameter_names[:argument_count])
call = '_%s(%s)' % (overload_name, argument_list)
body.Emit(template, CHECKS=' && '.join(checks), CALL=call)
@@ -480,15 +480,8 @@ class DartiumBackend(HtmlDartGenerator):
self._GenerateOperationNativeCallback(operation, operation.arguments[:argument_count], cpp_callback_name)
def GenerateChecksAndCall(operation, argument_count):
- checks = []
- for i in range(0, argument_count):
- argument = operation.arguments[i]
- argument_name = argument_names[i]
- type = self._DartType(argument.type.id)
- if type not in ['dynamic', 'Object']:
- checks.append('(%s is %s || %s == null)' % (argument_name, type, argument_name))
- checks.extend(['!?%s' % name for name in argument_names[argument_count:]])
- GenerateCall(operation, argument_count, checks)
+ GenerateCall(operation, argument_count,
+ self._OverloadChecks(operation, parameter_names, argument_count))
# TODO: Optimize the dispatch to avoid repeated checks.
if len(operations) > 1:
@@ -503,7 +496,7 @@ class DartiumBackend(HtmlDartGenerator):
argument_count = len(operation.arguments)
for position, argument in list(enumerate(operation.arguments))[::-1]:
if self._IsArgumentOptionalInWebCore(operation, argument):
- check = '?%s' % argument_names[position]
+ check = '?%s' % parameter_names[position]
# argument_count instead of position + 1 is used here to cover one
# complicated case with the effectively optional argument in the middle.
# Consider foo(x, [Optional] y, [Optional=DefaultIsNullString] z)

Powered by Google App Engine
This is Rietveld 408576698