SWIG typemap

Ng Pheng Siong ngps at vista.netmemetic.com
Fri Aug 30 12:51:05 EDT 2002


According to Giorgi Lekishvili  <gleki at gol.ge>:
> %typemap (in) file {
>  $1=(FILE*)PyFile_AsFile($input);
>  printf(Received a python file object , $1);
>  }

Here's what I use in M2Crypto, SWIG 1.3.something.not.the.latest:

%typemap(python, in) FILE * {
    if (!PyFile_Check($source)) {
        PyErr_SetString(PyExc_TypeError, "expected PyFile");
        return NULL;
    }
    $target=PyFile_AsFile($source);
}


-- 
Ng Pheng Siong <ngps at netmemetic.com> * http://www.netmemetic.com




More information about the Python-list mailing list