allow overriding functions with the same name in the parent in webidl binder
This commit is contained in:
Родитель
b915f42db8
Коммит
d470387f09
|
@ -10,6 +10,7 @@ Child1:7
|
|||
588
|
||||
14
|
||||
28
|
||||
Child1::parentFunc(90)
|
||||
c1 v2
|
||||
Parent:16
|
||||
Child1:15
|
||||
|
|
|
@ -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');
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче