Fix 'self' parameter name clash when generating for Python builtin

This commit is contained in:
William S Fulton 2014-10-31 07:23:08 +00:00
parent 6029b2f7d8
commit 6d6cefa791
2 changed files with 11 additions and 0 deletions

View File

@ -11,5 +11,6 @@ struct Foo {
virtual ~Foo() {} virtual ~Foo() {}
virtual void check_abstract(int abstract) {} // for Java, C#, D... virtual void check_abstract(int abstract) {} // for Java, C#, D...
virtual void check_self(int self) {} // self for Python virtual void check_self(int self) {} // self for Python
virtual void check_from(int from) {} // for Python
}; };
%} %}

View File

@ -4841,6 +4841,16 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
int idx; int idx;
bool ignored_method = GetFlag(n, "feature:ignore") ? true : false; bool ignored_method = GetFlag(n, "feature:ignore") ? true : false;
if (builtin) {
// Rename any wrapped parameters called 'self' as the generated code contains a variable with same name
Parm *p;
for (p = l; p; p = nextSibling(p)) {
String *arg = Getattr(p, "name");
if (arg && Cmp(arg, "self") == 0)
Delattr(p, "name");
}
}
if (Cmp(storage, "virtual") == 0) { if (Cmp(storage, "virtual") == 0) {
if (Cmp(value, "0") == 0) { if (Cmp(value, "0") == 0) {
pure_virtual = true; pure_virtual = true;