allow the result code to be passed to the error routine

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@8323 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2006-01-09 19:12:51 +00:00
commit 9e0c79bc1a
7 changed files with 189 additions and 147 deletions

View file

@ -30,9 +30,10 @@
%define Name ## _input_binary(TYPEMAP, SIZE)
%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)", $symname, $argnum);
(int res, Char *buf = 0, size_t size = 0, int alloc = 0) {
res = SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum);
}
$1 = ($1_ltype) buf;
$2 = ($2_ltype) size - 1;
@ -113,9 +114,10 @@
%define Name ## _bounded_mutable(TYPEMAP,MAX)
%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", $symname, $argnum);
(int res,Char temp[MAX+1], Char *t = 0, size_t n = 0, int alloc = 0) {
res = SWIG_AsCharPtrAndSize($input, &t, &n, &alloc);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "TYPEMAP", $symname, $argnum);
}
if ( n > (size_t) MAX ) n = (size_t) MAX;
memcpy(temp, t, sizeof(Char)*n);
@ -149,12 +151,13 @@
%define Name ## _mutable(TYPEMAP,EXP...)
%typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize) TYPEMAP
(Char* t = 0, size_t n = 0, int alloc = 0, size_t expansion = 0) {
(int res, Char* t = 0, size_t n = 0, int alloc = 0, size_t expansion = 0) {
#if #EXP != ""
expansion += EXP;
#endif
if (!SWIG_IsOK((SWIG_AsCharPtrAndSize($input, &t, &n, &alloc)))) {
%argument_fail(SWIG_TypeError, "TYPEMAP", $symname, $argnum);
res = SWIG_AsCharPtrAndSize($input, &t, &n, &alloc);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "TYPEMAP", $symname, $argnum);
}
$1 = %new_array(n+expansion, $*1_ltype);
memcpy($1,t,sizeof(Char)*n);
@ -181,9 +184,10 @@
*/
%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)", $symname, $argnum);
%typemap(in,noblock=1,fragment=SWIG_AsVal_frag(size_t)) (TYPEMAP, SIZE) (int res, size_t size, Char *buff = 0) {
res = SWIG_AsVal(size_t)($input, &size);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum);
}
buff= %new_array(size+1, Char);
$2 = %numeric_cast(size, $2_ltype);
@ -211,9 +215,10 @@
*/
%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)", $symname, $argnum);
%typemap(in,noblock=1,fragment=SWIG_AsVal_frag(size_t)) (TYPEMAP, SIZE) (int res, size_t n, Char *buff = 0, $*2_ltype size) {
res = SWIG_AsVal(size_t)($input, &n);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum);
}
buff= %new_array(n+1, Char);
$1 = %static_cast(buff, $1_ltype);

View file

