PageRenderTime 3ms CodeModel.GetById 1ms app.highlight 0ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Lib/python/file.i

#
Swig | 41 lines | 29 code | 5 blank | 7 comment | 0 complexity | d55bce4381cfc915926515c0ae0453d9 MD5 | raw file
 1/* -----------------------------------------------------------------------------
 2 * file.i
 3 *
 4 * Typemaps for FILE*
 5 * ----------------------------------------------------------------------------- */
 6
 7%types(FILE *);
 8
 9/* defining basic methods */
10%fragment("SWIG_AsValFilePtr","header") {
11SWIGINTERN int
12SWIG_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") {
32SWIGINTERNINLINE FILE*
33SWIG_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*);