add test for %extend on member variable

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11382 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2009-07-09 19:56:47 +00:00
parent 224c83ef09
commit 0576ffcde7
3 changed files with 50 additions and 1 deletions

View File

@ -79,7 +79,7 @@ CPP_TEST_BROKEN += \
extend_variable \
li_std_vector_ptr \
namespace_union \
nested_struct \
nested_structs \
overload_complicated \
template_default_pointer \
template_expr
@ -220,6 +220,7 @@ CPP_TEST_CASES += \
li_typemaps \
li_windows \
long_long_apply \
memberin_extend \
member_pointer \
member_template \
minherit \

View File

@ -0,0 +1,26 @@
import memberin_extend.*;
public class memberin_extend_runme {
static {
try {
System.loadLibrary("memberin_extend");
} 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[])
{
ExtendMe em1 = new ExtendMe();
ExtendMe em2 = new ExtendMe();
em1.setThing("em1thing");
em2.setThing("em2thing");
if (!em1.getThing().equals("em1thing"))
throw new RuntimeException("wrong: " + em1.getThing());
if (!em2.getThing().equals("em2thing"))
throw new RuntimeException("wrong: " + em2.getThing());
}
}

View File

@ -0,0 +1,22 @@
%module memberin_extend
// Tests memberin typemap. The default char * memberin typemap will be used.
// The test extends the struct with a pseudo member variable
%inline %{
#include <string>
struct ExtendMe {
};
%}
%{
#include <map>
std::map<ExtendMe*, char *> ExtendMeStringMap;
#define ExtendMe_thing_set(self_, val_) ExtendMeStringMap[self_]
#define ExtendMe_thing_get(self_) ExtendMeStringMap[self_]
%}
%extend ExtendMe {
char *thing;
}