@ -118,14 +118,14 @@ 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",$symname, $argnum);
%argument_fail(res,"$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",$symname, $argnum);
%argument_fail(res,"$type",$symname, $argnum);
}
if (!$1) {
%argument_nullref("$type",$symname, $argnum);

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", $symname, $argnum); }
if (!SWIG_IsOK(res) || !ptr) { %argument_fail(res, "$type", $symname, $argnum); }
$1 = *ptr;
if (SWIG_IsNewObj(res)) %delete(ptr);
}
@ -36,7 +36,7 @@
%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",$symname, $argnum); }
if (!SWIG_IsOK(res)) { %argument_fail(res,"$type",$symname, $argnum); }
if (!ptr) { %argument_nullref("$type",$symname, $argnum); }
$1 = ptr;
}
@ -51,7 +51,7 @@
%typemap(varin,fragment=frag) Type {
Type *ptr = (Type *)0;
int res = asptr_meth($input, &ptr);
if (!SWIG_IsOK(res) || !ptr) { %variable_fail(SWIG_TypeError, "$type", "$name"); }
if (!SWIG_IsOK(res) || !ptr) { %variable_fail(res, "$type", "$name"); }
$1 = *ptr;
if (SWIG_IsNewObj(res)) %delete(ptr);
}
@ -65,7 +65,7 @@
Type *optr = 0;
int ores = $input ? asptr_meth($input, &optr) : 0;
if (!SWIG_IsOK(ores) || !optr) {
%dirout_fail(SWIG_TypeError,"$type");
%dirout_fail(ores,"$type");
}
temp = *optr;
$result = &temp;
@ -76,7 +76,7 @@
Type *optr = 0;
int ores = asptr_meth($input, &optr);
if (!SWIG_IsOK(ores) || !optr) {
%dirout_fail(SWIG_TypeError,"$type");
%dirout_fail(ores,"$type");
}
$result = *optr;
if (SWIG_IsNewObj(ores)) %delete(optr);
@ -86,7 +86,7 @@
Type *optr = 0;
int ores = asptr_meth($input, &optr);
if (!SWIG_IsOK(ores)) {
%dirout_fail(SWIG_TypeError,"$type");
%dirout_fail(ores,"$type");
}
$result = optr;
if (SWIG_IsNewObj(ores)) {
@ -104,7 +104,7 @@
Type *optr = 0;
int ores = asptr_meth($input, &optr);
if (!SWIG_IsOK(ores)) {
%dirout_fail(SWIG_TypeError,"$type");
%dirout_fail(ores,"$type");
} else {
if (!optr) {
%dirout_nullref("$type");

View file

@ -29,10 +29,11 @@
/* in */
%typemap(in,noblock=1,fragment=#SWIG_AsCharPtr)
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",$symname, $argnum);
Char * (int res, Char *buf = 0, int alloc = 0),
const Char * (int res, Char *buf = 0, int alloc = 0) {
res = SWIG_AsCharPtr($input, &buf, &alloc);
if (!SWIG_IsOK(res)) {
%argument_fail(res,"$type",$symname, $argnum);
}
$1 = buf;
}
@ -40,9 +41,10 @@
if (alloc$argnum == SWIG_NEWOBJ) %delete_array(buf$argnum);
}
%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",$symname, $argnum);
%typemap(in,noblock=1,fragment=#SWIG_AsCharPtr) Char const*& (int res, Char *buf = 0, int alloc = 0) {
res = SWIG_AsCharPtr($input, &buf, &alloc);
if (!SWIG_IsOK(res)) {
%argument_fail(res,"$type",$symname, $argnum);
}
$1 = &temp;
}
@ -66,8 +68,9 @@
%typemap(varin,noblock=1,fragment=#SWIG_AsCharPtrAndSize) Char * {
Char *cptr = 0; size_t csize = 0; int alloc = SWIG_NEWOBJ;
if (!SWIG_IsOK((SWIG_AsCharPtrAndSize($input, &cptr, &csize, &alloc)))) {
%variable_fail(SWIG_TypeError,"$type","$name");
int res = SWIG_AsCharPtrAndSize($input, &cptr, &csize, &alloc);
if (!SWIG_IsOK(res)) {
%variable_fail(res,"$type","$name");
}
if ($1) %delete_array($1);
if (alloc == SWIG_NEWOBJ) {
@ -79,8 +82,9 @@
%typemap(varin,noblock=1,fragment=#SWIG_AsCharPtrAndSize,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) const Char * {
Char *cptr = 0; size_t csize = 0; int alloc = SWIG_NEWOBJ;
if (!SWIG_IsOK((SWIG_AsCharPtrAndSize($input, &cptr, &csize, &alloc)))) {
%variable_fail(SWIG_TypeError, "$type", "$name");
int res = SWIG_AsCharPtrAndSize($input, &cptr, &csize, &alloc);
if (!SWIG_IsOK(res)) {
%variable_fail(res, "$type", "$name");
}
if (alloc == SWIG_NEWOBJ) {
$1 = cptr;
@ -159,9 +163,10 @@
/* directorout */
%typemap(directorout,noblock=1,fragment=#SWIG_AsCharPtr,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG)
Char * (Char* buf = 0, int alloc = SWIG_NEWOBJ) {
if (!SWIG_IsOK((SWIG_AsCharPtr($input, &buf, &alloc)))) {
%dirout_fail(SWIG_TypeError, "$type");
Char * (int res, Char* buf = 0, int alloc = SWIG_NEWOBJ) {
res = SWIG_AsCharPtr($input, &buf, &alloc);
if (!SWIG_IsOK(res)) {
%dirout_fail(res, "$type");
}
if (alloc == SWIG_NEWOBJ) {
swig_acquire_ownership_array(buf);
@ -177,10 +182,11 @@
%typemap(directorout,noblock=1,fragment=#SWIG_AsCharPtr,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG)
Char * const& (Char* buf = 0, int alloc = SWIG_NEWOBJ),
Char const* const& (Char* buf = 0, int alloc = SWIG_NEWOBJ) {
if (!SWIG_IsOK((SWIG_AsCharPtr($input, &buf, &alloc)))) {
%dirout_fail(SWIG_TypeError, "$type");
Char * const& (int res, Char* buf = 0, int alloc = SWIG_NEWOBJ),
Char const* const& (int res, Char* buf = 0, int alloc = SWIG_NEWOBJ) {
res = SWIG_AsCharPtr($input, &buf, &alloc);
if (!SWIG_IsOK(res)) {
%dirout_fail(res, "$type");
}
static $*ltype tmp = buf;
$result = &tmp;
@ -247,20 +253,22 @@
/* in */
%typemap(in,noblock=1,fragment=#SWIG_AsCharArray)
Char [ANY] (Char temp[$1_dim0]),
const Char [ANY](Char temp[$1_dim0])
Char [ANY] (Char temp[$1_dim0], int res),
const Char [ANY](Char temp[$1_dim0], int res)
{
if (!SWIG_IsOK((SWIG_AsCharArray($input, temp, $1_dim0)))) {
%argument_fail(SWIG_TypeError,"$type",$symname, $argnum);
res = SWIG_AsCharArray($input, temp, $1_dim0);
if (!SWIG_IsOK(res)) {
%argument_fail(res,"$type",$symname, $argnum);
}
$1 = temp;
}
%typemap(freearg) Char [ANY], const Char [ANY] "";
%typemap(in,noblock=1,fragment=#SWIG_AsCharArray) const Char (&)[ANY] (Char temp[$1_dim0])
%typemap(in,noblock=1,fragment=#SWIG_AsCharArray) const Char (&)[ANY] (Char temp[$1_dim0], int res)
{
if (!SWIG_IsOK((SWIG_AsCharArray($input, temp, $1_dim0)))) {
%argument_fail(SWIG_TypeError,"$type",$symname, $argnum);
res = SWIG_AsCharArray($input, temp, $1_dim0);
if (!SWIG_IsOK(res)) {
%argument_fail(res,"$type",$symname, $argnum);
}
$1 = &temp;
}
@ -280,8 +288,9 @@
%typemap(varin,noblock=1,fragment=#SWIG_AsCharArray) Char [ANY]
{
if (!SWIG_IsOK((SWIG_AsCharArray($input, $1, $1_dim0)))) {
%variable_fail(SWIG_TypeError, "$type", "$name");
int res = SWIG_AsCharArray($input, $1, $1_dim0);
if (!SWIG_IsOK(res)) {
%variable_fail(res, "$type", "$name");
}
}
@ -326,10 +335,11 @@
%typemap(directorout,noblock=1,fragment=#SWIG_AsCharArray)
Char [ANY] (Char temp[$result_dim0]),
const Char [ANY] (Char temp[$result_dim0])
const Char [ANY] (Char temp[$result_dim0], int res)
{
if (!SWIG_IsOK((SWIG_AsCharArray($input, temp, $result_dim0)))) {
%dirout_fail(SWIG_TypeError, "$type");
res = SWIG_AsCharArray($input, temp, $result_dim0);
if (!SWIG_IsOK(res)) {
%dirout_fail(res, "$type");
}
$result = temp;
}
@ -395,11 +405,12 @@
/* Here len doesn't include the '0' terminator */
%typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize)
(Char *STRING, size_t LENGTH) (Char *buf = 0, size_t size = 0, int alloc = 0),
(const Char *STRING, size_t LENGTH) (Char *buf = 0, size_t size = 0, int alloc = 0)
(Char *STRING, size_t LENGTH) (int res, Char *buf = 0, size_t size = 0, int alloc = 0),
(const Char *STRING, size_t LENGTH) (int res, Char *buf = 0, size_t size = 0, int alloc = 0)
{
if (!SWIG_IsOK((SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc)))) {
%argument_fail(SWIG_TypeError,"$type",$symname, $argnum);
res = SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc);
if (!SWIG_IsOK(res)) {
%argument_fail(res,"$type",$symname, $argnum);
}
$1 = %static_cast(buf, $1_ltype);
$2 = %numeric_cast(size - 1, $2_ltype);
@ -414,11 +425,12 @@
/* Here size includes the '0' terminator */
%typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize)
(Char *STRING, size_t SIZE) (Char *buf = 0, size_t size = 0, int alloc = 0),
(const Char *STRING, size_t SIZE) (Char *buf = 0, size_t size = 0, int alloc = 0)
(Char *STRING, size_t SIZE) (int res, Char *buf = 0, size_t size = 0, int alloc = 0),
(const Char *STRING, size_t SIZE) (int res, Char *buf = 0, size_t size = 0, int alloc = 0)
{
if (!SWIG_IsOK((SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc)))) {
%argument_fail(SWIG_TypeError,"$type",$symname, $argnum);
res = SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc);
if (!SWIG_IsOK(res)) {
%argument_fail(res,"$type",$symname, $argnum);
}
$1 = %static_cast(buf, $1_ltype);
$2 = %numeric_cast(size, $2_ltype);
@ -435,11 +447,12 @@
/* Here len doesn't include the '0' terminator */
%typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize)
(size_t LENGTH, Char *STRING) (Char *buf = 0, size_t size = 0, int alloc = 0),
(size_t LENGHT, const Char *STRING) (Char *buf = 0, size_t size = 0, int alloc = 0)
(size_t LENGTH, Char *STRING) (int res, Char *buf = 0, size_t size = 0, int alloc = 0),
(size_t LENGHT, const Char *STRING) (int res, Char *buf = 0, size_t size = 0, int alloc = 0)
{
if (!SWIG_IsOK((SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc)))) {
%argument_fail(SWIG_TypeError,"$type",$symname, $argnum);
res = SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc);
if (!SWIG_IsOK(res)) {
%argument_fail(res,"$type",$symname, $argnum);
}
$2 = %static_cast(buf, $2_ltype) ;
$1 = %numeric_cast(size - 1, $1_ltype) ;
@ -453,11 +466,12 @@
/* Here size includes the '0' terminator */
%typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize)
(size_t SIZE, Char *STRING) (Char *buf = 0, size_t size = 0, int alloc = 0),
(size_t SIZE, const Char *STRING) (Char *buf = 0, size_t size = 0, int alloc = 0)
(size_t SIZE, Char *STRING) (int res, Char *buf = 0, size_t size = 0, int alloc = 0),
(size_t SIZE, const Char *STRING) (int res, Char *buf = 0, size_t size = 0, int alloc = 0)
{
if (!SWIG_IsOK((SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc)))) {
%argument_fail(SWIG_TypeError, "$type",$symname, $argnum);
res = SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type",$symname, $argnum);
}
$2 = %static_cast(buf, $2_ltype) ;
$1 = %numeric_cast(size, $1_ltype) ;

View file

@ -1,28 +1,30 @@
/* -----------------------------------------------------------------------------
* --- Input arguments ---
* ----------------------------------------------------------------------------- */
/* 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", $symname, $argnum);
%typemap(in, noblock=1) SWIGTYPE *(void *argp = 0, int res) {
res = SWIG_ConvertPtr($input, &argp,$descriptor, $disown | %convertptr_flags);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
}
$1 = %reinterpret_cast(argp, $ltype);
}
%typemap(freearg) SWIGTYPE * "";
%typemap(in, noblock=1) SWIGTYPE [] (void *argp = 0) {
if (!SWIG_IsOK((SWIG_ConvertPtr($input, &argp,$descriptor, $disown | %convertptr_flags)))) {
%argument_fail(SWIG_TypeError, "$type", $symname, $argnum);
%typemap(in, noblock=1) SWIGTYPE [] (void *argp = 0, int res) {
res = SWIG_ConvertPtr($input, &argp,$descriptor, $disown | %convertptr_flags);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
}
$1 = %reinterpret_cast(argp, $ltype);
}
%typemap(freearg) SWIGTYPE [] "";
%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", $symname, $argnum);
%typemap(in, noblock=1) SWIGTYPE* const& (void *argp = 0, int res, $*ltype temp) {
res = SWIG_ConvertPtr($input, &argp, $*descriptor, $disown | %convertptr_flags);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$*ltype", $symname, $argnum);
}
temp = %reinterpret_cast(argp, $*ltype);
$1 = &temp;
@ -31,9 +33,10 @@
/* Reference */
%typemap(in, noblock=1) SWIGTYPE & (void *argp = 0) {
if (!SWIG_IsOK((SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags)))) {
%argument_fail(SWIG_TypeError, "$type", $symname, $argnum);
%typemap(in, noblock=1) SWIGTYPE & (void *argp = 0, int res) {
res = SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
}
if (!argp) { %argument_nullref("$type", $symname, $argnum); }
$1 = %reinterpret_cast(argp, $ltype);
@ -44,7 +47,7 @@
%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", $symname, $argnum);
%argument_fail(res, "$type", $symname, $argnum);
}
if (!argp) { %argument_nullref("$type", $symname, $argnum); }
$1 = %reinterpret_cast(argp, $ltype);
@ -54,9 +57,10 @@
if (SWIG_IsNewObj(res$argnum)) %delete($1);
}
#else
%typemap(in,noblock=1) const SWIGTYPE & (void *argp) {
if (!SWIG_IsOK((SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags)))) {
%argument_fail(SWIG_TypeError, "$type", $symname, $argnum);
%typemap(in,noblock=1) const SWIGTYPE & (void *argp, int res) {
res = SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
}
if (!argp) { %argument_nullref("$type", $symname, $argnum); }
$1 = %reinterpret_cast(argp, $ltype);
@ -69,7 +73,7 @@
void *argp;
int res = SWIG_ConvertPtr($input, &argp, $&descriptor, %convertptr_flags | %implicitconv_flag);
if (!SWIG_IsOK(res)) {
%argument_fail(SWIG_TypeError, "$type", $symname, $argnum);
%argument_fail(res, "$type", $symname, $argnum);
}
if (!argp) {
%argument_nullref("$type", $symname, $argnum);
@ -83,8 +87,9 @@
%typemap(in) SWIGTYPE {
void *argp;
$&ltype temp;
if (!SWIG_IsOK((SWIG_ConvertPtr($input, &argp, $&descriptor, %convertptr_flags)))) {
%argument_fail(SWIG_TypeError, "$type", $symname, $argnum);
int res = SWIG_ConvertPtr($input, &argp, $&descriptor, %convertptr_flags);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
}
if (!argp) {
%argument_nullref("$type", $symname, $argnum);
@ -141,7 +146,7 @@
$basetype *inp = 0;
int res = SWIG_ConvertPtr($input, %as_voidptrptr(&inp), $descriptor, %convertptr_flags);
if (!SWIG_IsOK(res)) {
%variable_fail(SWIG_TypeError, "$type", "$name");
%variable_fail(res, "$type", "$name");
} else if (inp) {
size_t ii = 0;
for (; ii < (size_t)$dim0; ++ii) $1[ii] = inp[ii];
@ -189,7 +194,7 @@
$basetype (*inp)[$dim1] = 0;
int res = SWIG_ConvertPtr($input, %as_voidptrptr(&inp), $descriptor, %convertptr_flags);
if (!SWIG_IsOK(res)) {
%variable_fail(SWIG_TypeError, "$type", "$name");
%variable_fail(res, "$type", "$name");
} else if (inp) {
size_t ii = 0;
for (; ii < (size_t)$dim0; ++ii) {
@ -211,7 +216,7 @@
void *argp = 0;
int res = SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags);
if (!SWIG_IsOK(res)) {
%variable_fail(SWIG_TypeError, "$type", "$name");
%variable_fail(res, "$type", "$name");
}
$1 = %reinterpret_cast(argp, $ltype);
}
@ -225,7 +230,7 @@
void *argp = 0;
int res = SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags);
if (!SWIG_IsOK(res)) {
%variable_fail(SWIG_TypeError, "$type", "$name");
%variable_fail(res, "$type", "$name");
}
if (!argp) {
%variable_nullref("$type", "$name");
@ -238,7 +243,7 @@
void *argp = 0;
int res = SWIG_ConvertPtr($input, &argp, $&descriptor, %convertptr_flags | %implicitconv_flag);
if (!SWIG_IsOK(res)) {
%variable_fail(SWIG_TypeError, "$type", "$name");
%variable_fail(res, "$type", "$name");
}
if (!argp) {
%variable_nullref("$type", "$name");
@ -252,8 +257,9 @@
#else
%typemap(varin,noblock=1) SWIGTYPE {
void *argp = 0;
if (!SWIG_IsOK((SWIG_ConvertPtr($input, &argp, $&descriptor, %convertptr_flags)))) {
%variable_fail(SWIG_TypeError, "$type", "$name");
int res = SWIG_ConvertPtr($input, &argp, $&descriptor, %convertptr_flags);
if (!SWIG_IsOK(res)) {
%variable_fail(res, "$type", "$name");
}
if (!argp) {
%variable_nullref("$type", "$name");
@ -351,24 +357,26 @@
%typemap(directorout,noblock=1,implicitconv=1) SWIGTYPE (void * argp, int res) {
res = SWIG_ConvertPtr($input,&argp,$&descriptor, %convertptr_flags | %implicitconv_flag);
if (!SWIG_IsOK(res)) {
%dirout_fail(SWIG_TypeError,"$type");
%dirout_fail(res,"$type");
}
$result = *(%reinterpret_cast(argp, $&ltype));
if (SWIG_IsNewObj(res)) %delete(%reinterpret_cast(argp, $&ltype));
}
#else
%typemap(directorout,noblock=1) SWIGTYPE (void * argp) {
if (!SWIG_IsOK((SWIG_ConvertPtr($input,&argp,$&descriptor, %convertptr_flags)))) {
%dirout_fail(SWIG_TypeError,"$type");
%typemap(directorout,noblock=1) SWIGTYPE (void * argp, int res) {
res = SWIG_ConvertPtr($input,&argp,$&descriptor, %convertptr_flags);
if (!SWIG_IsOK(res)) {
%dirout_fail(res,"$type");
}
$result = *(%reinterpret_cast(argp, $&ltype));
}
#endif
%typemap(directorout,noblock=1,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG)
SWIGTYPE *(void *argp, swig_owntype own) {
if (!SWIG_IsOK((SWIG_ConvertPtrAndOwn($input, &argp, $descriptor, %convertptr_flags | SWIG_POINTER_DISOWN, &own)))) {
%dirout_fail(SWIG_TypeError,"$type");
SWIGTYPE *(void *argp, int res, swig_owntype own) {
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor, %convertptr_flags | SWIG_POINTER_DISOWN, &own);
if (!SWIG_IsOK(res)) {
%dirout_fail(res,"$type");
}
$result = %reinterpret_cast(argp, $ltype);
swig_acquire_ownership_obj(%as_voidptr($result), own);
@ -380,9 +388,10 @@
}
%typemap(directorout,noblock=1,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG)
SWIGTYPE &(void *argp, swig_owntype own) {
if (!SWIG_IsOK((SWIG_ConvertPtrAndOwn($input, &argp, $descriptor, %convertptr_flags | SWIG_POINTER_DISOWN, &own)))) {
%dirout_fail(SWIG_TypeError,"$type");
SWIGTYPE &(void *argp, int res, swig_owntype own) {
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor, %convertptr_flags | SWIG_POINTER_DISOWN, &own);
if (!SWIG_IsOK(res)) {
%dirout_fail(res,"$type");
}
if (!argp) { %dirout_nullref("$type"); }
$result = %reinterpret_cast(argp, $ltype);
@ -433,9 +442,10 @@
* --- CLASS::* typemaps ---
* ------------------------------------------------------------ */
%typemap(in,noblock=1) SWIGTYPE (CLASS::*) {
if (!SWIG_IsOK((SWIG_ConvertMember($input, %as_voidptr(&$1), sizeof($type),$descriptor)))) {
%argument_fail(SWIG_TypeError,"$type",$symname, $argnum);
%typemap(in) SWIGTYPE (CLASS::*) {
int res = SWIG_ConvertMember($input, %as_voidptr(&$1), sizeof($type),$descriptor);
if (!SWIG_IsOK(res)) {
%argument_fail(res,"$type",$symname, $argnum);
}
}
@ -443,9 +453,10 @@
%set_output(SWIG_NewMemberObj(%as_voidptr(&$1), sizeof($type), $descriptor));
}
%typemap(varin,noblock=1) SWIGTYPE (CLASS::*) {
if (!SWIG_IsOK((SWIG_ConvertMember($input,%as_voidptr(&$1), sizeof($type), $descriptor)))) {
%variable_fail(SWIG_TypeError, "$type", "$name");
%typemap(varin) SWIGTYPE (CLASS::*) {
int res = SWIG_ConvertMember($input,%as_voidptr(&$1), sizeof($type), $descriptor);
if (!SWIG_IsOK(res)) {
%variable_fail(res, "$type", "$name");
}
}
@ -467,9 +478,10 @@
/* directorout */
%typemap(directorout,noblock=1) SWIGTYPE (CLASS::*) {
if (!SWIG_IsOK((SWIG_ConvertMember($input,%as_voidptr(&$result), sizeof($type), $descriptor)))) {
%dirout_fail(SWIG_TypeError,"$type");
%typemap(directorout) SWIGTYPE (CLASS::*) {
int res = SWIG_ConvertMember($input,%as_voidptr(&$result), sizeof($type), $descriptor);
if (!SWIG_IsOK(res)) {
%dirout_fail(res,"$type");
}
$result = %reinterpret_cast(argp, $ltype);
}
@ -484,9 +496,10 @@
ptr. So, maybe the ptr sizes are not the same, and we need to take
some providences.
*/
%typemap(in, noblock=1) SWIGTYPE ((*)(ANY)) {
if (!SWIG_IsOK((SWIG_ConvertFunctionPtr($input, (void**)(&$1), $descriptor)))) {
%argument_fail(SWIG_TypeError,"$type",$symname, $argnum);
%typemap(in) SWIGTYPE ((*)(ANY)) {
int res = SWIG_ConvertFunctionPtr($input, (void**)(&$1), $descriptor);
if (!SWIG_IsOK(res)) {
%argument_fail(res,"$type",$symname, $argnum);
}
}
@ -501,9 +514,10 @@
%set_output(SWIG_NewFunctionPtrObj((void *)($1), $descriptor));
}
%typemap(varin,noblock=1) SWIGTYPE ((*)(ANY)) {
if (!SWIG_IsOK((SWIG_ConvertFunctionPtr($input, (void**)(&$1), $descriptor)))) {
%variable_fail(SWIG_TypeError, "$type", "$name");
%typemap(varin) SWIGTYPE ((*)(ANY)) {
int res = SWIG_ConvertFunctionPtr($input, (void**)(&$1), $descriptor);
if (!SWIG_IsOK(res)) {
%variable_fail(res, "$type", "$name");
}
}
@ -525,9 +539,10 @@
/* directorout */
%typemap(directorout,noblock=1) SWIGTYPE ((*)(ANY)) {
if (!SWIG_IsOK((SWIG_ConvertFunctionPtr($input,(void**)(&$result),$descriptor)))) {
%dirout_fail(SWIG_TypeError,"$type");
%typemap(directorout) SWIGTYPE ((*)(ANY)) {
int res = SWIG_ConvertFunctionPtr($input,(void**)(&$result),$descriptor);
if (!SWIG_IsOK(res)) {
%dirout_fail(res,"$type");
}
}
#endif
@ -544,16 +559,18 @@
/* DISOWN typemap */
%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", $symname, $argnum);
%typemap(in, noblock=1) SWIGTYPE *DISOWN (int res) {
res = SWIG_ConvertPtr($input, %as_voidptrptr(&$1), $descriptor, SWIG_POINTER_DISOWN | %convertptr_flags);
if (!SWIG_IsOK(res)) {
%argument_fail(res,"$type", $symname, $argnum);
}
}
%typemap(varin,noblock=1) SWIGTYPE *DISOWN {
void *temp = 0;
if (!SWIG_IsOK((SWIG_ConvertPtr($input, &temp, $descriptor, SWIG_POINTER_DISOWN | %convertptr_flags)))) {
%variable_fail(SWIG_TypeError, "$type", "$name");
int res = SWIG_ConvertPtr($input, &temp, $descriptor, SWIG_POINTER_DISOWN | %convertptr_flags);
if (!SWIG_IsOK(res)) {
%variable_fail(res, "$type", "$name");
}
$1 = ($ltype) temp;
}

View file

@ -132,13 +132,14 @@
* ----------------------------------------------------------------------------- */
#define %error_block(Block...) %block(Block)
#define %argument_fail(code, type, name, argn) SWIG_exception(code, %argfail_fmt(type, name, argn))
#define %default_code(code) ((code != SWIG_ERROR) ? code : SWIG_TypeError)
#define %argument_fail(code, type, name, argn) SWIG_exception(%default_code(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_fail(code, type, name) SWIG_exception(%default_code(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))
#define %dirout_fail(code, type) SWIG_DirOutFail(%default_code(code), %outfail_fmt(type))
#define %dirout_nullref(type) SWIG_DirOutFail(SWIG_ValueError, %outnullref_fmt(type))
#endif

View file

@ -4,16 +4,18 @@
/* in */
%typemap(in,noblock=1) void * {
if (!SWIG_IsOK((SWIG_ConvertPtr($input,%as_voidptrptr(&$1), 0, $disown)))) {
%argument_fail(SWIG_TypeError, "$type", $symname, $argnum);
%typemap(in,noblock=1) void * (int res) {
res = SWIG_ConvertPtr($input,%as_voidptrptr(&$1), 0, $disown);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$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", $symname, $argnum);
%typemap(in,noblock=1) void * const& ($*ltype temp, int res) {
res = SWIG_ConvertPtr($input, %as_voidptrptr(&temp), 0, $disown);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "Stype", $symname, $argnum);
}
$1 = &temp;
}
@ -32,8 +34,9 @@
%typemap(varin,noblock=1) void * {
void *temp = 0;
if (!SWIG_IsOK((SWIG_ConvertPtr($input, &temp, 0, SWIG_POINTER_DISOWN)))) {
%variable_fail(SWIG_TypeError, "$type", "$name");
int res = SWIG_ConvertPtr($input, &temp, 0, SWIG_POINTER_DISOWN);
if (!SWIG_IsOK(res)) {
%variable_fail(res, "$type", "$name");
}
$1 = ($1_ltype) temp;
}
@ -58,16 +61,18 @@
/* directorout */
%typemap(directorout,noblock=1) void * (void *argp) {
if (!SWIG_IsOK((SWIG_ConvertPtr($input, &argp, 0, 0)))) {
%dirout_fail(SWIG_TypeError,"$type");
%typemap(directorout,noblock=1) void * (void *argp, int res) {
res = SWIG_ConvertPtr($input, &argp, 0, 0);
if (!SWIG_IsOK(res)) {
%dirout_fail(res,"$type");
}
$result = %reinterpret_cast(argp, $ltype);
}
%typemap(directorout,noblock=1,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) void * const& (void *argp) {
if (!SWIG_IsOK((SWIG_ConvertPtr($input, &argp, 0, $disown)))) {
%dirout_fail(SWIG_TypeError,"$type");
%typemap(directorout,noblock=1,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) void * const& (void *argp, int res) {
res = SWIG_ConvertPtr($input, &argp, 0, $disown);
if (!SWIG_IsOK(res)) {
%dirout_fail(res,"$type");
}
static $*ltype temp = %reinterpret_cast(argp, $*ltype);
$result = &temp;