Index: Source/bindings/scripts/utilities.py |
diff --git a/Source/bindings/scripts/utilities.py b/Source/bindings/scripts/utilities.py |
index 0f16281b79fb434dd877b586cb211b245dc9a9ad..df1cc15b1b69d09514875d6fb9a2fb2c86d91738 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_right_or_left_interfaces_of_implements_from_idl(file_contents, interface_name, get_right): |
# 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 |
- |
+ # Get the right interfaces (identifier-Bs) when the statements are in the left interface (identifier-A) IDL. |
+ # Get the left interfaces (identifier-As) when the statements are in the right interface (identifier-B) IDL. |
+ # Support both cases to avoid layering violation. |
implements_re = (r'^\s*' |
r'(\w+)\s+' |
r'implements\s+' |
@@ -75,7 +72,15 @@ 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] |
- return [get_implemented(left, right) for left, right in implements_pairs] |
+ left_or_right_interfaces = [] |
+ for left, right in implements_pairs: |
+ if get_right: |
+ if left == interface_name: |
+ left_or_right_interfaces.append(right) |
+ else: |
+ if right == interface_name: |
+ left_or_right_interfaces.append(left) |
+ return left_or_right_interfaces |
def is_callback_interface_from_idl(file_contents): |