7 Aug 13:44
Some problems with function hiding (C# new)
From: Jan Jezabek <jezabek <at> poczta.onet.pl>
Subject: Some problems with function hiding (C# new)
Newsgroups: gmane.comp.programming.swig.devel
Date: 2008-08-07 11:45:12 GMT
Subject: Some problems with function hiding (C# new)
Newsgroups: gmane.comp.programming.swig.devel
Date: 2008-08-07 11:45:12 GMT
Hi,
I ran across a bug (?) in Allocate::function_is_defined_in_bases shown
by this example:
%module bbase
%rename (aaa2) B::aaa();
%rename (bbb) B::bbb2();
%inline %{
class A {
public:
int aaa();
int bbb();
int ccc;
};
class B : public A {
public:
int aaa();
int bbb2();
void ccc(int);
};
%}
The problem is the incorrect generation of the "hides" attribute -
B::aaa2 has this attribute set while B::bbb has it cleared. Thus B::aaa2
is declared as "new" in C# and B::bbb is not, leading to complaints from
the compiler in both cases.
A somewhat related problem arises with ccc - here mcs (version 0.96)
also complains that the "new" keyword is needed; the parameters of
B::ccc do not matter. I am unable to test under MS .NET, but I believe
that mcs is right.
Regarding the first problem - it seems that marking methods as "hides"
should be done in case of the same "sym:name", while marking them as
"overrides" needs to be done based on "name". Am I right here? I will
try to come up with a patch shortly to show what I have in mind.
I have not yet really looked at the second problem.
I am planning to do a small change to
Allocate::function_is_defined_in_bases for the COM module - I need to
check whether a function is overloading a name which was defined in a
superclass, e.g.:
class X {
public:
void aaa();
};
class Y : public X {
public:
void aaa(int);
};
COM cannot handle overloading and thus I need to ignore aaa(int).
Therefore I plan to add an "overloads_base" attribute for this case.
This situation is very similar to the situation when "hides" is set so I
decided that Allocate::function_is_defined_in_bases is the right place
to detect this case. I will send the relevant code as a separate patch.
Thanks,
Jan Jezabek
--
--
My GSoC 2008 development blog: http://jezabekgsoc.wordpress.com/
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
RSS Feed