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
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
%fragment("StdTraits","header",fragment="StdTraitsCommon")
|
%fragment("StdTraits","header",fragment="StdTraitsCommon")
|
||||||
{
|
{
|
||||||
namespace swig {
|
namespace swig {
|
||||||
// Traits that provides the from method
|
// Traits that provides the from method
|
||||||
template <class Type> struct traits_from_ptr {
|
template <class Type> struct traits_from_ptr {
|
||||||
static SwigSciObject from(Type *val, int owner = 0) {
|
static SwigSciObject from(Type *val, int owner = 0) {
|
||||||
|
|
@ -39,7 +39,7 @@ namespace swig {
|
||||||
|
|
||||||
// Traits that provides the asval/as/check method
|
// Traits that provides the asval/as/check method
|
||||||
template <class Type>
|
template <class Type>
|
||||||
struct traits_asptr {
|
struct traits_asptr {
|
||||||
static int asptr(const SwigSciObject& obj, Type **val) {
|
static int asptr(const SwigSciObject& obj, Type **val) {
|
||||||
Type *p;
|
Type *p;
|
||||||
int res = SWIG_ConvertPtr(obj, (void**)&p, type_info<Type>(), 0);
|
int res = SWIG_ConvertPtr(obj, (void**)&p, type_info<Type>(), 0);
|
||||||
|
|
@ -48,20 +48,21 @@ namespace swig {
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
inline int asptr(const SwigSciObject& obj, Type **vptr) {
|
inline int asptr(const SwigSciObject& obj, Type **vptr) {
|
||||||
return traits_asptr<Type>::asptr(obj, vptr);
|
return traits_asptr<Type>::asptr(obj, vptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
struct traits_asval {
|
struct traits_asval {
|
||||||
static int asval(const SwigSciObject& obj, Type *val) {
|
static int asval(const SwigSciObject& obj, Type *val) {
|
||||||
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;
|
||||||
|
|
@ -94,31 +95,32 @@ namespace swig {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
inline int asval(const SwigSciObject& obj, Type *val) {
|
inline int asval(const SwigSciObject& obj, Type *val) {
|
||||||
return traits_asval<Type>::asval(obj, val);
|
return traits_asval<Type>::asval(obj, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
struct traits_as<Type, value_category> {
|
struct traits_as<Type, value_category> {
|
||||||
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
struct traits_as<Type, pointer_category> {
|
struct traits_as<Type, pointer_category> {
|
||||||
static Type as(const SwigSciObject& obj, bool throw_error) {
|
static Type as(const SwigSciObject& obj, bool throw_error) {
|
||||||
Type *v = 0;
|
Type *v = 0;
|
||||||
int res = traits_asptr<Type>::asptr(obj, &v);
|
int res = traits_asptr<Type>::asptr(obj, &v);
|
||||||
if (SWIG_IsOK(res) && v) {
|
if (SWIG_IsOK(res) && v) {
|
||||||
if (SWIG_IsNewObj(res)) {
|
if (SWIG_IsNewObj(res)) {
|
||||||
|
|
@ -131,39 +133,37 @@ 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
struct traits_as<Type*, pointer_category> {
|
struct traits_as<Type*, pointer_category> {
|
||||||
static Type* as(const SwigSciObject& obj, bool throw_error) {
|
static Type* as(const SwigSciObject& obj, bool throw_error) {
|
||||||
Type *v = 0;
|
Type *v = 0;
|
||||||
int res = traits_asptr<Type>::asptr(obj, &v);
|
int res = traits_asptr<Type>::asptr(obj, &v);
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
inline Type as(const SwigSciObject& obj, bool te = false) {
|
inline Type as(const SwigSciObject& obj, bool te = false) {
|
||||||
return traits_as<Type, typename traits<Type>::category>::as(obj, te);
|
return traits_as<Type, typename traits<Type>::category>::as(obj, te);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
struct traits_check<Type, value_category> {
|
struct traits_check<Type, value_category> {
|
||||||
static bool check(const SwigSciObject& obj) {
|
static bool check(const SwigSciObject& obj) {
|
||||||
int res = asval(obj, (Type *)(0));
|
int res = asval(obj, (Type *)(0));
|
||||||
|
|
@ -171,7 +171,7 @@ namespace swig {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
struct traits_check<Type, pointer_category> {
|
struct traits_check<Type, pointer_category> {
|
||||||
static bool check(const SwigSciObject& obj) {
|
static bool check(const SwigSciObject& obj) {
|
||||||
int res = asptr(obj, (Type **)(0));
|
int res = asptr(obj, (Type **)(0));
|
||||||
|
|
@ -189,7 +189,7 @@ namespace swig {
|
||||||
%define %specialize_std_container(Type,Check,As,From)
|
%define %specialize_std_container(Type,Check,As,From)
|
||||||
%{
|
%{
|
||||||
namespace swig {
|
namespace swig {
|
||||||
template <> struct traits_asval<Type > {
|
template <> struct traits_asval<Type > {
|
||||||
typedef Type value_type;
|
typedef Type value_type;
|
||||||
static int asval(const SwigSciObject& obj, value_type *val) {
|
static int asval(const SwigSciObject& obj, value_type *val) {
|
||||||
if (Check(obj)) {
|
if (Check(obj)) {
|
||||||
|
|
@ -206,7 +206,7 @@ namespace swig {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct traits_check<Type, value_category> {
|
struct traits_check<Type, value_category> {
|
||||||
static int check(const SwigSciObject& obj) {
|
static int check(const SwigSciObject& obj) {
|
||||||
int res = Check(obj);
|
int res = Check(obj);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue