Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / crush / CrushWrapper.i
1 /* File : CrushWrapper.i */
2 %module CrushWrapper
3 %{
4 #include "CrushWrapper.h"
5 %}
6
7 %include typemaps.i
8
9 // This tells SWIG to treat 'int *data' as a special case
10 %typemap(in) int *items {
11   AV *tempav;
12   I32 len;
13   int i;
14   SV **tv;
15 //  int view;
16
17
18   //printf("typemap\n");
19
20   if (!SvROK($input))
21         croak("$input is not a reference.");
22   if (SvTYPE(SvRV($input)) != SVt_PVAV)
23         croak("$input is not an array.");
24
25   tempav = (AV*)SvRV($input);
26   len = av_len(tempav);
27   //printf("typemap len: %i\n",len);
28   $1 = (int *) malloc((len+1)*sizeof(int));
29   for (i = 0; i <= len; i++) {
30         tv = av_fetch(tempav, i, 0);
31         $1[i] = (int) SvIV(*tv);
32     
33         /*
34           view = SvIV(*tv);
35           printf("view: %d",view);
36           printf("\n");
37         */
38   }
39 }
40
41 %apply int *items { int *weights };
42 %apply double *OUTPUT { double *min, double *max, double *avg };
43
44 /* Let's just grab the original header file here */
45 %include "CrushWrapper.h"      
46
47 %clear double *min, double *max, double *avg;