fix for the typemap match option

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8108 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2005-12-28 07:52:55 +00:00
commit 88e6edcac3
7 changed files with 71 additions and 16 deletions

View file

@ -37,7 +37,7 @@
$1 = ($1_ltype) buf;
$2 = ($2_ltype) size - 1;
}
%typemap(freearg,noblock=1) (TYPEMAP, SIZE) {
%typemap(freearg,noblock=1,match="in") (TYPEMAP, SIZE) {
if (alloc$argnum == SWIG_NEWOBJ) %delete_array(buf$argnum);
}
%enddef
@ -61,6 +61,7 @@
%typemap(in,noblock=1,numinputs=0) TYPEMAP (Char temp[MAX+1]) {
$1 = ($1_ltype) temp;
}
%typemap(freearg,match="in") TYPEMAP "";
%typemap(argout,noblock=1,fragment= #SWIG_FromCharPtr ) TYPEMAP {
$1[MAX] = 0;
%append_output(SWIG_FromCharPtr($1));
@ -86,6 +87,7 @@
%typemap(in,noblock=1,numinputs=0) TYPEMAP(Char temp[SIZE]) {
$1 = ($1_ltype) temp;
}
%typemap(freearg,match="in") TYPEMAP "";
%typemap(argout,noblock=1,fragment= #SWIG_FromCharPtrAndSize) TYPEMAP {
%append_output(SWIG_FromCharPtrAndSize($1,SIZE));
}
@ -121,6 +123,7 @@
temp[n - 1] = 0;
$1 = ($1_ltype) temp;
}
%typemap(freearg,match="in") TYPEMAP "";
%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtr) TYPEMAP {
$1[MAX] = 0;
%append_output(SWIG_FromCharPtr($1));
@ -158,6 +161,7 @@
if (alloc == SWIG_NEWOBJ) %delete_array(t);
$1[n-1] = 0;
}
%typemap(freearg,match="in") TYPEMAP "";
%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtr) TYPEMAP {
%append_output(SWIG_FromCharPtr($1));
%delete_array($1);
@ -185,7 +189,7 @@
$2 = %numeric_cast(size, $2_ltype);
$1 = %static_cast(buff,$1_ltype);
}
%typemap(freearg,noblock=1) (TYPEMAP,SIZE) {
%typemap(freearg,noblock=1,match="in") (TYPEMAP,SIZE) {
if (buff$argnum) %delete_array(buff$argnum);
}
%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtr) (TYPEMAP,SIZE) {
@ -216,7 +220,7 @@
size = %numeric_cast(n,$*2_ltype);
$2 = &size;
}
%typemap(freearg,noblock=1)(TYPEMAP,SIZE) {
%typemap(freearg,noblock=1,match="in")(TYPEMAP,SIZE) {
if (buff$argnum) %delete_array(buff$argnum);
}
%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtrAndSize) (TYPEMAP,SIZE) {
@ -242,6 +246,7 @@
%typemap(in,noblock=1,numinputs=0) TYPEMAP($*1_ltype temp = 0) {
$1 = &temp;
}
%typemap(freearg,match="in") TYPEMAP "";
%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtr) TYPEMAP {
if (*$1) {
%append_output(SWIG_FromCharPtr(*$1));
@ -269,6 +274,7 @@
%typemap(in,noblock=1,numinputs=0) (TYPEMAP, SIZE) ($*1_ltype temp = 0, $*2_ltype tempn) {
$1 = &temp; $2 = &tempn;
}
%typemap(freearg,match="in") (TYPEMAP,SIZE) "";
%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtrAndSize)(TYPEMAP,SIZE) {
if (*$1) {
%append_output(SWIG_FromCharPtrAndSize(*$1,*$2));

View file

@ -422,7 +422,7 @@
$1 = %static_cast(buf, $1_ltype);
$2 = %numeric_cast(size, $2_ltype);
}
%typemap(freearg, noblock=1,match="in") (Char *STRING, size_t SIZE) {
%typemap(freearg,noblock=1,match="in") (Char *STRING, size_t SIZE) {
if (alloc$argnum == SWIG_NEWOBJ) %delete_array(buf$argnum);
}
/* old 'int' form */

View file

@ -9,6 +9,7 @@
}
$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))) {
@ -16,6 +17,7 @@
}
$1 = %reinterpret_cast(argp, $ltype);
}
%typemap(freearg) SWIGTYPE [] "";
%typemap(in, noblock=1) SWIGTYPE* const& (void *argp = 0, $*ltype temp) {
@ -25,6 +27,7 @@
temp = %reinterpret_cast(argp, $*ltype);
$1 = &temp;
}
%typemap(freearg) SWIGTYPE* const& "";
/* Reference */
@ -35,8 +38,10 @@
if (!argp) { %argument_nullref("$type", $argnum); }
$1 = %reinterpret_cast(argp, $ltype);
}
%typemap(freearg) SWIGTYPE & "";
#if defined(__cplusplus) && defined(%implicitconv_flag)
%typemap(in, noblock=1,implicitconv=1) const SWIGTYPE & (void *argp = 0, int res) {
%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);
@ -44,7 +49,7 @@
if (!argp) { %argument_nullref("$type", $argnum); }
$1 = %reinterpret_cast(argp, $ltype);
}
%typemap(freearg,noblock=1,match="in") const SWIGTYPE &
%typemap(freearg,noblock=1,match="in",implicitconv=1) const SWIGTYPE &
{
if (SWIG_IsNewObj(res$argnum)) %delete($1);
}
@ -87,6 +92,7 @@
$1 = *(%reinterpret_cast(argp, $&ltype));
}
}
%typemap(freearg) SWIGTYPE "";
#endif
/* -----------------------------------------------------------------------------