Extending ta-lib using SWIG

ta-lib (http://ta-lib.org/) is a package availiable which has port for
perl,python?,excel etc.

I needed it in ruby… since no port is availiable (AFAIK) … i
thought of building a port.

i have read along the pickaxe book of extending ruby…

after evaluating all the options i thought i will give SWIG a shot…

given the header like

=================================================
TA_RetCode TA_MA( int START_IDX,
int END_IDX,
const double IN_ARRAY / inReal /,
int OPT_INT /
optInTimePeriod /, / From
1 to 100000 /
TA_MAType OPT_MATYPE /
optInMAType */,
int *BEG_IDX,
int *OUT_SIZE,
double OUT_ARRAY / outReal */ );

in C it can be called like

TA_Real closePrice[400];
TA_Real out[400];
TA_Integer outBeg;
TA_Integer outNbElement;

/* … initialize your closing price here… */

retCode = TA_MA( 0, 399,
&closePrice[0],
30,TA_MAType_SMA,
&outBeg, &outNbElement, &out[0] );

/* The output is displayed here */
for( i=0; i < outNbElement; i++ )
printf( “Day %d = %f\n”, outBeg+i, out[i] );

=======================


could any one give me a lead how should the typemap for *IN_ARRAY look
like?

for python the typemap for *IN_ARRAY looks like

%typemap(in) const double *IN_ARRAY
{
int array_size = endIdx2 + 1;

$1 = ($1_ltype) calloc(array_size, sizeof($*1_ltype));
if (!convert_darray($input, $1, array_size))  goto fail;

}

cheers

Rajib