A helpful self review
Was just looking through an (unfinished) project I was working on with someone last year. I was busting my ass on making a bridge between the TALib technical analysis library (http://ta-lib.org/) and ruby. I was about 60% done on the bridge (about 2000 lines of code) when my partner bailed on me and I lost motivation to work on the project.
Looking back on the code I’m pretty impressed by what I was able to pull off considering I hadn’t written C in years and my Ruby knowledge was still pretty infantile. Here’s a tasty snippet to give you an example of what its like converting from C typedefs to Ruby built in types:
// TODO - Make the memory allocation relative to calculated size from lookback
void **c_output = (void *)malloc(sizeof(void *) * funcInfo->nbOutput);
const TA_OutputParameterInfo *outputParamInfo;
for (i = 0; i < funcInfo->nbOutput; i++) {
TA_GetOutputParameterInfo(funcInfo->handle, i, &outputParamInfo);
switch(outputParamInfo->type) { // type
case TA_Output_Real:
c_output[i] = (TA_Real*)malloc(sizeof(double) * endIdx);
retcode = TA_SetOutputParamRealPtr(paramHolder, i, c_output[i]);
break;
case TA_Output_Integer:
c_output[i] = (TA_Integer*)malloc(sizeof(int) * endIdx);
retcode = TA_SetOutputParamIntegerPtr(paramHolder, i, c_output[i]);
break;
default:
return INT2FIX(“666”);
}
if (retcode != TA_SUCCESS) {
return INT2FIX(retcode);
}
}
Nothing super impressive or whatever but it was fun to look at what I did in a very short time as encouragement to continue working on and learning things and proof to myself that I am capable to those things that I’m sheepish to start doing.