SWIG to the rescue (was Re: Modifying Python parms passed to C function?)
Thomas Heller
thomas.heller at ion-tof.com
Fri Sep 1 09:29:37 EDT 2000
It is even easier, because distutils contains support for swig:
from distutils.core import setup, Extension
setup (name = "afunc",
version = "1.0",
maintainer = "Alex Martelli",
maintainer_email = "aleaxit at yahoo.com",
description = "A simple SWIG example",
ext_modules = [
Extension('afunc',
sources = ['afunc.c',
'ifunc.i',
],
)
]
)
with afunc.c:
int afunc(int byvalue, int* justin, int* inout, int* justout)
{
*inout += byvalue+*justin;
*justout = 100*(*inout);
return 1000*(*inout);
}
and ifunc.i:
%module afunc
%include typemaps.i
extern int afunc(int, int* INPUT, int* BOTH, int* OUTPUT);
Thomas
More information about the Python-list
mailing list