PageRenderTime 5ms CodeModel.GetById 1ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/test-suite/intermediary_classname.i

#
Swig | 82 lines | 70 code | 12 blank | 0 comment | 0 complexity | 84d8a12135fd18f9b4878c197d154c70 MD5 | raw file
 1
 2// This test is to check the intermediary class name can be changed (C# and Java only use intermediary classes at time of writing)
 3%module(directors="1", jniclassname="intermediary_classname", imclassname="intermediary_classname") "intermediary_classname"
 4
 5%warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR);
 6
 7// change the access to the intermediary class for testing purposes
 8%pragma(java) jniclassclassmodifiers="public class";
 9%pragma(csharp) imclassclassmodifiers="public class";
10
11%feature("director") Base;
12%feature("director") Derived;
13
14// Test the throws attribute in these typemaps
15%typemap(javadirectorout, throws="InstantiationException/*javadirectorout Base&*/") Base& 
16  "$javaclassname.getCPtr($javacall)/* XYZ& typemap directorout*/"
17%typemap(javadirectorin, throws="ClassNotFoundException/*javadirectorin Base&*/") Base&
18  "new $javaclassname($jniinput, false)/*javadirectorin*/"
19%typemap(out, throws="IllegalAccessException/*out Base&*/") Base& {
20  // XYZ& typemap out
21  $result = 0; // remove unused variable warning
22}
23%inline %{
24
25template<class T> T maximum(const T a, const T b) { return  a>b ? a : b; }
26
27template<class T> class vector {
28  T *v;
29  int sz;
30 public:
31  vector(int _sz) {
32    v = new T[_sz];
33    sz = _sz;
34  }
35  T &get(int index) {
36    return v[index];
37  }
38  void set(int index, T &val) {
39    v[index] = val;
40  }
41  void testconst(const T x) { }
42};
43
44#if defined(_MSC_VER)
45  #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
46#endif
47
48class Base {
49public:
50  Base() : mVectInt(0) {}
51  Base(Base *b) : mVectInt(0) {}
52  virtual ~Base() {}
53  virtual Base& m1(Base &b) { return b; }
54  virtual Base& m1out() { static Base b; return b; }
55  virtual Base* m2(Base *b) { return b; }
56//  virtual Base m3(Base b) { return b; }
57  vector<int> mVectInt;
58  int mInt;
59  enum en { en1, en2 };
60  en enummethod(en e) { return e; }
61};
62class Derived : public Base {
63public:
64  Derived(Base *b) : Base(b) {}
65  virtual Base& m1(Base &b) { return b; }
66  virtual Base* m2(Base *b) { return b; }
67//  virtual Base m3(Base b) { return b; }
68  void throwspec() throw (int, Base) {}
69};
70#if defined(_MSC_VER)
71  #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
72#endif
73%}
74
75%template(maxint) maximum<int>;
76%template(maxdouble) maximum<double>;
77%template(vecint) vector<int>;
78%template(vecdouble) vector<double>;
79%template(maxintp) maximum<int (*)[10]>;
80%template(vecintp) vector<int (*)[10]>;
81
82