Home | History | Annotate | Download | only in python
      1 /* -----------------------------------------------------------------------------
      2  * file.i
      3  *
      4  * Typemaps for FILE*
      5  * ----------------------------------------------------------------------------- */
      6 
      7 %types(FILE *);
      8 
      9 /* defining basic methods */
     10 %fragment("SWIG_AsValFilePtr","header") {
     11 SWIGINTERN int
     12 SWIG_AsValFilePtr(PyObject *obj, FILE **val) {
     13   static swig_type_info* desc = 0;
     14   void *vptr = 0;
     15   if (!desc) desc = SWIG_TypeQuery("FILE *");
     16   if ((SWIG_ConvertPtr(obj, &vptr, desc, 0)) == SWIG_OK) {
     17     if (val) *val = (FILE *)vptr;
     18     return SWIG_OK;
     19   }
     20 %#if PY_VERSION_HEX < 0x03000000
     21   if (PyFile_Check(obj)) {
     22     if (val) *val =  PyFile_AsFile(obj);
     23     return SWIG_OK;
     24   }
     25 %#endif
     26   return SWIG_TypeError;
     27 }
     28 }
     29 
     30 
     31 %fragment("SWIG_AsFilePtr","header",fragment="SWIG_AsValFilePtr") {
     32 SWIGINTERNINLINE FILE*
     33 SWIG_AsFilePtr(PyObject *obj) {
     34   FILE *val = 0;
     35   SWIG_AsValFilePtr(obj, &val);
     36   return val;
     37 }
     38 }
     39 
     40 /* defining the typemaps */
     41 %typemaps_asval(%checkcode(POINTER), SWIG_AsValFilePtr, "SWIG_AsValFilePtr", FILE*);
     42