import source from 1.3.40
[external/swig.git] / Examples / test-suite / pointer_reference.i
1 /* This interface file tests whether SWIG handles pointer-reference
2    (*&) arguments.
3
4    SWIG 1.3a5 signals a syntax error.
5 */
6
7 %module pointer_reference
8
9 %warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK);                   /* memory leak when setting a ptr/ref variable */
10
11 #ifdef SWIGGUILE
12 /* A silly testing typemap for feeding a doubly indirect integer */
13 %typemap(in) int *&XYZZY (int temp1, int *temp2) {
14    temp1 = gh_scm2int($input); temp2 = &temp1; $1 = &temp2;
15 };
16 #endif
17
18 %inline %{
19 void foo(int *&XYZZY) {}
20 %}
21
22
23 // Test pointer reference typemaps shipped with SWIG (add in SWIG 1.3.28 for many languages)
24 %inline %{
25 struct Struct {
26   int value;
27   Struct(int v) : value(v) {}
28   static Struct instance;
29   static Struct *pInstance;
30 };
31
32 void set(Struct *& s) {
33   Struct::instance = *s;
34 }
35 Struct *& get() {
36   return Struct::pInstance;
37 }
38 %}
39
40 %{
41 Struct Struct::instance = Struct(10);
42 Struct *Struct::pInstance = &Struct::instance;
43 %}
44