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

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

Issue 9495014: Support Dart optional arguments which are not dispatched, but instead use default values. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: forgotten : 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
Index: client/dom/scripts/systemwrapping.py
diff --git a/client/dom/scripts/systemwrapping.py b/client/dom/scripts/systemwrapping.py
index 50073e23c5aeb1f348a28d6e1fe25c8c0a1ff206..e621dbc5cc1b521bfdb6b2a97df9f255d643a80d 100644
--- a/client/dom/scripts/systemwrapping.py
+++ b/client/dom/scripts/systemwrapping.py
@@ -454,25 +454,6 @@ class WrappingInterfaceGenerator(object):
# overloads and generates an overload specific check. Revisit
# when we move to named optional arguments.
- if position == 0:
- # Optional callback arguments are special. C++ counterparts do not have proper optional
- # arguments (as in some cases C++ counterparts require ec) and thus 0 ref ptrs are passed
- # instead of missing arguments. That means the only allowed form is a list of
- # arguments with trailing optional callbacks and we don't need any dispatch at all.
- def IsOptionalCallback(arg): return arg.is_optional and 'Callback' in arg.ext_attrs
- first_optional_callback = None
- for (i, arg) in enumerate(overloads[-1].arguments):
- if IsOptionalCallback(arg):
- first_optional_callback = i
- break
- if first_optional_callback is not None:
- for overload in overloads:
- for arg in overload.arguments[first_optional_callback:]:
- if not IsOptionalCallback(arg):
- raise Exception('Invalid overloading with optional callbacks')
- self.GenerateSingleOperation(emitter, info, indent, overloads[-1])
- return False
-
# Partition the overloads to divide and conquer on the dispatch.
positive = []
negative = []
@@ -488,6 +469,18 @@ class WrappingInterfaceGenerator(object):
test = TypeCheck(param_name, type)
pred = lambda op: len(op.arguments) > position and DartType(op.arguments[position].type.id) == type
else:
+ def IsConvertNullToDefaultValue(arg): return 'DartConvertNullToDefaultValue' in arg.ext_attrs
sra1 2012/02/28 22:04:42 Lines too long
antonm 2012/02/29 10:29:40 Done.
+ # Check if we dispatch on ConvertNullToDefaultValue arguments. In this case all
+ # trailing arguments must be ConvertNullToDefaultValue and there is no need in dispatch.
+ # TODO(antonm): better diagnositics.
+ last_overload = overloads[-1]
+ if len(last_overload.arguments) > position and IsConvertNullToDefaultValue(last_overload.arguments[position]):
+ for overload in overloads:
+ if not all([IsConvertNullToDefaultValue(arg) for arg in overload.arguments[position:]]):
+ raise Exception('Invalid overload with ConvertNullToDefaultValues')
+ self.GenerateSingleOperation(emitter, info, indent, last_overload)
+ return False
podivilov 2012/02/28 17:46:24 Could you please move this to another block, so it
antonm 2012/02/28 19:22:08 Again, I'll do that, but first I'll try to object
sra1 2012/02/28 22:04:42 So it possible (at least theoretically) to have a
antonm 2012/02/29 10:29:40 Yes, IDBDatabase.transaction is exactly the exampl
+
type = None
test = NullCheck(param_name)
pred = lambda op: position >= len(op.arguments)
« client/dom/scripts/databasebuilder.py ('K') | « client/dom/scripts/systemnative.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698