An improvement to error reporting and
more tests added to std::vector. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9723 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
8986650322
commit
7c4d3d8bd8
3 changed files with 13 additions and 7 deletions
|
|
@ -52,6 +52,7 @@ swig_assert_each_line(<<'EOF')
|
||||||
@iv.unshift(7, 3)
|
@iv.unshift(7, 3)
|
||||||
@iv.insert(1,5)
|
@iv.insert(1,5)
|
||||||
@iv.insert(0, 3)
|
@iv.insert(0, 3)
|
||||||
|
@iv.unshift(2,3,4)
|
||||||
x = average(@iv)
|
x = average(@iv)
|
||||||
y = average([1, 2, 3, 4])
|
y = average([1, 2, 3, 4])
|
||||||
half([10, 10.5, 11, 11.5])
|
half([10, 10.5, 11, 11.5])
|
||||||
|
|
|
||||||
|
|
@ -105,9 +105,7 @@ const char* Ruby_Format_TypeError( const char* msg,
|
||||||
str = rb_str_new(NULL, 0);
|
str = rb_str_new(NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
str = rb_str_cat2( str, "in method '" );
|
str = rb_str_cat2( str, "Expected argument " );
|
||||||
str = rb_str_cat2( str, name );
|
|
||||||
str = rb_str_cat2( str, "', argument " );
|
|
||||||
sprintf( buf, "%d of type ", argn-1 );
|
sprintf( buf, "%d of type ", argn-1 );
|
||||||
str = rb_str_cat2( str, buf );
|
str = rb_str_cat2( str, buf );
|
||||||
str = rb_str_cat2( str, type );
|
str = rb_str_cat2( str, type );
|
||||||
|
|
@ -125,5 +123,12 @@ const char* Ruby_Format_TypeError( const char* msg,
|
||||||
str = rb_str_append( str, asStr );
|
str = rb_str_append( str, asStr );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( name )
|
||||||
|
{
|
||||||
|
str = rb_str_cat2( str, "\n\tin SWIG method '" );
|
||||||
|
str = rb_str_cat2( str, name );
|
||||||
|
str = rb_str_cat2( str, "'\n" );
|
||||||
|
}
|
||||||
|
|
||||||
return StringValuePtr( str );
|
return StringValuePtr( str );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -111,11 +111,11 @@ namespace swig {
|
||||||
Type v;
|
Type v;
|
||||||
int res = asval(obj, &v);
|
int res = asval(obj, &v);
|
||||||
if (!obj || !SWIG_IsOK(res)) {
|
if (!obj || !SWIG_IsOK(res)) {
|
||||||
|
if (throw_error) throw std::invalid_argument("bad type");
|
||||||
VALUE lastErr = rb_gv_get("$!");
|
VALUE lastErr = rb_gv_get("$!");
|
||||||
if (lastErr == Qnil) {
|
if (lastErr == Qnil) {
|
||||||
%type_error(swig::type_name<Type>());
|
%type_error(swig::type_name<Type>());
|
||||||
}
|
}
|
||||||
if (throw_error) throw std::invalid_argument("bad type");
|
|
||||||
}
|
}
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
@ -136,12 +136,12 @@ 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));
|
if (throw_error) throw std::invalid_argument("bad type");
|
||||||
VALUE lastErr = rb_gv_get("$!");
|
VALUE lastErr = rb_gv_get("$!");
|
||||||
if (lastErr == Qnil) {
|
if (lastErr == Qnil) {
|
||||||
%type_error(swig::type_name<Type>());
|
%type_error(swig::type_name<Type>());
|
||||||
}
|
}
|
||||||
if (throw_error) throw std::invalid_argument("bad type");
|
static Type *v_def = (Type*) malloc(sizeof(Type));
|
||||||
memset(v_def,0,sizeof(Type));
|
memset(v_def,0,sizeof(Type));
|
||||||
return *v_def;
|
return *v_def;
|
||||||
}
|
}
|
||||||
|
|
@ -156,11 +156,11 @@ namespace swig {
|
||||||
if (SWIG_IsOK(res)) {
|
if (SWIG_IsOK(res)) {
|
||||||
return v;
|
return v;
|
||||||
} else {
|
} else {
|
||||||
|
if (throw_error) throw std::invalid_argument("bad type");
|
||||||
VALUE lastErr = rb_gv_get("$!");
|
VALUE lastErr = rb_gv_get("$!");
|
||||||
if (lastErr == Qnil) {
|
if (lastErr == Qnil) {
|
||||||
%type_error(swig::type_name<Type>());
|
%type_error(swig::type_name<Type>());
|
||||||
}
|
}
|
||||||
if (throw_error) throw std::invalid_argument("bad type");
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue