Commit 0383e8dacdb1592ef6298d845319825dcd817683
1 parent
b2d1f4fa
Add GFilename SWIG typemap that transparently converts a Python string into a GF…
…ilename object. This allows now replacing all std::string filenames by GFilename arguments.
Showing
19 changed files
with
116 additions
and
18 deletions
inst/com/pyext/com.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * com.i - COMPTEL module * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2012-2013 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2012-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -39,6 +39,9 @@ |
| 39 | 39 | /* __ Include standard typemaps for vectors and strings __________________ */ |
| 40 | 40 | %include stl.i |
| 41 | 41 | |
| 42 | +/* __ Include GammaLib typemaps __________________________________________ */ | |
| 43 | +%include typemap_GFilename.i | |
| 44 | + | |
| 42 | 45 | /* __ Include interface classes __________________________________________ */ |
| 43 | 46 | %import(module="gammalib.base") "GBase.i"; |
| 44 | 47 | %import(module="gammalib.base") "GRegistry.i"; | ... | ... |
inst/cta/pyext/cta.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * cta.i - Cherenkov Telescope Array module * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011-2015 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2011-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -39,6 +39,9 @@ |
| 39 | 39 | /* __ Include standard typemaps for vectors and strings __________________ */ |
| 40 | 40 | %include stl.i |
| 41 | 41 | |
| 42 | +/* __ Include GammaLib typemaps __________________________________________ */ | |
| 43 | +%include typemap_GFilename.i | |
| 44 | + | |
| 42 | 45 | /* __ Include interface classes __________________________________________ */ |
| 43 | 46 | %import(module="gammalib.base") "GBase.i"; |
| 44 | 47 | %import(module="gammalib.base") "GContainer.i"; | ... | ... |
inst/lat/pyext/lat.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * lat.i - Fermi/LAT module * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011-2013 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2011-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -39,6 +39,9 @@ |
| 39 | 39 | /* __ Include standard typemaps for vectors and strings __________________ */ |
| 40 | 40 | %include stl.i |
| 41 | 41 | |
| 42 | +/* __ Include GammaLib typemaps __________________________________________ */ | |
| 43 | +%include typemap_GFilename.i | |
| 44 | + | |
| 42 | 45 | /* __ Include interface classes __________________________________________ */ |
| 43 | 46 | %import(module="gammalib.base") "GBase.i"; |
| 44 | 47 | ... | ... |
inst/mwl/pyext/mwl.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * mwl.i - Multi-wavelength module * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011-2013 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2011-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -39,6 +39,9 @@ |
| 39 | 39 | /* __ Include standard typemaps for vectors and strings __________________ */ |
| 40 | 40 | %include stl.i |
| 41 | 41 | |
| 42 | +/* __ Include GammaLib typemaps __________________________________________ */ | |
| 43 | +%include typemap_GFilename.i | |
| 44 | + | |
| 42 | 45 | /* __ Include interface classes __________________________________________ */ |
| 43 | 46 | %import(module="gammalib.base") "GBase.i"; |
| 44 | 47 | ... | ... |
pyext/gammalib/app.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * app.i - Application module * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011-2013 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2011-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -39,6 +39,9 @@ |
| 39 | 39 | /* __ Include standard typemaps for vectors and strings __________________ */ |
| 40 | 40 | %include stl.i |
| 41 | 41 | |
| 42 | +/* __ Include GammaLib typemaps __________________________________________ */ | |
| 43 | +%include typemap_GFilename.i | |
| 44 | + | |
| 42 | 45 | /* __ Include interface classes __________________________________________ */ |
| 43 | 46 | %import(module="gammalib.base") "GBase.i"; |
| 44 | 47 | %import(module="gammalib.base") "GContainer.i"; | ... | ... |
pyext/gammalib/base.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * base.i - Base module * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2012-2013 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2012-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -39,6 +39,9 @@ |
| 39 | 39 | /* __ Include standard typemaps for vectors and strings __________________ */ |
| 40 | 40 | %include stl.i |
| 41 | 41 | |
| 42 | +/* __ Include GammaLib typemaps __________________________________________ */ | |
| 43 | +%include typemap_GFilename.i | |
| 44 | + | |
| 42 | 45 | /* __ Base module ________________________________________________________ */ |
| 43 | 46 | %include "GBase.i" |
| 44 | 47 | %include "GContainer.i" | ... | ... |
pyext/gammalib/fits.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * fits.i - FITS module * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011-2013 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2011-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -39,6 +39,9 @@ |
| 39 | 39 | /* __ Include standard typemaps for vectors and strings __________________ */ |
| 40 | 40 | %include stl.i |
| 41 | 41 | |
| 42 | +/* __ Include GammaLib typemaps __________________________________________ */ | |
| 43 | +%include typemap_GFilename.i | |
| 44 | + | |
| 42 | 45 | /* __ Include interface classes __________________________________________ */ |
| 43 | 46 | %import(module="gammalib.base") "GBase.i"; |
| 44 | 47 | %import(module="gammalib.base") "GContainer.i"; | ... | ... |
pyext/gammalib/linalg.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * linalg.i - Linear algebra module * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011-2013 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2011-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -39,6 +39,9 @@ |
| 39 | 39 | /* __ Include standard typemaps for vectors and strings __________________ */ |
| 40 | 40 | %include stl.i |
| 41 | 41 | |
| 42 | +/* __ Include GammaLib typemaps __________________________________________ */ | |
| 43 | +%include typemap_GFilename.i | |
| 44 | + | |
| 42 | 45 | /* __ Include interface classes __________________________________________ */ |
| 43 | 46 | %import(module="gammalib.base") "GBase.i"; |
| 44 | 47 | ... | ... |
pyext/gammalib/model.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * model.i - Model module * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011-2014 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2011-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -39,6 +39,9 @@ |
| 39 | 39 | /* __ Include standard typemaps for vectors and strings __________________ */ |
| 40 | 40 | %include stl.i |
| 41 | 41 | |
| 42 | +/* __ Include GammaLib typemaps __________________________________________ */ | |
| 43 | +%include typemap_GFilename.i | |
| 44 | + | |
| 42 | 45 | /* __ Include interface classes __________________________________________ */ |
| 43 | 46 | %import(module="gammalib.base") "GBase.i"; |
| 44 | 47 | %import(module="gammalib.base") "GContainer.i"; | ... | ... |
pyext/gammalib/numerics.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * numerics.i - Numerics module * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011-2013 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2011-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -39,6 +39,9 @@ |
| 39 | 39 | /* __ Include standard typemaps for vectors and strings __________________ */ |
| 40 | 40 | %include stl.i |
| 41 | 41 | |
| 42 | +/* __ Include GammaLib typemaps __________________________________________ */ | |
| 43 | +%include typemap_GFilename.i | |
| 44 | + | |
| 42 | 45 | /* __ Include interface classes __________________________________________ */ |
| 43 | 46 | %import(module="gammalib.base") "GBase.i"; |
| 44 | 47 | ... | ... |
pyext/gammalib/obs.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * obs.i - Observation module * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011-2014 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2011-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -39,6 +39,9 @@ |
| 39 | 39 | /* __ Include standard typemaps for vectors and strings __________________ */ |
| 40 | 40 | %include stl.i |
| 41 | 41 | |
| 42 | +/* __ Include GammaLib typemaps __________________________________________ */ | |
| 43 | +%include typemap_GFilename.i | |
| 44 | + | |
| 42 | 45 | /* __ Include interface classes __________________________________________ */ |
| 43 | 46 | %import(module="gammalib.base") "GBase.i"; |
| 44 | 47 | %import(module="gammalib.base") "GContainer.i"; | ... | ... |
pyext/gammalib/opt.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * opt.i - Optimization module * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011-2014 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2011-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -39,6 +39,9 @@ |
| 39 | 39 | /* __ Include standard typemaps for vectors and strings __________________ */ |
| 40 | 40 | %include stl.i |
| 41 | 41 | |
| 42 | +/* __ Include GammaLib typemaps __________________________________________ */ | |
| 43 | +%include typemap_GFilename.i | |
| 44 | + | |
| 42 | 45 | /* __ Include interface classes __________________________________________ */ |
| 43 | 46 | %import(module="gammalib.base") "GBase.i"; |
| 44 | 47 | %import(module="gammalib.base") "GContainer.i"; | ... | ... |
pyext/gammalib/sky.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * sky.i - Sky module * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011-2015 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2011-2016 by Jurgen Knodlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -39,6 +39,9 @@ |
| 39 | 39 | /* __ Include standard typemaps for vectors and strings __________________ */ |
| 40 | 40 | %include stl.i |
| 41 | 41 | |
| 42 | +/* __ Include GammaLib typemaps __________________________________________ */ | |
| 43 | +%include typemap_GFilename.i | |
| 44 | + | |
| 42 | 45 | /* __ Include interface classes __________________________________________ */ |
| 43 | 46 | %import(module="gammalib.base") "GBase.i"; |
| 44 | 47 | %import(module="gammalib.base") "GContainer.i"; | ... | ... |
pyext/gammalib/support.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * support.i - Support module * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011-2015 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2011-2016 by Jurgen Knodlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -39,6 +39,9 @@ |
| 39 | 39 | /* __ Include standard typemaps for vectors and strings __________________ */ |
| 40 | 40 | %include stl.i |
| 41 | 41 | |
| 42 | +/* __ Include GammaLib typemaps __________________________________________ */ | |
| 43 | +%include typemap_GFilename.i | |
| 44 | + | |
| 42 | 45 | /* __ Include interface classes __________________________________________ */ |
| 43 | 46 | %import(module="gammalib.base") "GBase.i"; |
| 44 | 47 | %import(module="gammalib.base") "GContainer.i"; | ... | ... |
pyext/gammalib/test.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * test.i - Test module * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2012-2013 by Jean-Baptiste Cayrou * | |
| 4 | + * copyright (C) 2012-2016 by Jean-Baptiste Cayrou * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -39,6 +39,9 @@ |
| 39 | 39 | /* __ Include standard typemaps for vectors and strings __________________ */ |
| 40 | 40 | %include stl.i |
| 41 | 41 | |
| 42 | +/* __ Include GammaLib typemaps __________________________________________ */ | |
| 43 | +%include typemap_GFilename.i | |
| 44 | + | |
| 42 | 45 | /* __ Include interface classes __________________________________________ */ |
| 43 | 46 | %import(module="gammalib.base") "GBase.i"; |
| 44 | 47 | %import(module="gammalib.base") "GContainer.i"; | ... | ... |
pyext/gammalib/vo.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * vo.i - Virtual Observatory module * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2014-2015 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2014-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -39,6 +39,9 @@ |
| 39 | 39 | /* __ Include standard typemaps for vectors and strings __________________ */ |
| 40 | 40 | %include stl.i |
| 41 | 41 | |
| 42 | +/* __ Include GammaLib typemaps __________________________________________ */ | |
| 43 | +%include typemap_GFilename.i | |
| 44 | + | |
| 42 | 45 | /* __ Include interface classes __________________________________________ */ |
| 43 | 46 | %import(module="gammalib.base") "GBase.i"; |
| 44 | 47 | //%import(module="gammalib.base") "GContainer.i"; | ... | ... |
pyext/gammalib/xml.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * xml.i - XML module * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011-2013 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2011-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -39,6 +39,9 @@ |
| 39 | 39 | /* __ Include standard typemaps for vectors and strings __________________ */ |
| 40 | 40 | %include stl.i |
| 41 | 41 | |
| 42 | +/* __ Include GammaLib typemaps __________________________________________ */ | |
| 43 | +%include typemap_GFilename.i | |
| 44 | + | |
| 42 | 45 | /* __ Include interface classes __________________________________________ */ |
| 43 | 46 | %import(module="gammalib.base") "GBase.i"; |
| 44 | 47 | %import(module="gammalib.base") "GContainer.i"; | ... | ... |
pyext/gammalib/xspec.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * xspec.i - XSPEC module * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2013 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2013-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -39,6 +39,9 @@ |
| 39 | 39 | /* __ Include standard typemaps for vectors and strings __________________ */ |
| 40 | 40 | %include stl.i |
| 41 | 41 | |
| 42 | +/* __ Include GammaLib typemaps __________________________________________ */ | |
| 43 | +%include typemap_GFilename.i | |
| 44 | + | |
| 42 | 45 | /* __ Include interface classes __________________________________________ */ |
| 43 | 46 | %import(module="gammalib.base") "GBase.i"; |
| 44 | 47 | //%import(module="gammalib.base") "GContainer.i"; | ... | ... |
pyext/typemap_GFilename.i
0 → 100644
| 1 | +/*************************************************************************** | |
| 2 | + * typemap_GFilename.i - Filename typemap * | |
| 3 | + * ----------------------------------------------------------------------- * | |
| 4 | + * copyright (C) 2016 by Juergen Knoedlseder * | |
| 5 | + * ----------------------------------------------------------------------- * | |
| 6 | + * * | |
| 7 | + * This program is free software: you can redistribute it and/or modify * | |
| 8 | + * it under the terms of the GNU General Public License as published by * | |
| 9 | + * the Free Software Foundation, either version 3 of the License, or * | |
| 10 | + * (at your option) any later version. * | |
| 11 | + * * | |
| 12 | + * This program is distributed in the hope that it will be useful, * | |
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of * | |
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | |
| 15 | + * GNU General Public License for more details. * | |
| 16 | + * * | |
| 17 | + * You should have received a copy of the GNU General Public License * | |
| 18 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. * | |
| 19 | + * * | |
| 20 | + ***************************************************************************/ | |
| 21 | + | |
| 22 | +/***********************************************************************//** | |
| 23 | + * @brief Input typemap for GFilename | |
| 24 | + * | |
| 25 | + * This typemap allows to pass a string for a GFilename& argument. In that | |
| 26 | + * way the user can simply pass a string to any function or method that has | |
| 27 | + * a GFilename argument, and the typemap transparently converts a string | |
| 28 | + * into a GFilename object. | |
| 29 | + ***************************************************************************/ | |
| 30 | +%typemap(in) GFilename& (GFilename temp) { | |
| 31 | + if (PyString_Check($input)) { | |
| 32 | + temp = GFilename(std::string(PyString_AsString($input))); | |
| 33 | + $1 = &temp; | |
| 34 | + } | |
| 35 | + else { | |
| 36 | + void *filename_argp1 = 0; | |
| 37 | + if (SWIG_IsOK(SWIG_ConvertPtr($input, &filename_argp1, SWIGTYPE_p_GFilename, 0))) { | |
| 38 | + $1 = reinterpret_cast<GFilename*>(filename_argp1); | |
| 39 | + } | |
| 40 | + else { | |
| 41 | + SWIG_exception(SWIG_TypeError, "GFilename expected"); | |
| 42 | + } | |
| 43 | + } | |
| 44 | +} | ... | ... |