From 64220b6a035d80c0ed413aeff74936094a58be77 Mon Sep 17 00:00:00 2001 From: Michael Rodriguez Date: Tue, 12 Feb 2008 10:51:04 -0800 Subject: [PATCH] swig wrapper --- src/crush/CrushWrapper.i | 47 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/crush/CrushWrapper.i diff --git a/src/crush/CrushWrapper.i b/src/crush/CrushWrapper.i new file mode 100644 index 0000000000000..509d217949f96 --- /dev/null +++ b/src/crush/CrushWrapper.i @@ -0,0 +1,47 @@ +/* File : CrushWrapper.i */ +%module CrushWrapper +%{ +#include "CrushWrapper.h" +%} + +%include typemaps.i + +// This tells SWIG to treat 'int *data' as a special case +%typemap(in) int *items { + AV *tempav; + I32 len; + int i; + SV **tv; + int view; + + + //printf("typemap\n"); + + if (!SvROK($input)) + croak("$input is not a reference."); + if (SvTYPE(SvRV($input)) != SVt_PVAV) + croak("$input is not an array."); + + tempav = (AV*)SvRV($input); + len = av_len(tempav); + //printf("typemap len: %i\n",len); + $1 = (int *) malloc((len+1)*sizeof(int)); + for (i = 0; i <= len; i++) { + tv = av_fetch(tempav, i, 0); + $1[i] = (int) SvIV(*tv); + + /* + view = SvIV(*tv); + printf("view: %d",view); + printf("\n"); + */ + } +} + +%apply int *items { int *weights }; +%apply double *OUTPUT { double *min, double *max, double *avg }; + +/* Let's just grab the original header file here */ +%include "CrushWrapper.h" + +%clear double *min, double *max, double *avg; -- 2.39.5