add to %argument_fail

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8185 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2006-01-02 17:37:53 +00:00
commit 4048f282c9
12 changed files with 72 additions and 76 deletions

View file

@ -57,7 +57,7 @@ SWIG_AsArgcArgv(PyObject* input,
argv = SWIG_AsArgcArgv($input, $descriptor(char**), &argc, &owner);
if (!argv) {
$1 = 0; $2 = 0;
%argument_fail(SWIG_TypeError, "int ARGC, char **ARGV", $argnum);
%argument_fail(SWIG_TypeError, "int ARGC, char **ARGV", $symname, $argnum);
} else {
$1 = ($1_ltype) argc;
$2 = ($2_ltype) argv;

View file

@ -32,7 +32,7 @@
%typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize) (TYPEMAP, SIZE)
(Char *buf = 0, size_t size = 0, int alloc = 0) {
if (!SWIG_IsOK((SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc)))) {
%argument_fail(SWIG_TypeError, "(TYPEMAP, SIZE)", $argnum);
%argument_fail(SWIG_TypeError, "(TYPEMAP, SIZE)", $symname, $argnum);
}
$1 = ($1_ltype) buf;
$2 = ($2_ltype) size - 1;
@ -115,7 +115,7 @@
%typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize) TYPEMAP
(Char temp[MAX+1], Char *t = 0, size_t n = 0, int alloc = 0) {
if (!SWIG_IsOK((SWIG_AsCharPtrAndSize($input, &t, &n, &alloc)))) {
%argument_fail(SWIG_TypeError, "TYPEMAP", $argnum);
%argument_fail(SWIG_TypeError, "TYPEMAP", $symname, $argnum);
}
if ( n > (size_t) MAX ) n = (size_t) MAX;
memcpy(temp, t, sizeof(Char)*n);
@ -154,7 +154,7 @@
expansion += EXP;
#endif
if (!SWIG_IsOK((SWIG_AsCharPtrAndSize($input, &t, &n, &alloc)))) {
%argument_fail(SWIG_TypeError, "TYPEMAP", $argnum);
%argument_fail(SWIG_TypeError, "TYPEMAP", $symname, $argnum);
}
$1 = %new_array(n+expansion, $*1_ltype);
memcpy($1,t,sizeof(Char)*n);
@ -183,7 +183,7 @@
%define Name ## _output_maxsize(TYPEMAP, SIZE)
%typemap(in,noblock=1,fragment=SWIG_AsVal_frag(size_t)) (TYPEMAP, SIZE) (size_t size, Char *buff = 0) {
if (!SWIG_IsOK((SWIG_AsVal(size_t)($input, &size)))) {
%argument_fail(SWIG_TypeError, "(TYPEMAP, SIZE)", $argnum);
%argument_fail(SWIG_TypeError, "(TYPEMAP, SIZE)", $symname, $argnum);
}
buff= %new_array(size+1, Char);
$2 = %numeric_cast(size, $2_ltype);
@ -213,7 +213,7 @@
%define Name ## _output_withsize(TYPEMAP, SIZE)
%typemap(in,noblock=1,fragment=SWIG_AsVal_frag(size_t)) (TYPEMAP, SIZE) (size_t n, Char *buff = 0, $*2_ltype size) {
if (!SWIG_IsOK((SWIG_AsVal(size_t)($input, &n)))) {
%argument_fail(SWIG_TypeError, "(TYPEMAP, SIZE)", $argnum);
%argument_fail(SWIG_TypeError, "(TYPEMAP, SIZE)", $symname, $argnum);
}
buff= %new_array(n+1, Char);
$1 = %static_cast(buff, $1_ltype);

View file

@ -8,7 +8,7 @@
%typemap(in,fragment=SWIG_AsVal_frag(int),noblock=1) const enum SWIGTYPE& (int val, int ecode, $basetype temp) {
ecode = SWIG_AsVal(int)($input, &val);
if (!SWIG_IsOK(ecode)) {
%argument_fail(ecode, "$type", $argnum);
%argument_fail(ecode, "$type", $symname, $argnum);
} else {
temp = %static_cast(val,$basetype);
$1 = &temp;

View file

@ -3,13 +3,13 @@
/* macros for error manipulation */
#define %nullref_fmt() "invalid null reference "
#define %varfail_fmt(_type,_name) "in variable '"_name"' of type '"_type"'"
#define %argfail_fmt(_type,_argn) "in argument " #_argn" of type '" _type"'"
#define %outfail_fmt(_type) "in output value of type '"_type"'"
#define %argnullref_fmt(_type, _argn) %nullref_fmt() %argfail_fmt(_type, _argn)
#define %varnullref_fmt(_type, _name) %nullref_fmt() %varfail_fmt(_type, _name)
#define %outnullref_fmt(_type) %nullref_fmt() %outfail_fmt(_type)
#define %nullref_fmt() "invalid null reference "
#define %varfail_fmt(_type,_name) "in variable '"`_name`"' of type '"`_type`"'"
#define %argfail_fmt(_type,_name,_argn) "in method '" `_name` "', argument " `_argn`" of type '" `_type`"'"
#define %outfail_fmt(_type) "in output value of type '"_type"'"
#define %argnullref_fmt(_type,_name,_argn) %nullref_fmt() %argfail_fmt(_type, _name, _argn)
#define %varnullref_fmt(_type,_name) %nullref_fmt() %varfail_fmt(_type, _name)
#define %outnullref_fmt(_type) %nullref_fmt() %outfail_fmt(_type)
/* setting an error */
#define %error(code,msg...) SWIG_Error(code, msg)

View file

@ -82,7 +82,7 @@ or you can use the %apply directive :
Type val;
int ecode = asval_meth($input, &val);
if (!SWIG_IsOK(ecode)) {
%argument_fail(ecode, "$*ltype",$argnum);
%argument_fail(ecode, "$*ltype",$symname, $argnum);
}
temp = %static_cast(val, $*ltype);
$1 = &temp;
@ -94,7 +94,7 @@ or you can use the %apply directive :
Type val;
int ecode = asval_meth($input, &val);
if (!SWIG_IsOK(ecode)) {
%argument_fail(ecode, "$*ltype",$argnum);
%argument_fail(ecode, "$*ltype",$symname, $argnum);
}
temp = %static_cast(val, $*ltype);
$1 = &temp;
@ -118,17 +118,17 @@ or you can use the %apply directive :
%typemap(in,noblock=1,fragment=asptr_frag) Type *INPUT(int res) {
res = asptr_meth($input, &$1);
if (!SWIG_IsOK(res)) {
%argument_fail(SWIG_TypeError,"$type",$argnum);
%argument_fail(SWIG_TypeError,"$type",$symname, $argnum);
}
res = SWIG_AddTmpMask(res);
}
%typemap(in,noblock=1,fragment=asptr_frag) Type &INPUT(int res) {
res = asptr_meth($input, &$1);
if (!SWIG_IsOK(res)) {
%argument_fail(SWIG_TypeError,"$type",$argnum);
%argument_fail(SWIG_TypeError,"$type",$symname, $argnum);
}
if (!$1) {
%argument_nullref("$type",$argnum);
%argument_nullref("$type",$symname, $argnum);
}
res = SWIG_AddTmpMask(res);
}

View file

@ -205,27 +205,23 @@ SWIGINTERNINLINE int
SWIG_CanCastAsInteger(double *d, double min, double max) {
double x = *d;
if (min <= x && x <= max) {
%#ifdef SWIG_HAS_NO_RINT
/* Use the python mechanism to round, or so */
double rd = (x < 0) ? ceil(x) : floor(x);
%#else
double rd = rint(x);
%#endif
if ((errno == EDOM) || (errno == ERANGE)) {
errno = 0;
} else {
if (rd == x) {
return 1;
} else {
double diff = rd - x;
double summ = rd + x;
double reps = diff/summ;
if (fabs(reps) < 8*DBL_EPSILON) {
*d = rd;
return 1;
}
}
}
double fx = floor(x);
double rd = ((x - fx) < 0.5) ? fx : ceil(x); /* simple rint */
if ((errno == EDOM) || (errno == ERANGE)) {
errno = 0;
} else {
if (rd == x) {
return 1;
} else {
double diff = rd - x;
double summ = rd + x;
double reps = diff/summ;
if (fabs(reps) < 8*DBL_EPSILON) {
*d = rd;
return 1;
}
}
}
}
return 0;
}

View file

@ -28,7 +28,7 @@
%typemap(in,fragment=frag) Type {
Type *ptr = (Type *)0;
int res = asptr_meth($input, &ptr);
if (!SWIG_IsOK(res) || !ptr) { %argument_fail(SWIG_TypeError, "$type", $argnum); }
if (!SWIG_IsOK(res) || !ptr) { %argument_fail(SWIG_TypeError, "$type", $symname, $argnum); }
$1 = *ptr;
if (SWIG_IsNewObj(res)) %delete(ptr);
}
@ -36,8 +36,8 @@
%typemap(in,fragment=frag) const Type & (int res = SWIG_OLDOBJ) {
Type *ptr = (Type *)0;
res = asptr_meth($input, &ptr);
if (!SWIG_IsOK(res)) { %argument_fail(SWIG_TypeError,"$type",$argnum); }
if (!ptr) { %argument_nullref("$type",$argnum); }
if (!SWIG_IsOK(res)) { %argument_fail(SWIG_TypeError,"$type",$symname, $argnum); }
if (!ptr) { %argument_nullref("$type",$symname, $argnum); }
$1 = ptr;
}
%typemap(freearg,noblock=1) const Type & {

View file

@ -31,7 +31,7 @@
Char * (Char *buf = 0, int alloc = 0),
const Char * (Char *buf = 0, int alloc = 0) {
if (!SWIG_IsOK(SWIG_AsCharPtr($input, &buf, &alloc))) {
%argument_fail(SWIG_TypeError,"$type",$argnum);
%argument_fail(SWIG_TypeError,"$type",$symname, $argnum);
}
$1 = buf;
}
@ -41,7 +41,7 @@
%typemap(in,noblock=1,fragment=#SWIG_AsCharPtr) Char const*& (Char *buf = 0, int alloc = 0) {
if (!SWIG_IsOK((SWIG_AsCharPtr($input, &buf, &alloc)))) {
%argument_fail(SWIG_TypeError,"$type",$argnum);
%argument_fail(SWIG_TypeError,"$type",$symname, $argnum);
}
$1 = &temp;
}
@ -250,7 +250,7 @@
const Char [ANY](Char temp[$1_dim0])
{
if (!SWIG_IsOK((SWIG_AsCharArray($input, temp, $1_dim0)))) {
%argument_fail(SWIG_TypeError,"$type",$argnum);
%argument_fail(SWIG_TypeError,"$type",$symname, $argnum);
}
$1 = temp;
}
@ -259,7 +259,7 @@
%typemap(in,noblock=1,fragment=#SWIG_AsCharArray) const Char (&)[ANY] (Char temp[$1_dim0])
{
if (!SWIG_IsOK((SWIG_AsCharArray($input, temp, $1_dim0)))) {
%argument_fail(SWIG_TypeError,"$type",$argnum);
%argument_fail(SWIG_TypeError,"$type",$symname, $argnum);
}
$1 = &temp;
}
@ -398,7 +398,7 @@
(const Char *STRING, size_t LENGTH) (Char *buf = 0, size_t size = 0, int alloc = 0)
{
if (!SWIG_IsOK((SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc)))) {
%argument_fail(SWIG_TypeError,"$type",$argnum);
%argument_fail(SWIG_TypeError,"$type",$symname, $argnum);
}
$1 = %static_cast(buf, $1_ltype);
$2 = %numeric_cast(size - 1, $2_ltype);
@ -417,7 +417,7 @@
(const Char *STRING, size_t SIZE) (Char *buf = 0, size_t size = 0, int alloc = 0)
{
if (!SWIG_IsOK((SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc)))) {
%argument_fail(SWIG_TypeError,"$type",$argnum);
%argument_fail(SWIG_TypeError,"$type",$symname, $argnum);
}
$1 = %static_cast(buf, $1_ltype);
$2 = %numeric_cast(size, $2_ltype);
@ -438,7 +438,7 @@
(size_t LENGHT, const Char *STRING) (Char *buf = 0, size_t size = 0, int alloc = 0)
{
if (!SWIG_IsOK((SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc)))) {
%argument_fail(SWIG_TypeError,"$type",$argnum);
%argument_fail(SWIG_TypeError,"$type",$symname, $argnum);
}
$2 = %static_cast(buf, $2_ltype) ;
$1 = %numeric_cast(size - 1, $1_ltype) ;
@ -456,7 +456,7 @@
(size_t SIZE, const Char *STRING) (Char *buf = 0, size_t size = 0, int alloc = 0)
{
if (!SWIG_IsOK((SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc)))) {
%argument_fail(SWIG_TypeError, "$type",$argnum);
%argument_fail(SWIG_TypeError, "$type",$symname, $argnum);
}
$2 = %static_cast(buf, $2_ltype) ;
$1 = %numeric_cast(size, $1_ltype) ;

View file

@ -5,7 +5,7 @@
/* Pointers and arrays */
%typemap(in, noblock=1) SWIGTYPE *(void *argp = 0) {
if (!SWIG_IsOK((SWIG_ConvertPtr($input, &argp,$descriptor, $disown | %convertptr_flags)))) {
%argument_fail(SWIG_TypeError, "$type", $argnum);
%argument_fail(SWIG_TypeError, "$type", $symname, $argnum);
}
$1 = %reinterpret_cast(argp, $ltype);
}
@ -13,7 +13,7 @@
%typemap(in, noblock=1) SWIGTYPE [] (void *argp = 0) {
if (!SWIG_IsOK((SWIG_ConvertPtr($input, &argp,$descriptor, $disown | %convertptr_flags)))) {
%argument_fail(SWIG_TypeError, "$type", $argnum);
%argument_fail(SWIG_TypeError, "$type", $symname, $argnum);
}
$1 = %reinterpret_cast(argp, $ltype);
}
@ -22,7 +22,7 @@
%typemap(in, noblock=1) SWIGTYPE* const& (void *argp = 0, $*ltype temp) {
if (!SWIG_IsOK((SWIG_ConvertPtr($input, &argp, $*descriptor, $disown | %convertptr_flags)))) {
%argument_fail(SWIG_TypeError, "$*ltype", $argnum);
%argument_fail(SWIG_TypeError, "$*ltype", $symname, $argnum);
}
temp = %reinterpret_cast(argp, $*ltype);
$1 = &temp;
@ -33,9 +33,9 @@
/* Reference */
%typemap(in, noblock=1) SWIGTYPE & (void *argp = 0) {
if (!SWIG_IsOK((SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags)))) {
%argument_fail(SWIG_TypeError, "$type", $argnum);
%argument_fail(SWIG_TypeError, "$type", $symname, $argnum);
}
if (!argp) { %argument_nullref("$type", $argnum); }
if (!argp) { %argument_nullref("$type", $symname, $argnum); }
$1 = %reinterpret_cast(argp, $ltype);
}
%typemap(freearg) SWIGTYPE & "";
@ -44,9 +44,9 @@
%typemap(in,implicitconv=1) const SWIGTYPE & (void *argp = 0, int res) {
res = SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags | %implicitconv_flag);
if (!SWIG_IsOK(res)) {
%argument_fail(SWIG_TypeError, "$type", $argnum);
%argument_fail(SWIG_TypeError, "$type", $symname, $argnum);
}
if (!argp) { %argument_nullref("$type", $argnum); }
if (!argp) { %argument_nullref("$type", $symname, $argnum); }
$1 = %reinterpret_cast(argp, $ltype);
}
%typemap(freearg,noblock=1,match="in",implicitconv=1) const SWIGTYPE &
@ -56,9 +56,9 @@
#else
%typemap(in,noblock=1) const SWIGTYPE & (void *argp) {
if (!SWIG_IsOK((SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags)))) {
%argument_fail(SWIG_TypeError, "$type", $argnum);
%argument_fail(SWIG_TypeError, "$type", $symname, $argnum);
}
if (!argp) { %argument_nullref("$type", $argnum); }
if (!argp) { %argument_nullref("$type", $symname, $argnum); }
$1 = %reinterpret_cast(argp, $ltype);
}
#endif
@ -69,10 +69,10 @@
void *argp;
int res = SWIG_ConvertPtr($input, &argp, $&descriptor, %convertptr_flags | %implicitconv_flag);
if (!SWIG_IsOK(res)) {
%argument_fail(SWIG_TypeError, "$type", $argnum);
%argument_fail(SWIG_TypeError, "$type", $symname, $argnum);
}
if (!argp) {
%argument_nullref("$type", $argnum);
%argument_nullref("$type", $symname, $argnum);
} else {
$&ltype temp = %reinterpret_cast(argp, $&ltype);
$1 = *temp;
@ -84,10 +84,10 @@
void *argp;
$&ltype temp;
if (!SWIG_IsOK((SWIG_ConvertPtr($input, &argp, $&descriptor, %convertptr_flags)))) {
%argument_fail(SWIG_TypeError, "$type", $argnum);
%argument_fail(SWIG_TypeError, "$type", $symname, $argnum);
}
if (!argp) {
%argument_nullref("$type", $argnum);
%argument_nullref("$type", $symname, $argnum);
} else {
$1 = *(%reinterpret_cast(argp, $&ltype));
}
@ -451,7 +451,7 @@
%typemap(in,noblock=1) SWIGTYPE (CLASS::*) {
if (!SWIG_IsOK((SWIG_ConvertMember($input, %as_voidptr(&$1), sizeof($type),$descriptor)))) {
%argument_fail(SWIG_TypeError,"$type",$argnum);
%argument_fail(SWIG_TypeError,"$type",$symname, $argnum);
}
}
@ -502,7 +502,7 @@
*/
%typemap(in, noblock=1) SWIGTYPE ((*)(ANY)) {
if (!SWIG_IsOK((SWIG_ConvertFunctionPtr($input, (void**)(&$1), $descriptor)))) {
%argument_fail(SWIG_TypeError,"$type",$argnum);
%argument_fail(SWIG_TypeError,"$type",$symname, $argnum);
}
}
@ -562,7 +562,7 @@
%typemap(in, noblock=1) SWIGTYPE *DISOWN {
if (!SWIG_IsOK((SWIG_ConvertPtr($input, %as_voidptrptr(&$1), $descriptor, SWIG_POINTER_DISOWN | %convertptr_flags)))) {
%argument_fail(SWIG_TypeError,"$type", $argnum);
%argument_fail(SWIG_TypeError,"$type", $symname, $argnum);
}
}

View file

@ -131,11 +131,11 @@
* Language independent definitions
* ----------------------------------------------------------------------------- */
#define %error_block(Block...) %block(Block)
#define %argument_fail(code, type, argn) SWIG_exception(code, %argfail_fmt(type, argn))
#define %argument_nullref(type, argn) SWIG_exception(SWIG_ValueError, %argnullref_fmt(type, argn))
#define %variable_fail(code, type, name) SWIG_exception(code, %varfail_fmt(type, name))
#define %variable_nullref(type, name) SWIG_exception(SWIG_ValueError, %varnullref_fmt(type, name))
#define %error_block(Block...) %block(Block)
#define %argument_fail(code, type, name, argn) SWIG_exception(code, %argfail_fmt(type, name, argn))
#define %argument_nullref(type, name, argn) SWIG_exception(SWIG_ValueError, %argnullref_fmt(type, name, argn))
#define %variable_fail(code, type, name) SWIG_exception(code, %varfail_fmt(type, name))
#define %variable_nullref(type, name) SWIG_exception(SWIG_ValueError, %varnullref_fmt(type, name))
#if defined(SWIG_DIRECTOR_TYPEMAPS)
#define %dirout_fail(code, type) SWIG_DirOutFail(code, %outfail_fmt(type))

View file

@ -34,7 +34,7 @@
%typemap(in,noblock=1,fragment=frag) Type (Type val, int ecode = 0) {
ecode = asval_meth($input, &val);
if (!SWIG_IsOK(ecode)) {
%argument_fail(ecode, "$ltype", $argnum);
%argument_fail(ecode, "$ltype", $symname, $argnum);
}
$1 = %static_cast(val,$ltype);
}
@ -42,7 +42,7 @@
%typemap(in,noblock=1,fragment=frag) const Type & ($*ltype temp, Type val, int ecode = 0) {
ecode = asval_meth($input, &val);
if (!SWIG_IsOK(ecode)) {
%argument_fail(ecode, "$*ltype", $argnum);
%argument_fail(ecode, "$*ltype", $symname, $argnum);
}
temp = %static_cast(val, $*ltype);
$1 = &temp;

View file

@ -6,14 +6,14 @@
%typemap(in,noblock=1) void * {
if (!SWIG_IsOK((SWIG_ConvertPtr($input,%as_voidptrptr(&$1), 0, $disown)))) {
%argument_fail(SWIG_TypeError, "$type", $argnum);
%argument_fail(SWIG_TypeError, "$type", $symname, $argnum);
}
}
%typemap(freearg) void * "";
%typemap(in,noblock=1) void * const& ($*ltype temp) {
if (!SWIG_IsOK((SWIG_ConvertPtr($input, %as_voidptrptr(&temp), 0, $disown)))) {
%argument_fail(SWIG_TypeError, "Stype", $argnum);
%argument_fail(SWIG_TypeError, "Stype", $symname, $argnum);
}
$1 = &temp;
}