SWIG typemap

Drew Perttula drewp at bigasterisk.com
Fri Aug 30 23:31:26 CEST 2002


I don't think your typemap is having any effect. Shouldn't it be:
%typemap (in) FILE * {
or similar? The one you have looks like it will match input arguments
of type 'file', which isn't even a real type in your interface.

Here's one of mine that works. It's a little different, since
it matches a specific argument name as well as type:
%typemap(python,in) uint8_t *buffer {
  $1 = (uint8_t*)($input);
}
extern int dv_parse_header(dv_decoder_t *dv, const uint8_t *buffer);


Giorgi Lekishvili <gleki at gol.ge> wrote in message news:<3D6F79E7.B96E1B52 at gol.ge>...
...
> Here is my interface file:
...
> %typemap (in) file {
>  $1=(FILE*)PyFile_AsFile($input);
>  printf(Received a python file object , $1);
>  }
> 
> extern void convert(char *buffer,FILE *outStream);
> extern char *readData(FILE *inStream);
...
> >>> convert (s, f)
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> TypeError: Type error. Expected _p_FILE



More information about the Python-list mailing list