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

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

Issue 9455090: Support optional callbacks. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressing Pavel's comments 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 | « client/dom/scripts/systemnative.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/dom/scripts/systemwrapping.py
diff --git a/client/dom/scripts/systemwrapping.py b/client/dom/scripts/systemwrapping.py
index 83a9fb6147fb35327687f0e929f670b77d3befde..50073e23c5aeb1f348a28d6e1fe25c8c0a1ff206 100644
--- a/client/dom/scripts/systemwrapping.py
+++ b/client/dom/scripts/systemwrapping.py
@@ -454,6 +454,25 @@ 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 = []
« no previous file with comments | « client/dom/scripts/systemnative.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698