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

Unified Diff: Source/bindings/scripts/utilities.py

Issue 270573005: Move modules-dependent IDL statements out of core by supporting 'implements' in RHS interface (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Addressed reviewer comments. Created 6 years, 7 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: Source/bindings/scripts/utilities.py
diff --git a/Source/bindings/scripts/utilities.py b/Source/bindings/scripts/utilities.py
index 0f16281b79fb434dd877b586cb211b245dc9a9ad..d234ed18f0850a22e3dfe7310331d9885c0f511e 100644
--- a/Source/bindings/scripts/utilities.py
+++ b/Source/bindings/scripts/utilities.py
@@ -58,15 +58,12 @@ def get_partial_interface_name_from_idl(file_contents):
return match and match.group(1)
-def get_implemented_interfaces_from_idl(file_contents, interface_name):
+def get_implements_from_idl(file_contents, interface_name):
# Rule is: identifier-A implements identifier-B;
# http://www.w3.org/TR/WebIDL/#idl-implements-statements
- def get_implemented(left_identifier, right_identifier):
- # identifier-A must be the current interface
- if left_identifier != interface_name:
- raise IdlBadFilenameError("Identifier on the left of the 'implements' statement should be %s in %s.idl, but found %s" % (interface_name, interface_name, left_identifier))
- return right_identifier
-
+ # Returns two lists of interfaces that contain identifier-As and identifier-Bs.
Nils Barth (inactive) 2014/05/08 02:46:47 Could you wrap at 80 cols? Actually, could you ma
+ # The 'implements' statements are supported in both identifier-A IDL and identifier-B IDL
+ # to avoid potential layering violation.
implements_re = (r'^\s*'
r'(\w+)\s+'
r'implements\s+'
@@ -75,7 +72,14 @@ def get_implemented_interfaces_from_idl(file_contents, interface_name):
implements_matches = re.finditer(implements_re, file_contents, re.MULTILINE)
implements_pairs = [(match.group(1), match.group(2))
for match in implements_matches]
Nils Barth (inactive) 2014/05/08 02:46:47 Could you add a check that *one* of the interfaces
- return [get_implemented(left, right) for left, right in implements_pairs]
+ A_interfaces = []
Nils Barth (inactive) 2014/05/08 02:46:47 List comprehensions please: A_interfaces = [left f
+ B_interfaces = []
+ for left, right in implements_pairs:
+ if left == interface_name:
+ B_interfaces.append(right)
+ elif right == interface_name:
+ A_interfaces.append(left)
+ return (A_interfaces, B_interfaces)
Nils Barth (inactive) 2014/05/08 02:46:47 No parens.
def is_callback_interface_from_idl(file_contents):

Powered by Google App Engine
This is Rietveld 408576698