Typemap attribute fixes
Fix for breakages in previous few commits: - Perl test-suite - the "varout" typemap "type" attribute is now expanded in typemap.c instead of Perl.cxx. - The swig_typemap_warn errors testcase showed that $1 was no longer being expanded correctly when used in output typemaps (lname not set).
This commit is contained in:
parent
beabf61ef6
commit
457e0bfa81
2 changed files with 52 additions and 50 deletions
|
|
@ -1045,21 +1045,9 @@ public:
|
||||||
|
|
||||||
String *tt = Getattr(n, "tmap:varout:type");
|
String *tt = Getattr(n, "tmap:varout:type");
|
||||||
if (tt) {
|
if (tt) {
|
||||||
String *tm = NewStringf("&SWIGTYPE%s", SwigType_manglestr(t));
|
tt = NewStringf("&%s", tt);
|
||||||
if (Replaceall(tt, "$1_descriptor", tm)) {
|
|
||||||
SwigType_remember(t);
|
|
||||||
}
|
|
||||||
Delete(tm);
|
|
||||||
SwigType *st = Copy(t);
|
|
||||||
SwigType_add_pointer(st);
|
|
||||||
tm = NewStringf("&SWIGTYPE%s", SwigType_manglestr(st));
|
|
||||||
if (Replaceall(tt, "$&1_descriptor", tm)) {
|
|
||||||
SwigType_remember(st);
|
|
||||||
}
|
|
||||||
Delete(tm);
|
|
||||||
Delete(st);
|
|
||||||
} else {
|
} else {
|
||||||
tt = (String *) "0";
|
tt = NewString("0");
|
||||||
}
|
}
|
||||||
/* Now add symbol to the PERL interpreter */
|
/* Now add symbol to the PERL interpreter */
|
||||||
if (GetFlag(n, "feature:immutable")) {
|
if (GetFlag(n, "feature:immutable")) {
|
||||||
|
|
@ -1087,6 +1075,7 @@ public:
|
||||||
if (export_all)
|
if (export_all)
|
||||||
Printf(exported, "$%s ", iname);
|
Printf(exported, "$%s ", iname);
|
||||||
|
|
||||||
|
Delete(tt);
|
||||||
DelWrapper(setf);
|
DelWrapper(setf);
|
||||||
DelWrapper(getf);
|
DelWrapper(getf);
|
||||||
Delete(getname);
|
Delete(getname);
|
||||||
|
|
|
||||||
|
|
@ -1318,6 +1318,7 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No
|
||||||
char *cmethod = Char(tmap_method);
|
char *cmethod = Char(tmap_method);
|
||||||
int optimal_attribute = 0;
|
int optimal_attribute = 0;
|
||||||
int optimal_substitution = 0;
|
int optimal_substitution = 0;
|
||||||
|
int delete_optimal_attribute = 0;
|
||||||
int num_substitutions = 0;
|
int num_substitutions = 0;
|
||||||
SwigType *matchtype = 0;
|
SwigType *matchtype = 0;
|
||||||
|
|
||||||
|
|
@ -1372,7 +1373,6 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No
|
||||||
Delete(typestr);
|
Delete(typestr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Delete(qpname);
|
Delete(qpname);
|
||||||
qpname = 0;
|
qpname = 0;
|
||||||
Delete(noscope_pname);
|
Delete(noscope_pname);
|
||||||
|
|
@ -1391,40 +1391,17 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No
|
||||||
|
|
||||||
s = Copy(s); /* Make a local copy of the typemap code */
|
s = Copy(s); /* Make a local copy of the typemap code */
|
||||||
|
|
||||||
/* Attach kwargs - ie the typemap attributes */
|
/* Look in the "out" typemap for the "optimal" attribute */
|
||||||
|
if (Cmp(cmethod, "out") == 0) {
|
||||||
kw = Getattr(tm, "kwargs");
|
kw = Getattr(tm, "kwargs");
|
||||||
while (kw) {
|
while (kw) {
|
||||||
String *value = Copy(Getattr(kw, "value"));
|
if (Cmp(Getattr(kw, "name"), "optimal") == 0) {
|
||||||
String *kwtype = Getattr(kw, "type");
|
optimal_attribute = GetFlag(kw, "value");
|
||||||
char *ckwname = Char(Getattr(kw, "name"));
|
break;
|
||||||
{
|
|
||||||
/* Expand special variables in typemap attributes. */
|
|
||||||
SwigType *ptype = Getattr(node, "type");
|
|
||||||
String *pname = Getattr(node, "name");
|
|
||||||
String *lname = Getattr(node, "lname");
|
|
||||||
SwigType *mtype = Getattr(node, "tmap:match");
|
|
||||||
SwigType *matchtype = mtype ? mtype : ptype;
|
|
||||||
ParmList *parm_sublist;
|
|
||||||
typemap_replace_vars(value, NULL, matchtype, ptype, pname, lname, 1);
|
|
||||||
|
|
||||||
/* Expand special variable macros (embedded typemaps) in typemap attributes. */
|
|
||||||
parm_sublist = NewParmWithoutFileLineInfo(ptype, pname);
|
|
||||||
Setattr(parm_sublist, "lname", lname);
|
|
||||||
replace_embedded_typemap(value, parm_sublist, NULL, tm);
|
|
||||||
Delete(parm_sublist);
|
|
||||||
}
|
}
|
||||||
if (kwtype) {
|
|
||||||
String *mangle = Swig_string_mangle(kwtype);
|
|
||||||
Append(value, mangle);
|
|
||||||
Delete(mangle);
|
|
||||||
}
|
|
||||||
sprintf(temp, "%s:%s", cmethod, ckwname);
|
|
||||||
Setattr(node, typemap_method_name(temp), value);
|
|
||||||
if (Cmp(temp, "out:optimal") == 0)
|
|
||||||
optimal_attribute = (Cmp(value, "0") != 0) ? 1 : 0;
|
|
||||||
Delete(value);
|
|
||||||
kw = nextSibling(kw);
|
kw = nextSibling(kw);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (optimal_attribute) {
|
if (optimal_attribute) {
|
||||||
/* Note: "out" typemap is the only typemap that will have the "optimal" attribute set.
|
/* Note: "out" typemap is the only typemap that will have the "optimal" attribute set.
|
||||||
|
|
@ -1456,12 +1433,13 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No
|
||||||
if (!optimal_substitution) {
|
if (!optimal_substitution) {
|
||||||
Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_IGNORED, Getfile(node), Getline(node), "Method %s usage of the optimal attribute ignored\n", Swig_name_decl(node));
|
Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_IGNORED, Getfile(node), Getline(node), "Method %s usage of the optimal attribute ignored\n", Swig_name_decl(node));
|
||||||
Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_IGNORED, Getfile(s), Getline(s), "in the out typemap as the following cannot be used to generate optimal code: %s\n", clname);
|
Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_IGNORED, Getfile(s), Getline(s), "in the out typemap as the following cannot be used to generate optimal code: %s\n", clname);
|
||||||
Delattr(node, "tmap:out:optimal");
|
delete_optimal_attribute = 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
assert(!f);
|
assert(!f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (actioncode) {
|
if (actioncode) {
|
||||||
assert(f);
|
assert(f);
|
||||||
Append(f->code, actioncode);
|
Append(f->code, actioncode);
|
||||||
|
|
@ -1502,6 +1480,41 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No
|
||||||
Delete(parm_sublist);
|
Delete(parm_sublist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Attach kwargs - ie the typemap attributes */
|
||||||
|
kw = Getattr(tm, "kwargs");
|
||||||
|
while (kw) {
|
||||||
|
String *value = Copy(Getattr(kw, "value"));
|
||||||
|
String *kwtype = Getattr(kw, "type");
|
||||||
|
char *ckwname = Char(Getattr(kw, "name"));
|
||||||
|
{
|
||||||
|
/* Expand special variables in typemap attributes. */
|
||||||
|
SwigType *ptype = Getattr(node, "type");
|
||||||
|
String *pname = Getattr(node, "name");
|
||||||
|
SwigType *mtype = Getattr(node, "tmap:match");
|
||||||
|
SwigType *matchtype = mtype ? mtype : ptype;
|
||||||
|
ParmList *parm_sublist;
|
||||||
|
typemap_replace_vars(value, NULL, matchtype, ptype, pname, (char *)lname, 1);
|
||||||
|
|
||||||
|
/* Expand special variable macros (embedded typemaps) in typemap attributes. */
|
||||||
|
parm_sublist = NewParmWithoutFileLineInfo(ptype, pname);
|
||||||
|
Setattr(parm_sublist, "lname", lname);
|
||||||
|
replace_embedded_typemap(value, parm_sublist, NULL, tm);
|
||||||
|
Delete(parm_sublist);
|
||||||
|
}
|
||||||
|
if (kwtype) {
|
||||||
|
String *mangle = Swig_string_mangle(kwtype);
|
||||||
|
Append(value, mangle);
|
||||||
|
Delete(mangle);
|
||||||
|
}
|
||||||
|
sprintf(temp, "%s:%s", cmethod, ckwname);
|
||||||
|
Setattr(node, typemap_method_name(temp), value);
|
||||||
|
Delete(value);
|
||||||
|
kw = nextSibling(kw);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (delete_optimal_attribute)
|
||||||
|
Delattr(node, "tmap:out:optimal");
|
||||||
|
|
||||||
Replace(s, "$name", pname, DOH_REPLACE_ANY);
|
Replace(s, "$name", pname, DOH_REPLACE_ANY);
|
||||||
|
|
||||||
symname = Getattr(node, "sym:name");
|
symname = Getattr(node, "sym:name");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue