scilab: clean error management code, remove useless macros
This commit is contained in:
parent
a87c6f9bf2
commit
7af4bc72c6
3 changed files with 39 additions and 41 deletions
|
|
@ -65,7 +65,7 @@ namespace swig
|
||||||
}
|
}
|
||||||
catch (std::exception& e)
|
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)
|
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)
|
catch (std::exception& e)
|
||||||
{
|
{
|
||||||
SWIG_Scilab_AddErrorMsg(e.what());
|
SWIG_Scilab_ErrorMsg(SWIG_RuntimeError, e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -222,6 +222,7 @@ SWIG_Scilab_ErrorType(int code) {
|
||||||
return "RuntimeError";
|
return "RuntimeError";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#define SWIG_ErrorType(code) SWIG_Scilab_ErrorType(code)
|
||||||
|
|
||||||
SWIGINTERN void
|
SWIGINTERN void
|
||||||
SWIG_Scilab_ErrorMsg(int code, const char *msg)
|
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);
|
Scierror(999, _("SWIG/Scilab %s: %s.\n"), SWIG_Scilab_ErrorType(code), msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SWIG_fail return SWIG_ERROR;
|
#define SWIG_Error(code, msg) SWIG_Scilab_ErrorMsg(code, msg)
|
||||||
#define SWIG_ErrorType(code) SWIG_Scilab_ErrorType(code)
|
|
||||||
#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
|
SWIGRUNTIME int
|
||||||
SwigScilabRaise(const char *type) {
|
SwigScilabRaise(const char *type) {
|
||||||
|
|
@ -243,9 +243,7 @@ SwigScilabRaise(const char *type) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#define Scilab_Error_Occurred() 0
|
#define SWIG_Scilab_Raise(obj, type, desc) SwigScilabRaise(type)
|
||||||
#define SWIG_Scilab_AddErrorMsg(msg) {;}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Pointer utility functions
|
* Pointer utility functions
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,8 @@ namespace swig {
|
||||||
if (val) {
|
if (val) {
|
||||||
Type *p = 0;
|
Type *p = 0;
|
||||||
int res = traits_asptr<Type>::asptr(obj, &p);
|
int res = traits_asptr<Type>::asptr(obj, &p);
|
||||||
if (!SWIG_IsOK(res)) return res;
|
if (!SWIG_IsOK(res))
|
||||||
|
return res;
|
||||||
if (p) {
|
if (p) {
|
||||||
typedef typename noconst_traits<Type>::noconst_type noconst_type;
|
typedef typename noconst_traits<Type>::noconst_type noconst_type;
|
||||||
*(const_cast<noconst_type*>(val)) = *p;
|
*(const_cast<noconst_type*>(val)) = *p;
|
||||||
|
|
@ -105,13 +106,14 @@ namespace swig {
|
||||||
static Type as(const SwigSciObject& obj, bool throw_error) {
|
static Type as(const SwigSciObject& obj, bool throw_error) {
|
||||||
Type v;
|
Type v;
|
||||||
int res = asval(obj, &v);
|
int res = asval(obj, &v);
|
||||||
//if (!obj.is_defined() || !SWIG_IsOK(res)) {
|
if (SWIG_IsOK(res)) {
|
||||||
if (!Scilab_Error_Occurred()) {
|
return v;
|
||||||
%type_error(swig::type_name<Type>());
|
} else {
|
||||||
}
|
%type_error(swig::type_name<Type>());
|
||||||
if (throw_error) throw std::invalid_argument("bad type");
|
if (throw_error)
|
||||||
//}
|
throw std::invalid_argument("bad type");
|
||||||
return v;
|
return res;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -131,10 +133,9 @@ namespace swig {
|
||||||
} else {
|
} else {
|
||||||
// Uninitialized return value, no Type() constructor required.
|
// Uninitialized return value, no Type() constructor required.
|
||||||
static Type *v_def = (Type*) malloc(sizeof(Type));
|
static Type *v_def = (Type*) malloc(sizeof(Type));
|
||||||
if (!Scilab_Error_Occurred()) {
|
%type_error(swig::type_name<Type>());
|
||||||
%type_error(swig::type_name<Type>());
|
if (throw_error)
|
||||||
}
|
throw std::invalid_argument("bad type");
|
||||||
if (throw_error) throw std::invalid_argument("bad type");
|
|
||||||
memset(v_def,0,sizeof(Type));
|
memset(v_def,0,sizeof(Type));
|
||||||
return *v_def;
|
return *v_def;
|
||||||
}
|
}
|
||||||
|
|
@ -149,10 +150,9 @@ namespace swig {
|
||||||
if (SWIG_IsOK(res)) {
|
if (SWIG_IsOK(res)) {
|
||||||
return v;
|
return v;
|
||||||
} else {
|
} else {
|
||||||
if (!Scilab_Error_Occurred()) {
|
%type_error(swig::type_name<Type>());
|
||||||
%type_error(swig::type_name<Type>());
|
if (throw_error)
|
||||||
}
|
throw std::invalid_argument("bad type");
|
||||||
if (throw_error) throw std::invalid_argument("bad type");
|
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue