Add testcase for bug #3378145 which was fixed in r12764

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12765 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2011-07-28 06:29:20 +00:00
commit 4511b13646
4 changed files with 77 additions and 0 deletions

View file

@ -390,6 +390,7 @@ CPP_TEST_CASES += \
template_typedef_cplx4 \
template_typedef_cplx5 \
template_typedef_funcptr \
template_typedef_inherit \
template_typedef_ns \
template_typedef_ptr \
template_typedef_rec \

View file

@ -0,0 +1,24 @@
import template_typedef_inherit.*;
public class template_typedef_inherit_runme {
static {
try {
System.loadLibrary("template_typedef_inherit");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
System.exit(1);
}
}
public static void main(String argv[]) {
DescriptionImplementationTypedCollectionInterfaceObject d = new DescriptionImplementationTypedCollectionInterfaceObject();
d.add("a string");
StringPersistentCollection s = new StringPersistentCollection();
s.add("a string");
}
}

View file

@ -0,0 +1,50 @@
%module template_typedef_virtual
// Bug 3378145
%include std_string.i
%inline %{
#include <string> // for std::string
typedef std::string String;
namespace Type {
template <class T> class TypedInterfaceObject {};
template <class T> class TypedCollectionInterfaceObject : public TypedInterfaceObject<T> {
public:
typedef T ImplementationType;
typedef typename ImplementationType::ElementType ImplementationElementType;
/** Method add() appends an element to the collection */
void add(const ImplementationElementType & elt) {}
};
template <class T> class PersistentCollection {
public:
typedef T ElementType;
/** Method add() appends an element to the collection */
inline virtual void add(const T & elt) {}
};
}
%}
%template(StringPersistentCollection) Type::PersistentCollection<String>;
%inline %{
namespace Type {
class DescriptionImplementation : public PersistentCollection<String> {
public:
typedef PersistentCollection<String>::ElementType ElementType;
DescriptionImplementation() {}
};
}
%}
%template(DescriptionImplementationTypedInterfaceObject) Type::TypedInterfaceObject<Type::DescriptionImplementation>;
%template(DescriptionImplementationTypedCollectionInterfaceObject) Type::TypedCollectionInterfaceObject<Type::DescriptionImplementation>;