1 // Tests passing of references to primitive datatypes
2 %module primitive_ref
3 
4 %define ref(type,name)
5 %inline %{
name(const type & x)6 const type &ref_##name(const type &x) {
7    static type y = x;
8    return y;
9 }
10 %}
11 %enddef
12 
13 ref(int,int);
14 ref(unsigned int, uint);
15 ref(short, short);
16 ref(unsigned short, ushort);
17 ref(long,long);
18 ref(unsigned long, ulong);
19 ref(signed char, schar);
20 ref(unsigned char, uchar);
21 ref(char, char);
22 ref(float, float);
23 ref(double, double);
24 ref(bool, bool);
25 ref(long long, longlong);
26 ref(unsigned long long, ulonglong);
27 
28 
29 %inline %{
30 
ref_over(int a)31 int ref_over(int a)
32 {
33   return a;
34 }
35 
36  struct A
37  {
38    int v;
AA39    A(int V) :v(V) {}
40  };
41 
ref_over(const A & a)42 int ref_over(const A& a)
43 {
44   return a.v;
45 }
46 
47 %}
48