From ab03eb18e70522f5ea878318ad74221f4328c05f Mon Sep 17 00:00:00 2001 From: Marcelo Matus Date: Sun, 29 Jan 2006 01:21:52 +0000 Subject: [PATCH] check/fix the %delobject feature for member methods git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8604 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/default_constructor.i | 2 +- Source/Modules/lang.cxx | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Examples/test-suite/default_constructor.i b/Examples/test-suite/default_constructor.i index e462c7fad..71600e55a 100644 --- a/Examples/test-suite/default_constructor.i +++ b/Examples/test-suite/default_constructor.i @@ -116,7 +116,7 @@ protected: ~G() { } public: - void destroy() { delete this; } + static void destroy(G *g) { delete g; } }; class GG : public G { diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index ec4f610fe..0aa72ffac 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -943,20 +943,25 @@ int Language::cDeclaration(Node *n) { int Language::functionHandler(Node *n) { - Parm *p; - p = Getattr(n,"parms"); + String *storage = Getattr(n,"storage"); + int isfriend = CurrentClass && Cmp(storage,"friend") == 0; + int isstatic = CurrentClass && Cmp(storage,"static") == 0 && + !(SmartPointer && Getattr(n,"allocate:smartpointeraccess")); + Parm *p= Getattr(n,"parms"); if (GetFlag(n,"feature:del")) { /* the method acts like a delete operator, ie, we need to disown the parameter */ - if (p) Setattr(p,"wrap:disown","1"); + if (CurrentClass && !isstatic && !isfriend) { + SetFlag(n,"feature:self:disown"); + } else { + if (p) SetFlag(p,"wrap:disown"); + } } if (!CurrentClass) { globalfunctionHandler(n); } else { - String *storage = Getattr(n,"storage"); - if (Cmp(storage,"static") == 0 && - !(SmartPointer && Getattr(n,"allocate:smartpointeraccess"))) { + if (isstatic) { staticmemberfunctionHandler(n); - } else if (Cmp(storage,"friend") == 0) { + } else if (isfriend) { globalfunctionHandler(n); } else { memberfunctionHandler(n);