Discussion:
[Swig-devel] ValueWrapper and Templates BUG?
William S Fulton
2015-11-25 20:14:04 UTC
Permalink
Hello,
I tried to get a SmartPointer-Template-Type not surrounded by a
ValueWrapper for an in typemap. I didn't find a solution. So I checked the
swig source code and realized that "SwigType_alttype" in "typsys.c" is
setting "use_wrapper" to true for all templates. "use_wrapper = !n ||
!GetFlag(n, "feature:novaluewrapper");" is always true, because of "!n". Is
this on purpose or a bug?
n = Swig_symbol_clookup(td, 0);
if (n) {
if (GetFlag(n, "feature:valuewrapper")) {
use_wrapper = 1;
} else {
if (Checkattr(n, "nodeType", "class")
&& (!Getattr(n, "allocate:default_constructor")
|| (Getattr(n, "allocate:noassign")))) {
use_wrapper = !GetFlag(n, "feature:novaluewrapper") || GetFlag(n,
"feature:nodefault");
}
}
} else {
if (SwigType_issimple(td) && SwigType_istemplate(td)) {
use_wrapper = !n || !GetFlag(n, "feature:novaluewrapper");
}
}
It should use ValueWrapper if it is a template that hasn't been parsed. If
n is zero, then there is no info on the instantiated template. If n (the
symbol) is zero then it also can't find "feature:novaluewrapper" from the
symbol. Maybe it could then try look it up from the template itself, I
dunno, perhaps send a simple example to look at. Anyway, if you use the
empty template instantiation -
http://swig.org/Doc3.0/SWIGPlus.html#SWIGPlus_nn30 then n should be non
NULL and then %feature will attach to the template instantiation.

William

Loading...