This should make you:
float * oldmain() {
static float output[] = {0.,1.};
return output;
}
You are returning a pointer here, and swig has no idea about its size. Plain $ 1_dim0 will not work, so you have to make hard code or do some other magic. Something like that:
%module example
%{
extern float * oldmain();
%}
%typemap(out) float* oldmain {
int i;
$result = PyList_New(2);
for (i = 0; i < 2; i++) {
PyObject *o = PyFloat_FromDouble((double) $1[i]);
PyList_SetItem($result,i,o);
}
}
%include "example.c"
Then in python you should get:
>> import example
>> example.oldmain()
[0.0, 1.0]
When adding typemaps you can find it -debug-tmsearchvery convenient, i.e.
swig -python -debug-tmsearch example.i
, 'out' typemap float *oldmain. , c, , typemap varout, out.