Index: Source/bindings/scripts/idl_definitions.py |
diff --git a/Source/bindings/scripts/idl_definitions.py b/Source/bindings/scripts/idl_definitions.py |
index eb9fee185fe6316c609076e32a318c55a9ab0760..b11a038572b6666e0b94d3d7c55db2455c5acbc7 100644 |
--- a/Source/bindings/scripts/idl_definitions.py |
+++ b/Source/bindings/scripts/idl_definitions.py |
@@ -148,6 +148,22 @@ class IdlDefinitions(object): |
for interface in self.interfaces.itervalues(): |
interface.resolve_typedefs(typedefs) |
+ def update(self, other): |
+ """Update with additional IdlDefinitions.""" |
+ for interface_name, new_interface in other.interfaces.iteritems(): |
+ if not new_interface.is_partial: |
+ # Add as new interface |
+ self.interfaces[interface_name] = new_interface |
+ continue |
+ |
+ # Merge partial to existing interface |
+ try: |
+ self.interfaces[interface_name].merge(new_interface) |
+ except KeyError: |
+ raise Exception('Tried to merge partial interface for {0}, ' |
+ 'but no existing interface by that name' |
+ .format(interface_name)) |
+ |
################################################################################ |
# Callback Functions |
@@ -241,6 +257,12 @@ class IdlInterface(object): |
for operation in self.operations: |
operation.resolve_typedefs(typedefs) |
+ def merge(self, other): |
+ """Merge in another interface's members (e.g., partial interface)""" |
+ self.attributes.extend(other.attributes) |
+ self.constants.extend(other.constants) |
+ self.operations.extend(other.operations) |
+ |
class IdlException(IdlInterface): |
# Properly exceptions and interfaces are distinct, and thus should inherit a |