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

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

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