Fix smart pointers and member methods

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9881 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2007-08-01 00:07:23 +00:00
commit 6a13675c16
4 changed files with 60 additions and 3 deletions

View file

@ -1,9 +1,13 @@
Version 1.3.32 (in progress)
============================
08/01/2007: wsfulton
Fix smart pointer handling for classes that have templated methods within the smart
pointer type. Problem reported by craigdo at ee.washington.edu.
07/31/2007: efuzzyone
[cffi] fixed memory access after being freed bug. thanks to Martin Percossi.
package name clos changed to cl. thanks to Ralf Mattes
[cffi] fixed memory access after being freed bug. thanks to Martin Percossi.
package name clos changed to cl. thanks to Ralf Mattes
07/24/2007: wsfulton
Parallel make support added for the examples and test-suite for developers who have

View file

@ -242,6 +242,7 @@ CPP_TEST_CASES += \
smart_pointer_overload \
smart_pointer_protected \
smart_pointer_rename \
smart_pointer_templatemethods \
smart_pointer_simple \
smart_pointer_static \
smart_pointer_typedef \

View file

@ -0,0 +1,52 @@
%module smart_pointer_templatemethods
%inline %{
namespace ns {
template <typename T>
class Ptr
{
public:
Ptr () {}
T *operator -> () { return 0; }
};
typedef unsigned short uint16_t;
class InterfaceId
{
public:
InterfaceId (uint16_t iid) {}
InterfaceId() {}
};
template <typename K> class Objekt
{
public:
Objekt () {}
virtual ~Objekt () {}
Ptr<K> QueryInterface (InterfaceId iid) const { return Ptr<K>(); }
void DisposeObjekt (void) {}
};
class Object
{
public:
Object () {}
virtual ~Object () {}
template <typename T> Ptr<T> QueryInterface (InterfaceId iid) const { return Ptr<T>(); }
void DisposeObject (void) {}
};
#ifdef SWIG
%template(PtrObject) Ptr<Object>;
%template(PtrInt) Ptr<int>;
%template(ObjektInt) Objekt<int>;
%template(PtrObjektInt) Ptr<Objekt<int> >;
%template(QueryInterfaceObject) Object::QueryInterface<Object>;
#endif
}; // namespace
%}

View file

@ -1224,7 +1224,7 @@ int Language::memberfunctionHandler(Node *n) {
if (GetFlag(n, "explicitcall"))
DirectorExtraCall = CWRAP_DIRECTOR_ONE_CALL;
Swig_MethodToFunction(n, ClassType, Getattr(n, "template") ? 0 : Extend | SmartPointer | DirectorExtraCall, director_type,
Swig_MethodToFunction(n, ClassType, Getattr(n, "template") ? SmartPointer : Extend | SmartPointer | DirectorExtraCall, director_type,
is_member_director(CurrentClass, n));
Setattr(n, "sym:name", fname);
functionWrapper(n);