more smart pointers + extend fixes

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6918 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2005-01-04 09:41:05 +00:00
commit d1f4bec910
3 changed files with 42 additions and 2 deletions

View file

@ -22,3 +22,13 @@ if b.hello() != p.hello():
d = DFoo()
dp = DPtrFoo(d)
if d.SExt(1) != dp.SExt(1):
raise RuntimeError
if d.Ext(1) != dp.Ext(1):
raise RuntimeError

View file

@ -97,3 +97,32 @@ public:
%}
%inline %{
class DFoo;
class DPtrFoo
{
DFoo *p;
public:
DPtrFoo(DFoo *ptr) : p(ptr)
{
}
DFoo* operator->(void) {return p;};
};
class DFoo
{
public:
void F(void) {};
};
%}
%extend DFoo {
static int SExt(int i = 1) {return i;};
int Ext(int i = 2) {return i;};
}

View file

@ -773,6 +773,7 @@ Swig_MethodToFunction(Node *n, String *classname, int flags) {
String *cname = Getattr(n,"classname") ? Getattr(n,"classname") : classname;
String *membername = Swig_name_member(cname, name);
String *mangled = Swig_name_mangle(membername);
int is_smart_pointer = flags & CWRAP_SMART_POINTER;
type = Getattr(n,"type");
@ -784,11 +785,11 @@ Swig_MethodToFunction(Node *n, String *classname, int flags) {
}
/* See if there is any code that we need to emit */
if (!defaultargs && code) {
if (!defaultargs && code &&!is_smart_pointer) {
Swig_add_extension_code(n, mangled, p, type, code, cparse_cplusplus);
}
if (flags & CWRAP_SMART_POINTER) {
if (is_smart_pointer) {
int i = 0;
Parm *pp = p;
String *func = NewStringf("%s(", mangled);