From: abn Date: Fri, 28 Feb 2014 14:39:24 +0000 (+0100) Subject: SWIG: give precedence to MEDCoupling namespace when both MEDLoader and X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4c2f62c7a2059fb369f4226d6acfb2211697a829;p=tools%2Fmedcoupling.git SWIG: give precedence to MEDCoupling namespace when both MEDLoader and MEDCoupling were loaded. All returned objects are now always from MEDCoupling. --- diff --git a/src/MEDLoader/Swig/MEDLoaderCommon.i b/src/MEDLoader/Swig/MEDLoaderCommon.i index 63acae414..99c52a16c 100644 --- a/src/MEDLoader/Swig/MEDLoaderCommon.i +++ b/src/MEDLoader/Swig/MEDLoaderCommon.i @@ -23,6 +23,18 @@ #define MEDCOUPLING_EXPORT #define MEDLOADER_EXPORT +// Little trick to give precedence to MEDCoupling namespace if +// both modules MEDLoader and MEDCoupling were loaded. Basically we cancel out SWIG type +// registration during the loading of MEDLoader if MEDCoupling is already there. +%pythoncode %{ +import sys +if sys.modules.has_key('MEDCoupling'): + mc_mod = sys.modules['MEDCoupling'] + for k, v in mc_mod.__dict__.items(): + if k.startswith("MED") and type(v) is type(type): + exec("_MEDLoader.%s_swigregister = lambda x: None" % k) +%} + %include "MEDCouplingCommon.i" %{