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:
parent
c524ada254
commit
88e6edcac3
7 changed files with 71 additions and 16 deletions
|
|
@ -299,7 +299,11 @@ Version 1.3.28 (unreleased).
|
||||||
entire test-suite compiles fine with and without the
|
entire test-suite compiles fine with and without the
|
||||||
castmode.
|
castmode.
|
||||||
|
|
||||||
Note2: the castmode disables the -fatdispatch option.
|
Note2: the cast mode can't be comnined with the fast
|
||||||
|
dispatch mode, ie, the -fastdispatch option has no effect
|
||||||
|
when the cast mode is selected. The penalties, however,
|
||||||
|
are minimum since the cast dispatch code is already based
|
||||||
|
in the same fast dispatch mechanism.
|
||||||
|
|
||||||
See the file overload_dispatch_cast_runme.py file for
|
See the file overload_dispatch_cast_runme.py file for
|
||||||
new cases and examples.
|
new cases and examples.
|
||||||
|
|
|
||||||
|
|
@ -189,7 +189,7 @@ typedef struct {
|
||||||
int implicitconv;
|
int implicitconv;
|
||||||
} PySwigClientData;
|
} PySwigClientData;
|
||||||
|
|
||||||
SWIGRUNTIME int
|
SWIGRUNTIMEINLINE int
|
||||||
SWIG_Python_CheckImplicit(swig_type_info *ty)
|
SWIG_Python_CheckImplicit(swig_type_info *ty)
|
||||||
{
|
{
|
||||||
PySwigClientData *data = (PySwigClientData *)ty->clientdata;
|
PySwigClientData *data = (PySwigClientData *)ty->clientdata;
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
$1 = ($1_ltype) buf;
|
$1 = ($1_ltype) buf;
|
||||||
$2 = ($2_ltype) size - 1;
|
$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);
|
if (alloc$argnum == SWIG_NEWOBJ) %delete_array(buf$argnum);
|
||||||
}
|
}
|
||||||
%enddef
|
%enddef
|
||||||
|
|
@ -61,6 +61,7 @@
|
||||||
%typemap(in,noblock=1,numinputs=0) TYPEMAP (Char temp[MAX+1]) {
|
%typemap(in,noblock=1,numinputs=0) TYPEMAP (Char temp[MAX+1]) {
|
||||||
$1 = ($1_ltype) temp;
|
$1 = ($1_ltype) temp;
|
||||||
}
|
}
|
||||||
|
%typemap(freearg,match="in") TYPEMAP "";
|
||||||
%typemap(argout,noblock=1,fragment= #SWIG_FromCharPtr ) TYPEMAP {
|
%typemap(argout,noblock=1,fragment= #SWIG_FromCharPtr ) TYPEMAP {
|
||||||
$1[MAX] = 0;
|
$1[MAX] = 0;
|
||||||
%append_output(SWIG_FromCharPtr($1));
|
%append_output(SWIG_FromCharPtr($1));
|
||||||
|
|
@ -86,6 +87,7 @@
|
||||||
%typemap(in,noblock=1,numinputs=0) TYPEMAP(Char temp[SIZE]) {
|
%typemap(in,noblock=1,numinputs=0) TYPEMAP(Char temp[SIZE]) {
|
||||||
$1 = ($1_ltype) temp;
|
$1 = ($1_ltype) temp;
|
||||||
}
|
}
|
||||||
|
%typemap(freearg,match="in") TYPEMAP "";
|
||||||
%typemap(argout,noblock=1,fragment= #SWIG_FromCharPtrAndSize) TYPEMAP {
|
%typemap(argout,noblock=1,fragment= #SWIG_FromCharPtrAndSize) TYPEMAP {
|
||||||
%append_output(SWIG_FromCharPtrAndSize($1,SIZE));
|
%append_output(SWIG_FromCharPtrAndSize($1,SIZE));
|
||||||
}
|
}
|
||||||
|
|
@ -121,6 +123,7 @@
|
||||||
temp[n - 1] = 0;
|
temp[n - 1] = 0;
|
||||||
$1 = ($1_ltype) temp;
|
$1 = ($1_ltype) temp;
|
||||||
}
|
}
|
||||||
|
%typemap(freearg,match="in") TYPEMAP "";
|
||||||
%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtr) TYPEMAP {
|
%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtr) TYPEMAP {
|
||||||
$1[MAX] = 0;
|
$1[MAX] = 0;
|
||||||
%append_output(SWIG_FromCharPtr($1));
|
%append_output(SWIG_FromCharPtr($1));
|
||||||
|
|
@ -158,6 +161,7 @@
|
||||||
if (alloc == SWIG_NEWOBJ) %delete_array(t);
|
if (alloc == SWIG_NEWOBJ) %delete_array(t);
|
||||||
$1[n-1] = 0;
|
$1[n-1] = 0;
|
||||||
}
|
}
|
||||||
|
%typemap(freearg,match="in") TYPEMAP "";
|
||||||
%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtr) TYPEMAP {
|
%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtr) TYPEMAP {
|
||||||
%append_output(SWIG_FromCharPtr($1));
|
%append_output(SWIG_FromCharPtr($1));
|
||||||
%delete_array($1);
|
%delete_array($1);
|
||||||
|
|
@ -185,7 +189,7 @@
|
||||||
$2 = %numeric_cast(size, $2_ltype);
|
$2 = %numeric_cast(size, $2_ltype);
|
||||||
$1 = %static_cast(buff,$1_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);
|
if (buff$argnum) %delete_array(buff$argnum);
|
||||||
}
|
}
|
||||||
%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtr) (TYPEMAP,SIZE) {
|
%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtr) (TYPEMAP,SIZE) {
|
||||||
|
|
@ -216,7 +220,7 @@
|
||||||
size = %numeric_cast(n,$*2_ltype);
|
size = %numeric_cast(n,$*2_ltype);
|
||||||
$2 = &size;
|
$2 = &size;
|
||||||
}
|
}
|
||||||
%typemap(freearg,noblock=1)(TYPEMAP,SIZE) {
|
%typemap(freearg,noblock=1,match="in")(TYPEMAP,SIZE) {
|
||||||
if (buff$argnum) %delete_array(buff$argnum);
|
if (buff$argnum) %delete_array(buff$argnum);
|
||||||
}
|
}
|
||||||
%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtrAndSize) (TYPEMAP,SIZE) {
|
%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtrAndSize) (TYPEMAP,SIZE) {
|
||||||
|
|
@ -242,6 +246,7 @@
|
||||||
%typemap(in,noblock=1,numinputs=0) TYPEMAP($*1_ltype temp = 0) {
|
%typemap(in,noblock=1,numinputs=0) TYPEMAP($*1_ltype temp = 0) {
|
||||||
$1 = &temp;
|
$1 = &temp;
|
||||||
}
|
}
|
||||||
|
%typemap(freearg,match="in") TYPEMAP "";
|
||||||
%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtr) TYPEMAP {
|
%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtr) TYPEMAP {
|
||||||
if (*$1) {
|
if (*$1) {
|
||||||
%append_output(SWIG_FromCharPtr(*$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) {
|
%typemap(in,noblock=1,numinputs=0) (TYPEMAP, SIZE) ($*1_ltype temp = 0, $*2_ltype tempn) {
|
||||||
$1 = &temp; $2 = &tempn;
|
$1 = &temp; $2 = &tempn;
|
||||||
}
|
}
|
||||||
|
%typemap(freearg,match="in") (TYPEMAP,SIZE) "";
|
||||||
%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtrAndSize)(TYPEMAP,SIZE) {
|
%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtrAndSize)(TYPEMAP,SIZE) {
|
||||||
if (*$1) {
|
if (*$1) {
|
||||||
%append_output(SWIG_FromCharPtrAndSize(*$1,*$2));
|
%append_output(SWIG_FromCharPtrAndSize(*$1,*$2));
|
||||||
|
|
|
||||||
|
|
@ -422,7 +422,7 @@
|
||||||
$1 = %static_cast(buf, $1_ltype);
|
$1 = %static_cast(buf, $1_ltype);
|
||||||
$2 = %numeric_cast(size, $2_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);
|
if (alloc$argnum == SWIG_NEWOBJ) %delete_array(buf$argnum);
|
||||||
}
|
}
|
||||||
/* old 'int' form */
|
/* old 'int' form */
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
}
|
}
|
||||||
$1 = %reinterpret_cast(argp, $ltype);
|
$1 = %reinterpret_cast(argp, $ltype);
|
||||||
}
|
}
|
||||||
|
%typemap(freearg) SWIGTYPE * "";
|
||||||
|
|
||||||
%typemap(in, noblock=1) SWIGTYPE [] (void *argp = 0) {
|
%typemap(in, noblock=1) SWIGTYPE [] (void *argp = 0) {
|
||||||
if (!SWIG_IsOK(SWIG_ConvertPtr($input, &argp,$descriptor, $disown | %convertptr_flags))) {
|
if (!SWIG_IsOK(SWIG_ConvertPtr($input, &argp,$descriptor, $disown | %convertptr_flags))) {
|
||||||
|
|
@ -16,6 +17,7 @@
|
||||||
}
|
}
|
||||||
$1 = %reinterpret_cast(argp, $ltype);
|
$1 = %reinterpret_cast(argp, $ltype);
|
||||||
}
|
}
|
||||||
|
%typemap(freearg) SWIGTYPE [] "";
|
||||||
|
|
||||||
|
|
||||||
%typemap(in, noblock=1) SWIGTYPE* const& (void *argp = 0, $*ltype temp) {
|
%typemap(in, noblock=1) SWIGTYPE* const& (void *argp = 0, $*ltype temp) {
|
||||||
|
|
@ -25,6 +27,7 @@
|
||||||
temp = %reinterpret_cast(argp, $*ltype);
|
temp = %reinterpret_cast(argp, $*ltype);
|
||||||
$1 = &temp;
|
$1 = &temp;
|
||||||
}
|
}
|
||||||
|
%typemap(freearg) SWIGTYPE* const& "";
|
||||||
|
|
||||||
|
|
||||||
/* Reference */
|
/* Reference */
|
||||||
|
|
@ -35,8 +38,10 @@
|
||||||
if (!argp) { %argument_nullref("$type", $argnum); }
|
if (!argp) { %argument_nullref("$type", $argnum); }
|
||||||
$1 = %reinterpret_cast(argp, $ltype);
|
$1 = %reinterpret_cast(argp, $ltype);
|
||||||
}
|
}
|
||||||
|
%typemap(freearg) SWIGTYPE & "";
|
||||||
|
|
||||||
#if defined(__cplusplus) && defined(%implicitconv_flag)
|
#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);
|
res = SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags | %implicitconv_flag);
|
||||||
if (!SWIG_IsOK(res)) {
|
if (!SWIG_IsOK(res)) {
|
||||||
%argument_fail(SWIG_TypeError, "$type", $argnum);
|
%argument_fail(SWIG_TypeError, "$type", $argnum);
|
||||||
|
|
@ -44,7 +49,7 @@
|
||||||
if (!argp) { %argument_nullref("$type", $argnum); }
|
if (!argp) { %argument_nullref("$type", $argnum); }
|
||||||
$1 = %reinterpret_cast(argp, $ltype);
|
$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);
|
if (SWIG_IsNewObj(res$argnum)) %delete($1);
|
||||||
}
|
}
|
||||||
|
|
@ -87,6 +92,7 @@
|
||||||
$1 = *(%reinterpret_cast(argp, $<ype));
|
$1 = *(%reinterpret_cast(argp, $<ype));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
%typemap(freearg) SWIGTYPE "";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -1404,7 +1404,7 @@ public:
|
||||||
const char *get_implicitconv_flag(Node *klass)
|
const char *get_implicitconv_flag(Node *klass)
|
||||||
{
|
{
|
||||||
int conv = 0;
|
int conv = 0;
|
||||||
if (klass && Getattr(klass,"feature:implicitconv")) {
|
if (klass && GetFlag(klass,"feature:implicitconv")) {
|
||||||
conv = 1;
|
conv = 1;
|
||||||
}
|
}
|
||||||
return conv ? "SWIG_POINTER_IMPLICIT_CONV" : "0";
|
return conv ? "SWIG_POINTER_IMPLICIT_CONV" : "0";
|
||||||
|
|
@ -1537,9 +1537,12 @@ public:
|
||||||
|
|
||||||
if (constructor && num_arguments == 1 && num_required == 1) {
|
if (constructor && num_arguments == 1 && num_required == 1) {
|
||||||
if (Cmp(storage,"explicit") == 0) {
|
if (Cmp(storage,"explicit") == 0) {
|
||||||
String *desc = NewStringf("SWIGTYPE%s", SwigType_manglestr(Getattr(n,"type")));
|
Node *parent = Swig_methodclass(n);
|
||||||
Printf(f->code, "if (SWIG_CheckImplicit(%s)) SWIG_fail;\n", desc);
|
if (GetFlag(parent,"feature:implicitconv")) {
|
||||||
Delete(desc);
|
String *desc = NewStringf("SWIGTYPE%s", SwigType_manglestr(Getattr(n,"type")));
|
||||||
|
Printf(f->code, "if (SWIG_CheckImplicit(%s)) SWIG_fail;\n", desc);
|
||||||
|
Delete(desc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1703,9 +1706,19 @@ public:
|
||||||
|
|
||||||
/* Insert cleanup code */
|
/* Insert cleanup code */
|
||||||
for (p = l; p;) {
|
for (p = l; p;) {
|
||||||
if (!checkAttribute(p,"tmap:in:numinputs","0") &&
|
if (!checkAttribute(p,"tmap:in:numinputs","0") && !Getattr(p,"tmap:in:parse")) {
|
||||||
!Getattr(p,"tmap:in:parse") && (tm = Getattr(p,"tmap:freearg"))) {
|
tm = Getattr(p,"tmap:freearg");
|
||||||
if (Len(tm) != 0) {
|
if (Getattr(p,"tmap:freearg:implicitconv")) {
|
||||||
|
const char *convflag = "0";
|
||||||
|
if (!Getattr(p,"self")) {
|
||||||
|
SwigType *ptype = Getattr(p,"type");
|
||||||
|
convflag = get_implicitconv_flag(classLookup(ptype));
|
||||||
|
}
|
||||||
|
tm = (strcmp(convflag,"0") != 0) ? Getattr(p,"tmap:freearg") : 0;
|
||||||
|
} else {
|
||||||
|
tm = Getattr(p,"tmap:freearg");
|
||||||
|
}
|
||||||
|
if (tm && (Len(tm) != 0)) {
|
||||||
Replaceall(tm,"$source",Getattr(p,"lname"));
|
Replaceall(tm,"$source",Getattr(p,"lname"));
|
||||||
Printv(cleanup,tm,"\n",NIL);
|
Printv(cleanup,tm,"\n",NIL);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1421,6 +1421,9 @@ Swig_typemap_attach_kwargs(Hash *tm, const String_or_char *op, Parm *p) {
|
||||||
Delete(value);
|
Delete(value);
|
||||||
kw = nextSibling(kw);
|
kw = nextSibling(kw);
|
||||||
}
|
}
|
||||||
|
Clear(temp);
|
||||||
|
Printf(temp,"%s:match_type",op);
|
||||||
|
Setattr(p,tmop_name(temp),Getattr(tm,k_type));
|
||||||
Delete(temp);
|
Delete(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1507,8 +1510,31 @@ Swig_typemap_attach_parms(const String_or_char *op, ParmList *parms, Wrapper *f)
|
||||||
if (kwmatch) {
|
if (kwmatch) {
|
||||||
String *tmname = NewStringf("tmap:%s",kwmatch);
|
String *tmname = NewStringf("tmap:%s",kwmatch);
|
||||||
Hash *tmin = Getattr(p,tmname);
|
Hash *tmin = Getattr(p,tmname);
|
||||||
if (!tmin || !Equal(Getattr(tmin,k_type),Getattr(tm,k_type))) {
|
if (tmin) {
|
||||||
|
SwigType *typetm = Getattr(tm,k_type);
|
||||||
|
SwigType *typein = Getattr(tmin,k_type);
|
||||||
|
if (!typein) {
|
||||||
|
String *temp = NewStringf("tmap:%s:match_type",kwmatch);
|
||||||
|
typein = Getattr(p,temp);
|
||||||
|
Delete(temp);
|
||||||
|
}
|
||||||
|
if (!typetm) {
|
||||||
|
Printf(stderr,"notm %s\n",tm);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!typein) {
|
||||||
|
Printf(stderr,"noin %s\n",tmin);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Equal(typein,typetm)) {
|
||||||
|
Printf(stderr,"type in %s tm %s\n", typein, typetm);
|
||||||
|
p = nextSibling(p);
|
||||||
|
Delete(tmname);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
p = nextSibling(p);
|
p = nextSibling(p);
|
||||||
|
Delete(tmname);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Delete(tmname);
|
Delete(tmname);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue