diff options
author | Alon Zakai <alonzakai@gmail.com> | 2014-05-14 13:17:13 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2014-05-14 13:17:13 -0700 |
commit | d470387f096d6427720a9c8a61776fa3d276683e (patch) | |
tree | 83e0d3a798308ca139983a621ad96a19c0ecf60b | |
parent | b915f42db8e2b454b8b07e0eb7f8a176fefdc534 (diff) |
allow overriding functions with the same name in the parent in webidl binder
-rw-r--r-- | tests/webidl/output.txt | 1 | ||||
-rw-r--r-- | tests/webidl/post.js | 2 | ||||
-rw-r--r-- | tests/webidl/test.h | 2 | ||||
-rw-r--r-- | tests/webidl/test.idl | 2 | ||||
-rw-r--r-- | third_party/WebIDL.py | 12 |
5 files changed, 14 insertions, 5 deletions
diff --git a/tests/webidl/output.txt b/tests/webidl/output.txt index b874d928..af3b0087 100644 --- a/tests/webidl/output.txt +++ b/tests/webidl/output.txt @@ -10,6 +10,7 @@ Child1:7 588 14 28 +Child1::parentFunc(90) c1 v2 Parent:16 Child1:15 diff --git a/tests/webidl/post.js b/tests/webidl/post.js index 444efcd1..8056a5ff 100644 --- a/tests/webidl/post.js +++ b/tests/webidl/post.js @@ -5,6 +5,7 @@ var sme = new Module.Parent(42); sme.mulVal(2); Module.print('*') Module.print(sme.getVal()); +sme.parentFunc(90); Module.print('c1'); @@ -16,6 +17,7 @@ Module.print(c1.getValSqr()); Module.print(c1.getValSqr(3)); Module.print(c1.getValTimes()); // default argument should be 1 Module.print(c1.getValTimes(2)); +c1.parentFunc(90); Module.print('c1 v2'); diff --git a/tests/webidl/test.h b/tests/webidl/test.h index 903f8f78..d8eb0fbc 100644 --- a/tests/webidl/test.h +++ b/tests/webidl/test.h @@ -10,6 +10,7 @@ public: Parent(Parent *p, Parent *q); // overload constructor int getVal() { return value; }; // inline should work just fine here, unlike Way 1 before void mulVal(int mul); + void parentFunc() {} }; class Child1 : public Parent { @@ -19,6 +20,7 @@ public: int getValSqr() { return value*value; } int getValSqr(int more) { return value*value*more; } int getValTimes(int times=1) { return value*times; } + void parentFunc(int x) { printf("Child1::parentFunc(%d)\n", x); } }; // Child2 has vtable, parent does not. Checks we cast child->parent properly - (Parent*)child is not a no-op, must offset diff --git a/tests/webidl/test.idl b/tests/webidl/test.idl index 98ab5070..6d87d5e3 100644 --- a/tests/webidl/test.idl +++ b/tests/webidl/test.idl @@ -5,12 +5,14 @@ interface Parent { void Parent(long val); long getVal(); void mulVal(long mul); + void parentFunc(); }; interface Child1 { void Child1(optional long val); long getValSqr(optional long more); long getValTimes(optional long times=1); + void parentFunc(long x); // redefinition, name collides with parent }; Child1 implements Parent; diff --git a/third_party/WebIDL.py b/third_party/WebIDL.py index 867a7cbc..1ce44e06 100644 --- a/third_party/WebIDL.py +++ b/third_party/WebIDL.py @@ -649,13 +649,15 @@ class IDLInterface(IDLObjectWithScope): # Flag the interface as being someone's consequential interface iface.setIsConsequentialInterfaceOf(self) additionalMembers = iface.originalMembers; - for additionalMember in additionalMembers: + for additionalMember in additionalMembers[:]: for member in self.members: if additionalMember.identifier.name == member.identifier.name: - raise WebIDLError( - "Multiple definitions of %s on %s coming from 'implements' statements" % - (member.identifier.name, self), - [additionalMember.location, member.location]) + # XXX emscripten: allow such name collisions, ignore parent + additionalMembers.remove(additionalMember) + #raise WebIDLError( + # "Multiple definitions of %s on %s coming from 'implements' statements" % + # (member.identifier.name, self), + # [additionalMember.location, member.location]) self.members.extend(additionalMembers) iface.interfacesImplementingSelf.add(self) |