diff --git a/Lib/scilab/scicontainer.swg b/Lib/scilab/scicontainer.swg index c99fbb2d8..2701781fc 100644 --- a/Lib/scilab/scicontainer.swg +++ b/Lib/scilab/scicontainer.swg @@ -65,7 +65,7 @@ namespace swig } catch (std::exception& e) { - SWIG_Scilab_AddErrorMsg(e.what()); + SWIG_Scilab_ErrorMsg(SWIG_RuntimeError, e.what()); } } @@ -395,7 +395,7 @@ namespace swig { } catch (std::exception& e) { - SWIG_Scilab_AddErrorMsg(e.what()); + SWIG_Scilab_ErrorMsg(SWIG_RuntimeError, e.what()); } } } @@ -436,7 +436,7 @@ namespace swig { } catch (std::exception& e) { - SWIG_Scilab_AddErrorMsg(e.what()); + SWIG_Scilab_ErrorMsg(SWIG_RuntimeError, e.what()); } } }; diff --git a/Lib/scilab/scirun.swg b/Lib/scilab/scirun.swg index 9ae400015..8b7129cae 100644 --- a/Lib/scilab/scirun.swg +++ b/Lib/scilab/scirun.swg @@ -222,6 +222,7 @@ SWIG_Scilab_ErrorType(int code) { return "RuntimeError"; } } +#define SWIG_ErrorType(code) SWIG_Scilab_ErrorType(code) SWIGINTERN void SWIG_Scilab_ErrorMsg(int code, const char *msg) @@ -229,11 +230,10 @@ SWIG_Scilab_ErrorMsg(int code, const char *msg) Scierror(999, _("SWIG/Scilab %s: %s.\n"), SWIG_Scilab_ErrorType(code), msg); } -#define SWIG_fail return SWIG_ERROR; -#define SWIG_ErrorType(code) SWIG_Scilab_ErrorType(code) -#define SWIG_Error(code, msg) SWIG_Scilab_ErrorMsg(code, msg) +#define SWIG_Error(code, msg) SWIG_Scilab_ErrorMsg(code, msg) + +#define SWIG_fail return SWIG_ERROR; -#define SWIG_Scilab_Raise(obj, type, desc) SwigScilabRaise(type) SWIGRUNTIME int SwigScilabRaise(const char *type) { @@ -243,9 +243,7 @@ SwigScilabRaise(const char *type) { #endif } -#define Scilab_Error_Occurred() 0 -#define SWIG_Scilab_AddErrorMsg(msg) {;} - +#define SWIG_Scilab_Raise(obj, type, desc) SwigScilabRaise(type) /* * Pointer utility functions diff --git a/Lib/scilab/scistdcommon.swg b/Lib/scilab/scistdcommon.swg index f1c8d0b23..7fdc72212 100644 --- a/Lib/scilab/scistdcommon.swg +++ b/Lib/scilab/scistdcommon.swg @@ -1,6 +1,6 @@ %fragment("StdTraits","header",fragment="StdTraitsCommon") { -namespace swig { +namespace swig { // Traits that provides the from method template struct traits_from_ptr { static SwigSciObject from(Type *val, int owner = 0) { @@ -39,7 +39,7 @@ namespace swig { // Traits that provides the asval/as/check method template - struct traits_asptr { + struct traits_asptr { static int asptr(const SwigSciObject& obj, Type **val) { Type *p; int res = SWIG_ConvertPtr(obj, (void**)&p, type_info(), 0); @@ -48,20 +48,21 @@ namespace swig { } return res; } - }; + }; template inline int asptr(const SwigSciObject& obj, Type **vptr) { return traits_asptr::asptr(obj, vptr); } - template + template struct traits_asval { static int asval(const SwigSciObject& obj, Type *val) { if (val) { Type *p = 0; int res = traits_asptr::asptr(obj, &p); - if (!SWIG_IsOK(res)) return res; + if (!SWIG_IsOK(res)) + return res; if (p) { typedef typename noconst_traits::noconst_type noconst_type; *(const_cast(val)) = *p; @@ -94,31 +95,32 @@ namespace swig { } } }; - + template inline int asval(const SwigSciObject& obj, Type *val) { return traits_asval::asval(obj, val); } - template + template struct traits_as { static Type as(const SwigSciObject& obj, bool throw_error) { Type v; int res = asval(obj, &v); - //if (!obj.is_defined() || !SWIG_IsOK(res)) { - if (!Scilab_Error_Occurred()) { - %type_error(swig::type_name()); - } - if (throw_error) throw std::invalid_argument("bad type"); - //} - return v; + if (SWIG_IsOK(res)) { + return v; + } else { + %type_error(swig::type_name()); + if (throw_error) + throw std::invalid_argument("bad type"); + return res; + } } }; - template + template struct traits_as { static Type as(const SwigSciObject& obj, bool throw_error) { - Type *v = 0; + Type *v = 0; int res = traits_asptr::asptr(obj, &v); if (SWIG_IsOK(res) && v) { if (SWIG_IsNewObj(res)) { @@ -131,39 +133,37 @@ namespace swig { } else { // Uninitialized return value, no Type() constructor required. static Type *v_def = (Type*) malloc(sizeof(Type)); - if (!Scilab_Error_Occurred()) { - %type_error(swig::type_name()); - } - if (throw_error) throw std::invalid_argument("bad type"); + %type_error(swig::type_name()); + if (throw_error) + throw std::invalid_argument("bad type"); memset(v_def,0,sizeof(Type)); return *v_def; } } }; - template + template struct traits_as { static Type* as(const SwigSciObject& obj, bool throw_error) { - Type *v = 0; + Type *v = 0; int res = traits_asptr::asptr(obj, &v); if (SWIG_IsOK(res)) { return v; } else { - if (!Scilab_Error_Occurred()) { - %type_error(swig::type_name()); - } - if (throw_error) throw std::invalid_argument("bad type"); + %type_error(swig::type_name()); + if (throw_error) + throw std::invalid_argument("bad type"); return SWIG_OK; } } }; - + template inline Type as(const SwigSciObject& obj, bool te = false) { return traits_as::category>::as(obj, te); } - template + template struct traits_check { static bool check(const SwigSciObject& obj) { int res = asval(obj, (Type *)(0)); @@ -171,7 +171,7 @@ namespace swig { } }; - template + template struct traits_check { static bool check(const SwigSciObject& obj) { int res = asptr(obj, (Type **)(0)); @@ -189,7 +189,7 @@ namespace swig { %define %specialize_std_container(Type,Check,As,From) %{ namespace swig { - template <> struct traits_asval { + template <> struct traits_asval { typedef Type value_type; static int asval(const SwigSciObject& obj, value_type *val) { if (Check(obj)) { @@ -206,7 +206,7 @@ namespace swig { } }; - template <> + template <> struct traits_check { static int check(const SwigSciObject& obj) { int res = Check(obj);