PageRenderTime 19ms CodeModel.GetById 14ms app.highlight 1ms RepoModel.GetById 2ms app.codeStats 0ms

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

#
Swig | 42 lines | 30 code | 12 blank | 0 comment | 0 complexity | 1a214d4bc92dc6d2241c70b8c571436c MD5 | raw file
 1%module simple_array
 2
 3extern int x[10];
 4extern double y[7];
 5
 6
 7%inline %{
 8
 9struct BarArray {
10  int i;
11  double d;
12};
13
14extern struct BarArray bars[2]; 
15
16int x[10];
17double y[7];
18struct BarArray bars[2]; 
19
20void
21initArray()
22{
23  int i, n;
24
25  n = sizeof(x)/sizeof(x[0]);
26  for(i = 0; i < n; i++) 
27    x[i] = i;
28
29  n = sizeof(y)/sizeof(y[0]);
30  for(i = 0; i < n; i++) 
31    y[i] = ((double) i)/ ((double) n);
32
33  n = sizeof(bars)/sizeof(bars[0]);
34  for(i = 0; i < n; i++)  {
35    bars[i].i = x[i+2];
36    bars[i].d = y[i+2];
37  }
38
39  return;
40}
41
42%}